Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cleanups and simplifications to our build system
[simgrid.git] / src / smpi / smpi_base.c
index 57ae7e0..bc7ac71 100644 (file)
@@ -250,10 +250,8 @@ static MPI_Request build_request(void *buf, int count,
   else
     request->refcount = 0;
   request->op = MPI_REPLACE;
-#ifdef HAVE_TRACING
   request->send = 0;
   request->recv = 0;
-#endif
   if (flags & SEND) smpi_datatype_unuse(datatype);
 
   return request;
@@ -344,17 +342,20 @@ void smpi_mpi_start(MPI_Request request)
 
   if (request->flags & RECV) {
     print_request("New recv", request);
+        
+    xbt_mutex_t mut=smpi_process_mailboxes_mutex();
+    xbt_mutex_acquire(mut);
     
     if (request->flags & RMA || request->size < sg_cfg_get_int("smpi/async_small_thres")){
     //We have to check both mailboxes (because SSEND messages are sent to the large mbox). begin with the more appropriate one : the small one.
       mailbox = smpi_process_mailbox_small();
       XBT_DEBUG("Is there a corresponding send already posted in the small mailbox %p (in case of SSEND)?", mailbox);
-      smx_synchro_t action = SIMIX_comm_iprobe(SIMIX_process_self(), mailbox, 0, request->src,request->tag, &match_recv, (void*)request);
+      smx_synchro_t action = simcall_comm_iprobe(mailbox, 0, request->src,request->tag, &match_recv, (void*)request);
     
       if(action ==NULL){
         mailbox = smpi_process_mailbox();
         XBT_DEBUG("No, nothing in the small mailbox test the other one : %p", mailbox);
-        action = SIMIX_comm_iprobe(SIMIX_process_self(), mailbox, 0, request->src,request->tag, &match_recv, (void*)request);
+        action = simcall_comm_iprobe(mailbox, 0, request->src,request->tag, &match_recv, (void*)request);
         if(action ==NULL){
           XBT_DEBUG("Still nothing, switch back to the small mailbox : %p", mailbox);
           mailbox = smpi_process_mailbox_small();
@@ -365,7 +366,7 @@ void smpi_mpi_start(MPI_Request request)
     }else{
       mailbox = smpi_process_mailbox_small();
       XBT_DEBUG("Is there a corresponding send already posted the small mailbox?");
-    smx_synchro_t action = SIMIX_comm_iprobe(SIMIX_process_self(), mailbox, 0, request->src,request->tag, &match_recv, (void*)request);
+    smx_synchro_t action = simcall_comm_iprobe(mailbox, 0, request->src,request->tag, &match_recv, (void*)request);
     
       if(action ==NULL){
         XBT_DEBUG("No, nothing in the permanent receive mailbox");
@@ -393,18 +394,16 @@ void smpi_mpi_start(MPI_Request request)
                                          request, -1.0);
         XBT_DEBUG("recv simcall posted");
 
-
+    xbt_mutex_release(mut);
   } else {
 
 
     int receiver = request->dst;
 
-    #ifdef HAVE_TRACING
-      int rank = request->src;
-      if (TRACE_smpi_view_internals()) {
-        TRACE_smpi_send(rank, rank, receiver,request->size);
-      }
-    #endif
+    int rank = request->src;
+    if (TRACE_smpi_view_internals()) {
+       TRACE_smpi_send(rank, rank, receiver,request->size);
+    }
     print_request("New send", request);
     
         //if we are giving back the control to the user without waiting for completion, we have to inject timings
@@ -419,10 +418,13 @@ void smpi_mpi_start(MPI_Request request)
         XBT_DEBUG("sending size of %zu : sleep %f ", request->size, smpi_os(request->size));
     }
     
+    xbt_mutex_t mut=smpi_process_remote_mailboxes_mutex(receiver);
+    xbt_mutex_acquire(mut);
+    
     if (request->flags & RMA || request->size < sg_cfg_get_int("smpi/async_small_thres")) { // eager mode
       mailbox = smpi_process_remote_mailbox(receiver);
       XBT_DEBUG("Is there a corresponding recv already posted in the large mailbox %p?", mailbox);
-      smx_synchro_t action = SIMIX_comm_iprobe(SIMIX_process_self(), mailbox, 1,request->dst, request->tag, &match_send, (void*)request);
+      smx_synchro_t action = simcall_comm_iprobe(mailbox, 1,request->dst, request->tag, &match_send, (void*)request);
       if(action ==NULL){
        if (! (request->flags & SSEND)){
          mailbox = smpi_process_remote_mailbox_small(receiver);
@@ -430,7 +432,7 @@ void smpi_mpi_start(MPI_Request request)
        } else{
          mailbox = smpi_process_remote_mailbox_small(receiver);
          XBT_DEBUG("SSEND : Is there a corresponding recv already posted in the small mailbox %p?", mailbox);
-         action = SIMIX_comm_iprobe(SIMIX_process_self(), mailbox, 1,request->dst, request->tag, &match_send, (void*)request);
+         action = simcall_comm_iprobe(mailbox, 1,request->dst, request->tag, &match_send, (void*)request);
          if(action ==NULL){
            XBT_DEBUG("No, we are first, send to large mailbox");
            mailbox = smpi_process_remote_mailbox(receiver);
@@ -484,13 +486,11 @@ void smpi_mpi_start(MPI_Request request)
 
 
 
-#ifdef HAVE_TRACING
     /* FIXME: detached sends are not traceable (request->action == NULL) */
     if (request->action)
-      simcall_set_category(request->action, TRACE_internal_smpi_get_category());
-
-#endif
+       simcall_set_category(request->action, TRACE_internal_smpi_get_category());
 
+    xbt_mutex_release(mut);
   }
 
 }
@@ -719,7 +719,6 @@ static void finish_wait(MPI_Request * request, MPI_Status * status)
 
   }
 
-#ifdef HAVE_TRACING
   if (TRACE_smpi_view_internals()) {
     if(req->flags & RECV){
       int rank = smpi_process_index();
@@ -727,7 +726,6 @@ static void finish_wait(MPI_Request * request, MPI_Status * status)
       TRACE_smpi_recv(rank, src_traced, rank);
     }
   }
-#endif
 
   if(req->detached_sender!=NULL){
     smpi_mpi_request_free(&(req->detached_sender));