Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill all horizontal tabs
[simgrid.git] / src / smpi / smpi_request.cpp
index 29661e8..0126847 100644 (file)
@@ -3,17 +3,18 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include <xbt/config.hpp>
-#include <algorithm>
-#include "private.h"
 #include "mc/mc.h"
 #include "src/mc/mc_replay.h"
-#include "src/simix/smx_private.h"
-#include "simgrid/sg_config.h"
-#include "smpi/smpi_utils.hpp"
 #include "src/smpi/SmpiHost.hpp"
-#include <simgrid/s4u/host.hpp>
 #include "src/kernel/activity/SynchroComm.hpp"
+#include "src/smpi/private.h"
+#include "src/smpi/smpi_comm.hpp"
+#include "src/smpi/smpi_datatype.hpp"
+#include "src/smpi/smpi_op.hpp"
+#include "src/smpi/smpi_process.hpp"
+#include "src/smpi/smpi_request.hpp"
+
+#include <algorithm>
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_request, smpi, "Logging specific to SMPI (reques)");
 
@@ -33,7 +34,7 @@ Request::Request(void *buf, int count, MPI_Datatype datatype, int src, int dst,
 {
   void *old_buf = nullptr;
 // FIXME Handle the case of a partial shared malloc.
-  if(((((flags & RECV) != 0) && ((flags & ACCUMULATE) !=0)) || (datatype->flags() & DT_FLAG_DERIVED))) { // && (!smpi_is_shared(buf_))){
+  if ((((flags & RECV) != 0) && ((flags & ACCUMULATE) != 0)) || (datatype->flags() & DT_FLAG_DERIVED)) {
     // This part handles the problem of non-contiguous memory
     old_buf = buf;
     if (count==0){
@@ -396,7 +397,7 @@ void Request::start()
       refcount_++;
       if(!(old_type_->flags() & DT_FLAG_DERIVED)){
         oldbuf = buf_;
-        if (!process->replaying() && oldbuf != nullptr && size_!=0){
+        if (not process->replaying() && oldbuf != nullptr && size_ != 0) {
           if((smpi_privatize_global_variables != 0)
             && (static_cast<char*>(buf_) >= smpi_start_data_exe)
             && (static_cast<char*>(buf_) < smpi_start_data_exe + smpi_size_data_exe )){
@@ -461,13 +462,12 @@ void Request::start()
 
     // we make a copy here, as the size is modified by simix, and we may reuse the request in another receive later
     real_size_=size_;
-    action_ = simcall_comm_isend(SIMIX_process_from_PID(src_+1), mailbox, size_, -1.0,
-                                         buf, real_size_, &match_send,
-                         &xbt_free_f, // how to free the userdata if a detached send fails
-                         !process->replaying() ? smpi_comm_copy_data_callback
-                         : &smpi_comm_null_copy_buffer_callback, this,
-                         // detach if msg size < eager/rdv switch limit
-                         detached_);
+    action_   = simcall_comm_isend(
+        SIMIX_process_from_PID(src_ + 1), mailbox, size_, -1.0, buf, real_size_, &match_send,
+        &xbt_free_f, // how to free the userdata if a detached send fails
+        not process->replaying() ? smpi_comm_copy_data_callback : &smpi_comm_null_copy_buffer_callback, this,
+        // detach if msg size < eager/rdv switch limit
+        detached_);
     XBT_DEBUG("send simcall posted");
 
     /* FIXME: detached sends are not traceable (action_ == nullptr) */
@@ -517,24 +517,22 @@ int Request::test(MPI_Request * request, MPI_Status * status) {
 
 int Request::testsome(int incount, MPI_Request requests[], int *indices, MPI_Status status[])
 {
-  int i;
   int count = 0;
   int count_dead = 0;
   MPI_Status stat;
   MPI_Status *pstat = status == MPI_STATUSES_IGNORE ? MPI_STATUS_IGNORE : &stat;
 
-  for(i = 0; i < incount; i++) {
-    if((requests[i] != MPI_REQUEST_NULL)) {
-      if(test(&requests[i], pstat)) {
-         indices[i] = 1;
-         count++;
-         if(status != MPI_STATUSES_IGNORE) {
-           status[i] = *pstat;
-         }
-         if ((requests[i] != MPI_REQUEST_NULL) && requests[i]->flags_ & NON_PERSISTENT)
-         requests[i]=MPI_REQUEST_NULL;
+  for (int i = 0; i < incount; i++) {
+    if (requests[i] != MPI_REQUEST_NULL) {
+      if (test(&requests[i], pstat)) {
+        indices[i] = 1;
+        count++;
+        if (status != MPI_STATUSES_IGNORE)
+          status[i] = *pstat;
+        if ((requests[i] != MPI_REQUEST_NULL) && requests[i]->flags_ & NON_PERSISTENT)
+          requests[i] = MPI_REQUEST_NULL;
       }
-    }else{
+    } else {
       count_dead++;
     }
   }
@@ -560,7 +558,7 @@ int Request::testany(int count, MPI_Request requests[], int *index, MPI_Status *
        map.push_back(i);
     }
   }
-  if(!map.empty()) {
+  if (not map.empty()) {
     //multiplier to the sleeptime, to increase speed of execution, each failed testany will increase it
     static int nsleeps = 1;
     if(smpi_test_sleep > 0) 
@@ -691,9 +689,10 @@ void Request::finish_wait(MPI_Request* request, MPI_Status * status)
     MPI_Datatype datatype = req->old_type_;
 
 // FIXME Handle the case of a partial shared malloc.
-    if((((req->flags_ & ACCUMULATE) != 0) || (datatype->flags() & DT_FLAG_DERIVED))){// && (!smpi_is_shared(req->old_buf_))){
+    if (((req->flags_ & ACCUMULATE) != 0) ||
+        (datatype->flags() & DT_FLAG_DERIVED)) { // && (not smpi_is_shared(req->old_buf_))){
 
-      if (!smpi_process()->replaying()){
+      if (not smpi_process()->replaying()) {
         if( smpi_privatize_global_variables != 0 && (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 ");
@@ -856,7 +855,7 @@ int Request::waitall(int count, MPI_Request requests[], MPI_Status status[])
     }
   }
 
-  if (!accumulates.empty()) {
+  if (not accumulates.empty()) {
     std::sort(accumulates.begin(), accumulates.end(), sort_accumulates);
     for (auto req : accumulates) {
       finish_wait(&req, status);