Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use an ActorPtr as parameter to smpi_switch_data_segemnt.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 15 Mar 2018 20:53:17 +0000 (21:53 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 19 Mar 2018 11:54:30 +0000 (12:54 +0100)
13 files changed:
src/mc/remote/Client.cpp
src/simix/ActorImpl.cpp
src/simix/ActorImpl.hpp
src/simix/smx_global.cpp
src/smpi/include/private.hpp
src/smpi/internals/smpi_bench.cpp
src/smpi/internals/smpi_global.cpp
src/smpi/internals/smpi_memory.cpp
src/smpi/internals/smpi_process.cpp
src/smpi/mpi/smpi_comm.cpp
src/smpi/mpi/smpi_datatype.cpp
src/smpi/mpi/smpi_op.cpp
src/smpi/mpi/smpi_request.cpp

index 6521d94..f515ae4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2017. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2018. The SimGrid Team. All rights reserved.          */
 
 /* 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. */
@@ -114,7 +114,7 @@ void Client::handleSimcall(s_mc_message_simcall_handle_t* message)
 void Client::handleRestore(s_mc_message_restore_t* message)
 {
 #if HAVE_SMPI
-  smpi_really_switch_data_segment(message->index);
+  smpi_really_switch_data_segment(simgrid::s4u::Actor::byPid(message->index));
 #endif
 }
 void Client::handleActorEnabled(s_mc_message_actor_enabled_t* msg)
index 7bdaca7..e7445fb 100644 (file)
@@ -749,7 +749,7 @@ void SIMIX_process_yield(smx_actor_t self)
   }
 
   if (SMPI_switch_data_segment && not self->finished) {
-    SMPI_switch_data_segment(self->pid);
+    SMPI_switch_data_segment(self->iface());
   }
 }
 
index ad51e8b..942064c 100644 (file)
@@ -148,7 +148,7 @@ XBT_PRIVATE void SIMIX_process_change_host(smx_actor_t process, sg_host_t dest);
 
 XBT_PRIVATE void SIMIX_process_auto_restart_set(smx_actor_t process, int auto_restart);
 
-extern void (*SMPI_switch_data_segment)(int dest);
+extern void (*SMPI_switch_data_segment)(simgrid::s4u::ActorPtr actor);
 }
 
 XBT_PRIVATE void SIMIX_process_sleep_destroy(smx_activity_t synchro);
index 887a2fb..f813a39 100644 (file)
@@ -68,7 +68,7 @@ public:
   s_smx_timer_t(double date, simgrid::xbt::Task<void()> callback) : date(date), callback(std::move(callback)) {}
 };
 
-void (*SMPI_switch_data_segment)(int) = nullptr;
+void (*SMPI_switch_data_segment)(simgrid::s4u::ActorPtr) = nullptr;
 
 int _sg_do_verbose_exit = 1;
 static void inthandler(int)
index ad5ae02..f095454 100644 (file)
@@ -89,8 +89,8 @@ extern XBT_PRIVATE int smpi_data_exe_size;    // size of the data+bss segment of
 enum shared_malloc_type { shmalloc_none, shmalloc_local, shmalloc_global };
 extern XBT_PRIVATE shared_malloc_type smpi_cfg_shared_malloc; // Whether to activate shared malloc
 
-XBT_PRIVATE void smpi_switch_data_segment(int dest);
-XBT_PRIVATE void smpi_really_switch_data_segment(int dest);
+XBT_PRIVATE void smpi_switch_data_segment(simgrid::s4u::ActorPtr actor);
+XBT_PRIVATE void smpi_really_switch_data_segment(simgrid::s4u::ActorPtr actor);
 XBT_PRIVATE int smpi_is_privatization_file(char* file);
 
 XBT_PRIVATE void smpi_get_executable_global_size();
index d0ccc26..b71adc7 100644 (file)
@@ -47,7 +47,7 @@ void smpi_execute_flops(double flops) {
   smx_activity_t action = simcall_execution_start("computation", flops, 1, 0, smpi_process()->process()->getHost());
   simcall_set_category (action, TRACE_internal_smpi_get_category());
   simcall_execution_wait(action);
-  smpi_switch_data_segment(simgrid::s4u::Actor::self()->getPid());
+  smpi_switch_data_segment(simgrid::s4u::Actor::self());
 }
 
 void smpi_execute(double duration)
@@ -79,7 +79,7 @@ void smpi_execute_benched(double duration)
 void smpi_bench_begin()
 {
   if (smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP) {
-    smpi_switch_data_segment(simgrid::s4u::Actor::self()->getPid());
+    smpi_switch_data_segment(simgrid::s4u::Actor::self());
   }
 
   if (MC_is_active() || MC_record_replay_is_active())
index b3e4714..f75d237 100644 (file)
@@ -192,7 +192,7 @@ void smpi_comm_copy_buffer_callback(smx_activity_t synchro, void *buff, size_t b
   if ((smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP) && (static_cast<char*>(buff) >= smpi_data_exe_start) &&
       (static_cast<char*>(buff) < smpi_data_exe_start + smpi_data_exe_size)) {
     XBT_DEBUG("Privatization : We are copying from a zone inside global memory... Saving data to temp buffer !");
-    smpi_switch_data_segment(comm->src_proc->pid);
+    smpi_switch_data_segment(comm->src_proc->iface());
     tmpbuff = static_cast<void*>(xbt_malloc(buff_size));
     memcpy_private(tmpbuff, buff, private_blocks);
   }
@@ -200,7 +200,7 @@ void smpi_comm_copy_buffer_callback(smx_activity_t synchro, void *buff, size_t b
   if ((smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP) && ((char*)comm->dst_buff >= smpi_data_exe_start) &&
       ((char*)comm->dst_buff < smpi_data_exe_start + smpi_data_exe_size)) {
     XBT_DEBUG("Privatization : We are copying to a zone inside global memory - Switch data segment");
-    smpi_switch_data_segment(comm->dst_proc->pid);
+    smpi_switch_data_segment(comm->dst_proc->iface());
   }
   XBT_DEBUG("Copying %zu bytes from %p to %p", buff_size, tmpbuff,comm->dst_buff);
   memcpy_private(comm->dst_buff, tmpbuff, private_blocks);
index 461eab8..be0e7da 100644 (file)
@@ -97,12 +97,13 @@ static void* asan_safe_memcpy(void* dest, void* src, size_t n)
 #endif
 
 /** Map a given SMPI privatization segment (make a SMPI process active) */
-void smpi_switch_data_segment(int dest) {
-  if (smpi_loaded_page == dest)//no need to switch, we've already loaded the one we want
+void smpi_switch_data_segment(simgrid::s4u::ActorPtr actor)
+{
+  if (smpi_loaded_page == actor->getPid()) // no need to switch, we've already loaded the one we want
     return;
 
   // So the job:
-  smpi_really_switch_data_segment(dest);
+  smpi_really_switch_data_segment(actor);
 }
 
 /** Map a given SMPI privatization segment (make a SMPI process active)  even if SMPI thinks it is already active
@@ -110,21 +111,21 @@ void smpi_switch_data_segment(int dest) {
  *  When doing a state restoration, the state of the restored variables  might not be consistent with the state of the
  *  virtual memory. In this case, we to change the data segment.
  */
-void smpi_really_switch_data_segment(int dest)
+void smpi_really_switch_data_segment(simgrid::s4u::ActorPtr actor)
 {
   if (smpi_data_exe_size == 0) // no need to switch
     return;
 
 #if HAVE_PRIVATIZATION
   // FIXME, cross-process support (mmap across process when necessary)
-  XBT_DEBUG("Switching data frame to the one of process %d", dest);
-  simgrid::smpi::Process* process = smpi_process_remote(simgrid::s4u::Actor::byPid(dest));
+  XBT_DEBUG("Switching data frame to the one of process %ld", actor->getPid());
+  simgrid::smpi::Process* process = smpi_process_remote(actor);
   int current                     = process->privatized_region()->file_descriptor;
   void* tmp =
       mmap(TOPAGE(smpi_data_exe_start), smpi_data_exe_size, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_SHARED, current, 0);
   if (tmp != TOPAGE(smpi_data_exe_start))
     xbt_die("Couldn't map the new region (errno %d): %s", errno, strerror(errno));
-  smpi_loaded_page = dest;
+  smpi_loaded_page = actor->getPid();
 #endif
 }
 
index 2e173de..fc8e8e1 100644 (file)
@@ -262,12 +262,11 @@ void Process::init(int *argc, char ***argv){
     // cheinrich: I'm not sure what the impact of the SMPI_switch_data_segment on this call is. I moved
     // this up here so that I can set the privatized region before the switch.
     Process* process = smpi_process_remote(proc);
-    int my_proc_id   = proc->getPid();
     if(smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP){
       /* Now using the segment index of this process  */
       process->set_privatized_region(smpi_init_global_memory_segment_process());
       /* Done at the process's creation */
-      SMPI_switch_data_segment(my_proc_id);
+      SMPI_switch_data_segment(proc);
     }
 
     process->set_data(argc, argv);
index 4652d05..c256f12 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2017. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2018. The SimGrid Team. All rights reserved.          */
 
 /* 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. */
@@ -57,7 +57,7 @@ void Comm::destroy(Comm* comm)
 
 int Comm::dup(MPI_Comm* newcomm){
   if(smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP){ //we need to switch as the called function may silently touch global variables
-    smpi_switch_data_segment(simgrid::s4u::Actor::self()->getPid());
+    smpi_switch_data_segment(simgrid::s4u::Actor::self());
   }
   MPI_Group cp = new  Group(this->group());
   (*newcomm)   = new  Comm(cp, this->topo());
@@ -300,7 +300,7 @@ void Comm::init_smp(){
   }
 
   if(smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP){ //we need to switch as the called function may silently touch global variables
-    smpi_switch_data_segment(simgrid::s4u::Actor::self()->getPid());
+    smpi_switch_data_segment(simgrid::s4u::Actor::self());
   }
   //identify neighbours in comm
   //get the indices of all processes sharing the same simix host
@@ -336,7 +336,7 @@ void Comm::init_smp(){
   Coll_allgather_mpich::allgather(&leader, 1, MPI_INT , leaders_map, 1, MPI_INT, this);
 
   if(smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP){ //we need to switch as the called function may silently touch global variables
-    smpi_switch_data_segment(simgrid::s4u::Actor::self()->getPid());
+    smpi_switch_data_segment(simgrid::s4u::Actor::self());
   }
 
   if(leaders_map_==nullptr){
@@ -408,7 +408,7 @@ void Comm::init_smp(){
   Coll_bcast_mpich::bcast(&(is_uniform_),1, MPI_INT, 0, comm_intra );
 
   if(smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP){ //we need to switch as the called function may silently touch global variables
-    smpi_switch_data_segment(simgrid::s4u::Actor::self()->getPid());
+    smpi_switch_data_segment(simgrid::s4u::Actor::self());
   }
   // Are the ranks blocked ? = allocated contiguously on the SMP nodes
   int is_blocked=1;
index aea96fe..7103d09 100644 (file)
@@ -1,5 +1,5 @@
 /* smpi_datatype.cpp -- MPI primitives to handle datatypes                  */
-/* Copyright (c) 2009-2017. The SimGrid Team.  All rights reserved.         */
+/* Copyright (c) 2009-2018. The SimGrid Team.  All rights reserved.         */
 
 /* 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. */
@@ -277,7 +277,7 @@ int Datatype::copy(void *sendbuf, int sendcount, MPI_Datatype sendtype,
 // FIXME Handle the case of a partial shared malloc.
 
   if(smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP){
-    smpi_switch_data_segment(simgrid::s4u::Actor::self()->getPid());
+    smpi_switch_data_segment(simgrid::s4u::Actor::self());
   }
   /* First check if we really have something to do */
   if (recvcount > 0 && recvbuf != sendbuf) {
index 53fa2cb..521f9b0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2017. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2018. The SimGrid Team. All rights reserved.          */
 
 /* 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. */
@@ -242,7 +242,7 @@ void Op::apply(void *invec, void *inoutvec, int *len, MPI_Datatype datatype)
 {
   if(smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP){//we need to switch as the called function may silently touch global variables
     XBT_DEBUG("Applying operation, switch to the right data frame ");
-    smpi_switch_data_segment(simgrid::s4u::Actor::self()->getPid());
+    smpi_switch_data_segment(simgrid::s4u::Actor::self());
   }
 
   if (not smpi_process()->replaying() && *len > 0) {
index c961ef2..6b461e1 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2018. The SimGrid Team. All rights reserved.          */
 
 /* 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. */
@@ -413,7 +413,7 @@ void Request::start()
           if ((smpi_privatize_global_variables != 0) && (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 ");
-            smpi_switch_data_segment(src_);
+            smpi_switch_data_segment(simgrid::s4u::Actor::byPid(src_));
           }
           buf = xbt_malloc(size_);
           memcpy(buf,oldbuf,size_);
@@ -708,7 +708,7 @@ void Request::finish_wait(MPI_Request* request, MPI_Status * status)
           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(simgrid::s4u::Actor::self()->getPid());
+        smpi_switch_data_segment(simgrid::s4u::Actor::self());
       }
 
       if(datatype->flags() & DT_FLAG_DERIVED){