From: Martin Quinson Date: Sat, 14 Nov 2015 21:47:32 +0000 (+0100) Subject: cosmetics in the VM/energy code X-Git-Tag: v3_13~1586 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/2b7f31c28960f312a8c7eb09f7e80adae1502401 cosmetics in the VM/energy code --- diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index 345ad6cd37..1493337e47 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -228,7 +228,7 @@ void Cpu::setState(e_surf_resource_state_t state) surf_callback_emit(cpuStateChangedCallbacks, this, old, state); } -void Cpu::setVirtual(Cpu *physCpu) +void Cpu::setPhysicalCPU(Cpu *physCpu) { if (!surf_energy) return; @@ -239,7 +239,7 @@ void Cpu::setVirtual(Cpu *physCpu) (*surf_energy)[this] = cpu_energy_it->second; } -Cpu* Cpu::isVirtual(void) +Cpu* Cpu::getPhysicalCPU(void) { return physCpu; } diff --git a/src/surf/cpu_interface.hpp b/src/surf/cpu_interface.hpp index 6ac0ad9cfb..e5c82bdc77 100644 --- a/src/surf/cpu_interface.hpp +++ b/src/surf/cpu_interface.hpp @@ -207,8 +207,8 @@ public: // Adrien - Oct 2015. Additional code related to VM energy extensions /* TODO: 1./ create a VirtualCpuModel that inherits from CpuModel or create - a VirtualCpuCas01Model that inherist from CpuCas01Model - => Question: not sure which one is really usefull :( The objective is to + a VirtualCpuCas01Model that inherit from CpuCas01Model + => Question: not sure which one is really useful :( The objective is to be able to create a VirtualCpu instead of a Cpu (i.e. a CpuCas01 to be exact). 2. create VirtualCpu class that inherits from Cpu or create a VirtualCpuCas01 class that inherits from CpuCas01 (same issue as the one described above). @@ -221,19 +221,11 @@ public: */ Cpu *physCpu = NULL; - /** - * @brief Set the current Cpu as virtual or physical - * - * @param isVirtual true to indicate this Cpu is virtual, false otherwise - */ - void setVirtual(Cpu *physCpu); - - /** - * @brief Learn if this Cpu is physical or virtual - * - * @return phys CPU if the current Cpu is a VM, null otherwise - */ - Cpu* isVirtual(void); + /** @brief Specify the physical CPU of the current CPU (which is a vCPU) */ + void setPhysicalCPU(Cpu *physCpu); + + /** @brief Get the physical if the current one is a vCPU, or NULL if it's already a physical CPU */ + Cpu* getPhysicalCPU(void); // Adrien - Oct 2015. End of additional code related to VM energy extensions // //// diff --git a/src/surf/plugins/energy.cpp b/src/surf/plugins/energy.cpp index d1d871f300..d3f8c6844e 100644 --- a/src/surf/plugins/energy.cpp +++ b/src/surf/plugins/energy.cpp @@ -87,9 +87,8 @@ static void energyCpuDestructedCallback(Cpu *cpu){ CpuEnergy *cpu_energy = cpu_energy_it->second; update_consumption(cpu, cpu_energy); - // Adrien - October 2015, Changes related to VM energy extensions - // Only report/delete and erase if the cpu_energy is related to a physical one - if(cpu->isVirtual() == NULL){ + // Do nothing if that's a virtual CPU, only act for physical CPUs + if(cpu->getPhysicalCPU() == NULL){ XBT_INFO("Total energy of host %s: %f Joules", cpu->getName(), cpu_energy->getConsumedEnergy()); delete cpu_energy_it->second; surf_energy->erase(cpu_energy_it); diff --git a/src/surf/vm_hl13.cpp b/src/surf/vm_hl13.cpp index 10dd53e757..f35a2c7293 100644 --- a/src/surf/vm_hl13.cpp +++ b/src/surf/vm_hl13.cpp @@ -208,7 +208,7 @@ VMHL13::VMHL13(VMModel *model, const char* name, xbt_dict_t props, NULL, // host->state_trace, NULL); // host->properties, - p_cpu->setVirtual(sub_cpu); + p_cpu->setPhysicalCPU(sub_cpu); /* We create cpu_action corresponding to a VM process on the host operating system. */ /* FIXME: TODO: we have to periodically input GUESTOS_NOISE to the system? how ? */