From c495fe6769bec6f17769365a17a7a2673902efcc Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 4 Jan 2016 11:44:31 +0100 Subject: [PATCH 1/1] Do the right thing in CpuL07::onSpeedChange - That's very close to what we have in CpuCas01 - I guess that existing actions were not correctly updated when an avail event occurred. That's fixed now. - It make ptask07 model usable with DVFS (fix: #43) YUHU!!! --- .../consumption/energy_consumption.tesh | 2 +- src/surf/host_ptask_L07.cpp | 23 +++++++++++++++++-- src/surf/host_ptask_L07.hpp | 2 ++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/examples/msg/energy/consumption/energy_consumption.tesh b/examples/msg/energy/consumption/energy_consumption.tesh index d7cc2eefdf..8cd12b63b5 100644 --- a/examples/msg/energy/consumption/energy_consumption.tesh +++ b/examples/msg/energy/consumption/energy_consumption.tesh @@ -39,8 +39,8 @@ $ $SG_TEST_EXENV energy/consumption/energy_consumption$EXEEXT ${srcdir:=.}/../pl > [ 16.000000] (1:dvfs_test@MyHost1) Sleep for 4 seconds > [ 20.000000] (1:dvfs_test@MyHost1) Done sleeping (duration: 4.00 s). Current peak speed=2E+07 flop/s; Energy dissipated=2310 J > [ 20.000000] (1:dvfs_test@MyHost1) Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 dissipated 2000 J so far. +> [ 30.000000] (1:dvfs_test@MyHost1) Done sleeping (duration: 10.00 s). Current peak speed=2E+07 flop/s; Energy dissipated=3210 J > [ 30.000000] (0:@) Total simulation time: 30.00 > [ 30.000000] (0:@) Total energy of host MyHost1: 3210.000000 Joules > [ 30.000000] (0:@) Total energy of host MyHost2: 2100.000000 Joules > [ 30.000000] (0:@) Total energy of host MyHost3: 3000.000000 Joules -> [ 30.000000] (1:dvfs_test@MyHost1) Done sleeping (duration: 10.00 s). Current peak speed=2E+07 flop/s; Energy dissipated=3210 J diff --git a/src/surf/host_ptask_L07.cpp b/src/surf/host_ptask_L07.cpp index e5a7d6670a..fba3ef6324 100644 --- a/src/surf/host_ptask_L07.cpp +++ b/src/surf/host_ptask_L07.cpp @@ -474,6 +474,25 @@ bool CpuL07::isUsed(){ return lmm_constraint_used(getModel()->getMaxminSystem(), getConstraint()); } +/** @brief take into account changes of speed (either load or max) */ +void CpuL07::onSpeedChange() { + lmm_variable_t var = NULL; + lmm_element_t elem = NULL; + + lmm_update_constraint_bound(getModel()->getMaxminSystem(), getConstraint(), m_speedPeak * m_speedScale); + while ((var = lmm_get_var_from_cnst + (getModel()->getMaxminSystem(), getConstraint(), &elem))) { + Action *action = static_cast(lmm_variable_id(var)); + + lmm_update_variable_bound(getModel()->getMaxminSystem(), + action->getVariable(), + m_speedScale * m_speedPeak); + } + + Cpu::onSpeedChange(); +} + + bool LinkL07::isUsed(){ return lmm_constraint_used(getModel()->getMaxminSystem(), getConstraint()); } @@ -481,8 +500,8 @@ bool LinkL07::isUsed(){ void CpuL07::updateState(tmgr_trace_event_t event_type, double value, double /*date*/){ XBT_DEBUG("Updating cpu %s (%p) with value %g", getName(), this, value); if (event_type == p_speedEvent) { - m_speedScale = value; - lmm_update_constraint_bound(getModel()->getMaxminSystem(), getConstraint(), m_speedPeak * m_speedScale); + m_speedScale = value; + onSpeedChange(); if (tmgr_trace_event_free(event_type)) p_speedEvent = NULL; } else if (event_type == p_stateEvent) { diff --git a/src/surf/host_ptask_L07.hpp b/src/surf/host_ptask_L07.hpp index 89ab7c8061..8100346c8d 100644 --- a/src/surf/host_ptask_L07.hpp +++ b/src/surf/host_ptask_L07.hpp @@ -105,6 +105,8 @@ public: void updateState(tmgr_trace_event_t event_type, double value, double date) override; Action *execute(double size) override; Action *sleep(double duration) override; +protected: + void onSpeedChange() override; }; class LinkL07 : public Link { -- 2.20.1