Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
sanitize the option smpi/shared-malloc, and improve its doc
authorMartin Quinson <martin.quinson@loria.fr>
Thu, 16 Feb 2017 16:11:52 +0000 (17:11 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Thu, 16 Feb 2017 18:45:21 +0000 (19:45 +0100)
doc/doxygen/options.doc
src/simgrid/sg_config.cpp
src/smpi/private.h
src/smpi/smpi_bench.cpp
src/smpi/smpi_global.cpp

index 90d637c..68228d0 100644 (file)
@@ -1044,14 +1044,27 @@ Here is an example:
     also disable this behavior for MPI_Iprobe.
 
 
-\subsection options_model_smpi_use_shared_malloc smpi/use-shared-malloc: Factorize malloc()s
+\subsection options_model_smpi_shared_malloc smpi/shared-malloc: Factorize malloc()s
 
-\b Default: 1
+\b Default: yes
+
+If your simulation consumes too much memory, you may want to modify
+your code so that the working areas are shared by all MPI ranks. For
+example, in a bloc-cyclic matrix multiplication, you will only
+allocate one set of blocs, and every processes will share them.
+Naturally, this will lead to very wrong results, but this will save a
+lot of memory so this is still desirable for some studies. For more on
+the motivation for that feature, please refer to the 
+<a href="https://simgrid.github.io/SMPI_CourseWare/topic_understanding_performance/matrixmultiplication/">relevant
+section</a> of the SMPI CourseWare (see Activity #2.2 of the pointed
+assignment).
 
 SMPI can use shared memory by calling shm_* functions; this might speed up the simulation.
 This opens or creates a new POSIX shared memory object, kept in RAM, in /dev/shm.
 
-If you want to disable this behavior, set the value to 0.
+If you want to disable this behavior (for example for debugging
+purposes), set its value to "no" or "0".
+
 
 \subsection options_model_smpi_wtime smpi/wtime: Inject constant times for calls to MPI_Wtime
 
@@ -1208,9 +1221,9 @@ It can be done by using XBT. Go to \ref XBT_log for more details.
 - \c smpi/papi-events: \ref options_smpi_papi_events
 - \c smpi/privatize-global-variables: \ref options_smpi_global
 - \c smpi/send-is-detached-thresh: \ref options_model_smpi_detached
+- \c smpi/shared-malloc: \ref options_model_smpi_shared_malloc
 - \c smpi/simulate-computation: \ref options_smpi_bench
 - \c smpi/test: \ref options_model_smpi_test
-- \c smpi/use-shared-malloc: \ref options_model_smpi_use_shared_malloc
 - \c smpi/wtime: \ref options_model_smpi_wtime
 
 - \c <b>Tracing configuration options can be found in Section \ref tracing_tracing_options</b>.
index e10539e..3a084c2 100644 (file)
@@ -539,8 +539,10 @@ void sg_config_init(int *argc, char **argv)
     xbt_cfg_register_boolean("smpi/simulate-computation", "yes", nullptr, "Whether the computational part of the simulated application should be simulated.");
     xbt_cfg_register_alias("smpi/simulate-computation","smpi/simulate_computation");
 
-    xbt_cfg_register_boolean("smpi/use-shared-malloc", "yes", nullptr, "Whether SMPI_SHARED_MALLOC is enabled. Disable it for debugging purposes.");
-    xbt_cfg_register_alias("smpi/use-shared-malloc", "smpi/use_shared_malloc");
+    xbt_cfg_register_boolean("smpi/shared-malloc", "yes", nullptr,
+                             "Whether SMPI_SHARED_MALLOC is enabled. Disable it for debugging purposes.");
+    xbt_cfg_register_alias("smpi/shared-malloc", "smpi/use-shared-malloc");
+    xbt_cfg_register_alias("smpi/shared-malloc", "smpi/use_shared_malloc");
 
     xbt_cfg_register_double("smpi/cpu-threshold", 1e-6, nullptr, "Minimal computation time (in seconds) not discarded, or -1 for infinity.");
     xbt_cfg_register_alias("smpi/cpu-threshold", "smpi/cpu_threshold");
index a2c1256..161703d 100644 (file)
@@ -413,6 +413,7 @@ extern XBT_PRIVATE double smpi_host_speed;
 extern XBT_PRIVATE bool smpi_privatize_global_variables;
 extern XBT_PRIVATE char* smpi_start_data_exe; //start of the data+bss segment of the executable
 extern XBT_PRIVATE int smpi_size_data_exe; //size of the data+bss segment of the executable
+extern XBT_PRIVATE bool smpi_cfg_shared_malloc; // Whether to activate shared malloc
 
 XBT_PRIVATE void smpi_switch_data_segment(int dest);
 XBT_PRIVATE void smpi_really_switch_data_segment(int dest);
index a4f0521..496809d 100644 (file)
@@ -85,6 +85,7 @@ int smpi_loaded_page = -1;
 char* smpi_start_data_exe = nullptr;
 int smpi_size_data_exe = 0;
 bool smpi_privatize_global_variables;
+bool smpi_cfg_shared_malloc    = true;
 double smpi_total_benched_time = 0;
 smpi_privatisation_region_t smpi_privatisation_regions;
 
@@ -564,7 +565,7 @@ void smpi_sample_3(int global, const char *file, int line)
 void *smpi_shared_malloc(size_t size, const char *file, int line)
 {
   void* mem;
-  if (size > 0 && xbt_cfg_get_boolean("smpi/use-shared-malloc")){
+  if (size > 0 && smpi_cfg_shared_malloc) {
     int fd;
     smpi_source_location loc(file, line);
     auto res = allocs.insert(std::make_pair(loc, shared_data_t()));
@@ -605,7 +606,7 @@ void smpi_shared_free(void *ptr)
 {
   char loc[PTR_STRLEN];
 
-  if (xbt_cfg_get_boolean("smpi/use-shared-malloc")){
+  if (smpi_cfg_shared_malloc) {
     snprintf(loc, PTR_STRLEN, "%p", ptr);
     auto meta = allocs_metadata.find(ptr);
     if (meta == allocs_metadata.end()) {
index f6094d5..3933638 100644 (file)
@@ -770,6 +770,7 @@ static void smpi_init_options(){
     smpi_privatize_global_variables = xbt_cfg_get_boolean("smpi/privatize-global-variables");
     if (smpi_cpu_threshold < 0)
       smpi_cpu_threshold = DBL_MAX;
+    smpi_cfg_shared_malloc = xbt_cfg_get_boolean("smpi/shared-malloc");
 }
 
 int smpi_main(int (*realmain) (int argc, char *argv[]), int argc, char *argv[])