X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/880401e24cd7e56dce580be316deb841a1ed5ed2..97a3566477c35dea5ea4d31bde30cc59529114bf:/src/smpi/internals/smpi_global.cpp diff --git a/src/smpi/internals/smpi_global.cpp b/src/smpi/internals/smpi_global.cpp index 749fd2f046..08eddf8f3b 100644 --- a/src/smpi/internals/smpi_global.cpp +++ b/src/smpi/internals/smpi_global.cpp @@ -20,6 +20,7 @@ #include #include /* split */ #include +#include #include #include #include /* intmax_t */ @@ -473,9 +474,7 @@ static void smpi_init_privatization_dlopen(const std::string& executable) // Copy the dynamic library, the new name must be the same length as the old one // just replace the name with 7 digits for the rank and the rest of the name. - unsigned int pad = 7; - if (libname.length() < pad) - pad = libname.length(); + auto pad = std::min(7, libname.length()); std::string target_libname = std::string(pad - std::to_string(rank).length(), '0') + std::to_string(rank) + libname.substr(pad); std::string target_lib = simgrid::config::get_value("smpi/tmpdir") + "/" + target_libname; target_libs.push_back(target_lib); @@ -636,8 +635,27 @@ 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() != 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("smpi/list-leaks"); + if (n > 0) { + std::for_each(simgrid::smpi::F2C::lookup()->begin(), + simgrid::smpi::F2C::lookup()->end(), + [n](const std::pair &p) { + static int printed = 0; + if(p.first >= simgrid::smpi::F2C::get_num_default_handles() && printed < n){ + XBT_WARN ("Leak %p of type %s", p.second, boost::core::demangle(typeid(*(p.second)).name()).c_str() ); + printed++; + } + }); + } + } simgrid::smpi::F2C::delete_lookup(); + } } void smpi_mpi_init() {