X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/994908f535190638662797b1215506fc0664bd37..1372e35c79dba117ae1b592394821a3f716a3f13:/src/smpi/smpi_sender.c diff --git a/src/smpi/smpi_sender.c b/src/smpi/smpi_sender.c index f8f9aa92f7..9098aa2c94 100644 --- a/src/smpi/smpi_sender.c +++ b/src/smpi/smpi_sender.c @@ -3,8 +3,8 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_sender, smpi, "Logging specific to SMPI (sender)"); -int smpi_sender(int argc, char **argv) -{ +int smpi_sender(int argc,char*argv[]) { + smpi_host_data_t mydata = SIMIX_process_get_data(SIMIX_process_self()); smx_process_t self; smx_host_t shost; @@ -12,8 +12,6 @@ int smpi_sender(int argc, char **argv) xbt_fifo_t request_queue; - int running_hosts_count; - smpi_mpi_request_t request; smx_host_t dhost; @@ -26,25 +24,17 @@ int smpi_sender(int argc, char **argv) int dindex; - smx_process_t receiver_process; - self = SIMIX_process_self(); shost = SIMIX_host_self(); - index = smpi_host_index(); + index = mydata->index; request_queue = smpi_global->pending_send_request_queues[index]; - smpi_global->sender_processes[index] = self; - - do { - + while (1) { request = xbt_fifo_shift(request_queue); - if (NULL == request) { - SIMIX_process_suspend(self); - } else { - + if (NULL != request) { message = xbt_mallocator_get(smpi_global->message_mallocator); SIMIX_mutex_lock(request->mutex); @@ -94,16 +84,16 @@ int smpi_sender(int argc, char **argv) SIMIX_mutex_unlock(request->mutex); // wake up receiver if necessary - receiver_process = smpi_global->receiver_processes[dindex]; - if (SIMIX_process_is_suspended(receiver_process)) { - SIMIX_process_resume(receiver_process); - } + smpi_host_data_t remote_host = SIMIX_host_get_data(SIMIX_process_get_host(smpi_global->main_processes[dindex])); + SIMIX_process_resume(remote_host->receiver); + } else if (mydata->finalize>0) { /* main wants me to die and nothing to do */ + mydata->finalize--; + SIMIX_cond_signal(mydata->cond); + return 0; + } else { + SIMIX_process_suspend(self); } - - running_hosts_count = smpi_global->running_hosts_count; - - } while (0 < running_hosts_count); - + } return 0; }