X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/70e4dad5ffd1ba6f56eb7bc97408411b9a73119b..9dd8fd5b897bdd4bd61472be676722df1ffd3fd3:/src/smpi/smpi_receiver.c diff --git a/src/smpi/smpi_receiver.c b/src/smpi/smpi_receiver.c index 0097875810..4f214184c0 100644 --- a/src/smpi/smpi_receiver.c +++ b/src/smpi/smpi_receiver.c @@ -1,5 +1,7 @@ #include "private.h" +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_receiver, smpi, "Logging specific to SMPI (receiver)"); + int smpi_receiver(int argc, char **argv) { smx_process_t self; @@ -22,7 +24,7 @@ int smpi_receiver(int argc, char **argv) // make sure root is done before own initialization SIMIX_mutex_lock(smpi_global->start_stop_mutex); - if (!smpi_global->root_ready) { + while (!smpi_global->root_ready) { SIMIX_cond_wait(smpi_global->start_stop_cond, smpi_global->start_stop_mutex); } SIMIX_mutex_unlock(smpi_global->start_stop_mutex); @@ -39,16 +41,15 @@ int smpi_receiver(int argc, char **argv) // wait for all nodes to signal initializatin complete SIMIX_mutex_lock(smpi_global->start_stop_mutex); smpi_global->ready_process_count++; - if (smpi_global->ready_process_count < 3 * smpi_global->host_count) { - SIMIX_cond_wait(smpi_global->start_stop_cond, smpi_global->start_stop_mutex); - } else { + if (smpi_global->ready_process_count >= 3 * smpi_global->host_count) { SIMIX_cond_broadcast(smpi_global->start_stop_cond); } + while (smpi_global->ready_process_count < 3 * smpi_global->host_count) { + SIMIX_cond_wait(smpi_global->start_stop_cond, smpi_global->start_stop_mutex); + } SIMIX_mutex_unlock(smpi_global->start_stop_mutex); do { - request = NULL; - message = NULL; // FIXME: better algorithm, maybe some kind of balanced tree? or a heap? @@ -63,15 +64,22 @@ int smpi_receiver(int argc, char **argv) NULL != message_item; message_item = xbt_fifo_get_next_item(message_item)) { message = xbt_fifo_get_item_content(message_item); - if (request->comm == message->comm && - (MPI_ANY_SOURCE == request->src || request->src == message->src) && - (MPI_ANY_TAG == request->tag || request->tag == message->tag)) { + if ( + request->comm == message->comm && + (MPI_ANY_SOURCE == request->src || request->src == message->src) && + (MPI_ANY_TAG == request->tag || request->tag == message->tag)) { xbt_fifo_remove_item(request_queue, request_item); + xbt_fifo_free_item(request_item); xbt_fifo_remove_item(message_queue, message_item); + xbt_fifo_free_item(message_item); goto stopsearch; } } } + + request = NULL; + message = NULL; + stopsearch: SIMIX_mutex_unlock(message_queue_mutex); SIMIX_mutex_unlock(request_queue_mutex);