From: Martin Quinson Date: Thu, 16 Feb 2017 16:11:52 +0000 (+0100) Subject: sanitize the option smpi/shared-malloc, and improve its doc X-Git-Tag: v3_15~341 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/a7bcf0f57ffe5ef60e309c4472e6715898da7d8d?hp=6671c48e9ba13cfa005d59f6b88167c302f7ba06 sanitize the option smpi/shared-malloc, and improve its doc --- diff --git a/doc/doxygen/options.doc b/doc/doxygen/options.doc index 90d637c68d..68228d0cd8 100644 --- a/doc/doxygen/options.doc +++ b/doc/doxygen/options.doc @@ -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 +relevant +section 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 Tracing configuration options can be found in Section \ref tracing_tracing_options. diff --git a/src/simgrid/sg_config.cpp b/src/simgrid/sg_config.cpp index e10539e6f4..3a084c2c67 100644 --- a/src/simgrid/sg_config.cpp +++ b/src/simgrid/sg_config.cpp @@ -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"); diff --git a/src/smpi/private.h b/src/smpi/private.h index a2c125607f..161703d66e 100644 --- a/src/smpi/private.h +++ b/src/smpi/private.h @@ -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); diff --git a/src/smpi/smpi_bench.cpp b/src/smpi/smpi_bench.cpp index a4f05211ca..496809d588 100644 --- a/src/smpi/smpi_bench.cpp +++ b/src/smpi/smpi_bench.cpp @@ -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()) { diff --git a/src/smpi/smpi_global.cpp b/src/smpi/smpi_global.cpp index f6094d53e3..3933638e8f 100644 --- a/src/smpi/smpi_global.cpp +++ b/src/smpi/smpi_global.cpp @@ -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[])