From 8d2c36cd20b653f7f58123b6b6ac5e5b69624e6b Mon Sep 17 00:00:00 2001 From: Daniele De Sensi Date: Mon, 19 Sep 2016 20:57:17 +0200 Subject: [PATCH] [FIX] CpuCounter Cores detection. --- mammut/energy/energy-linux.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/mammut/energy/energy-linux.cpp b/mammut/energy/energy-linux.cpp index 7d3a38a1..d6d43341 100644 --- a/mammut/energy/energy-linux.cpp +++ b/mammut/energy/energy-linux.cpp @@ -84,17 +84,17 @@ void CounterCpusLinuxRefresher::run(){ bool CounterCpusLinux::hasCoresCounter(topology::Cpu* cpu){ uint64_t dummy; - return Msr(cpu->getVirtualCore()->getVirtualCoreId()).read(MSR_PP0_ENERGY_STATUS, dummy); + return Msr(cpu->getVirtualCore()->getVirtualCoreId()).read(MSR_PP0_ENERGY_STATUS, dummy) && dummy > 0; } bool CounterCpusLinux::hasGraphicCounter(topology::Cpu* cpu){ uint64_t dummy; - return Msr(cpu->getVirtualCore()->getVirtualCoreId()).read(MSR_PP1_ENERGY_STATUS, dummy); + return Msr(cpu->getVirtualCore()->getVirtualCoreId()).read(MSR_PP1_ENERGY_STATUS, dummy) && dummy > 0; } bool CounterCpusLinux::hasDramCounter(topology::Cpu* cpu){ uint64_t dummy; - return Msr(cpu->getVirtualCore()->getVirtualCoreId()).read(MSR_DRAM_ENERGY_STATUS, dummy); + return Msr(cpu->getVirtualCore()->getVirtualCoreId()).read(MSR_DRAM_ENERGY_STATUS, dummy) && dummy > 0; } bool CounterCpusLinux::isCpuSupported(topology::Cpu* cpu){ @@ -125,7 +125,7 @@ CounterCpusLinux::CounterCpusLinux(): _lastReadCountersCores(NULL), _lastReadCountersGraphic(NULL), _lastReadCountersDram(NULL), - _hasJoulesCores(false), + _hasJoulesCores(false), _hasJoulesGraphic(false), _hasJoulesDram(false){ ; @@ -193,7 +193,7 @@ bool CounterCpusLinux::init(){ _hasJoulesGraphic = true; for(size_t i = 0; i < _cpus.size(); i++){ if(!hasCoresCounter(_cpus.at(i))){ - _hasJoulesCores = false; + _hasJoulesCores = false; } if(!hasDramCounter(_cpus.at(i))){ _hasJoulesDram = false; @@ -276,13 +276,13 @@ Joules CounterCpusLinux::getJoulesCpu(topology::CpuId cpuId){ } Joules CounterCpusLinux::getJoulesCores(topology::CpuId cpuId){ - if(hasJoulesCores()){ - ScopedLock sLock(_lock); - updateCounter(cpuId, _joulesCpus[cpuId].cores, _lastReadCountersCores[cpuId], MSR_PP0_ENERGY_STATUS); - return _joulesCpus[cpuId].cores; - }else{ - return 0; - } + if(hasJoulesCores()){ + ScopedLock sLock(_lock); + updateCounter(cpuId, _joulesCpus[cpuId].cores, _lastReadCountersCores[cpuId], MSR_PP0_ENERGY_STATUS); + return _joulesCpus[cpuId].cores; + }else{ + return 0; + } } Joules CounterCpusLinux::getJoulesGraphic(topology::CpuId cpuId){