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;
+smpi_privatization_region_t smpi_privatization_regions;
+// 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 );
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)
void smpi_initialize_global_memory_segments()
{
-
#if HAVE_PRIVATIZATION
smpi_get_executable_global_size();
XBT_DEBUG("bss+data segment found : size %d starting at %p", smpi_data_exe_size, smpi_data_exe_start);
- if (smpi_data_exe_size == 0) { // no need to switch
+ if (smpi_data_exe_size == 0) { // no need to switch as global variables don't exist
smpi_privatize_global_variables=false;
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++){
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;