bool isOff() { return not isOn(); }
double getSpeed();
+ double get_available_speed();
int getCoreCount();
std::map<std::string, std::string>* getProperties();
const char* getProperty(const char* key);
#include "simgrid/s4u/VirtualMachine.hpp"
#include "src/surf/cpu_interface.hpp"
#include "src/surf/network_interface.hpp"
+#include "src/surf/surf_interface.hpp"
#include "src/surf/xml/platf_private.hpp"
#include "surf/surf.hpp"
#include "xbt/graph.h"
}
}
+static void instr_host_on_speed_change(simgrid::s4u::Host& host)
+{
+ simgrid::instr::Container::by_name(host.get_cname())
+ ->get_variable("power")
+ ->set_event(surf_get_clock(), host.getCoreCount() * host.get_available_speed());
+}
+
static void instr_cpu_action_on_state_change(simgrid::surf::CpuAction* action,
simgrid::kernel::resource::Action::State /* previous */)
{
SIMIX_get_clock() - action->get_last_update());
}
+static void instr_link_on_communication_state_change(simgrid::kernel::resource::NetworkAction* action)
+{
+ int n = action->get_variable()->get_number_of_constraint();
+
+ for (int i = 0; i < n; i++) {
+ simgrid::kernel::lmm::Constraint* constraint = action->get_variable()->get_constraint(i);
+ simgrid::kernel::resource::LinkImpl* link = static_cast<simgrid::kernel::resource::LinkImpl*>(constraint->get_id());
+ double value = action->get_variable()->get_value() * action->get_variable()->get_constraint_weight(i);
+ TRACE_surf_resource_set_utilization("LINK", "bandwidth_used", link->get_cname(), action->get_category(), value,
+ action->get_last_update(), SIMIX_get_clock() - action->get_last_update());
+ }
+}
+static void instr_link_on_bandwidth_change(simgrid::s4u::Link& link)
+{
+ simgrid::instr::Container::by_name(link.get_cname())
+ ->get_variable("bandwidth")
+ ->set_event(surf_get_clock(), sg_bandwidth_factor * link.bandwidth());
+}
+
static void instr_netpoint_on_creation(simgrid::kernel::routing::NetPoint* netpoint)
{
if (netpoint->is_router() && TRACE_needs_platform() && TRACE_is_enabled())
if (TRACE_needs_platform()) {
simgrid::s4u::on_platform_created.connect(instr_on_platform_created);
simgrid::s4u::Host::on_creation.connect(instr_host_on_creation);
+ simgrid::s4u::Host::on_speed_change.connect(instr_host_on_speed_change);
simgrid::s4u::Link::on_creation.connect(instr_link_on_creation);
+ simgrid::s4u::Link::on_bandwidth_change.connect(instr_link_on_bandwidth_change);
}
simgrid::s4u::NetZone::onCreation.connect(instr_netzone_on_creation);
simgrid::s4u::NetZone::onSeal.connect(instr_netzone_on_seal);
simgrid::kernel::routing::NetPoint::onCreation.connect(instr_netpoint_on_creation);
simgrid::surf::CpuAction::onStateChange.connect(instr_cpu_action_on_state_change);
+ simgrid::s4u::Link::on_communication_state_change.connect(instr_link_on_communication_state_change);
if (TRACE_actor_is_enabled()) {
simgrid::s4u::Actor::on_creation.connect(instr_actor_on_creation);
{
return pimpl_cpu->getSpeed(1.0);
}
+double Host::get_available_speed()
+{
+ return pimpl_cpu->get_available_speed();
+}
/** @brief Returns the number of core of the processor. */
int Host::getCoreCount()
double sg_host_get_available_speed(sg_host_t host)
{
- return host->pimpl_cpu->get_available_speed();
+ return host->get_available_speed();
}
/** @brief Returns the number of power states for a host.
}
void Cpu::onSpeedChange() {
- if (TRACE_categorized() || TRACE_uncategorized() || TRACE_platform())
- instr::Container::by_name(get_cname())
- ->get_variable("power")
- ->set_event(surf_get_clock(), coresAmount_ * speed_.scale * speed_.peak);
s4u::Host::on_speed_change(*host_);
}
#include "network_cm02.hpp"
#include "simgrid/s4u/Host.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"
/* } */
void surf_network_model_init_CM02()
{
-
if (surf_network_model)
return;
NetworkCm02Action* action = static_cast<NetworkCm02Action*>(get_action_heap().pop());
XBT_DEBUG("Something happened to action %p", action);
- if (TRACE_is_enabled()) {
- int n = action->get_variable()->get_number_of_constraint();
-
- for (int i = 0; i < n; i++){
- kernel::lmm::Constraint* constraint = action->get_variable()->get_constraint(i);
- NetworkCm02Link* link = static_cast<NetworkCm02Link*>(constraint->get_id());
- double value = action->get_variable()->get_value() * action->get_variable()->get_constraint_weight(i);
- TRACE_surf_link_set_utilization(link->get_cname(), action->get_category(), value, action->get_last_update(),
- now - action->get_last_update());
- }
- }
// if I am wearing a latency hat
if (action->get_type() == ActionHeap::Type::latency) {
if (action.latency_ <= 0.0 && not action.is_suspended())
get_maxmin_system()->update_variable_weight(action.get_variable(), action.weight_);
}
- if (TRACE_is_enabled()) {
- int n = action.get_variable()->get_number_of_constraint();
- for (int i = 0; i < n; i++) {
- kernel::lmm::Constraint* constraint = action.get_variable()->get_constraint(i);
- NetworkCm02Link* link = static_cast<NetworkCm02Link*>(constraint->get_id());
- TRACE_surf_link_set_utilization(
- link->get_cname(), action.get_category(),
- (action.get_variable()->get_value() * action.get_variable()->get_constraint_weight(i)),
- action.get_last_update(), now - action.get_last_update());
- }
- }
+
if (not action.get_variable()->get_number_of_constraint()) {
/* There is actually no link used, hence an infinite bandwidth. This happens often when using models like
* vivaldi. In such case, just make sure that the action completes immediately.
#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"
s4u::Link::on_state_change(this->piface_);
}
}
+
void LinkImpl::turn_off()
{
if (is_on()) {
void LinkImpl::on_bandwidth_change()
{
- if (TRACE_categorized() || TRACE_uncategorized() || TRACE_platform())
- instr::Container::by_name(get_cname())
- ->get_variable("bandwidth")
- ->set_event(surf_get_clock(), sg_bandwidth_factor * bandwidth_.scale * bandwidth_.peak);
s4u::Link::on_bandwidth_change(this->piface_);
}
void NetworkAction::set_state(Action::State state)
{
+ Action::State previous = get_state();
Action::set_state(state);
- s4u::Link::on_communication_state_change(this);
+ if (previous != state) // Trigger only if the state changed
+ s4u::Link::on_communication_state_change(this);
}
/** @brief returns a list of all Links that this action is using */