From a2ae1feca28e9c5aec67fa2716eff576f5aad2c2 Mon Sep 17 00:00:00 2001 From: mquinson Date: Wed, 24 Jun 2009 19:55:20 +0000 Subject: [PATCH] SMPI: move the last queue (received_message_queue) from global to process data git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6345 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/smpi/private.h | 8 +++----- src/smpi/smpi_base.c | 2 ++ src/smpi/smpi_global.c | 17 ----------------- src/smpi/smpi_receiver.c | 2 +- src/smpi/smpi_sender.c | 6 +++--- 5 files changed, 9 insertions(+), 26 deletions(-) diff --git a/src/smpi/private.h b/src/smpi/private.h index d90f632bee..109ce231a5 100644 --- a/src/smpi/private.h +++ b/src/smpi/private.h @@ -84,14 +84,11 @@ typedef struct smpi_global_t { // state vars - smx_host_t *hosts; + smx_host_t *hosts; //FIXME:killme int host_count; xbt_mallocator_t request_mallocator; xbt_mallocator_t message_mallocator; - // FIXME: request queues should be moved to host data... - xbt_fifo_t *received_message_queues; - smx_process_t *main_processes; xbt_os_timer_t timer; @@ -116,10 +113,11 @@ typedef struct smpi_host_data_t { smx_process_t sender; smx_process_t receiver; - int finalize; /* for main stopping sender&receiver */ + int finalize; /* so that main process stops its sender&receiver */ xbt_fifo_t pending_recv_request_queue; xbt_fifo_t pending_send_request_queue; + xbt_fifo_t received_message_queue; } s_smpi_host_data_t; typedef struct smpi_host_data_t *smpi_host_data_t; diff --git a/src/smpi/smpi_base.c b/src/smpi/smpi_base.c index fb80869be6..dd3353ef75 100644 --- a/src/smpi/smpi_base.c +++ b/src/smpi/smpi_base.c @@ -69,6 +69,7 @@ void smpi_process_init() hdata->pending_recv_request_queue = xbt_fifo_new(); hdata->pending_send_request_queue = xbt_fifo_new(); + hdata->received_message_queue = xbt_fifo_new(); hdata->main = SIMIX_process_self(); hdata->sender = SIMIX_process_create("smpi_sender", @@ -99,6 +100,7 @@ void smpi_process_finalize() SIMIX_cond_destroy(hdata->cond); xbt_fifo_free(hdata->pending_recv_request_queue); xbt_fifo_free(hdata->pending_send_request_queue); + xbt_fifo_free(hdata->received_message_queue); } int smpi_mpi_barrier(smpi_mpi_communicator_t comm) diff --git a/src/smpi/smpi_global.c b/src/smpi/smpi_global.c index 0d1b432425..49f57b663e 100644 --- a/src/smpi/smpi_global.c +++ b/src/smpi/smpi_global.c @@ -160,9 +160,6 @@ void smpi_global_init() xbt_mallocator_new(SMPI_MESSAGE_MALLOCATOR_SIZE, smpi_message_new, smpi_message_free, smpi_message_reset); - // queues - smpi_global->received_message_queues = xbt_new(xbt_fifo_t, size); - // sender/receiver processes smpi_global->main_processes = xbt_new(smx_process_t, size); @@ -175,10 +172,6 @@ void smpi_global_init() smpi_global->do_once_duration = NULL; smpi_global->do_once_mutex = SIMIX_mutex_init(); - for (i = 0; i < size; i++) { - smpi_global->received_message_queues[i] = xbt_fifo_new(); - } - smpi_global->hosts = SIMIX_host_get_table(); smpi_global->host_count = SIMIX_host_get_number(); @@ -217,10 +210,6 @@ void smpi_global_init() void smpi_global_destroy() { - int i; - - int size = SIMIX_host_get_number(); - smpi_do_once_duration_node_t curr, next; // processes @@ -242,12 +231,6 @@ void smpi_global_destroy() SIMIX_mutex_destroy(smpi_global->do_once_mutex); - for (i = 0; i < size; i++) { - xbt_fifo_free(smpi_global->received_message_queues[i]); - } - - xbt_free(smpi_global->received_message_queues); - xbt_free(smpi_global); smpi_global = NULL; diff --git a/src/smpi/smpi_receiver.c b/src/smpi/smpi_receiver.c index bd0d13fd84..f76d8d34a1 100644 --- a/src/smpi/smpi_receiver.c +++ b/src/smpi/smpi_receiver.c @@ -21,7 +21,7 @@ int smpi_receiver(int argc, char*argv[]) self = SIMIX_process_self(); request_queue = mydata->pending_recv_request_queue; - message_queue = smpi_global->received_message_queues[index]; + message_queue = mydata->received_message_queue; while (1) { // FIXME: better algorithm, maybe some kind of balanced tree? or a heap? diff --git a/src/smpi/smpi_sender.c b/src/smpi/smpi_sender.c index ae5a74ec34..dbb0b7c48f 100644 --- a/src/smpi/smpi_sender.c +++ b/src/smpi/smpi_sender.c @@ -48,7 +48,8 @@ int smpi_sender(int argc,char*argv[]) { request->datatype->size * request->count); dindex = request->comm->rank_to_index_map[request->dst]; - dhost = smpi_global->hosts[dindex]; + dhost = SIMIX_process_get_host(smpi_global->main_processes[dindex]); + smpi_host_data_t remote_host = SIMIX_host_get_data(dhost); message->forward = (request->forward - 1) / 2; request->forward = request->forward / 2; @@ -76,7 +77,7 @@ int smpi_sender(int argc,char*argv[]) { SIMIX_cond_wait(request->cond, request->mutex); } - xbt_fifo_push(smpi_global->received_message_queues[dindex], message); + xbt_fifo_push(remote_host->received_message_queue, message); SIMIX_unregister_action_to_condition(action, request->cond); SIMIX_action_destroy(action); @@ -84,7 +85,6 @@ int smpi_sender(int argc,char*argv[]) { SIMIX_mutex_unlock(request->mutex); // wake up receiver if necessary - 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 */ -- 2.20.1