Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
makes a lot more sense to use request->cond than a dummy cond in smpi_sender
authormarkls <markls@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 1 Aug 2007 19:53:18 +0000 (19:53 +0000)
committermarkls <markls@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 1 Aug 2007 19:53:18 +0000 (19:53 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@3934 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/smpi/src/smpi_base.c

index 1db7a1d..f507940 100644 (file)
@@ -37,8 +37,6 @@ int inline smpi_mpi_comm_world_rank_self()
 
 int smpi_sender(int argc, char **argv)
 {
 
 int smpi_sender(int argc, char **argv)
 {
-       smx_mutex_t mutex;
-       smx_cond_t cond;
        smx_process_t self;
        smx_host_t shost;
        int rank;
        smx_process_t self;
        smx_host_t shost;
        int rank;
@@ -61,8 +59,6 @@ int smpi_sender(int argc, char **argv)
 
        smx_process_t receiver_process;
 
 
        smx_process_t receiver_process;
 
-       mutex = SIMIX_mutex_init();
-       cond  = SIMIX_cond_init();
        self  = SIMIX_process_self();
        shost = SIMIX_host_self();
        rank  = smpi_mpi_comm_rank(smpi_mpi_global->mpi_comm_world, shost);
        self  = SIMIX_process_self();
        shost = SIMIX_host_self();
        rank  = smpi_mpi_comm_rank(smpi_mpi_global->mpi_comm_world, shost);
@@ -99,19 +95,8 @@ int smpi_sender(int argc, char **argv)
                if (NULL == request) {
                        SIMIX_process_suspend(self);
                } else {
                if (NULL == request) {
                        SIMIX_process_suspend(self);
                } else {
-                       SIMIX_mutex_lock(request->mutex);
-
-                       dhost = request->comm->hosts[request->dst];
 
 
-                       communicate_action = SIMIX_action_communicate(shost, dhost,
-                               "communication", request->datatype->size * request->count * 1.0, -1.0);
-
-                       SIMIX_register_condition_to_action(communicate_action, cond);
-                       SIMIX_register_action_to_condition(communicate_action, cond);
-
-                       SIMIX_mutex_lock(mutex);
-                       SIMIX_cond_wait(cond, mutex);
-                       SIMIX_mutex_unlock(mutex);
+                       SIMIX_mutex_lock(request->mutex);
 
                        // copy request to appropriate received queue
                        message       = xbt_mallocator_get(smpi_global->message_mallocator);
 
                        // copy request to appropriate received queue
                        message       = xbt_mallocator_get(smpi_global->message_mallocator);
@@ -122,6 +107,7 @@ int smpi_sender(int argc, char **argv)
                        message->buf  = xbt_malloc(request->datatype->size * request->count);
                        memcpy(message->buf, request->buf, request->datatype->size * request->count);
 
                        message->buf  = xbt_malloc(request->datatype->size * request->count);
                        memcpy(message->buf, request->buf, request->datatype->size * request->count);
 
+                       dhost = request->comm->hosts[request->dst];
                        drank = smpi_mpi_comm_rank(smpi_mpi_global->mpi_comm_world, dhost);
 
                        SIMIX_mutex_lock(smpi_global->received_message_queues_mutexes[drank]);
                        drank = smpi_mpi_comm_rank(smpi_mpi_global->mpi_comm_world, dhost);
 
                        SIMIX_mutex_lock(smpi_global->received_message_queues_mutexes[drank]);
@@ -130,7 +116,13 @@ int smpi_sender(int argc, char **argv)
 
                        request->completed = 1;
 
 
                        request->completed = 1;
 
-                       SIMIX_cond_broadcast(request->cond);
+                       communicate_action = SIMIX_action_communicate(shost, dhost,
+                               "communication", request->datatype->size * request->count * 1.0, -1.0);
+
+                       SIMIX_register_condition_to_action(communicate_action, request->cond);
+                       SIMIX_register_action_to_condition(communicate_action, request->cond);
+
+                       SIMIX_cond_wait(request->cond, request->mutex);
 
                        SIMIX_mutex_unlock(request->mutex);
 
 
                        SIMIX_mutex_unlock(request->mutex);
 
@@ -158,9 +150,6 @@ int smpi_sender(int argc, char **argv)
        }
        SIMIX_mutex_unlock(smpi_global->start_stop_mutex);
 
        }
        SIMIX_mutex_unlock(smpi_global->start_stop_mutex);
 
-       SIMIX_mutex_destroy(mutex);
-       SIMIX_cond_destroy(cond);
-
        return 0;
 }
 
        return 0;
 }