Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
adding documentation
[simgrid.git] / src / instr / instr_platform.cpp
index 0c785975c85e9357f6bedb709db6ca3be34af4ca..b2c01c9980939199add40f55adfb61412083a226 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2022. 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. */
@@ -24,7 +24,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_routing, instr, "Tracing platform hierarch
 
 std::string instr_pid(simgrid::s4u::Actor const& proc)
 {
-  return std::string(proc.get_name()) + "-" + std::to_string(proc.get_pid());
+  return proc.get_name() + "-" + std::to_string(proc.get_pid());
 }
 
 static simgrid::instr::Container* lowestCommonAncestor(const simgrid::instr::Container* a1,
@@ -142,10 +142,10 @@ static void recursiveNewVariableType(const std::string& new_typename, const std:
                                      simgrid::instr::Type* root)
 {
   if (root->get_name() == "HOST" || root->get_name() == "VM")
-    root->by_name_or_create(std::string("p") + new_typename, color);
+    root->by_name_or_create("p" + new_typename, color);
 
   if (root->get_name() == "LINK")
-    root->by_name_or_create(std::string("b") + new_typename, color);
+    root->by_name_or_create("b" + new_typename, color);
 
   for (auto const& [_, child] : root->get_children()) {
     recursiveNewVariableType(new_typename, color, child.get());
@@ -248,7 +248,8 @@ void platform_graph_export_graphviz(const std::string& output_filename)
   xbt_graph_free_graph(g, xbt_free_f, xbt_free_f, nullptr);
 }
 
-void platform_graph_export_csv(const std::string& output_filename) {
+void platform_graph_export_csv(const std::string& output_filename)
+{
   auto* g         = xbt_graph_new_graph(0, nullptr);
   std::map<std::string, xbt_node_t, std::less<>> nodes;
   std::map<std::string, xbt_edge_t, std::less<>> edges;
@@ -259,10 +260,10 @@ void platform_graph_export_csv(const std::string& output_filename) {
   xbt_assert(not fs.fail(), "Failed to open %s", output_filename.c_str());
 
   fs << "src,dst" << std::endl;
-  for (auto const& elm : edges) {
-    const char* src_s = static_cast<char*>(elm.second->src->data);
-    const char* dst_s = static_cast<char*>(elm.second->dst->data);
-    fs << src_s << "," << dst_s << std::endl;
+  for (auto const& [_, edge] : edges) {
+    const char* src_s = static_cast<char*>(edge->src->data);
+    const char* dst_s = static_cast<char*>(edge->dst->data);
+    fs << src_s << "," << dst_s << "\n";
   }
   fs.close();
   xbt_graph_free_graph(g, xbt_free_f, xbt_free_f, nullptr);
@@ -449,7 +450,10 @@ void define_callbacks()
     s4u::Link::on_bandwidth_change_cb([](s4u::Link const& link) {
       Container::by_name(link.get_name())
           ->get_variable("bandwidth")
-          ->set_event(simgrid_get_clock(), sg_bandwidth_factor * link.get_bandwidth());
+          ->set_event(
+              simgrid_get_clock(),
+              static_cast<kernel::resource::NetworkModel*>(link.get_impl()->get_model())->get_bandwidth_factor() *
+                  link.get_bandwidth());
     });
     s4u::NetZone::on_seal_cb([](s4u::NetZone const& /*netzone*/) { currentContainer.pop_back(); });
     kernel::routing::NetPoint::on_creation.connect([](kernel::routing::NetPoint const& netpoint) {
@@ -497,14 +501,12 @@ void define_callbacks()
 
   if (TRACE_smpi_is_enabled() && TRACE_smpi_is_computing()) {
     s4u::Exec::on_start_cb([](s4u::Exec const& exec) {
-      Container::by_name(std::string("rank-") + std::to_string(s4u::Actor::self()->get_pid()))
+      Container::by_name("rank-" + std::to_string(s4u::Actor::self()->get_pid()))
           ->get_state("MPI_STATE")
           ->push_event("computing", new CpuTIData("compute", exec.get_cost()));
     });
     s4u::Activity::on_completion_cb([](const s4u::Activity&) {
-      Container::by_name(std::string("rank-") + std::to_string(s4u::Actor::self()->get_pid()))
-          ->get_state("MPI_STATE")
-          ->pop_event();
+      Container::by_name("rank-" + std::to_string(s4u::Actor::self()->get_pid()))->get_state("MPI_STATE")->pop_event();
     });
   }