Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
SMPI: Kill the global list of senders and receivers
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 24 Jun 2009 19:54:08 +0000 (19:54 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 24 Jun 2009 19:54:08 +0000 (19:54 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6341 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/smpi/private.h
src/smpi/smpi_base.c
src/smpi/smpi_global.c
src/smpi/smpi_receiver.c
src/smpi/smpi_sender.c

index 90b5b34..2db330e 100644 (file)
@@ -94,8 +94,6 @@ typedef struct smpi_global_t {
   xbt_fifo_t *received_message_queues;
 
   smx_process_t *main_processes;
   xbt_fifo_t *received_message_queues;
 
   smx_process_t *main_processes;
-  smx_process_t *sender_processes;
-  smx_process_t *receiver_processes;
 
   int running_hosts_count;
 
 
   int running_hosts_count;
 
index fbc34fb..d8fd995 100644 (file)
@@ -60,6 +60,7 @@ void smpi_process_init()
 
   hdata = xbt_new(s_smpi_host_data_t, 1);
   SIMIX_host_set_data(host, hdata);
 
   hdata = xbt_new(s_smpi_host_data_t, 1);
   SIMIX_host_set_data(host, hdata);
+  SIMIX_process_set_data(SIMIX_process_self(),hdata);
 
   for (i = 0; i < smpi_global->host_count && host != smpi_global->hosts[i]; i++);
 
 
   for (i = 0; i < smpi_global->host_count && host != smpi_global->hosts[i]; i++);
 
@@ -97,14 +98,16 @@ void smpi_process_finalize()
   if (0 >= i) {
 
     // wake up senders/receivers
   if (0 >= i) {
 
     // wake up senders/receivers
+         /* MQ: (FIXME) Don't do so: it breaks since some hosts are already gone
     for (i = 0; i < smpi_global->host_count; i++) {
     for (i = 0; i < smpi_global->host_count; i++) {
-      if (SIMIX_process_is_suspended(smpi_global->sender_processes[i])) {
-        SIMIX_process_resume(smpi_global->sender_processes[i]);
-      }
-      if (SIMIX_process_is_suspended(smpi_global->receiver_processes[i])) {
-        SIMIX_process_resume(smpi_global->receiver_processes[i]);
-      }
-    }
+      smpi_host_data_t remote_hdata =  SIMIX_process_get_data(smpi_global->main_processes[i]);
+
+      if (SIMIX_process_is_suspended(remote_hdata->sender))
+        SIMIX_process_resume(remote_hdata->sender);
+
+      if (SIMIX_process_is_suspended(remote_hdata->receiver))
+        SIMIX_process_resume(remote_hdata->receiver);
+    }*/
 
     SIMIX_mutex_destroy(smpi_mpi_global->mpi_comm_world->barrier_mutex);
     SIMIX_cond_destroy(smpi_mpi_global->mpi_comm_world->barrier_cond);
 
     SIMIX_mutex_destroy(smpi_mpi_global->mpi_comm_world->barrier_mutex);
     SIMIX_cond_destroy(smpi_mpi_global->mpi_comm_world->barrier_cond);
@@ -118,9 +121,7 @@ void smpi_process_finalize()
     xbt_free(smpi_mpi_global->mpi_sum);
 
     xbt_free(smpi_mpi_global);
     xbt_free(smpi_mpi_global->mpi_sum);
 
     xbt_free(smpi_mpi_global);
-
   }
   }
-
 }
 
 int smpi_mpi_barrier(smpi_mpi_communicator_t comm)
 }
 
 int smpi_mpi_barrier(smpi_mpi_communicator_t comm)
@@ -143,16 +144,16 @@ int smpi_mpi_barrier(smpi_mpi_communicator_t comm)
 
 int smpi_mpi_isend(smpi_mpi_request_t request)
 {
 
 int smpi_mpi_isend(smpi_mpi_request_t request)
 {
+       smpi_host_data_t hdata =  SIMIX_host_get_data(SIMIX_host_self());
   int retval = MPI_SUCCESS;
   int retval = MPI_SUCCESS;
-  int index = smpi_host_index();
 
   if (NULL == request) {
     retval = MPI_ERR_INTERN;
   } else {
 
   if (NULL == request) {
     retval = MPI_ERR_INTERN;
   } else {
-    xbt_fifo_push(smpi_global->pending_send_request_queues[index], request);
+    xbt_fifo_push(smpi_global->pending_send_request_queues[hdata->index], request);
 
 
-    if (SIMIX_process_is_suspended(smpi_global->sender_processes[index])) {
-      SIMIX_process_resume(smpi_global->sender_processes[index]);
+    if (SIMIX_process_is_suspended(hdata->sender)) {
+      SIMIX_process_resume(hdata->sender);
     }
   }
 
     }
   }
 
@@ -169,8 +170,8 @@ int smpi_mpi_irecv(smpi_mpi_request_t request)
   } else {
     xbt_fifo_push(hdata->pending_recv_request_queue, request);
 
   } else {
     xbt_fifo_push(hdata->pending_recv_request_queue, request);
 
-    if (SIMIX_process_is_suspended(smpi_global->receiver_processes[hdata->index])) {
-      SIMIX_process_resume(smpi_global->receiver_processes[hdata->index]);
+    if (SIMIX_process_is_suspended(hdata->receiver)) {
+      SIMIX_process_resume(hdata->receiver);
     }
   }
 
     }
   }
 
index 870bae3..8e1057b 100644 (file)
@@ -169,8 +169,6 @@ void smpi_global_init()
 
   // sender/receiver processes
   smpi_global->main_processes = xbt_new(smx_process_t, size);
 
   // sender/receiver processes
   smpi_global->main_processes = xbt_new(smx_process_t, size);
-  smpi_global->sender_processes = xbt_new(smx_process_t, size);
-  smpi_global->receiver_processes = xbt_new(smx_process_t, size);
 
   // timers
   smpi_global->timer = xbt_os_timer_new();
 
   // timers
   smpi_global->timer = xbt_os_timer_new();
@@ -232,8 +230,6 @@ void smpi_global_destroy()
 
   // processes
   xbt_free(smpi_global->main_processes);
 
   // processes
   xbt_free(smpi_global->main_processes);
-  xbt_free(smpi_global->sender_processes);
-  xbt_free(smpi_global->receiver_processes);
 
   // mallocators
   xbt_mallocator_free(smpi_global->request_mallocator);
 
   // mallocators
   xbt_mallocator_free(smpi_global->request_mallocator);
index ff6d1d8..b81c997 100644 (file)
@@ -25,8 +25,6 @@ int smpi_receiver(int argc, char*argv[])
   request_queue = mydata->pending_recv_request_queue;
   message_queue = smpi_global->received_message_queues[index];
 
   request_queue = mydata->pending_recv_request_queue;
   message_queue = smpi_global->received_message_queues[index];
 
-  smpi_global->receiver_processes[index] = self;
-
   do {
 
     // FIXME: better algorithm, maybe some kind of balanced tree? or a heap?
   do {
 
     // FIXME: better algorithm, maybe some kind of balanced tree? or a heap?
index d366d45..732ed78 100644 (file)
@@ -35,8 +35,6 @@ int smpi_sender(int argc,char*argv[]) {
 
   request_queue = smpi_global->pending_send_request_queues[index];
 
 
   request_queue = smpi_global->pending_send_request_queues[index];
 
-  smpi_global->sender_processes[index] = self;
-
   do {
 
     request = xbt_fifo_shift(request_queue);
   do {
 
     request = xbt_fifo_shift(request_queue);
@@ -94,11 +92,10 @@ int smpi_sender(int argc,char*argv[]) {
       SIMIX_mutex_unlock(request->mutex);
 
       // wake up receiver if necessary
       SIMIX_mutex_unlock(request->mutex);
 
       // wake up receiver if necessary
-      receiver_process = smpi_global->receiver_processes[dindex];
-      if (SIMIX_process_is_suspended(receiver_process)) {
+      smpi_host_data_t remote_host = SIMIX_host_get_data(SIMIX_process_get_host(smpi_global->main_processes[dindex]));
+      receiver_process = remote_host->receiver;
+      if (SIMIX_process_is_suspended(receiver_process))
         SIMIX_process_resume(receiver_process);
         SIMIX_process_resume(receiver_process);
-      }
-
     }
 
     running_hosts_count = smpi_global->running_hosts_count;
     }
 
     running_hosts_count = smpi_global->running_hosts_count;