->set_event(surf_get_clock(), host.get_core_count() * host.get_available_speed());
}
->set_event(surf_get_clock(), host.get_core_count() * host.get_available_speed());
}
-static void instr_cpu_action_on_state_change(simgrid::surf::CpuAction* action)
+static void instr_cpu_action_on_state_change(simgrid::surf::CpuAction* action,
+ simgrid::kernel::resource::Action::State /* previous */)
{
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(),
{
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(),
host.extension_set(new HostEnergy(&host));
}
host.extension_set(new HostEnergy(&host));
}
-static void on_action_state_change(simgrid::surf::CpuAction* action)
+static void on_action_state_change(simgrid::surf::CpuAction* action, simgrid::kernel::resource::Action::State previous)
{
for (simgrid::surf::Cpu* const& cpu : action->cpus()) {
simgrid::s4u::Host* host = cpu->get_host();
{
for (simgrid::surf::Cpu* const& cpu : action->cpus()) {
simgrid::s4u::Host* host = cpu->get_host();
}
/* This callback is called when an action (computation, idle, ...) terminates */
}
/* This callback is called when an action (computation, idle, ...) terminates */
-static void on_action_state_change(simgrid::surf::CpuAction* action)
+static void on_action_state_change(simgrid::surf::CpuAction* action, simgrid::kernel::resource::Action::State /*previous*/)
{
for (simgrid::surf::Cpu* const& cpu : action->cpus()) {
simgrid::s4u::Host* host = cpu->get_host();
{
for (simgrid::surf::Cpu* const& cpu : action->cpus()) {
simgrid::s4u::Host* host = cpu->get_host();
set_last_value(get_variable()->get_value());
}
set_last_value(get_variable()->get_value());
}
-simgrid::xbt::signal<void(simgrid::surf::CpuAction*)> CpuAction::on_state_change;
+simgrid::xbt::signal<void(simgrid::surf::CpuAction*, kernel::resource::Action::State)> CpuAction::on_state_change;
void CpuAction::suspend(){
void CpuAction::suspend(){
+ Action::State previous = get_state();
+ on_state_change(this, previous);
Action::suspend();
}
void CpuAction::resume(){
Action::suspend();
}
void CpuAction::resume(){
+ Action::State previous = get_state();
+ on_state_change(this, previous);
Action::resume();
}
void CpuAction::set_state(Action::State state)
{
Action::resume();
}
void CpuAction::set_state(Action::State state)
{
+ Action::State previous = get_state();
Action::set_state(state);
Action::set_state(state);
+ on_state_change(this, previous);
/** @brief returns a list of all CPUs that this action is using */
std::list<Cpu*> CpuAction::cpus() {
std::list<Cpu*> retlist;
/** @brief returns a list of all CPUs that this action is using */
std::list<Cpu*> CpuAction::cpus() {
std::list<Cpu*> retlist;
class XBT_PUBLIC CpuAction : public simgrid::kernel::resource::Action {
public:
/** @brief Signal emitted when the action state changes (ready/running/done, etc)
class XBT_PUBLIC CpuAction : public simgrid::kernel::resource::Action {
public:
/** @brief Signal emitted when the action state changes (ready/running/done, etc)
- * Signature: `void(CpuAction *action)`
+ * Signature: `void(CpuAction *action, simgrid::kernel::resource::Action::State previous)`
- static simgrid::xbt::signal<void(simgrid::surf::CpuAction*)> on_state_change;
+ static simgrid::xbt::signal<void(simgrid::surf::CpuAction*, simgrid::kernel::resource::Action::State)> on_state_change;
/** @brief Signal emitted when the action share changes (amount of flops it gets)
* Signature: `void(CpuAction *action)`
*/
/** @brief Signal emitted when the action share changes (amount of flops it gets)
* Signature: `void(CpuAction *action)`
*/
- static simgrid::xbt::signal<void(simgrid::surf::CpuAction*)> onShareChange;
+ static simgrid::xbt::signal<void(simgrid::surf::CpuAction*)> on_share_change;
CpuAction(simgrid::kernel::resource::Model * model, double cost, bool failed) : Action(model, cost, failed) {}
CpuAction(simgrid::kernel::resource::Model * model, double cost, bool failed, kernel::lmm::Variable* var)
CpuAction(simgrid::kernel::resource::Model * model, double cost, bool failed) : Action(model, cost, failed) {}
CpuAction(simgrid::kernel::resource::Model * model, double cost, bool failed, kernel::lmm::Variable* var)