Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
leaks --. Maybe
[simgrid.git] / src / smpi / mpi / smpi_request.cpp
index 988dc1d..10c3639 100644 (file)
@@ -107,6 +107,10 @@ size_t Request::real_size(){
   return real_size_;
 }
 
+void Request::ref(){
+  refcount_++;
+}
+
 void Request::unref(MPI_Request* request)
 {
   if((*request) != MPI_REQUEST_NULL){
@@ -361,7 +365,7 @@ void Request::start()
   xbt_assert(action_ == nullptr, "Cannot (re-)start unfinished communication");
   flags_ &= ~MPI_REQ_PREPARED;
   flags_ &= ~MPI_REQ_FINISHED;
-  refcount_++;
+  this->ref();
 
   if ((flags_ & MPI_REQ_RECV) != 0) {
     this->print_request("New recv");
@@ -431,11 +435,11 @@ void Request::start()
       void *oldbuf = nullptr;
       detached_ = 1;
       XBT_DEBUG("Send request %p is detached", this);
-      refcount_++;
+      this->ref();
       if (not(old_type_->flags() & DT_FLAG_DERIVED)) {
         oldbuf = buf_;
         if (not process->replaying() && oldbuf != nullptr && size_ != 0) {
-          if ((smpi_privatize_global_variables != SmpiPrivStrategies::None) &&
+          if ((smpi_privatize_global_variables != SmpiPrivStrategies::NONE) &&
               (static_cast<char*>(buf_) >= smpi_data_exe_start) &&
               (static_cast<char*>(buf_) < smpi_data_exe_start + smpi_data_exe_size)) {
             XBT_DEBUG("Privatization : We are sending from a zone inside global memory. Switch data segment ");
@@ -676,7 +680,7 @@ void Request::iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status*
   // nsleeps is a multiplier to the sleeptime, to increase speed of execution, each failed iprobe will increase it
   // This can speed up the execution of certain applications by an order of magnitude, such as HPL
   static int nsleeps = 1;
-  double speed        = simgrid::s4u::Actor::self()->get_host()->getSpeed();
+  double speed        = simgrid::s4u::Actor::self()->get_host()->get_speed();
   double maxrate      = simgrid::config::get_value<double>("smpi/iprobe-cpu-usage");
   MPI_Request request = new Request(nullptr, 0, MPI_CHAR,
                                     source == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : comm->group()->actor(source)->get_pid(),
@@ -733,6 +737,9 @@ void Request::finish_wait(MPI_Request* request, MPI_Status * status)
   if (req->cancelled_==1){
     if (status!=MPI_STATUS_IGNORE)
       status->cancelled=1;
+    if(req->detached_sender_ != nullptr)
+      unref(&(req->detached_sender_));
+    unref(request);
     return;
   }
 
@@ -753,7 +760,7 @@ void Request::finish_wait(MPI_Request* request, MPI_Status * status)
     if (((req->flags_ & MPI_REQ_ACCUMULATE) != 0) ||
         (datatype->flags() & DT_FLAG_DERIVED)) { // && (not smpi_is_shared(req->old_buf_))){
 
-      if (not smpi_process()->replaying() && smpi_privatize_global_variables != SmpiPrivStrategies::None &&
+      if (not smpi_process()->replaying() && smpi_privatize_global_variables != SmpiPrivStrategies::NONE &&
           static_cast<char*>(req->old_buf_) >= smpi_data_exe_start &&
           static_cast<char*>(req->old_buf_) < smpi_data_exe_start + smpi_data_exe_size) {
         XBT_VERB("Privatization : We are unserializing to a zone in global memory  Switch data segment ");
@@ -870,7 +877,7 @@ int Request::waitany(int count, MPI_Request requests[], MPI_Status * status)
         if ((requests[index] == MPI_REQUEST_NULL) ||
             (not((requests[index]->flags_ & MPI_REQ_ACCUMULATE) && (requests[index]->flags_ & MPI_REQ_RECV)))) {
           finish_wait(&requests[index],status);
-          if (requests[i] != MPI_REQUEST_NULL && (requests[i]->flags_ & MPI_REQ_NON_PERSISTENT))
+          if (requests[index] != MPI_REQUEST_NULL && (requests[index]->flags_ & MPI_REQ_NON_PERSISTENT))
             requests[index] = MPI_REQUEST_NULL;
         }
       }