Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove XBT_INFO call
[simgrid.git] / src / smpi / smpi_base.c
index 2bb5b8c..6295038 100644 (file)
@@ -367,6 +367,8 @@ void smpi_mpi_start(MPI_Request request)
       XBT_DEBUG("Send request %p is not in the permanent receive mailbox (buf: %p)",request,request->buf);
       mailbox = smpi_process_remote_mailbox(receiver);
     }
+
+    void* buf = request->buf;
     if ( (! (request->flags & SSEND)) && (request->size < sg_cfg_get_int("smpi/send_is_detached_thres"))) {
       void *oldbuf = NULL;
       request->detached = 1;
@@ -374,8 +376,17 @@ void smpi_mpi_start(MPI_Request request)
       if(request->old_type->has_subtype == 0){
         oldbuf = request->buf;
         if (!_xbt_replay_is_active() && oldbuf && request->size!=0){
-          request->buf = xbt_malloc(request->size);
-          memcpy(request->buf,oldbuf,request->size);
+          if((smpi_privatize_global_variables)
+           && ((char*)request->buf >= start_data_exe)
+           && ((char*)request->buf < start_data_exe + size_data_exe )
+       ){
+                 XBT_WARN("Privatization : We are sending from a zone inside global memory. Switch data segment ");
+                 switch_data_segment(smpi_process_index());
+       }
+
+
+          buf = xbt_malloc(request->size);
+          memcpy(buf,oldbuf,request->size);
         }
       }
       XBT_DEBUG("Send request %p is detached; buf %p copied into %p",request,oldbuf,request->buf);
@@ -387,20 +398,20 @@ void smpi_mpi_start(MPI_Request request)
     smpi_comm_use(request->comm);
 
     //if we are giving back the control to the user without waiting for completion, we have to inject timings
-    double sleeptime =0.0;
+    double sleeptime = 0.0;
     if(request->detached || (request->flags & (ISEND|SSEND))){// issend should be treated as isend
       //isend and send timings may be different
       sleeptime = (request->flags & ISEND)? smpi_ois(request->size) : smpi_os(request->size);
     }
 
-    if(sleeptime!=0.0){
+    if(sleeptime != 0.0){
         simcall_process_sleep(sleeptime);
         XBT_DEBUG("sending size of %zu : sleep %f ", request->size, smpi_os(request->size));
     }
 
     request->action =
       simcall_comm_isend(mailbox, request->size, -1.0,
-                         request->buf, request->real_size,
+                         buf, request->real_size,
                          &match_send,
                          &xbt_free, // how to free the userdata if a detached send fails
                          request,
@@ -585,6 +596,15 @@ static void finish_wait(MPI_Request * request, MPI_Status * status)
     MPI_Datatype datatype = req->old_type;
 
     if(datatype->has_subtype == 1){
+      if (!_xbt_replay_is_active()){
+        if( smpi_privatize_global_variables
+            && ((char*)req->old_buf >= start_data_exe)
+            && ((char*)req->old_buf < start_data_exe + size_data_exe )
+        ){
+            XBT_VERB("Privatization : We are unserializing to a zone in global memory - Switch data segment ");
+            switch_data_segment(smpi_process_index());
+        }
+      }
       // This part handles the problem of non-contignous memory
       // the unserialization at the reception
       s_smpi_subtype_t *subtype = datatype->substruct;
@@ -772,7 +792,7 @@ void smpi_mpi_wait(MPI_Request * request, MPI_Status * status)
   if ((*request)->action != NULL) { // this is not a detached send
     simcall_comm_wait((*request)->action, -1.0);
 #ifdef HAVE_MC
-  if(MC_is_active())
+  if(MC_is_active() && (*request)->action)
     (*request)->action->comm.dst_data = NULL; // dangling pointer : dst_data is freed with a wait, need to set it to NULL for system state comparison
 #endif
   }