Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix count for SMPI leak report.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 2 Apr 2021 20:31:04 +0000 (22:31 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 2 Apr 2021 20:31:04 +0000 (22:31 +0200)
src/smpi/internals/smpi_utils.cpp
teshsuite/smpi/coll-allreduce-with-leaks/coll-allreduce-with-leaks.tesh
teshsuite/smpi/coll-allreduce-with-leaks/mc-coll-allreduce-with-leaks.tesh

index 784db99..d280569 100644 (file)
@@ -16,6 +16,8 @@
 #include "smpi_f2c.hpp"
 #include "src/simix/smx_private.hpp"
 
+#include <algorithm>
+
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_utils, smpi, "Logging specific to SMPI (utils)");
 
 extern std::string surf_parsed_filename;
@@ -129,13 +131,18 @@ void print_time_analysis(double global_time){
   }
 }
 
-void print_memory_analysis(){
-  if (simgrid::smpi::F2C::lookup() != nullptr &&
-      simgrid::smpi::F2C::lookup()->size() > simgrid::smpi::F2C::get_num_default_handles()) {
+void print_memory_analysis()
+{
+  size_t leak_count = 0;
+  if (simgrid::smpi::F2C::lookup() != nullptr)
+    leak_count =
+        std::count_if(simgrid::smpi::F2C::lookup()->cbegin(), simgrid::smpi::F2C::lookup()->cend(),
+                      [](auto const& entry) { return entry.first >= simgrid::smpi::F2C::get_num_default_handles(); });
+  if (leak_count > 0) {
     XBT_INFO("Probable memory leaks in your code: SMPI detected %zu unfreed MPI handles : "
              "display types and addresses (n max) with --cfg=smpi/list-leaks:n.\n"
              "Running smpirun with -wrapper \"valgrind --leak-check=full\" can provide more information",
-             simgrid::smpi::F2C::lookup()->size() - simgrid::smpi::F2C::get_num_default_handles());
+             leak_count);
     int n = simgrid::config::get_value<int>("smpi/list-leaks");
     for (auto const& p : *simgrid::smpi::F2C::lookup()) {
       static int printed = 0;
@@ -162,7 +169,6 @@ void print_memory_analysis(){
       XBT_INFO("%lu bytes were automatically shared between processes, in %u calls\n", total_shared_size, total_shared_calls);
   }
 }
-
 }
 }
 } // namespace simgrid
index a4ac497..dc83fbc 100644 (file)
@@ -23,7 +23,7 @@ $ $VALGRIND_NO_LEAK_CHECK ${bindir:=.}/../../../smpi_script/bin/smpirun -map -ho
 > Largest allocation at once from a single process was 64 bytes, at sysdep.h:59. It was called 32 times during the whole simulation.
 > Running smpirun with -wrapper "valgrind --leak-check=full" can provide more information
 > This can be done automatically by setting --cfg=smpi/auto-shared-malloc-thresh to the minimum size wanted size (this can alter execution if data content is necessary)
-> [0.023768] [smpi_utils/INFO] Probable memory leaks in your code: SMPI detected 31 unfreed MPI handles : display types and addresses (n max) with --cfg=smpi/list-leaks:n.
+> [0.023768] [smpi_utils/INFO] Probable memory leaks in your code: SMPI detected 32 unfreed MPI handles : display types and addresses (n max) with --cfg=smpi/list-leaks:n.
 > [0.023768] [smpi_utils/INFO] Memory Usage: Simulated application allocated 2048 bytes during its lifetime through malloc/calloc calls.
 
 
index 004ebee..6cf42f3 100644 (file)
@@ -7,14 +7,14 @@ $ $VALGRIND_NO_LEAK_CHECK ${bindir:=.}/../../../smpi_script/bin/smpirun -wrapper
 > [rank 1] -> Tremblay
 > [rank 2] -> Tremblay
 > [rank 3] -> Tremblay
-> [0.000000] [smpi_utils/INFO] Probable memory leaks in your code: SMPI detected 7 unfreed MPI handles : display types and addresses (n max) with --cfg=smpi/list-leaks:n.
+> [0.000000] [smpi_utils/INFO] Probable memory leaks in your code: SMPI detected 8 unfreed MPI handles : display types and addresses (n max) with --cfg=smpi/list-leaks:n.
 > Running smpirun with -wrapper "valgrind --leak-check=full" can provide more information
 > [0.000000] [smpi_utils/INFO] Memory Usage: Simulated application allocated 128 bytes during its lifetime through malloc/calloc calls.
 > Largest allocation at once from a single process was 16 bytes, at sysdep.h:59. It was called 8 times during the whole simulation.
 > If this is too much, consider sharing allocations for computation buffers.
 > This can be done automatically by setting --cfg=smpi/auto-shared-malloc-thresh to the minimum size wanted size (this can alter execution if data content is necessary)
 >
-> [0.000000] [smpi_utils/INFO] Probable memory leaks in your code: SMPI detected 7 unfreed MPI handles : display types and addresses (n max) with --cfg=smpi/list-leaks:n.
+> [0.000000] [smpi_utils/INFO] Probable memory leaks in your code: SMPI detected 8 unfreed MPI handles : display types and addresses (n max) with --cfg=smpi/list-leaks:n.
 > Running smpirun with -wrapper "valgrind --leak-check=full" can provide more information
 > [0.000000] [smpi_utils/INFO] Memory Usage: Simulated application allocated 128 bytes during its lifetime through malloc/calloc calls.
 > Largest allocation at once from a single process was 16 bytes, at sysdep.h:59. It was called 8 times during the whole simulation.