- 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());
+ /* 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) {
+ double value = action->get_variable()->get_value() * action->get_variable()->get_constraint_weight(i);
+ TRACE_surf_resource_set_utilization("HOST", "power_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) {
+ 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());
+ }