- simgrid::surf::Cpu* cpu = static_cast<simgrid::surf::Cpu*>(action->get_variable()->get_constraint(0)->get_id());
- TRACE_surf_resource_set_utilization("HOST", "power_used", cpu->get_cname(), action->get_category(),
- action->get_variable()->get_value(), action->get_last_update(),
- SIMIX_get_clock() - action->get_last_update());
+ simgrid::instr::Container::by_name(host.get_cname())
+ ->get_variable("speed")
+ ->set_event(surf_get_clock(), host.get_core_count() * host.get_available_speed());
+}
+
+static void instr_action_on_state_change(simgrid::kernel::resource::Action* action,
+ simgrid::kernel::resource::Action::State /* previous */)
+{
+ int n = action->get_variable()->get_number_of_constraint();
+
+ for (int i = 0; i < n; i++) {
+ double value = action->get_variable()->get_value() * action->get_variable()->get_constraint_weight(i);
+ /* Beware of composite actions: ptasks put links and cpus together. Extra pb: we cannot dynamic_cast from void* */
+ simgrid::kernel::resource::Resource* resource =
+ static_cast<simgrid::kernel::resource::Resource*>(action->get_variable()->get_constraint(i)->get_id());
+ simgrid::surf::Cpu* cpu = dynamic_cast<simgrid::surf::Cpu*>(resource);
+
+ if (cpu != nullptr)
+ TRACE_surf_resource_set_utilization("HOST", "speed_used", cpu->get_cname(), action->get_category(), value,
+ action->get_last_update(), SIMIX_get_clock() - action->get_last_update());
+
+ simgrid::kernel::resource::LinkImpl* link = dynamic_cast<simgrid::kernel::resource::LinkImpl*>(resource);
+
+ if (link != nullptr)
+ 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.get_bandwidth());