/** @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;
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
}
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_);
}
+++ /dev/null
-/* 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);
- }
-}
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);
#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_
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());
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(
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);
}
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
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