From 4dccd2b096ee264f8e190b55b76ad8d5a7ad12d7 Mon Sep 17 00:00:00 2001 From: Christian Heinrich Date: Tue, 10 Oct 2017 11:23:40 +0200 Subject: [PATCH] [SMPI] Privatization changes, step 1 This commit introduces a new variable that retains the whole initial data segment during the execution of the program. We need this as we will soon allow new processes to be added dynamically and we can hence no longer assume that we can initialize all processes at the beginning of the execution. --- src/smpi/include/smpi_process.hpp | 1 + src/smpi/internals/smpi_memory.cpp | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/smpi/include/smpi_process.hpp b/src/smpi/include/smpi_process.hpp index 0e480b0105..a69c16afdd 100644 --- a/src/smpi/include/smpi_process.hpp +++ b/src/smpi/include/smpi_process.hpp @@ -7,6 +7,7 @@ #ifndef SMPI_PROCESS_HPP #define SMPI_PROCESS_HPP +#include "private.hpp" #include "simgrid/s4u/Mailbox.hpp" #include "src/instr/instr_smpi.hpp" #include "xbt/synchro.h" diff --git a/src/smpi/internals/smpi_memory.cpp b/src/smpi/internals/smpi_memory.cpp index 7ac4abd024..f56b0fd033 100644 --- a/src/smpi/internals/smpi_memory.cpp +++ b/src/smpi/internals/smpi_memory.cpp @@ -28,10 +28,12 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_memory, smpi, "Memory layout support for SMPI"); -int smpi_loaded_page = -1; +int smpi_loaded_page = -1; char* smpi_data_exe_start = nullptr; int smpi_data_exe_size = 0; int smpi_privatize_global_variables; +static char* smpi_data_exe_copy; +// static std::set smpi_privatization_regions; static const int PROT_RWX = (PROT_READ | PROT_WRITE | PROT_EXEC); static const int PROT_RW = (PROT_READ | PROT_WRITE ); @@ -110,10 +112,8 @@ void smpi_really_switch_data_segment(int dest) return; #if HAVE_PRIVATIZATION - if(smpi_loaded_page==-1){//initial switch, do the copy from the real page here - for (int i=0; i< smpi_process_count(); i++){ - asan_safe_memcpy(smpi_privatization_regions[i].address, TOPAGE(smpi_data_exe_start), smpi_data_exe_size); - } + if (smpi_loaded_page == -1) { // initial switch, do the copy from the real page here + asan_safe_memcpy(smpi_data_exe_copy, TOPAGE(smpi_data_exe_start), smpi_data_exe_size); } // FIXME, cross-process support (mmap across process when necessary) @@ -146,6 +146,8 @@ void smpi_initialize_global_memory_segments() return; } + smpi_data_exe_copy = (char*)malloc(smpi_data_exe_size); + asan_safe_memcpy(smpi_data_exe_copy, TOPAGE(smpi_data_exe_start), smpi_data_exe_size); smpi_privatization_regions = new s_smpi_privatization_region_t[smpi_process_count()]; for (int i=0; i< smpi_process_count(); i++){ @@ -192,7 +194,7 @@ Ask the Internet about tutorials on how to increase the files limit such as: htt xbt_die("Impossible to unlink temporary file for memory mapping"); // initialize the values - asan_safe_memcpy(address, TOPAGE(smpi_data_exe_start), smpi_data_exe_size); + asan_safe_memcpy(address, smpi_data_exe_copy, smpi_data_exe_size); // store the address of the mapping for further switches smpi_privatization_regions[i].file_descriptor = file_descriptor; -- 2.20.1