From: David Glesser Date: Wed, 16 Mar 2016 17:25:02 +0000 (+0100) Subject: Energy were not computed correctly for parallel tasks. X-Git-Tag: v3_13~390^2~2^2^2~1 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/6a07d63f0f7ce92c6e77881af3ca2fd1113f1fd1?hp=1fd75c7bb1fbd3684604b22d841e3715c4472a7e Energy were not computed correctly for parallel tasks. The change of computing states were only reported to the first host of the parallel task. --- diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index e084657416..ccdad63294 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -26,10 +26,15 @@ namespace surf { * Callbacks * *************/ -Cpu *getActionCpu(CpuAction *action) { - return static_cast(lmm_constraint_id(lmm_get_cnst_from_var - (action->getModel()->getMaxminSystem(), - action->getVariable(), 0))); +std::list getActionCpus(CpuAction *action) { + std::list retlist; + lmm_system_t sys = action->getModel()->getMaxminSystem(); + int llen = lmm_get_number_of_cnst_from_var(sys, action->getVariable()); + + for(int i = 0; igetVariable(), i) )) ); + } + return retlist; } simgrid::xbt::signal cpuActionStateChangedCallbacks; diff --git a/src/surf/cpu_interface.hpp b/src/surf/cpu_interface.hpp index 5aa2b4bd4b..bb4ceecacf 100644 --- a/src/surf/cpu_interface.hpp +++ b/src/surf/cpu_interface.hpp @@ -25,7 +25,7 @@ class CpuPlugin; /************* * Callbacks * *************/ -XBT_PUBLIC(Cpu*) getActionCpu(CpuAction *action); +XBT_PUBLIC(std::list) getActionCpus(CpuAction *action); /********* * Model * diff --git a/src/surf/plugins/energy.cpp b/src/surf/plugins/energy.cpp index c972873381..c0aa3570ce 100644 --- a/src/surf/plugins/energy.cpp +++ b/src/surf/plugins/energy.cpp @@ -206,16 +206,22 @@ static void onCreation(simgrid::s4u::Host& host) { } static void onActionStateChange(simgrid::surf::CpuAction *action, e_surf_action_state_t previous) { - const char *name = getActionCpu(action)->getName(); - simgrid::surf::HostImpl *host = sg_host_by_name(name)->extension(); - simgrid::surf::VirtualMachine *vm = dynamic_cast(host); - if (vm) // If it's a VM, take the corresponding PM - host = vm->getPm()->extension(); - - HostEnergy *host_energy = host->p_host->extension(); - - if(host_energy->last_updated < surf_get_clock()) - host_energy->update(); + std::list cpus = getActionCpus(action); + for(simgrid::surf::Cpu* cpu : cpus) { + const char *name = cpu->getName(); + sg_host_t sghost = sg_host_by_name(name); + if(sghost == NULL) + continue; + simgrid::surf::HostImpl *host = sghost->extension(); + simgrid::surf::VirtualMachine *vm = dynamic_cast(host); + if (vm) // If it's a VM, take the corresponding PM + host = vm->getPm()->extension(); + + HostEnergy *host_energy = host->p_host->extension(); + + if(host_energy->last_updated < surf_get_clock()) + host_energy->update(); + } } static void onHostStateChange(simgrid::s4u::Host &host) {