Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
alltoall implemented (almost opmpi algorithms)
[simgrid.git] / src / smpi / smpi_sender.c
index 9098aa2..eb5e727 100644 (file)
@@ -3,8 +3,9 @@
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_sender, smpi,
                                 "Logging specific to SMPI (sender)");
 
-int smpi_sender(int argc,char*argv[]) {
-       smpi_host_data_t mydata = SIMIX_process_get_data(SIMIX_process_self());
+int smpi_sender(int argc, char *argv[])
+{
+  smpi_process_data_t mydata = SIMIX_process_get_data(SIMIX_process_self());
   smx_process_t self;
   smx_host_t shost;
 
@@ -29,7 +30,9 @@ int smpi_sender(int argc,char*argv[]) {
 
   index = mydata->index;
 
-  request_queue = smpi_global->pending_send_request_queues[index];
+  DEBUG0("Up and running");
+
+  request_queue = mydata->pending_send_request_queue;
 
   while (1) {
     request = xbt_fifo_shift(request_queue);
@@ -48,8 +51,12 @@ 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];
+      smpi_process_data_t remote_process =
+        SIMIX_process_get_data(smpi_global->main_processes[dindex]);
+      dhost = SIMIX_process_get_host(smpi_global->main_processes[dindex]);
 
+      DEBUG4("handle send request %p to %s (req_dst=%d,req_tag=%d)",
+                      request,SIMIX_host_get_name(dhost),request->dst,message->tag);
       message->forward = (request->forward - 1) / 2;
       request->forward = request->forward / 2;
 
@@ -58,6 +65,8 @@ int smpi_sender(int argc,char*argv[]) {
           (request->dst + message->forward + 1) % request->comm->size;
         xbt_fifo_push(request_queue, request);
       } else {
+        DEBUG4("DONE Handling send request %p to %s (req_dst=%d,req_tag=%d)",
+                        request, SIMIX_host_get_name(dhost),request->dst,message->tag);
         request->completed = 1;
       }
 
@@ -76,7 +85,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_process->received_message_queue, message);
 
       SIMIX_unregister_action_to_condition(action, request->cond);
       SIMIX_action_destroy(action);
@@ -84,15 +93,17 @@ 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);
+      SIMIX_process_resume(remote_process->receiver);
 
-    } else if (mydata->finalize>0) { /* main wants me to die and nothing to do */
-       mydata->finalize--;
-       SIMIX_cond_signal(mydata->cond);
-       return 0;
+    } else if (mydata->finalize > 0) {  /* main wants me to die and nothing to do */
+      DEBUG0("===Main wants me to die and I'm done. Bye, guys.===");
+      mydata->finalize--;
+      SIMIX_cond_signal(mydata->cond);
+      return 0;
     } else {
-       SIMIX_process_suspend(self);
+      DEBUG0("Nothing to do. Let's get a nap");
+      SIMIX_process_suspend(self);
+      DEBUG0("===Uh? Someone called me?===");
     }
   }
   return 0;