From: mquinson Date: Tue, 23 Jun 2009 15:07:04 +0000 (+0000) Subject: SMPI: Kill a whole bunch of unneeded synchronization: processes run in exclusive... X-Git-Tag: SVN~1306 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/b110f915460bff6576e1fc6d3a4f391992852714 SMPI: Kill a whole bunch of unneeded synchronization: processes run in exclusive manner within the simulator git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6334 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/ChangeLog b/ChangeLog index f89e5eaa1e..53cfbfa057 100644 --- a/ChangeLog +++ b/ChangeLog @@ -54,7 +54,8 @@ SimGrid (3.4-svn) unstable; urgency=high SMPI: * Cleanup the initialization process * Improve smpirun to accept -platform and -hostfile arguments - + * Kill a whole bunch of unneeded synchronization: processes run in + exclusive manner within the simulator Build Chain: * Do not require doxygen in maintainer mode diff --git a/src/smpi/private.h b/src/smpi/private.h index 6c38d98b37..5f731a54f7 100644 --- a/src/smpi/private.h +++ b/src/smpi/private.h @@ -91,13 +91,8 @@ typedef struct smpi_global_t { // FIXME: request queues should be moved to host data... xbt_fifo_t *pending_send_request_queues; - smx_mutex_t *pending_send_request_queues_mutexes; - xbt_fifo_t *pending_recv_request_queues; - smx_mutex_t *pending_recv_request_queues_mutexes; - xbt_fifo_t *received_message_queues; - smx_mutex_t *received_message_queues_mutexes; smx_process_t *sender_processes; smx_process_t *receiver_processes; diff --git a/src/smpi/smpi_base.c b/src/smpi/smpi_base.c index dcbef986c6..8378556b14 100644 --- a/src/smpi/smpi_base.c +++ b/src/smpi/smpi_base.c @@ -138,10 +138,7 @@ int smpi_mpi_isend(smpi_mpi_request_t request) if (NULL == request) { retval = MPI_ERR_INTERN; } else { - SIMIX_mutex_lock(smpi_global->pending_send_request_queues_mutexes[index]); xbt_fifo_push(smpi_global->pending_send_request_queues[index], request); - SIMIX_mutex_unlock(smpi_global->pending_send_request_queues_mutexes - [index]); if (SIMIX_process_is_suspended(smpi_global->sender_processes[index])) { SIMIX_process_resume(smpi_global->sender_processes[index]); @@ -159,10 +156,7 @@ int smpi_mpi_irecv(smpi_mpi_request_t request) if (NULL == request) { retval = MPI_ERR_INTERN; } else { - SIMIX_mutex_lock(smpi_global->pending_recv_request_queues_mutexes[index]); xbt_fifo_push(smpi_global->pending_recv_request_queues[index], request); - SIMIX_mutex_unlock(smpi_global->pending_recv_request_queues_mutexes - [index]); if (SIMIX_process_is_suspended(smpi_global->receiver_processes[index])) { SIMIX_process_resume(smpi_global->receiver_processes[index]); diff --git a/src/smpi/smpi_global.c b/src/smpi/smpi_global.c index f0ad13e1eb..7d52216209 100644 --- a/src/smpi/smpi_global.c +++ b/src/smpi/smpi_global.c @@ -166,13 +166,8 @@ void smpi_global_init() // queues smpi_global->pending_send_request_queues = xbt_new(xbt_fifo_t, size); - smpi_global->pending_send_request_queues_mutexes = - xbt_new(smx_mutex_t, size); smpi_global->pending_recv_request_queues = xbt_new(xbt_fifo_t, size); - smpi_global->pending_recv_request_queues_mutexes = - xbt_new(smx_mutex_t, size); smpi_global->received_message_queues = xbt_new(xbt_fifo_t, size); - smpi_global->received_message_queues_mutexes = xbt_new(smx_mutex_t, size); // sender/receiver processes smpi_global->sender_processes = xbt_new(smx_process_t, size); @@ -189,11 +184,8 @@ void smpi_global_init() for (i = 0; i < size; i++) { smpi_global->pending_send_request_queues[i] = xbt_fifo_new(); - smpi_global->pending_send_request_queues_mutexes[i] = SIMIX_mutex_init(); smpi_global->pending_recv_request_queues[i] = xbt_fifo_new(); - smpi_global->pending_recv_request_queues_mutexes[i] = SIMIX_mutex_init(); smpi_global->received_message_queues[i] = xbt_fifo_new(); - smpi_global->received_message_queues_mutexes[i] = SIMIX_mutex_init(); } smpi_global->hosts = SIMIX_host_get_table(); @@ -265,19 +257,13 @@ void smpi_global_destroy() for (i = 0; i < size; i++) { xbt_fifo_free(smpi_global->pending_send_request_queues[i]); - SIMIX_mutex_destroy(smpi_global->pending_send_request_queues_mutexes[i]); xbt_fifo_free(smpi_global->pending_recv_request_queues[i]); - SIMIX_mutex_destroy(smpi_global->pending_recv_request_queues_mutexes[i]); xbt_fifo_free(smpi_global->received_message_queues[i]); - SIMIX_mutex_destroy(smpi_global->received_message_queues_mutexes[i]); } xbt_free(smpi_global->pending_send_request_queues); - xbt_free(smpi_global->pending_send_request_queues_mutexes); xbt_free(smpi_global->pending_recv_request_queues); - xbt_free(smpi_global->pending_recv_request_queues_mutexes); xbt_free(smpi_global->received_message_queues); - xbt_free(smpi_global->received_message_queues_mutexes); xbt_free(smpi_global); diff --git a/src/smpi/smpi_receiver.c b/src/smpi/smpi_receiver.c index 0f56f84b9e..579791161a 100644 --- a/src/smpi/smpi_receiver.c +++ b/src/smpi/smpi_receiver.c @@ -9,9 +9,7 @@ int smpi_receiver(int argc, char **argv) int index; xbt_fifo_t request_queue; - smx_mutex_t request_queue_mutex; xbt_fifo_t message_queue; - smx_mutex_t message_queue_mutex; int running_hosts_count; @@ -26,10 +24,7 @@ int smpi_receiver(int argc, char **argv) index = smpi_host_index(); request_queue = smpi_global->pending_recv_request_queues[index]; - request_queue_mutex = - smpi_global->pending_recv_request_queues_mutexes[index]; message_queue = smpi_global->received_message_queues[index]; - message_queue_mutex = smpi_global->received_message_queues_mutexes[index]; smpi_global->receiver_processes[index] = self; @@ -37,9 +32,6 @@ int smpi_receiver(int argc, char **argv) // FIXME: better algorithm, maybe some kind of balanced tree? or a heap? - // FIXME: not the best way to request multiple locks... - SIMIX_mutex_lock(request_queue_mutex); - SIMIX_mutex_lock(message_queue_mutex); for (request_item = xbt_fifo_get_first_item(request_queue); NULL != request_item; request_item = xbt_fifo_get_next_item(request_item)) { @@ -64,9 +56,6 @@ int smpi_receiver(int argc, char **argv) message = NULL; stopsearch: - SIMIX_mutex_unlock(message_queue_mutex); - SIMIX_mutex_unlock(request_queue_mutex); - if (NULL == request || NULL == message) { SIMIX_process_suspend(self); } else { diff --git a/src/smpi/smpi_sender.c b/src/smpi/smpi_sender.c index 71e9fa991d..0d2c433ab6 100644 --- a/src/smpi/smpi_sender.c +++ b/src/smpi/smpi_sender.c @@ -11,7 +11,6 @@ int smpi_sender(int argc, char **argv) int index; xbt_fifo_t request_queue; - smx_mutex_t request_queue_mutex; int running_hosts_count; @@ -35,16 +34,12 @@ int smpi_sender(int argc, char **argv) index = smpi_host_index(); request_queue = smpi_global->pending_send_request_queues[index]; - request_queue_mutex = - smpi_global->pending_send_request_queues_mutexes[index]; smpi_global->sender_processes[index] = self; do { - SIMIX_mutex_lock(request_queue_mutex); request = xbt_fifo_shift(request_queue); - SIMIX_mutex_unlock(request_queue_mutex); if (NULL == request) { SIMIX_process_suspend(self); @@ -71,9 +66,7 @@ int smpi_sender(int argc, char **argv) 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; } @@ -93,10 +86,7 @@ int smpi_sender(int argc, char **argv) SIMIX_cond_wait(request->cond, request->mutex); } - 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]); SIMIX_unregister_action_to_condition(action, request->cond); SIMIX_action_destroy(action);