A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
New function allowing to alias datatypes
[simgrid.git]
/
src
/
gras
/
DataDesc
/
ddt_exchange.c
diff --git
a/src/gras/DataDesc/ddt_exchange.c
b/src/gras/DataDesc/ddt_exchange.c
index
effcd84
..
e0d59d1
100644
(file)
--- a/
src/gras/DataDesc/ddt_exchange.c
+++ b/
src/gras/DataDesc/ddt_exchange.c
@@
-23,7
+23,7
@@
const char *gras_datadesc_cat_names[9] = {
static gras_datadesc_type_t int_type = NULL;
static gras_datadesc_type_t pointer_type = NULL;
static gras_datadesc_type_t int_type = NULL;
static gras_datadesc_type_t pointer_type = NULL;
-static
_
XBT_INLINE void
+static XBT_INLINE void
gras_dd_send_int(gras_socket_t sock,int *i, int stable) {
if (!int_type) {
gras_dd_send_int(gras_socket_t sock,int *i, int stable) {
if (!int_type) {
@@
-35,7
+35,7
@@
gras_dd_send_int(gras_socket_t sock,int *i, int stable) {
gras_trp_send(sock, (char*)i, int_type->size[GRAS_THISARCH], stable);
}
gras_trp_send(sock, (char*)i, int_type->size[GRAS_THISARCH], stable);
}
-static
_
XBT_INLINE void
+static XBT_INLINE void
gras_dd_recv_int(gras_socket_t sock, int r_arch, int *i) {
if (!int_type) {
gras_dd_recv_int(gras_socket_t sock, int r_arch, int *i) {
if (!int_type) {
@@
-63,7
+63,7
@@
gras_dd_recv_int(gras_socket_t sock, int r_arch, int *i) {
* of 'length' bytes set to 0.
* FIXME: Check in configure?
*/
* of 'length' bytes set to 0.
* FIXME: Check in configure?
*/
-static
_
XBT_INLINE int
+static XBT_INLINE int
gras_dd_is_r_null(char **r_ptr, long int length) {
int i;
gras_dd_is_r_null(char **r_ptr, long int length) {
int i;
@@
-76,7
+76,7
@@
gras_dd_is_r_null(char **r_ptr, long int length) {
return 1;
}
return 1;
}
-static
_
XBT_INLINE void
+static XBT_INLINE void
gras_dd_alloc_ref(xbt_dict_t refs,
long int size,
char **r_ref,
gras_dd_alloc_ref(xbt_dict_t refs,
long int size,
char **r_ref,
@@
-95,18
+95,17
@@
gras_dd_alloc_ref(xbt_dict_t refs,
if (detect_cycle && r_ref && !gras_dd_is_r_null( r_ref, r_len)) {
void *ptr = xbt_malloc(sizeof(void *));
if (detect_cycle && r_ref && !gras_dd_is_r_null( r_ref, r_len)) {
void *ptr = xbt_malloc(sizeof(void *));
- CRITICAL0("Check for cycles");
memcpy(ptr,l_ref, sizeof(void *));
DEBUG2("Insert l_ref=%p under r_ref=%p",*(void**)ptr, *(void**)r_ref);
memcpy(ptr,l_ref, sizeof(void *));
DEBUG2("Insert l_ref=%p under r_ref=%p",*(void**)ptr, *(void**)r_ref);
-
+
if (detect_cycle)
if (detect_cycle)
- xbt_dict_set_ext(refs,(const char *) r_ref, r_len, ptr,
free
);
+ xbt_dict_set_ext(refs,(const char *) r_ref, r_len, ptr,
xbt_free_f
);
}
}
static int
}
}
static int
-gras_datadesc_
co
py_rec(gras_cbps_t state,
+gras_datadesc_
memc
py_rec(gras_cbps_t state,
xbt_dict_t refs,
gras_datadesc_type_t type,
char *src,
xbt_dict_t refs,
gras_datadesc_type_t type,
char *src,
@@
-154,23
+153,25
@@
gras_datadesc_copy_rec(gras_cbps_t state,
if (field->send)
field->send(type,state,field_src);
if (field->send)
field->send(type,state,field_src);
-
VERB
1("Copy field %s",field->name);
- count += gras_datadesc_
co
py_rec(state,refs,sub_type, field_src, field_dst, 0,
+
DEBUG
1("Copy field %s",field->name);
+ count += gras_datadesc_
memc
py_rec(state,refs,sub_type, field_src, field_dst, 0,
detect_cycle || sub_type->cycle);
detect_cycle || sub_type->cycle);
- if (XBT_LOG_ISENABLED(gras_ddt_exchange,xbt_log_priority_
debug
)) {
+ if (XBT_LOG_ISENABLED(gras_ddt_exchange,xbt_log_priority_
verbose
)) {
if (sub_type == gras_datadesc_by_name("unsigned int")) {
if (sub_type == gras_datadesc_by_name("unsigned int")) {
-
DEBUG2("Copied value for field %s
: %d (type: unsigned int)",field->name, *(unsigned int*)field_dst);
+
VERB2("Copied value for field '%s'
: %d (type: unsigned int)",field->name, *(unsigned int*)field_dst);
} else if (sub_type == gras_datadesc_by_name("int")) {
} else if (sub_type == gras_datadesc_by_name("int")) {
-
DEBUG2("Copied value for field %s
: %d (type: int)",field->name, *(int*)field_dst);
+
VERB2("Copied value for field '%s'
: %d (type: int)",field->name, *(int*)field_dst);
} else if (sub_type == gras_datadesc_by_name("unsigned long int")) {
} else if (sub_type == gras_datadesc_by_name("unsigned long int")) {
-
DEBUG2("Copied value for field %s
: %ld (type: unsigned long int)",field->name, *(unsigned long int*)field_dst);
+
VERB2("Copied value for field '%s'
: %ld (type: unsigned long int)",field->name, *(unsigned long int*)field_dst);
} else if (sub_type == gras_datadesc_by_name("long int")) {
} else if (sub_type == gras_datadesc_by_name("long int")) {
-
DEBUG2("Copied value for field %s
: %ld (type: long int)",field->name, *(long int*)field_dst);
+
VERB2("Copied value for field '%s'
: %ld (type: long int)",field->name, *(long int*)field_dst);
} else if (sub_type == gras_datadesc_by_name("string")) {
} else if (sub_type == gras_datadesc_by_name("string")) {
- DEBUG2("Copied value for field %s: '%s' (type: string)", field->name, *(char**)field_dst);
+ VERB2("Copied value for field '%s': '%s' (type: string)", field->name, *(char**)field_dst);
+ } else {
+ VERB1("Copied a value for field '%s' (type not scalar?)", field->name);
}
}
}
}
@@
-208,7
+209,7
@@
gras_datadesc_copy_rec(gras_cbps_t state,
if (field->send)
field->send(type,state,src);
if (field->send)
field->send(type,state,src);
- count += gras_datadesc_
co
py_rec(state,refs, sub_type, src, dst,0,
+ count += gras_datadesc_
memc
py_rec(state,refs, sub_type, src, dst,0,
detect_cycle || sub_type->cycle);
break;
detect_cycle || sub_type->cycle);
break;
@@
-238,11
+239,12
@@
gras_datadesc_copy_rec(gras_cbps_t state,
reference_is_to_cpy = 0;
TRY {
reference_is_to_cpy = 0;
TRY {
- if (detect_cycle)
+ if (detect_cycle)
{
/* return ignored. Just checking whether it's known or not */
n_ref=xbt_dict_get_ext(refs,(char*)o_ref, sizeof(char*));
/* return ignored. Just checking whether it's known or not */
n_ref=xbt_dict_get_ext(refs,(char*)o_ref, sizeof(char*));
- else
+ } else {
reference_is_to_cpy = 1;
reference_is_to_cpy = 1;
+ }
} CATCH(e) {
if (e.category != not_found_error)
RETHROW;
} CATCH(e) {
if (e.category != not_found_error)
RETHROW;
@@
-283,7
+285,7
@@
gras_datadesc_copy_rec(gras_cbps_t state,
detect_cycle);
}
detect_cycle);
}
- count += gras_datadesc_
co
py_rec(state,refs, sub_type,
+ count += gras_datadesc_
memc
py_rec(state,refs, sub_type,
*o_ref,(char*)l_referenced, subsubcount,
detect_cycle || sub_type->cycle);
*o_ref,(char*)l_referenced, subsubcount,
detect_cycle || sub_type->cycle);
@@
-342,7
+344,7
@@
gras_datadesc_copy_rec(gras_cbps_t state,
VERB1("Array of %ld stuff, copy it in one after the other",array_count);
for (cpt=0; cpt<array_count; cpt++) {
VERB2("Copy the %dth stuff out of %ld",cpt,array_count);
VERB1("Array of %ld stuff, copy it in one after the other",array_count);
for (cpt=0; cpt<array_count; cpt++) {
VERB2("Copy the %dth stuff out of %ld",cpt,array_count);
- count += gras_datadesc_
co
py_rec(state,refs, sub_type, src_ptr, dst_ptr, 0,
+ count += gras_datadesc_
memc
py_rec(state,refs, sub_type, src_ptr, dst_ptr, 0,
detect_cycle || sub_type->cycle);
src_ptr += elm_size;
dst_ptr += elm_size;
detect_cycle || sub_type->cycle);
src_ptr += elm_size;
dst_ptr += elm_size;
@@
-358,30
+360,32
@@
gras_datadesc_copy_rec(gras_cbps_t state,
return count;
}
/**
return count;
}
/**
- * gras_datadesc_
co
py:
+ * gras_datadesc_
memc
py:
*
* Copy the data pointed by src and described by type
* to a new location, and store a pointer to it in dst.
*
*/
*
* Copy the data pointed by src and described by type
* to a new location, and store a pointer to it in dst.
*
*/
-int gras_datadesc_
co
py(gras_datadesc_type_t type,
+int gras_datadesc_
memc
py(gras_datadesc_type_t type,
void *src, void *dst) {
xbt_ex_t e;
void *src, void *dst) {
xbt_ex_t e;
-
gras_cbps_t state
;
-
xbt_dict_t refs
; /* all references already sent */
+
static gras_cbps_t state=NULL
;
+
static xbt_dict_t refs=NULL
; /* all references already sent */
int size=0;
xbt_assert0(type,"called with NULL type descriptor");
int size=0;
xbt_assert0(type,"called with NULL type descriptor");
- refs = xbt_dict_new();
- state = gras_cbps_new();
+ if (!state) {
+ state = gras_cbps_new();
+ refs = xbt_dict_new();
+ }
TRY {
TRY {
- size = gras_datadesc_
co
py_rec(state,refs,type,(char*)src,(char*)dst,0,
- type->cycle);
+ size = gras_datadesc_
memc
py_rec(state,refs,type,(char*)src,(char*)dst,0,
+
type->cycle);
} CLEANUP {
} CLEANUP {
- xbt_dict_
free(&
refs);
- gras_cbps_
free(&
state);
+ xbt_dict_
reset(
refs);
+ gras_cbps_
reset(
state);
} CATCH(e) {
RETHROW;
}
} CATCH(e) {
RETHROW;
}
@@
-607,18
+611,19
@@
void gras_datadesc_send(gras_socket_t sock,
xbt_ex_t e;
static gras_cbps_t state=NULL;
xbt_ex_t e;
static gras_cbps_t state=NULL;
-
xbt_dict_t refs
; /* all references already sent */
+
static xbt_dict_t refs=NULL
; /* all references already sent */
xbt_assert0(type,"called with NULL type descriptor");
xbt_assert0(type,"called with NULL type descriptor");
- refs = xbt_dict_new();
- if (!state)
+ if (!state) {
state = gras_cbps_new();
state = gras_cbps_new();
-
+ refs = xbt_dict_new();
+ }
+
TRY {
gras_datadesc_send_rec(sock,state,refs,type,(char*)src, type->cycle);
} CLEANUP {
TRY {
gras_datadesc_send_rec(sock,state,refs,type,(char*)src, type->cycle);
} CLEANUP {
- xbt_dict_
free(&
refs);
+ xbt_dict_
reset(
refs);
gras_cbps_reset(state);
} CATCH(e) {
RETHROW;
gras_cbps_reset(state);
} CATCH(e) {
RETHROW;
@@
-775,16
+780,18
@@
gras_datadesc_recv_rec(gras_socket_t sock,
reference_is_to_recv = 0;
TRY {
reference_is_to_recv = 0;
TRY {
- if (detect_cycle)
+ if (detect_cycle)
{
l_ref = xbt_dict_get_ext(refs, (char*)r_ref, pointer_type->size[r_arch]);
l_ref = xbt_dict_get_ext(refs, (char*)r_ref, pointer_type->size[r_arch]);
- else
+ } else {
reference_is_to_recv = 1;
reference_is_to_recv = 1;
+ }
} CATCH(e) {
if (e.category != not_found_error)
RETHROW;
reference_is_to_recv = 1;
xbt_ex_free(e);
}
} CATCH(e) {
if (e.category != not_found_error)
RETHROW;
reference_is_to_recv = 1;
xbt_ex_free(e);
}
+
if (reference_is_to_recv) {
int subsubcount = 0;
void *l_referenced=NULL;
if (reference_is_to_recv) {
int subsubcount = 0;
void *l_referenced=NULL;
@@
-942,12
+949,13
@@
gras_datadesc_recv(gras_socket_t sock,
xbt_ex_t e;
static gras_cbps_t state=NULL; /* callback persistent state */
xbt_ex_t e;
static gras_cbps_t state=NULL; /* callback persistent state */
-
xbt_dict_t refs
; /* all references already sent */
+
static xbt_dict_t refs=NULL
; /* all references already sent */
- refs = xbt_dict_new();
- if (!state)
+ if (!state) {
state = gras_cbps_new();
state = gras_cbps_new();
-
+ refs = xbt_dict_new();
+ }
+
xbt_assert0(type,"called with NULL type descriptor");
TRY {
gras_datadesc_recv_rec(sock, state, refs, type,
xbt_assert0(type,"called with NULL type descriptor");
TRY {
gras_datadesc_recv_rec(sock, state, refs, type,
@@
-955,7
+963,7
@@
gras_datadesc_recv(gras_socket_t sock,
(char *) dst,-1,
type->cycle);
} CLEANUP {
(char *) dst,-1,
type->cycle);
} CLEANUP {
- xbt_dict_
free(&
refs);
+ xbt_dict_
reset(
refs);
gras_cbps_reset(state);
} CATCH(e) {
RETHROW;
gras_cbps_reset(state);
} CATCH(e) {
RETHROW;