From e23598cf4d2dd48bd650c938e5072f698c0ea2e9 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Sun, 8 Apr 2018 18:58:13 +0200 Subject: [PATCH] Avoid multiple initializations for active_processes. Fixes a memory leak seen with smpi-replay-multiple (smpi_free_replay_tmp_buffers() was not called). --- examples/smpi/replay_multiple/replay_multiple.tesh | 1 + src/smpi/internals/smpi_replay.cpp | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/smpi/replay_multiple/replay_multiple.tesh b/examples/smpi/replay_multiple/replay_multiple.tesh index abdf3ccefc..9ca0587915 100644 --- a/examples/smpi/replay_multiple/replay_multiple.tesh +++ b/examples/smpi/replay_multiple/replay_multiple.tesh @@ -10,4 +10,5 @@ $ ./replay_multiple description_file ${srcdir:=.}/../../platforms/small_platform > [0.000000] [smpi_kernel/INFO] You did not set the power of the host running the simulation. The timings will certainly not be accurate. Use the option "--cfg=smpi/host-speed:" to set its value.Check http://simgrid.org/simgrid/latest/doc/options.html#options_smpi_bench for more information. > [0.000000] [msg_test/INFO] Initializing instance 1 of size 32 > [0.000000] [msg_test/INFO] Initializing instance 2 of size 32 +> [Ginette:2:(34) 37298.251477] [smpi_replay/INFO] Simulation time 10442.494756 > [37298.251477] [msg_test/INFO] Simulation time 37298.3 diff --git a/src/smpi/internals/smpi_replay.cpp b/src/smpi/internals/smpi_replay.cpp index 40f5cdbd15..1aca704338 100644 --- a/src/smpi/internals/smpi_replay.cpp +++ b/src/smpi/internals/smpi_replay.cpp @@ -22,7 +22,6 @@ using simgrid::s4u::Actor; XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_replay,smpi,"Trace Replay with SMPI"); -static int active_processes = 0; static std::unordered_map*> reqq; static MPI_Datatype MPI_DEFAULT_TYPE; @@ -566,9 +565,6 @@ public: /* start a simulated timer */ smpi_process()->simulated_start(); - /*initialize the number of active processes */ - active_processes = smpi_process_count(); - set_reqq_self(new std::vector); } }; @@ -860,6 +856,8 @@ void smpi_replay_init(int* argc, char*** argv) /** @brief actually run the replay after initialization */ void smpi_replay_main(int* argc, char*** argv) { + static int active_processes = 0; + active_processes++; simgrid::xbt::replay_runner(*argc, *argv); /* and now, finalize everything */ -- 2.20.1