X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/e9a0e5cab0ef004c02f9f2fb381fbf72cef9fcba..e6573c0e5ec4c7626833ebce8aa28d10f096db96:/src/smpi/internals/smpi_global.cpp diff --git a/src/smpi/internals/smpi_global.cpp b/src/smpi/internals/smpi_global.cpp index 1f2f20c601..e2569677f9 100644 --- a/src/smpi/internals/smpi_global.cpp +++ b/src/smpi/internals/smpi_global.cpp @@ -4,12 +4,13 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "mc/mc.h" -#include "simgrid/s4u/Engine.hpp" #include "simgrid/plugins/file_system.h" +#include "simgrid/s4u/Engine.hpp" #include "smpi_coll.hpp" +#include "smpi_config.hpp" #include "smpi_f2c.hpp" #include "smpi_host.hpp" -#include "smpi_config.hpp" +#include "src/kernel/EngineImpl.hpp" #include "src/kernel/activity/CommImpl.hpp" #include "src/simix/smx_private.hpp" #include "src/smpi/include/smpi_actor.hpp" @@ -183,21 +184,15 @@ void smpi_comm_copy_buffer_callback(simgrid::kernel::activity::CommImpl* comm, v auto private_blocks = merge_private_blocks(src_private_blocks, dst_private_blocks); check_blocks(private_blocks, buff_size); void* tmpbuff=buff; - if ((smpi_cfg_privatization() == SmpiPrivStrategies::MMAP) && - (static_cast(buff) >= smpi_data_exe_start) && - (static_cast(buff) < smpi_data_exe_start + smpi_data_exe_size)) { + if (smpi_switch_data_segment(comm->src_actor_->get_iface(), buff)) { XBT_DEBUG("Privatization : We are copying from a zone inside global memory... Saving data to temp buffer !"); - smpi_switch_data_segment(comm->src_actor_->get_iface()); tmpbuff = xbt_malloc(buff_size); memcpy_private(tmpbuff, buff, private_blocks); } - if ((smpi_cfg_privatization() == SmpiPrivStrategies::MMAP) && - ((char*)comm->dst_buff_ >= smpi_data_exe_start) && - ((char*)comm->dst_buff_ < smpi_data_exe_start + smpi_data_exe_size)) { + if (smpi_switch_data_segment(comm->dst_actor_->get_iface(), comm->dst_buff_)) XBT_DEBUG("Privatization : We are copying to a zone inside global memory - Switch data segment"); - smpi_switch_data_segment(comm->dst_actor_->get_iface()); - } + XBT_DEBUG("Copying %zu bytes from %p to %p", buff_size, tmpbuff, comm->dst_buff_); memcpy_private(comm->dst_buff_, tmpbuff, private_blocks); @@ -511,8 +506,16 @@ static void smpi_init_privatization_no_dlopen(const std::string& executable) // Execute the same entry point for each simulated process: simgrid::s4u::Engine::get_instance()->register_default([entry_point, executable](std::vector args) { - return std::function( - [entry_point, executable, args] { smpi_run_entry_point(entry_point, executable, args); }); + return std::function([entry_point, executable, args] { + if (smpi_cfg_privatization() == SmpiPrivStrategies::MMAP) { + simgrid::smpi::ActorExt* ext = smpi_process(); + /* Now using the segment index of this process */ + ext->set_privatized_region(smpi_init_global_memory_segment_process()); + /* Done at the process's creation */ + smpi_switch_data_segment(simgrid::s4u::Actor::self()); + } + smpi_run_entry_point(entry_point, executable, args); + }); }); } @@ -523,9 +526,8 @@ int smpi_main(const char* executable, int argc, char* argv[]) * configuration tools */ return 0; } - - SMPI_switch_data_segment = &smpi_switch_data_segment; - smpi_init_options(); + + smpi_init_options(true); simgrid::instr::init(); SIMIX_global_init(&argc, argv); @@ -564,7 +566,7 @@ int smpi_main(const char* executable, int argc, char* argv[]) if (MC_is_active()) { MC_run(); } else { - SIMIX_run(); + simgrid::kernel::EngineImpl::get_instance()->run(); xbt_os_walltimer_stop(global_timer); simgrid::smpi::utils::print_time_analysis(xbt_os_timer_elapsed(global_timer));