From a1d0f5ae6be48d26770a264562100706e9a5e9ff Mon Sep 17 00:00:00 2001 From: Christian Heinrich Date: Wed, 17 Jan 2018 21:38:10 +0100 Subject: [PATCH] [SMPI] Remove index_ and index() from smpi::Process --- src/smpi/include/smpi_process.hpp | 4 +-- src/smpi/internals/smpi_global.cpp | 8 ++---- src/smpi/internals/smpi_process.cpp | 40 ++++++++++------------------- 3 files changed, 17 insertions(+), 35 deletions(-) diff --git a/src/smpi/include/smpi_process.hpp b/src/smpi/include/smpi_process.hpp index f6bfa80176..d9ef794662 100644 --- a/src/smpi/include/smpi_process.hpp +++ b/src/smpi/include/smpi_process.hpp @@ -28,7 +28,6 @@ class Process { MPI_Comm comm_intra_ = MPI_COMM_NULL; MPI_Comm* comm_world_ = nullptr; void* data_ = nullptr; /* user data */ - int index_ = MPI_UNDEFINED; char state_; int sampling_ = 0; /* inside an SMPI_SAMPLE_ block? */ char* instance_id_ = nullptr; @@ -45,7 +44,7 @@ class Process { #endif public: explicit Process(simgrid::s4u::ActorPtr actor, msg_bar_t barrier); - void set_data(int index, int* argc, char*** argv); + void set_data(int* argc, char*** argv); void finalize(); int finalized(); int initialized(); @@ -57,7 +56,6 @@ class Process { smpi_trace_call_location_t* call_location(); void set_privatized_region(smpi_privatization_region_t region); smpi_privatization_region_t privatized_region(); - int index(); smx_mailbox_t mailbox(); smx_mailbox_t mailbox_small(); xbt_mutex_t mailboxes_mutex(); diff --git a/src/smpi/internals/smpi_global.cpp b/src/smpi/internals/smpi_global.cpp index 2c66eb3743..82fa33c4c1 100644 --- a/src/smpi/internals/smpi_global.cpp +++ b/src/smpi/internals/smpi_global.cpp @@ -197,9 +197,7 @@ void smpi_comm_copy_buffer_callback(smx_activity_t synchro, void *buff, size_t b (static_cast(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( - static_cast((static_cast(comm->src_proc->userdata)->data)) - ->index()); + smpi_switch_data_segment(Actor::self()->getPid()); tmpbuff = static_cast(xbt_malloc(buff_size)); memcpy_private(tmpbuff, buff, private_blocks); } @@ -207,9 +205,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( - static_cast((static_cast(comm->dst_proc->userdata)->data)) - ->index()); + smpi_switch_data_segment(Actor::self()->getPid()); } XBT_DEBUG("Copying %zu bytes from %p to %p", buff_size, tmpbuff,comm->dst_buff); memcpy_private(comm->dst_buff, tmpbuff, private_blocks); diff --git a/src/smpi/internals/smpi_process.cpp b/src/smpi/internals/smpi_process.cpp index 313324acb9..4478a931ab 100644 --- a/src/smpi/internals/smpi_process.cpp +++ b/src/smpi/internals/smpi_process.cpp @@ -66,7 +66,7 @@ Process::Process(ActorPtr actor, msg_bar_t finalization_barrier) #endif } -void Process::set_data(int index, int* argc, char*** argv) +void Process::set_data(int* argc, char*** argv) { char* instance_id = (*argv)[1]; comm_world_ = smpi_deployment_comm_world(instance_id); @@ -74,7 +74,6 @@ void Process::set_data(int index, int* argc, char*** argv) if (barrier != nullptr) // don't overwrite the current one if the instance has none finalization_barrier_ = barrier; instance_id_ = instance_id; - index_ = index; process_ = simgrid::s4u::Actor::self(); static_cast(process_->getImpl()->userdata)->data = this; @@ -89,29 +88,26 @@ void Process::set_data(int index, int* argc, char*** argv) argv_ = argv; // set the process attached to the mailbox mailbox_small_->setReceiver(simgrid::s4u::Actor::self()); - XBT_DEBUG("<%d> New process in the game: %p", index_, process_); + XBT_DEBUG("<%lu> New process in the game: %p", process_->getPid(), process_); } /** @brief Prepares the current process for termination. */ void Process::finalize() { state_ = SMPI_FINALIZED; - XBT_DEBUG("<%d> Process left the game", index_); + XBT_DEBUG("<%lu> Process left the game", process_->getPid()); - // This leads to an explosion of the search graph which cannot be reduced: - if(MC_is_active() || MC_record_replay_is_active()) - return; - // wait for all pending asynchronous comms to finish - MSG_barrier_wait(finalization_barrier_); + // This leads to an explosion of the search graph which cannot be reduced: + if(MC_is_active() || MC_record_replay_is_active()) + return; + // wait for all pending asynchronous comms to finish + MSG_barrier_wait(finalization_barrier_); } /** @brief Check if a process is finalized */ int Process::finalized() { - if (index_ != MPI_UNDEFINED) - return (state_ == SMPI_FINALIZED); - else - return 0; + return (state_ == SMPI_FINALIZED); } /** @brief Check if a process is initialized */ @@ -119,26 +115,23 @@ int Process::initialized() { // TODO cheinrich: Check if we still need this. This should be a global condition, not for a // single process ... ? - return ((index_ != MPI_UNDEFINED) && (state_ == SMPI_INITIALIZED)); + return (state_ == SMPI_INITIALIZED); } /** @brief Mark a process as initialized (=MPI_Init called) */ void Process::mark_as_initialized() { - if ((index_ != MPI_UNDEFINED) && (state_ != SMPI_FINALIZED)) + if (state_ != SMPI_FINALIZED) state_ = SMPI_INITIALIZED; } void Process::set_replaying(bool value){ - if ((index_ != MPI_UNDEFINED) && (state_ != SMPI_FINALIZED)) + if (state_ != SMPI_FINALIZED) replaying_ = value; } bool Process::replaying(){ - if (index_ != MPI_UNDEFINED) - return replaying_; - else - return false; + return replaying_; } void Process::set_user_data(void *data) @@ -175,11 +168,6 @@ smpi_privatization_region_t Process::privatized_region() return privatized_region_; } -int Process::index() -{ - return index_; -} - MPI_Comm Process::comm_world() { return comm_world_==nullptr ? MPI_COMM_NULL : *comm_world_; @@ -297,7 +285,7 @@ void Process::init(int *argc, char ***argv){ SMPI_switch_data_segment(my_proc_id); } - process->set_data(my_proc_id, argc, argv); + process->set_data(argc, argv); } xbt_assert(smpi_process(), "smpi_process() returned nullptr. You probably gave a nullptr parameter to MPI_Init. " -- 2.20.1