Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
simplify/extend setup of resource tracing
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 24 Apr 2018 12:22:55 +0000 (14:22 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 24 Apr 2018 12:22:55 +0000 (14:22 +0200)
include/simgrid/s4u/Link.hpp
src/s4u/s4u_Link.cpp
src/surf/cpu_interface.cpp
src/surf/instr_surf.cpp [deleted file]
src/surf/network_cm02.cpp
src/surf/network_interface.cpp
src/surf/network_interface.hpp
src/surf/ptask_L07.cpp
src/surf/surf_private.hpp
tools/cmake/DefinePackages.cmake

index 9857e6c..df89744 100644 (file)
@@ -86,6 +86,9 @@ public:
   /** @brief Callback signal fired when the state of a Link changes (when it is turned on or off) */
   static simgrid::xbt::signal<void(s4u::Link&)> onStateChange;
 
+  /** @brief Callback signal fired when the bandwidth of a Link changes */
+  static simgrid::xbt::signal<void(s4u::Link&)> on_bandwidth_change;
+
   /** @brief Callback signal fired when a communication starts */
   static simgrid::xbt::signal<void(kernel::resource::NetworkAction*, s4u::Host* src, s4u::Host* dst)> onCommunicate;
 
index 512c2a7..b0257ff 100644 (file)
@@ -163,6 +163,7 @@ void Link::setProperty(std::string key, std::string value)
 simgrid::xbt::signal<void(s4u::Link&)> Link::onCreation;
 simgrid::xbt::signal<void(s4u::Link&)> Link::onDestruction;
 simgrid::xbt::signal<void(s4u::Link&)> Link::onStateChange;
+simgrid::xbt::signal<void(s4u::Link&)> Link::on_bandwidth_change;
 simgrid::xbt::signal<void(kernel::resource::NetworkAction*, s4u::Host* src, s4u::Host* dst)> Link::onCommunicate;
 simgrid::xbt::signal<void(kernel::resource::NetworkAction*)> Link::onCommunicationStateChange;
 } // namespace s4u
index 17ba993..320f777 100644 (file)
@@ -144,7 +144,10 @@ double Cpu::get_available_speed()
 }
 
 void Cpu::onSpeedChange() {
-  TRACE_surf_host_set_speed(surf_get_clock(), get_cname(), coresAmount_ * speed_.scale * speed_.peak);
+  if (TRACE_categorized() || TRACE_uncategorized() || TRACE_platform())
+    instr::Container::byName(get_cname())
+        ->getVariable("power")
+        ->setEvent(surf_get_clock(), coresAmount_ * speed_.scale * speed_.peak);
   s4u::Host::onSpeedChange(*host_);
 }
 
diff --git a/src/surf/instr_surf.cpp b/src/surf/instr_surf.cpp
deleted file mode 100644 (file)
index 8a996b7..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Copyright (c) 2010-2018. 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 "src/instr/instr_private.hpp"
-#include "src/surf/surf_interface.hpp"
-
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_surf, instr, "Tracing Surf");
-
-void TRACE_surf_host_set_speed(double date, const char *resource, double speed)
-{
-  if (TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) {
-    simgrid::instr::Container::byName(resource)->getVariable("power")->setEvent(date, speed);
-  }
-}
-
-void TRACE_surf_link_set_bandwidth(double date, const char *resource, double bandwidth)
-{
-  if (TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) {
-    simgrid::instr::Container::byName(resource)->getVariable("bandwidth")->setEvent(date, bandwidth);
-  }
-}
index 52ebc62..45140ed 100644 (file)
@@ -393,8 +393,8 @@ void NetworkCm02Link::setBandwidth(double value)
 
   get_model()->get_maxmin_system()->update_constraint_bound(get_constraint(),
                                                             sg_bandwidth_factor * (bandwidth_.peak * bandwidth_.scale));
-  TRACE_surf_link_set_bandwidth(surf_get_clock(), get_cname(),
-                                sg_bandwidth_factor * bandwidth_.peak * bandwidth_.scale);
+
+  LinkImpl::on_bandwidth_change();
 
   if (sg_weight_S_parameter > 0) {
     double delta = sg_weight_S_parameter / value - sg_weight_S_parameter / (bandwidth_.peak * bandwidth_.scale);
index 856c3f9..2e3bc1e 100644 (file)
@@ -5,7 +5,9 @@
 
 #include "network_interface.hpp"
 #include "simgrid/sg_config.hpp"
+#include "src/instr/instr_private.hpp" // TRACE_is_enabled(). FIXME: remove by subscribing tracing to the surf signals
 #include "src/surf/surf_interface.hpp"
+#include "surf/surf.hpp"
 
 #ifndef NETWORK_INTERFACE_CPP_
 #define NETWORK_INTERFACE_CPP_
@@ -182,6 +184,16 @@ void LinkImpl::turn_off()
     s4u::Link::onStateChange(this->piface_);
   }
 }
+
+void LinkImpl::on_bandwidth_change()
+{
+  if (TRACE_categorized() || TRACE_uncategorized() || TRACE_platform())
+    instr::Container::byName(get_cname())
+        ->getVariable("bandwidth")
+        ->setEvent(surf_get_clock(), sg_bandwidth_factor * bandwidth_.scale * bandwidth_.peak);
+  s4u::Link::on_bandwidth_change(this->piface_);
+}
+
 void LinkImpl::setStateTrace(tmgr_trace_t trace)
 {
   xbt_assert(stateEvent_ == nullptr, "Cannot set a second state trace to Link %s", get_cname());
index d809adf..fc01cae 100644 (file)
@@ -145,6 +145,8 @@ public:
   void turn_on() override;
   void turn_off() override;
 
+  void on_bandwidth_change();
+
   virtual void setStateTrace(tmgr_trace_t trace); /*< setup the trace file with states events (ON or OFF).
                                                           Trace must contain boolean values. */
   virtual void setBandwidthTrace(
index b26fa21..f16a311 100644 (file)
@@ -349,6 +349,8 @@ void LinkL07::apply_event(tmgr_trace_event_t triggered, double value)
 void LinkL07::setBandwidth(double value)
 {
   bandwidth_.peak = value;
+  LinkImpl::on_bandwidth_change();
+
   get_model()->get_maxmin_system()->update_constraint_bound(get_constraint(), bandwidth_.peak * bandwidth_.scale);
 }
 
index 7fb470d..375960c 100644 (file)
@@ -24,9 +24,4 @@ XBT_PUBLIC void storage_register_callbacks();
 
 XBT_PRIVATE void parse_after_config();
 
-/********** Tracing **********/
-/* from surf_instr.c */
-void TRACE_surf_host_set_speed(double date, const char* resource, double power);
-void TRACE_surf_link_set_bandwidth(double date, const char* resource, double bandwidth);
-
 #endif
index 6913ae3..aae0218 100644 (file)
@@ -329,7 +329,6 @@ set(SURF_SRC
   src/surf/cpu_interface.cpp
   src/surf/cpu_ti.cpp
   src/surf/instr_routing.cpp
-  src/surf/instr_surf.cpp
   src/surf/network_cm02.cpp
   src/surf/network_constant.cpp
   src/surf/network_interface.cpp