#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)");
comm->type = type;
comm->sem = SIMIX_sem_init(0);
comm->refcount = 1;
+ VERB2("Create communication %p; refcount initially %d", comm,
+ comm->refcount);
return 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
static XBT_INLINE void SIMIX_communication_use(smx_comm_t comm)
{
comm->refcount++;
+
+ VERB2("Use communication %p; refcount is now %d", comm,
+ comm->refcount);
}
/**
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",
/* 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);
}
}
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);
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;
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;