Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Simplify a bit smpi_sample_* functions.
[simgrid.git] / src / smpi / internals / instr_smpi.cpp
index ad52a2e..36f00c7 100644 (file)
@@ -1,17 +1,15 @@
-/* Copyright (c) 2010-2021. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2022. 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 <boost/algorithm/string.hpp>
-#include <simgrid/s4u/Actor.hpp>
-#include <cctype>
-#include <cstdarg>
-#include <cwchar>
 #include <deque>
-#include <simgrid/sg_config.hpp>
+#include <simgrid/host.h>
+#include <simgrid/s4u/Actor.hpp>
 #include <simgrid/s4u/Host.hpp>
+#include <simgrid/sg_config.hpp>
 #include <string>
 #include <vector>
 
@@ -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 ...
@@ -169,12 +167,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->get_type()->by_name_or_create(it.first, "");
+    container->get_type()->by_name_or_create(counter, "");
   }
 #endif
 }