#include <array>
#include <boost/algorithm/string.hpp> /* split */
#include <boost/tokenizer.hpp>
+#include <boost/core/demangle.hpp>
#include <cerrno>
#include <cinttypes>
#include <cstdint> /* intmax_t */
#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
// 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<unsigned>(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<std::string>("smpi/tmpdir") + "/" + target_libname;
target_libs.push_back(target_lib);
for (const std::string& target_lib : target_libs)
unlink(target_lib.c_str());
}
- xbt_assert(handle != nullptr, "dlopen failed: %s (errno: %d -- %s)", dlerror(), saved_errno,
- strerror(saved_errno));
+ xbt_assert(handle != nullptr,
+ "dlopen failed: %s (errno: %d -- %s).\nError: Did you compile the program with a SMPI-specific "
+ "compiler (spmicc or friends)?",
+ dlerror(), saved_errno, strerror(saved_errno));
smpi_entry_point_type entry_point = smpi_resolve_function(handle);
xbt_assert(entry_point, "Could not resolve entry point");
if (smpi_cfg_privatization() == SmpiPrivStrategies::MMAP)
smpi_destroy_global_memory_segments();
- if (simgrid::smpi::F2C::lookup() != nullptr)
- simgrid::smpi::F2C::delete_lookup();
+
+ 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++;
+ }
+ }
+ }
}
void smpi_mpi_init() {