-/* 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. */
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)
}
if (SMPI_switch_data_segment && not self->finished) {
- SMPI_switch_data_segment(self->pid);
+ SMPI_switch_data_segment(self->iface());
}
}
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);
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)
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();
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)
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())
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);
}
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);
#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
* 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
}
// 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);
-/* 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. */
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());
}
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
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){
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;
/* 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. */
// 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) {
-/* 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. */
{
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) {
-/* 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. */
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_);
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){