X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/a3d08dd00246eb26ced68c5b0e046096706bbe23..e144241627aac6cef02dbf39972e41e8c24f013a:/src/smpi/internals/smpi_global.cpp diff --git a/src/smpi/internals/smpi_global.cpp b/src/smpi/internals/smpi_global.cpp index 1ccc8bfbae..6d71a0c26b 100644 --- a/src/smpi/internals/smpi_global.cpp +++ b/src/smpi/internals/smpi_global.cpp @@ -3,21 +3,20 @@ /* 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. */ -#include "mc/mc.h" -#include "simgrid/s4u/Mailbox.hpp" -#include "simgrid/s4u/Host.hpp" -#include "src/msg/msg_private.h" -#include "src/simix/smx_private.h" -#include "src/surf/surf_interface.hpp" #include "SmpiHost.hpp" -#include "xbt/config.hpp" -#include "private.h" +#include "mc/mc.h" #include "private.hpp" +#include "simgrid/s4u/Host.hpp" +#include "simgrid/s4u/Mailbox.hpp" #include "smpi_coll.hpp" #include "smpi_comm.hpp" #include "smpi_group.hpp" #include "smpi_info.hpp" #include "smpi_process.hpp" +#include "src/msg/msg_private.hpp" +#include "src/simix/smx_private.hpp" +#include "src/surf/surf_interface.hpp" +#include "xbt/config.hpp" #include /* DBL_MAX */ #include @@ -173,24 +172,23 @@ void smpi_comm_copy_buffer_callback(smx_activity_t synchro, void *buff, size_t b auto private_blocks = merge_private_blocks(src_private_blocks, dst_private_blocks); check_blocks(private_blocks, buff_size); void* tmpbuff=buff; - if((smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP) && (static_cast(buff) >= smpi_start_data_exe) - && (static_cast(buff) < smpi_start_data_exe + smpi_size_data_exe ) - ){ - 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()); - tmpbuff = static_cast(xbt_malloc(buff_size)); - memcpy_private(tmpbuff, buff, private_blocks); + if ((smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP) && (static_cast(buff) >= smpi_data_exe_start) && + (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()); + tmpbuff = static_cast(xbt_malloc(buff_size)); + memcpy_private(tmpbuff, buff, private_blocks); } - if((smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP) && ((char*)comm->dst_buff >= smpi_start_data_exe) - && ((char*)comm->dst_buff < smpi_start_data_exe + smpi_size_data_exe )){ - 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()); + 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()); } XBT_DEBUG("Copying %zu bytes from %p to %p", buff_size, tmpbuff,comm->dst_buff); memcpy_private(comm->dst_buff, tmpbuff, private_blocks); @@ -235,8 +233,6 @@ int smpi_enabled() { void smpi_global_init() { - MPI_Group group; - if (not MC_is_active()) { global_timer = xbt_os_timer_new(); xbt_os_walltimer_start(global_timer); @@ -345,6 +341,7 @@ void smpi_global_init() } //if the process was launched through smpirun script we generate a global mpi_comm_world //if not, we let MPI_COMM_NULL, and the comm world will be private to each mpi instance + MPI_Group group; if (smpirun) { group = new simgrid::smpi::Group(process_count); MPI_COMM_WORLD = new simgrid::smpi::Comm(group, nullptr); @@ -357,8 +354,6 @@ void smpi_global_init() void smpi_global_destroy() { - int count = smpi_process_count(); - smpi_bench_destroy(); smpi_shared_destroy(); if (MPI_COMM_WORLD != MPI_COMM_UNINITIALIZED){ @@ -367,7 +362,7 @@ void smpi_global_destroy() }else{ smpi_deployment_cleanup_instances(); } - for (int i = 0; i < count; i++) { + for (int i = 0, count = smpi_process_count(); i < count; i++) { if(process_data[i]->comm_self()!=MPI_COMM_NULL){ simgrid::smpi::Comm::destroy(process_data[i]->comm_self()); } @@ -666,9 +661,8 @@ int smpi_main(const char* executable, int argc, char *argv[]) "You may want to use sampling functions or trace replay to reduce this."); } } - int count = smpi_process_count(); int ret = 0; - for (int i = 0; i < count; i++) { + for (int i = 0, count = smpi_process_count(); i < count; i++) { if(process_data[i]->return_value()!=0){ ret=process_data[i]->return_value();//return first non 0 value break; @@ -690,7 +684,7 @@ void SMPI_init(){ TRACE_smpi_alloc(); simgrid::surf::surfExitCallbacks.connect(TRACE_smpi_release); if(smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP) - smpi_initialize_global_memory_segments(); + smpi_backup_global_memory_segment(); } void SMPI_finalize(){