X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/18069359141e79577f53782e320401788d18dfb5..548029a96b99a66a16b530071b492e7d3dcd9e5e:/src/simix/smx_network.c diff --git a/src/simix/smx_network.c b/src/simix/smx_network.c index 15039a14c7..ab5a33f147 100644 --- a/src/simix/smx_network.c +++ b/src/simix/smx_network.c @@ -9,12 +9,6 @@ #include "mc/mc.h" #include "xbt/dict.h" -/* Pimple to get an histogram of message sizes in the simulation */ -xbt_dict_t msg_sizes = NULL; -#ifdef HAVE_LATENCY_BOUND_TRACKING -xbt_dict_t latency_limited_dict = NULL; -#endif - XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_network, simix, "Logging specific to SIMIX (network)"); @@ -156,6 +150,8 @@ smx_comm_t SIMIX_communication_new(smx_comm_type_t type) comm->type = type; comm->sem = SIMIX_sem_init(0); comm->refcount = 1; + VERB2("Create communication %p; refcount initially %d", comm, + comm->refcount); return comm; } @@ -169,15 +165,15 @@ void SIMIX_communication_destroy(smx_comm_t comm) VERB2("Destroy communication %p; refcount initially %d", comm, comm->refcount); + if(!(comm->refcount>0)) + xbt_die(bprintf("the refcount of comm %p is already 0 before decreasing it. That's a bug!",comm)); + #ifdef HAVE_LATENCY_BOUND_TRACKING //save is latency limited flag to use afterwards - if (latency_limited_dict == NULL) { - latency_limited_dict = xbt_dict_new(); - } if (comm->act) { DEBUG2("adding key %p with latency limited value %d to the dict", comm, SIMIX_action_is_latency_bounded(comm->act)); - xbt_dicti_set(latency_limited_dict, (uintptr_t) comm, + xbt_dicti_set(simix_global->latency_limited_dict, (uintptr_t) comm, SIMIX_action_is_latency_bounded(comm->act)); } #endif @@ -224,6 +220,9 @@ void SIMIX_communication_destroy(smx_comm_t comm) static XBT_INLINE void SIMIX_communication_use(smx_comm_t comm) { comm->refcount++; + + VERB2("Use communication %p; refcount is now %d", comm, + comm->refcount); } /** @@ -401,7 +400,7 @@ XBT_INLINE int SIMIX_communication_is_latency_bounded(smx_comm_t comm) uintptr_t key = 0; uintptr_t data = 0; xbt_dict_cursor_t cursor; - xbt_dict_foreach(latency_limited_dict, cursor, key, data) { + xbt_dict_foreach(simix_global->latency_limited_dict, cursor, key, data) { DEBUG2("comparing key=%p with comm=%p", (void *) key, (void *) comm); if ((void *) comm == (void *) key) { DEBUG2("key %p found, return value latency limited value %d", @@ -475,13 +474,11 @@ void SIMIX_network_copy_data(smx_comm_t comm) /* pimple to display the message sizes */ { - if (msg_sizes == NULL) - msg_sizes = xbt_dict_new(); casted_size = comm->task_size; - amount = xbt_dicti_get(msg_sizes, casted_size); + amount = xbt_dicti_get(simix_global->msg_sizes, casted_size); amount++; - xbt_dicti_set(msg_sizes, casted_size, amount); + xbt_dicti_set(simix_global->msg_sizes, casted_size, amount); } } @@ -496,7 +493,7 @@ void SIMIX_message_sizes_output(const char *filename) out = fopen(filename, "w"); xbt_assert1(out, "Cannot open file %s", filename); - xbt_dict_foreach(msg_sizes, cursor, key, data) { + xbt_dict_foreach(simix_global->msg_sizes, cursor, key, data) { fprintf(out, "%zu %zu\n", key, data); } fclose(out); @@ -557,14 +554,14 @@ XBT_INLINE void SIMIX_network_send(smx_rdv_t rdv, double task_size, smx_comm_t * comm_ref, void *data) { xbt_ex_t e; - *comm_ref = - SIMIX_network_isend(rdv, task_size, rate, src_buff, src_buff_size, - data); + smx_comm_t comm = *comm_ref = + SIMIX_network_isend(rdv, task_size, rate, src_buff, src_buff_size, + data); TRY { - SIMIX_network_wait(*comm_ref, timeout); + SIMIX_network_wait(comm, timeout); } TRY_CLEANUP { - SIMIX_communication_destroy(*comm_ref); + SIMIX_communication_destroy(comm); } CATCH(e) { RETHROW; @@ -589,13 +586,13 @@ XBT_INLINE void SIMIX_network_recv(smx_rdv_t rdv, double timeout, smx_comm_t * comm_ref) { xbt_ex_t e; - *comm_ref = + smx_comm_t comm = *comm_ref = (smx_comm_t) SIMIX_network_irecv(rdv, dst_buff, dst_buff_size); TRY { - SIMIX_network_wait(*comm_ref, timeout); + SIMIX_network_wait(comm, timeout); } TRY_CLEANUP { - SIMIX_communication_destroy(*comm_ref); + SIMIX_communication_destroy(comm); } CATCH(e) { RETHROW;