Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Yet another dlopen merge
[simgrid.git] / src / smpi / smpi_request.cpp
index f1b5a23..2ff10a2 100644 (file)
@@ -111,9 +111,13 @@ Request::Request(void *buf, int count, MPI_Datatype datatype, int src, int dst,
   if(((((flags & RECV) != 0) && ((flags & ACCUMULATE) !=0)) || (datatype->flags() & DT_FLAG_DERIVED)) && (!smpi_is_shared(buf_))){
     // This part handles the problem of non-contiguous memory
     old_buf = buf;
-    buf_ = count==0 ? nullptr : xbt_malloc(count*datatype->size());
-    if ((datatype->flags() & DT_FLAG_DERIVED) && ((flags & SEND) != 0)) {
-      datatype->serialize(old_buf, buf_, count);
+    if (count==0){
+      buf_ = nullptr;
+    }else {
+      buf_ = xbt_malloc(count*datatype->size());
+      if ((datatype->flags() & DT_FLAG_DERIVED) && ((flags & SEND) != 0)) {
+        datatype->serialize(old_buf, buf_, count);
+      }
     }
   }
   // This part handles the problem of non-contiguous memory (for the unserialisation at the reception)
@@ -468,7 +472,7 @@ void Request::start()
       if(!(old_type_->flags() & DT_FLAG_DERIVED)){
         oldbuf = buf_;
         if (!process->replaying() && oldbuf != nullptr && size_!=0){
-          if((smpi_privatize_global_variables != 0)
+          if((smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP)
             && (static_cast<char*>(buf_) >= smpi_start_data_exe)
             && (static_cast<char*>(buf_) < smpi_start_data_exe + smpi_size_data_exe )){
             XBT_DEBUG("Privatization : We are sending from a zone inside global memory. Switch data segment ");
@@ -762,7 +766,7 @@ void Request::finish_wait(MPI_Request* request, MPI_Status * status)
     if((((req->flags_ & ACCUMULATE) != 0) || (datatype->flags() & DT_FLAG_DERIVED)) && (!smpi_is_shared(req->old_buf_))){
 
       if (!smpi_process()->replaying()){
-        if( smpi_privatize_global_variables != 0 && (static_cast<char*>(req->old_buf_) >= smpi_start_data_exe)
+        if( smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP && (static_cast<char*>(req->old_buf_) >= smpi_start_data_exe)
             && ((char*)req->old_buf_ < smpi_start_data_exe + smpi_size_data_exe )){
             XBT_VERB("Privatization : We are unserializing to a zone in global memory  Switch data segment ");
             smpi_switch_data_segment(smpi_process()->index());
@@ -775,8 +779,10 @@ void Request::finish_wait(MPI_Request* request, MPI_Status * status)
           datatype->unserialize(req->buf_, req->old_buf_, req->real_size_/datatype->size() , req->op_);
         xbt_free(req->buf_);
       }else if(req->flags_ & RECV){//apply op on contiguous buffer for accumulate
-          int n =req->real_size_/datatype->size();
-          req->op_->apply(req->buf_, req->old_buf_, &n, datatype);
+          if(datatype->size()!=0){
+            int n =req->real_size_/datatype->size();
+            req->op_->apply(req->buf_, req->old_buf_, &n, datatype);
+          }
           xbt_free(req->buf_);
       }
     }