X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c086caac4026d0bbd54508d51ce4738157d15238..70e4dad5ffd1ba6f56eb7bc97408411b9a73119b:/src/smpi/smpi_sender.c?ds=sidebyside diff --git a/src/smpi/smpi_sender.c b/src/smpi/smpi_sender.c index 23d4831661..f02e0abfa0 100644 --- a/src/smpi/smpi_sender.c +++ b/src/smpi/smpi_sender.c @@ -8,7 +8,6 @@ int smpi_sender(int argc, char **argv) xbt_fifo_t request_queue; smx_mutex_t request_queue_mutex; - int size; int running_hosts_count; @@ -36,7 +35,6 @@ int smpi_sender(int argc, char **argv) SIMIX_mutex_unlock(smpi_global->start_stop_mutex); index = smpi_host_index(); - size = smpi_global->host_count; request_queue = smpi_global->pending_send_request_queues[index]; request_queue_mutex = smpi_global->pending_send_request_queues_mutexes[index]; @@ -46,7 +44,7 @@ int smpi_sender(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 * size) { + 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 { SIMIX_cond_broadcast(smpi_global->start_stop_cond); @@ -63,25 +61,35 @@ int smpi_sender(int argc, char **argv) SIMIX_process_suspend(self); } else { - message = xbt_mallocator_get(smpi_global->message_mallocator); + message = xbt_mallocator_get(smpi_global->message_mallocator); SIMIX_mutex_lock(request->mutex); - message->comm = request->comm; - // FIXME: maybe we don't need this map - message->src = request->comm->index_to_rank_map[index]; - message->tag = request->tag; - message->buf = xbt_malloc(request->datatype->size * request->count); + message->comm = request->comm; + message->src = request->comm->index_to_rank_map[index]; + message->tag = request->tag; + message->data = request->data; + message->buf = xbt_malloc(request->datatype->size * request->count); memcpy(message->buf, request->buf, request->datatype->size * request->count); dindex = request->comm->rank_to_index_map[request->dst]; dhost = smpi_global->hosts[dindex]; + message->forward = (request->forward - 1) / 2; + request->forward = request->forward / 2; + SIMIX_mutex_lock(smpi_global->received_message_queues_mutexes[dindex]); xbt_fifo_push(smpi_global->received_message_queues[dindex], message); SIMIX_mutex_unlock(smpi_global->received_message_queues_mutexes[dindex]); - request->completed = 1; + if (0 < request->forward) { + request->dst = (request->dst + message->forward + 1) % request->comm->size; + SIMIX_mutex_lock(request_queue_mutex); + xbt_fifo_push(request_queue, request); + SIMIX_mutex_unlock(request_queue_mutex); + } else { + request->completed = 1; + } action = SIMIX_action_communicate(shost, dhost, communication, request->datatype->size * request->count, -1.0); @@ -91,8 +99,6 @@ int smpi_sender(int argc, char **argv) SIMIX_mutex_unlock(request->mutex); - //SIMIX_action_destroy(action); - // wake up receiver if necessary receiver_process = smpi_global->receiver_processes[dindex]; if (SIMIX_process_is_suspended(receiver_process)) {