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.
#ifndef SMPI_PROCESS_HPP
#define SMPI_PROCESS_HPP
#ifndef SMPI_PROCESS_HPP
#define SMPI_PROCESS_HPP
#include "simgrid/s4u/Mailbox.hpp"
#include "src/instr/instr_smpi.hpp"
#include "xbt/synchro.h"
#include "simgrid/s4u/Mailbox.hpp"
#include "src/instr/instr_smpi.hpp"
#include "xbt/synchro.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_memory, smpi, "Memory layout support for SMPI");
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;
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 );
static const int PROT_RWX = (PROT_READ | PROT_WRITE | PROT_EXEC);
static const int PROT_RW = (PROT_READ | PROT_WRITE );
return;
#if HAVE_PRIVATIZATION
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)
}
// FIXME, cross-process support (mmap across process when necessary)
+ 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++){
smpi_privatization_regions = new s_smpi_privatization_region_t[smpi_process_count()];
for (int i=0; i< smpi_process_count(); i++){
xbt_die("Impossible to unlink temporary file for memory mapping");
// initialize the values
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;
// store the address of the mapping for further switches
smpi_privatization_regions[i].file_descriptor = file_descriptor;