Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[SMPI] Program against s4u::Actor and not smx_actor_t
[simgrid.git] / src / smpi / mpi / smpi_request.cpp
index 8834d32..57e5a6b 100644 (file)
@@ -5,15 +5,16 @@
 
 #include "smpi_request.hpp"
 
-#include "mc/mc.h"
-#include "src/kernel/activity/CommImpl.hpp"
-#include "src/mc/mc_replay.h"
 #include "SmpiHost.hpp"
+#include "mc/mc.h"
 #include "private.hpp"
 #include "smpi_comm.hpp"
 #include "smpi_datatype.hpp"
 #include "smpi_op.hpp"
 #include "smpi_process.hpp"
+#include "src/kernel/activity/CommImpl.hpp"
+#include "src/mc/mc_replay.hpp"
+#include "src/simix/ActorImpl.hpp"
 
 #include <algorithm>
 
@@ -31,7 +32,8 @@ extern void (*smpi_comm_copy_data_callback) (smx_activity_t, void*, size_t);
 namespace simgrid{
 namespace smpi{
 
-Request::Request(void *buf, int count, MPI_Datatype datatype, int src, int dst, int tag, MPI_Comm comm, unsigned flags) : buf_(buf), old_type_(datatype), src_(src), dst_(dst), tag_(tag), comm_(comm), flags_(flags)
+Request::Request(void* buf, int count, MPI_Datatype datatype, int src, int dst, int tag, MPI_Comm comm, unsigned flags)
+    : buf_(buf), old_type_(datatype), src_(src), dst_(dst), tag_(tag), comm_(comm), flags_(flags)
 {
   void *old_buf = nullptr;
 // FIXME Handle the case of a partial shared malloc.
@@ -376,7 +378,7 @@ 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_irecv(
-        process->process(), mailbox, buf_, &real_size_, &match_recv,
+        process->process()->getImpl(), mailbox, buf_, &real_size_, &match_recv,
         process->replaying() ? &smpi_comm_null_copy_buffer_callback : smpi_comm_copy_data_callback, this, -1.0);
     XBT_DEBUG("recv simcall posted");
 
@@ -463,7 +465,7 @@ 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,
+        simgrid::s4u::Actor::byPid(src_ + 1)->getImpl(), 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
@@ -628,7 +630,9 @@ void Request::iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status*
   MPI_Request request = new Request(nullptr, 0, MPI_CHAR, source == MPI_ANY_SOURCE ? MPI_ANY_SOURCE :
                  comm->group()->index(source), comm->rank(), tag, comm, PERSISTENT | RECV);
   if (smpi_iprobe_sleep > 0) {
-    smx_activity_t iprobe_sleep = simcall_execution_start("iprobe", /* flops to executek*/nsleeps*smpi_iprobe_sleep*speed*maxrate, /* priority */1.0, /* performance bound */maxrate*speed);
+    smx_activity_t iprobe_sleep = simcall_execution_start(
+        "iprobe", /* flops to executek*/ nsleeps * smpi_iprobe_sleep * speed * maxrate, /* priority */ 1.0,
+        /* performance bound */ maxrate * speed, smpi_process()->process()->getImpl()->host);
     simcall_execution_wait(iprobe_sleep);
   }
   // behave like a receive, but don't do it
@@ -691,12 +695,11 @@ void Request::finish_wait(MPI_Request* request, MPI_Status * status)
     if (((req->flags_ & ACCUMULATE) != 0) ||
         (datatype->flags() & DT_FLAG_DERIVED)) { // && (not smpi_is_shared(req->old_buf_))){
 
-      if (not smpi_process()->replaying()) {
-        if (smpi_privatize_global_variables != 0 && (static_cast<char*>(req->old_buf_) >= smpi_data_exe_start) &&
-            ((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 ");
-          smpi_switch_data_segment(smpi_process()->index());
-        }
+      if (not smpi_process()->replaying() && smpi_privatize_global_variables != 0 &&
+          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 ");
+        smpi_switch_data_segment(smpi_process()->index());
       }
 
       if(datatype->flags() & DT_FLAG_DERIVED){