-/* Copyright (c) 2010, 2012-2013. The SimGrid Team.
+/* Copyright (c) 2010, 2012-2014. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
+ * under the terms of the license (GNU LGPL) which comes with this package. */
#include "energy.hpp"
#include "../cpu_cas01.hpp"
std::map<CpuPtr, CpuEnergyPtr> *surf_energy=NULL;
-static void createCpuCallback(CpuPtr cpu){
+static void energyCpuCreatedCallback(CpuPtr cpu){
(*surf_energy)[cpu] = new CpuEnergy(cpu);
}
-static void deleteCpuCallback(CpuPtr cpu){
+static void energyCpuDestructedCallback(CpuPtr cpu){
std::map<CpuPtr, CpuEnergyPtr>::iterator cpuIt = surf_energy->find(cpu);
xbt_assert(cpuIt != surf_energy->end(), "The cpu is not in surf_energy.");
XBT_INFO("Total energy (Joules) of host %s: %f", cpu->getName(), cpuIt->second->getConsumedEnergy());
surf_energy->erase(cpuIt);
}
-static void updateActionEnergyCallback(CpuActionPtr action){
+static void energyCpuActionStateChangedCallback(CpuActionPtr action){
CpuPtr cpu = getActionCpu(action);
CpuEnergyPtr cpu_energy = (*surf_energy)[cpu];
}
}
+static void sg_energy_plugin_exit()
+{
+ delete surf_energy;
+ surf_energy = NULL;
+}
+
/** \ingroup SURF_plugin_energy
* \brief Enable energy plugin
* \details Enable energy plugin to get joules consumption of each cpu.
void sg_energy_plugin_init() {
if (surf_energy == NULL) {
surf_energy = new std::map<CpuPtr, CpuEnergyPtr>();
- surf_callback_connect(createCpuCallbacks, createCpuCallback);
- surf_callback_connect(deleteCpuCallbacks, deleteCpuCallback);
- surf_callback_connect(updateCpuActionCallbacks, updateActionEnergyCallback);
+ surf_callback_connect(cpuCreatedCallbacks, energyCpuCreatedCallback);
+ surf_callback_connect(cpuDestructedCallbacks, energyCpuDestructedCallback);
+ surf_callback_connect(cpuActionStateChangedCallbacks, energyCpuActionStateChangedCallback);
+ surf_callback_connect(surfExitCallbacks, sg_energy_plugin_exit);
}
}
cpu->getName());*/
/* retrieve the power values associated with the current pstate */
- xbt_dynar_t current_power_values = xbt_dynar_get_as(power_range_list, static_cast<CpuCas01Ptr>(cpu)->m_pstate, xbt_dynar_t);
+ xbt_dynar_t current_power_values = xbt_dynar_get_as(power_range_list, static_cast<CpuCas01Ptr>(cpu)->getPState(), xbt_dynar_t);
/* min_power corresponds to the idle power (cpu load = 0) */
/* max_power is the power consumed at 100% cpu load */