Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
alltoall implemented (almost opmpi algorithms)
[simgrid.git] / src / smpi / smpi_receiver.c
index 90d6ea8..999f561 100644 (file)
@@ -23,11 +23,13 @@ int smpi_receiver(int argc, char *argv[])
   request_queue = mydata->pending_recv_request_queue;
   message_queue = mydata->received_message_queue;
 
+  DEBUG0("Up and running");
 
 
   while (1) {
     // FIXME: better algorithm, maybe some kind of balanced tree? or a heap?
 
+    DEBUG0("Look for matching");
     xbt_fifo_foreach(request_queue, request_item, request, smpi_mpi_request_t) {
       xbt_fifo_foreach(message_queue, message_item, message,
                        smpi_received_message_t) {
@@ -38,17 +40,18 @@ int smpi_receiver(int argc, char *argv[])
                         __FILE__,request->src,message->src,request->tag, message->tag);
 #endif
         if (request->comm == message->comm &&
-            (MPI_ANY_SOURCE == request->src || request->src == message->src)
-            && (MPI_ANY_TAG == request->tag || request->tag == message->tag)) {
-          xbt_fifo_remove_item(request_queue, request_item);
-          xbt_fifo_free_item(request_item);
-          xbt_fifo_remove_item(message_queue, message_item);
-          xbt_fifo_free_item(message_item);
-#ifdef DEBUG_MATCH
-        printf("[%s] found match: req_src=%d,msg_src=%d)x(req_tag=%d,msg_tag=%d)\n",
-                        __FILE__,request->src,message->src,request->tag, message->tag);
-#endif
-          goto stopsearch;
+                        (MPI_ANY_SOURCE == request->src || request->src == message->src)
+                        && (MPI_ANY_TAG == request->tag || request->tag == message->tag)) {
+                xbt_fifo_remove_item(request_queue, request_item);
+                xbt_fifo_free_item(request_item);
+                xbt_fifo_remove_item(message_queue, message_item);
+                xbt_fifo_free_item(message_item);
+                DEBUG5("found matching request %p: (req_src=%d,msg_src=%d)x(req_tag=%d,msg_tag=%d)",
+                                request,request->src,message->src,request->tag, message->tag);
+                goto stopsearch;
+        } else {
+                DEBUG5("fail to match request %p: (req_src=%d,msg_src=%d)x(req_tag=%d,msg_tag=%d)",
+                                request,request->src,message->src,request->tag, message->tag);
         }
       }
     }
@@ -84,11 +87,14 @@ int smpi_receiver(int argc, char *argv[])
 
     } else if (mydata->finalize > 0) {  /* main wants me to die and nothing to do */
       // FIXME: display the list of remaining requests and messages (user code synchronization faulty?)
+      DEBUG0("Main wants me to die and I'm done. Bye, guys.");
       mydata->finalize--;
       SIMIX_cond_signal(mydata->cond);
       return 0;
     } else {
+      DEBUG0("Nothing to do. Let's get a nap");
       SIMIX_process_suspend(self);
+      DEBUG0("=== Uh? Someone called me? ===");
     }
   }