X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b348b0d4cff528bb4562222aa9f7874b8d30626f..c9680266ff5262307dd726d248c4e965cacc8e21:/src/smpi/smpi_memory.cpp diff --git a/src/smpi/smpi_memory.cpp b/src/smpi/smpi_memory.cpp index f21f5dcfaa..22fbd560b8 100644 --- a/src/smpi/smpi_memory.cpp +++ b/src/smpi/smpi_memory.cpp @@ -1,11 +1,11 @@ -/* Copyright (c) 2015. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2015-2017. The SimGrid Team. All rights reserved. */ /* 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 #include +#include #include @@ -21,9 +21,9 @@ #include #include -#include "../xbt/memory_map.hpp" +#include "src/xbt/memory_map.hpp" -#include "private.h" +#include "src/smpi/private.h" #include "private.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_memory, smpi, "Memory layout support for SMPI"); @@ -91,22 +91,22 @@ void smpi_really_switch_data_segment(int dest) #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++){ - memcpy(smpi_privatisation_regions[i].address, TOPAGE(smpi_start_data_exe), smpi_size_data_exe); + memcpy(smpi_privatization_regions[i].address, TOPAGE(smpi_start_data_exe), smpi_size_data_exe); } } // FIXME, cross-process support (mmap across process when necessary) - int current = smpi_privatisation_regions[dest].file_descriptor; + int current = smpi_privatization_regions[dest].file_descriptor; XBT_DEBUG("Switching data frame to the one of process %d", dest); void* tmp = mmap(TOPAGE(smpi_start_data_exe), smpi_size_data_exe, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_SHARED, current, 0); if (tmp != TOPAGE(smpi_start_data_exe)) - xbt_die("Couldn't map the new region"); + xbt_die("Couldn't map the new region (errno %d): %s", errno, strerror(errno)); smpi_loaded_page = dest; #endif } -int smpi_is_privatisation_file(char* file) +int smpi_is_privatization_file(char* file) { return strncmp("/dev/shm/my-buffer-", file, std::strlen("/dev/shm/my-buffer-")) == 0; } @@ -114,12 +114,7 @@ int smpi_is_privatisation_file(char* file) void smpi_initialize_global_memory_segments() { -#if !HAVE_PRIVATIZATION - smpi_privatize_global_variables=false; - xbt_die("You are trying to use privatization on a system that does not support it. Don't."); - return; -#else - +#if HAVE_PRIVATIZATION smpi_get_executable_global_size(); XBT_DEBUG ("bss+data segment found : size %d starting at %p", smpi_size_data_exe, smpi_start_data_exe ); @@ -129,8 +124,8 @@ void smpi_initialize_global_memory_segments() return; } - smpi_privatisation_regions = static_cast( - xbt_malloc(smpi_process_count() * sizeof(struct s_smpi_privatisation_region))); + smpi_privatization_regions = static_cast( + xbt_malloc(smpi_process_count() * sizeof(struct s_smpi_privatization_region))); for (int i=0; i< smpi_process_count(); i++){ // create SIMIX_process_count() mappings of this size with the same data inside @@ -179,9 +174,13 @@ Ask the Internet about tutorials on how to increase the files limit such as: htt memcpy(address, TOPAGE(smpi_start_data_exe), smpi_size_data_exe); // store the address of the mapping for further switches - smpi_privatisation_regions[i].file_descriptor = file_descriptor; - smpi_privatisation_regions[i].address = address; + smpi_privatization_regions[i].file_descriptor = file_descriptor; + smpi_privatization_regions[i].address = address; } +#else /* ! HAVE_PRIVATIZATION */ + smpi_privatize_global_variables = false; + xbt_die("You are trying to use privatization on a system that does not support it. Don't."); + return; #endif } @@ -190,11 +189,11 @@ void smpi_destroy_global_memory_segments(){ return; #if HAVE_PRIVATIZATION for (int i=0; i< smpi_process_count(); i++) { - if (munmap(smpi_privatisation_regions[i].address, smpi_size_data_exe) < 0) - XBT_WARN("Unmapping of fd %d failed: %s", smpi_privatisation_regions[i].file_descriptor, strerror(errno)); - close(smpi_privatisation_regions[i].file_descriptor); + if (munmap(smpi_privatization_regions[i].address, smpi_size_data_exe) < 0) + XBT_WARN("Unmapping of fd %d failed: %s", smpi_privatization_regions[i].file_descriptor, strerror(errno)); + close(smpi_privatization_regions[i].file_descriptor); } - xbt_free(smpi_privatisation_regions); + xbt_free(smpi_privatization_regions); #endif }