X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f4ed74ca6d4a744d2956a4f2906c897e1886cefd..b1da263522ee9c5ca0b60d0ce75d3f06a2e641ba:/src/surf/cpu_interface.cpp diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index 23929b021b..03cea6deee 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -1,10 +1,11 @@ -/* Copyright (c) 2013-2014. The SimGrid Team. +/* Copyright (c) 2013-2015. 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. */ #include "cpu_interface.hpp" +#include "plugins/energy.hpp" XBT_LOG_EXTERNAL_CATEGORY(surf_kernel); XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu, surf, @@ -143,6 +144,7 @@ void CpuModel::updateActionsStateFull(double now, double delta) Cpu::Cpu(){ surf_callback_emit(cpuCreatedCallbacks, this); + physCpu = NULL; } Cpu::Cpu(Model *model, const char *name, xbt_dict_t props, @@ -155,6 +157,7 @@ Cpu::Cpu(Model *model, const char *name, xbt_dict_t props, , p_constraintCoreId(NULL) { surf_callback_emit(cpuCreatedCallbacks, this); + physCpu = NULL; } Cpu::Cpu(Model *model, const char *name, xbt_dict_t props, @@ -182,6 +185,7 @@ Cpu::Cpu(Model *model, const char *name, xbt_dict_t props, p_constraintCore[i] = lmm_constraint_new(model->getMaxminSystem(), p_constraintCoreId[i], m_powerScale * m_powerPeak); } } + physCpu = NULL; } Cpu::~Cpu(){ @@ -223,6 +227,21 @@ void Cpu::setState(e_surf_resource_state_t state) Resource::setState(state); surf_callback_emit(cpuStateChangedCallbacks, this, old, state); } + +void Cpu::setVirtual(Cpu *physCpu) +{ + this->physCpu = physCpu; + XBT_DEBUG("The CPU is virtual so associate the cpu energy to the physical cpu instead of creating a new one"); + std::map::iterator cpu_energy_it = surf_energy->find(physCpu); + xbt_assert(cpu_energy_it != surf_energy->end(), "The cpu is not in surf_energy."); + (*surf_energy)[this] = cpu_energy_it->second; +} + +Cpu* Cpu::isVirtual(void) +{ + return physCpu; +} + /********** * Action * **********/