#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;
}
}
-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;
XBT_INFO("%lu bytes were automatically shared between processes, in %u calls\n", total_shared_size, total_shared_calls);
}
}
-
}
}
} // namespace simgrid
> 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.
> [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.