Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
change message a bit
[simgrid.git] / src / smpi / internals / smpi_global.cpp
index ceda03f..5cf7025 100644 (file)
@@ -65,7 +65,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_kernel, smpi, "Logging specific to SMPI (ke
 #endif
 
 #if HAVE_PAPI
-std::string papi_default_config_name = "default";
 std::map</* computation unit name */ std::string, papi_process_data, std::less<>> units2papi_setup;
 #endif
 
@@ -635,23 +634,23 @@ void SMPI_finalize()
 
   if (smpi_cfg_privatization() == SmpiPrivStrategies::MMAP)
     smpi_destroy_global_memory_segments();
-  if (simgrid::smpi::F2C::lookup() != nullptr){
-    if (simgrid::smpi::F2C::lookup()->size() > simgrid::smpi::F2C::get_num_default_handles()){
-      XBT_WARN("Probable 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());
-      int n = simgrid::config::get_value<int>("smpi/list-leaks");
-      if (n > 0) {
-        std::for_each(simgrid::smpi::F2C::lookup()->begin(),
-                  simgrid::smpi::F2C::lookup()->end(),
-                  [n](const std::pair<unsigned int, simgrid::smpi::F2C*> &p) {
-                      if(p.first >= simgrid::smpi::F2C::get_num_default_handles() && p.first < simgrid::smpi::F2C::get_num_default_handles() + n) 
-                        XBT_WARN ("Leak %p of type %s", p.second, boost::core::demangle(typeid(*(p.second)).name()).c_str() );
-                  });
+
+  if (simgrid::smpi::F2C::lookup() != nullptr &&
+      simgrid::smpi::F2C::lookup()->size() > simgrid::smpi::F2C::get_num_default_handles()) {
+    XBT_WARN("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());
+    int n = simgrid::config::get_value<int>("smpi/list-leaks");
+    for (auto const& p : *simgrid::smpi::F2C::lookup()) {
+      static int printed = 0;
+      if (printed >= n)
+        break;
+      if (p.first >= simgrid::smpi::F2C::get_num_default_handles()) {
+        XBT_WARN("Leak %p of type %s", p.second, boost::core::demangle(typeid(*(p.second)).name()).c_str());
+        printed++;
       }
     }
-    simgrid::smpi::F2C::delete_lookup();
   }
 }