X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f368403c7b31807751cbc287deeb4d92e90070cd..f52bb9560085e6507728145fa4ee31b6cafb8075:/src/smpi/internals/instr_smpi.cpp diff --git a/src/smpi/internals/instr_smpi.cpp b/src/smpi/internals/instr_smpi.cpp index f3e1b4129a..63e8f338ee 100644 --- a/src/smpi/internals/instr_smpi.cpp +++ b/src/smpi/internals/instr_smpi.cpp @@ -1,22 +1,20 @@ -/* Copyright (c) 2010-2021. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2010-2023. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ #include "private.hpp" -#include +#include "src/simgrid/sg_config.hpp" +#include "src/smpi/include/smpi_actor.hpp" +#include #include -#include -#include -#include -#include -#include #include + +#include +#include #include #include -#include "src/smpi/include/smpi_actor.hpp" - XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_smpi, instr, "Tracing SMPI"); static std::unordered_map> keys; @@ -88,9 +86,9 @@ static const char* instr_find_color(const char* c_state) if (smpi_colors.find(state) != smpi_colors.end()) { // Exact match in the map? return smpi_colors.find(state)->second.c_str(); } - for (const auto& pair : smpi_colors) { // Is an entry of our map a substring of this state name? - if (std::strstr(state.c_str(), pair.first.c_str()) != nullptr) - return pair.second.c_str(); + for (const auto& [smpi_state, color] : smpi_colors) { // Is an entry of our map a substring of this state name? + if (state.find(smpi_state) != std::string::npos) + return color.c_str(); } return "0.5 0.5 0.5"; // Just in case we find nothing in the map ... @@ -98,7 +96,7 @@ static const char* instr_find_color(const char* c_state) XBT_PRIVATE simgrid::instr::Container* smpi_container(aid_t pid) { - return simgrid::instr::Container::by_name(std::string("rank-") + std::to_string(pid)); + return simgrid::instr::Container::by_name("rank-" + std::to_string(pid)); } static std::string TRACE_smpi_put_key(aid_t src, aid_t dst, int tag, int send) @@ -122,8 +120,7 @@ static std::string TRACE_smpi_get_key(aid_t src, aid_t dst, int tag, int send) std::string key; std::string aux = std::to_string(src) + "#" + std::to_string(dst) + "#" + std::to_string(tag) + "#" + std::to_string(send == 1 ? 0 : 1); - auto it = keys.find(aux); - if (it == keys.end()) { + if (auto it = keys.find(aux); it == keys.end()) { // first posted key = TRACE_smpi_put_key(src, dst, tag, send); } else { @@ -142,7 +139,7 @@ void TRACE_smpi_setup_container(aid_t pid, const_sg_host_t host) parent = simgrid::instr::Container::by_name_or_null(host->get_name()); xbt_assert(parent != nullptr, "Could not find a parent for mpi rank 'rank-%ld' at function %s", pid, __func__); } - parent->create_child(std::string("rank-") + std::to_string(pid), "MPI"); // This container is of type MPI + parent->create_child("rank-" + std::to_string(pid), "MPI"); // This container is of type MPI } void TRACE_smpi_init(aid_t pid, const std::string& calling_func) @@ -150,7 +147,7 @@ void TRACE_smpi_init(aid_t pid, const std::string& calling_func) if (not TRACE_smpi_is_enabled()) return; - auto self = simgrid::s4u::Actor::self(); + const auto* self = simgrid::s4u::Actor::self(); TRACE_smpi_setup_container(pid, sg_host_self()); simgrid::s4u::this_actor::on_exit([self](bool) { smpi_container(self->get_pid())->remove_from_parent(); }); @@ -169,12 +166,12 @@ void TRACE_smpi_init(aid_t pid, const std::string& calling_func) const simgrid::instr::Container* container = smpi_container(pid); papi_counter_t counters = smpi_process()->papi_counters(); - for (auto const& it : counters) { + for (auto const& [counter, _] : counters) { /** * Check whether this variable already exists or not. Otherwise, it will be created * multiple times but only the last one would be used... */ - container->type_->by_name_or_create(it.first, ""); + container->get_type()->by_name_or_create(counter, ""); } #endif }