SMUCNGPerfOperator.cpp 18.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
//================================================================================
// Name        : SMUCNGPerfOperator.cpp
// Author      : Carla Guillen
// Contact     : info@dcdb.it
// Copyright   : Leibniz Supercomputing Centre
// Description : Template implementing features to use Units in Operators.
//================================================================================

//================================================================================
// This file is part of DCDB (DataCenter DataBase)
// Copyright (C) 2018-2019 Leibniz Supercomputing Centre
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
//================================================================================
27

28
#include "SMUCNGPerfOperator.h"
29

30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
#include <boost/log/sources/record_ostream.hpp>
#include <boost/log/utility/formatting_ostream.hpp>
#include <boost/parameter/keyword.hpp>
#include <cstdint>
#include <memory>
#include <string>
#include <utility>
#include <vector>

#include "../../../common/include/cacheentry.h"
#include "../../../common/include/logging.h"
#include "../../../common/include/sensorbase.h"
#include "../../../common/include/timestamp.h"
#include "../../includes/QueryEngine.h"
#include "../../includes/UnitTemplate.h"
#include "SKXPMUMetrics.h"

Carla Guillen's avatar
Carla Guillen committed
47
SMUCNGPerfOperator::SMUCNGPerfOperator(const std::string& name): OperatorTemplate(name), _go_back_ns(0), _measuring_interval_s(1) {
48
    _buffers.resize(64);
Carla Guillen's avatar
Carla Guillen committed
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
    _metricToPerSecId[SMUCSensorBase::INSTRUCTIONS] = SMUCSensorBase::INSTRUCTIONS_PER_SECOND; 
    _metricToPerSecId[SMUCSensorBase::ARITH_FPU_DIVIDER_ACTIVE] = SMUCSensorBase::EXPENSIVE_INSTRUCTIONS_PER_SECOND;
//    _metricToPerSecId[SMUCSensorBase::L2_HITS] = SMUCSensorBase::L2_HITS_PER_SECOND;
    _metricToPerSecId[SMUCSensorBase::L2_RQSTS_MISS] = SMUCSensorBase::L2_MISSES_PER_SECOND;
    _metricToPerSecId[SMUCSensorBase::MEM_LOAD_RETIRED_L3_HIT] = SMUCSensorBase::L3_HITS_PER_SECOND;
    _metricToPerSecId[SMUCSensorBase::MEM_LOAD_RETIRED_L3_MISS] = SMUCSensorBase::L3_MISSES_PER_SECOND;
    _metricToPerSecId[SMUCSensorBase::PERF_COUNT_HW_BRANCH_MISSES] = SMUCSensorBase::MISSBRANCHES_PER_SECOND;
    _metricToPerSecId[SMUCSensorBase::NETWORK_XMIT] = SMUCSensorBase::NETWORK_BYTES_XMIT_PER_SECOND;
    _metricToPerSecId[SMUCSensorBase::NETWORK_RCVD] = SMUCSensorBase::NETWORK_BYTES_RCVD_PER_SECOND;
    _metricToPerSecId[SMUCSensorBase::IOOPENS] = SMUCSensorBase::IOOPENS_PER_SECOND;
    _metricToPerSecId[SMUCSensorBase::IOCLOSES] = SMUCSensorBase::IOCLOSES_PER_SECOND;
    _metricToPerSecId[SMUCSensorBase::IOBYTESREAD] = SMUCSensorBase::IOBYTESREAD_PER_SECOND;
    _metricToPerSecId[SMUCSensorBase::IOBYTESWRITE] = SMUCSensorBase::IOBYTESWRITE_PER_SECOND;
    _metricToPerSecId[SMUCSensorBase::IOREADS] = SMUCSensorBase::IOREADS_PER_SECOND;
    _metricToPerSecId[SMUCSensorBase::IOWRITES] = SMUCSensorBase::IOWRITES_PER_SECOND;
64 65
}

66
SMUCNGPerfOperator::~SMUCNGPerfOperator() {
67 68
}

69
SMUCNGPerfOperator::SMUCNGPerfOperator(const SMUCNGPerfOperator& other) : OperatorTemplate(other){
70
    copy(other);
71 72 73
}

SMUCNGPerfOperator& SMUCNGPerfOperator::operator=(const SMUCNGPerfOperator& other){
Carla Guillen's avatar
Carla Guillen committed
74
    OperatorTemplate::operator =(other);
75 76 77 78 79
    copy(other);
    return *this;
}

void SMUCNGPerfOperator::copy(const SMUCNGPerfOperator& other){
Carla Guillen's avatar
Carla Guillen committed
80 81
    this->_buffers = other._buffers;
    this->_metricToPosition = other._metricToPosition;
Carla Guillen's avatar
Carla Guillen committed
82 83 84
    this->_measuring_interval_s = other._measuring_interval_s;
    this->_go_back_ns = other._go_back_ns;
    this->_metricToPerSecId = other._metricToPerSecId;
85 86
}

87
void SMUCNGPerfOperator::printConfig(LOG_LEVEL ll) {
88
    OperatorTemplate<SMUCSensorBase>::printConfig(ll);
89
    LOG_VAR(ll) << "Metric to position map size(" << _metricToPosition.size() << "):";
90
    for(auto &kv : _metricToPosition){
91
    	LOG_VAR(ll) << "Metric = " << kv.first << " Position = " << kv.second;
92
    }
Carla Guillen's avatar
Carla Guillen committed
93 94
    LOG_VAR(ll) << "_measuring_interval_s = " << _measuring_interval_s;
    LOG_VAR(ll) << "_go_back_ns = " << _go_back_ns;
95 96
}

97
void SMUCNGPerfOperator::compute(U_Ptr unit) {
98
	auto inputs = unit->getInputs();
Carla Guillen's avatar
Carla Guillen committed
99
	auto timestamp = getTimestamp() - _go_back_ns;
100
	for(auto& outSensor : unit->getOutputs()){
101
		if( outSensor->getMetric() == SMUCSensorBase::CPI) {
102
			computeCPI(inputs, outSensor, timestamp);
103
		} else if (outSensor->getMetric() == SMUCSensorBase::FREQUENCY) {
104 105 106 107 108
			computeFREQUENCY(inputs, outSensor, timestamp);
		} else if (outSensor->getMetric() == SMUCSensorBase::FLOPS || outSensor->getMetric() == SMUCSensorBase::PACKED_FLOPS ||
				outSensor->getMetric() == SMUCSensorBase::AVX512_TOVECTORIZED_RATIO || outSensor->getMetric() == SMUCSensorBase::VECTORIZED_RATIO ||
				outSensor->getMetric() == SMUCSensorBase::SINGLE_PRECISION_TO_TOTAL_RATIO) {
			computeFLOPS(inputs, outSensor, timestamp);
Carla Guillen Carias's avatar
Carla Guillen Carias committed
109 110 111 112 113 114 115 116 117 118 119 120 121 122
		} else if (outSensor->getMetric() == SMUCSensorBase::L3_TO_INSTRUCTIONS_RATIO){
			computeL3_TO_INSTRUCTIONS_RATIO(inputs, outSensor, timestamp);
		} else if (outSensor->getMetric() == SMUCSensorBase::L3HIT_TO_L3MISS_RATIO ){
			computeL3HIT_TO_L3MISS_RATIO(inputs, outSensor, timestamp);
		} else if (outSensor->getMetric() == SMUCSensorBase::LOADS_TO_STORES ){
			computeLOADS_TO_STORES(inputs, outSensor, timestamp);
		} else if (outSensor->getMetric() == SMUCSensorBase::LOADS_TOL3MISS_RATIO ){
			computeLOADS_TOL3MISS_RATIO(inputs, outSensor, timestamp);
		} else if (outSensor->getMetric() == SMUCSensorBase::BRANCH_PER_INSTRUCTIONS){
			computeBRANCH_PER_INSTRUCTIONS(inputs, outSensor, timestamp);
		} else if (outSensor->getMetric() == SMUCSensorBase::MISSBRANCHES_TO_TOTAL_BRANCH_RATIO){
			computeMISSBRANCHES_TO_TOTAL_BRANCH_RATIO(inputs, outSensor, timestamp);
		} else if (outSensor->getMetric() == SMUCSensorBase::MEMORY_BANDWIDTH) {
			computeMEMORY_BANDWIDTH(inputs, outSensor, timestamp);
Carla Guillen's avatar
Carla Guillen committed
123 124
		} else if (isAMetricPerSecond(outSensor->getMetric())){
			computeMetricPerSecond(_metricToPerSecId[outSensor->getMetric()], inputs, outSensor, timestamp);
125
		}
Carla Guillen Carias's avatar
Carla Guillen Carias committed
126 127 128 129
		resetBuffers();
	}
}

Carla Guillen's avatar
Carla Guillen committed
130
void SMUCNGPerfOperator::query(const std::string & sensor_name, const uint64_t timestamp, vector<reading_t> &buffer){
Carla Guillen's avatar
Bug fix  
Carla Guillen committed
131
	if(!_queryEngine.querySensor(sensor_name, timestamp, timestamp, buffer, false)) {
Carla Guillen's avatar
Carla Guillen committed
132 133
		LOG(debug) << "SMUCNGPerf Operator " << _name << " cannot read from sensor " << sensor_name  << "!";
	}
134 135
}

Carla Guillen Carias's avatar
Carla Guillen Carias committed
136 137 138
void SMUCNGPerfOperator::resetBuffers(){
	for(auto &buffer: _buffers){
		buffer.clear();
139 140
	}
}
141 142 143 144 145 146 147 148

void SMUCNGPerfOperator::computeCPI(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr &outSensor, const uint64_t timestamp){
	std::vector<reading_t> & instructions = _buffers[0];
	std::vector<reading_t> & clocks = _buffers[1];
	query(inputs[_metricToPosition[SMUCSensorBase::INSTRUCTIONS]]->getName(), timestamp, instructions);
	query(inputs[_metricToPosition[SMUCSensorBase::CLOCKS]]->getName(), timestamp, clocks);
	bool wascalced = false;
	reading_t cpi;
149
	if (instructions.size() > 0 && clocks.size() > 0 && calculateMetricRatio(clocks[0], instructions[0], cpi)) {
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
		outSensor->storeReading(cpi);
	}
}

void SMUCNGPerfOperator::computeFREQUENCY(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr& outSensor, const uint64_t timestamp) {
	std::vector<reading_t> & clocks = _buffers[0];
	std::vector<reading_t> & clocks_ref = _buffers[1];
	query(inputs[_metricToPosition[SMUCSensorBase::CLOCKS]]->getName(), timestamp, clocks);
	query(inputs[_metricToPosition[SMUCSensorBase::CLOCKS_REF]]->getName(), timestamp, clocks_ref);
	reading_t frequency;
	if( clocks.size() > 0 && clocks_ref.size() > 0 && calculateFrequency(clocks_ref[0],clocks[0], MIN_FREQ_MHZ, MAX_FREQ_MHZ, frequency)) {
		outSensor->storeReading(frequency);
	}
}

void SMUCNGPerfOperator::computeFLOPS(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr& outSensor, const uint64_t timestamp) {
	SMUCSensorBase::Metric_t flop_metric = outSensor->getMetric();
	std::vector<reading_t> & fp_arith_scalar_double = _buffers[0];
	std::vector<reading_t> & fp_arith_scalar_single = _buffers[1];
	std::vector<reading_t> & fp_arith_128b_packed_double = _buffers[2];
	std::vector<reading_t> & fp_arith_128b_packed_single = _buffers[3];
	std::vector<reading_t> & fp_arith_256b_packed_double = _buffers[4];
	std::vector<reading_t> & fp_arith_256b_packed_single = _buffers[5];
	std::vector<reading_t> & fp_arith_512b_packed_double = _buffers[6];
	std::vector<reading_t> & fp_arith_512b_packed_single = _buffers[7];


	query(inputs[_metricToPosition[SMUCSensorBase::FP_ARITH_SCALAR_DOUBLE]]->getName(), timestamp, fp_arith_scalar_double);
	query(inputs[_metricToPosition[SMUCSensorBase::FP_ARITH_SCALAR_SINGLE]]->getName(), timestamp, fp_arith_scalar_single);
	query(inputs[_metricToPosition[SMUCSensorBase::FP_ARITH_128B_PACKED_DOUBLE]]->getName(), timestamp, fp_arith_128b_packed_double);
	query(inputs[_metricToPosition[SMUCSensorBase::FP_ARITH_128B_PACKED_SINGLE]]->getName(), timestamp, fp_arith_128b_packed_single);
	query(inputs[_metricToPosition[SMUCSensorBase::FP_ARITH_256B_PACKED_DOUBLE]]->getName(), timestamp, fp_arith_256b_packed_double);
	query(inputs[_metricToPosition[SMUCSensorBase::FP_ARITH_256B_PACKED_SINGLE]]->getName(), timestamp, fp_arith_256b_packed_single);
	query(inputs[_metricToPosition[SMUCSensorBase::FP_ARITH_512B_PACKED_DOUBLE]]->getName(), timestamp, fp_arith_512b_packed_double);
	query(inputs[_metricToPosition[SMUCSensorBase::FP_ARITH_512B_PACKED_SINGLE]]->getName(), timestamp, fp_arith_512b_packed_single);
	reading_t empty;
	empty.value = 0;
	empty.timestamp = 0;
	reading_t & scalar_double = fp_arith_scalar_double.size() > 0 ? fp_arith_scalar_double[0]: empty;
	reading_t & scalar_single = fp_arith_scalar_single.size() > 0 ? fp_arith_scalar_single[0]: empty;
	reading_t & packed128_double = fp_arith_128b_packed_double.size() > 0 ? fp_arith_128b_packed_double[0] : empty;
	reading_t & packed128_single = fp_arith_128b_packed_single.size() > 0 ? fp_arith_128b_packed_single[0] : empty;
	reading_t & packed256_double =  fp_arith_256b_packed_double.size() > 0 ?  fp_arith_256b_packed_double[0] : empty;
	reading_t & packed256_single = fp_arith_256b_packed_single.size() > 0 ? fp_arith_256b_packed_single[0] : empty;
	reading_t & packed512_double =  fp_arith_512b_packed_double.size() > 0 ?  fp_arith_512b_packed_double[0] :empty;
	reading_t & packed512_single = fp_arith_512b_packed_single.size() > 0 ? fp_arith_512b_packed_single[0] : empty;

	reading_t result;
	if(flop_metric == SMUCSensorBase::FLOPS) {
199
		if (calculateFlopsPerSec(scalar_double, scalar_single, packed128_double,
200
				packed128_single, packed256_double, packed256_single,
201
				packed512_double, packed512_single, result, _measuring_interval_s) ) {
202 203 204
			outSensor->storeReading(result);
		}
	} else if(flop_metric == SMUCSensorBase::PACKED_FLOPS){
205
		if(calculatePackedFlopsPerSec(packed128_double,packed128_single,packed256_double,packed256_single,packed512_double,packed512_single, result, _measuring_interval_s)){
206 207 208 209 210
			outSensor->storeReading(result);
		}
	} else if(flop_metric == SMUCSensorBase::VECTORIZED_RATIO) {
		if(calculateVectorizationRatio(scalar_double, scalar_single, packed128_double,
				packed128_single, packed256_double, packed256_single,
211
				packed512_double, packed512_single, result)) {
212 213 214 215 216
			outSensor->storeReading(result);
		}
	} else if (flop_metric == SMUCSensorBase::AVX512_TOVECTORIZED_RATIO) {
		if (calculateAVX512FlopsToVectorizedRatio(packed128_double,
				packed128_single, packed256_double, packed256_single,
217
				packed512_double, packed512_single, result )) {
218 219 220 221 222
			outSensor->storeReading(result);
		}
	} else if (flop_metric == SMUCSensorBase::SINGLE_PRECISION_TO_TOTAL_RATIO) {
		if(calculateSP_TO_TOTAL_RATIO(scalar_double, scalar_single, packed128_double,
				packed128_single, packed256_double, packed256_single,
223
				packed512_double, packed512_single, result)){
224 225 226 227 228 229 230 231 232 233 234 235 236
			outSensor->storeReading(result);
		}
	}
}



/*void SMUCNGPerfOperator::computeINSTR_INTRA_NODE_LOADIMBALANCE(std::vector<SMUCNGPtr>& inputs,
		SMUCNGPtr& outSensor, const uint64_t timestamp) {
}*/

void SMUCNGPerfOperator::computeL3_TO_INSTRUCTIONS_RATIO(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr& outSensor,
		const uint64_t timestamp) {
Carla Guillen Carias's avatar
Carla Guillen Carias committed
237 238 239 240 241
	std::vector<reading_t> & l3_misses = _buffers[0];
	std::vector<reading_t> & instructions = _buffers[1];
	query(inputs[_metricToPosition[SMUCSensorBase::MEM_LOAD_UOPS_RETIRED_L3_MISS]]->getName(), timestamp, l3_misses);
	query(inputs[_metricToPosition[SMUCSensorBase::INSTRUCTIONS]]->getName(), timestamp, instructions);
	reading_t l3toinstrRatio;
242
	if (instructions.size() > 0 && l3_misses.size() > 0 && calculateMetricRatio(instructions[0], l3_misses[0], l3toinstrRatio)) {
Carla Guillen Carias's avatar
Carla Guillen Carias committed
243 244
		outSensor->storeReading(l3toinstrRatio);
	}
245 246 247 248 249 250 251 252
}

void SMUCNGPerfOperator::computeL3_BANDWIDTH(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr& outSensor,
		const uint64_t timestamp) {
}

void SMUCNGPerfOperator::computeL3HIT_TO_L3MISS_RATIO(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr& outSensor,
		const uint64_t timestamp) {
Carla Guillen Carias's avatar
Carla Guillen Carias committed
253 254 255 256 257 258 259 260
	//MEM_LOAD_UOPS_RETIRED_L3_MISS/(MEM_LOAD_RETIRED_L3_HIT+MEM_LOAD_RETIRED_L3_MISS
	std::vector<reading_t> & l3_misses = _buffers[0];
	std::vector<reading_t> & l3_hits = _buffers[1];
	std::vector<reading_t> & l3_load_miss = _buffers[2];
	query(inputs[_metricToPosition[SMUCSensorBase::MEM_LOAD_UOPS_RETIRED_L3_MISS]]->getName(), timestamp, l3_misses);
	query(inputs[_metricToPosition[SMUCSensorBase::MEM_LOAD_RETIRED_L3_HIT]]->getName(), timestamp, l3_hits);
	query(inputs[_metricToPosition[SMUCSensorBase::MEM_LOAD_RETIRED_L3_MISS]]->getName(), timestamp, l3_load_miss);
	reading_t l3hitToMissRatio;
261
	if (l3_misses.size() > 0 && l3_hits.size() > 0 && l3_load_miss.size() > 0 && calculateL3HitToL3MissRatio(l3_misses[0], l3_hits[0], l3_load_miss[0], l3hitToMissRatio)) {
Carla Guillen Carias's avatar
Carla Guillen Carias committed
262 263
		outSensor->storeReading(l3hitToMissRatio);
	}
264 265
}

Carla Guillen's avatar
Carla Guillen committed
266 267 268 269 270 271 272 273
void SMUCNGPerfOperator::computeMetricPerSecond(SMUCSensorBase::Metric_t metric, std::vector<SMUCNGPtr> &inputs, SMUCNGPtr& outSensor, const uint64_t timestamp) {
	query(inputs[_metricToPosition[metric]]->getName(), timestamp, _buffers[0]);
	reading_t metricpersec;
	if(_buffers[0].size() > 0 && calculateMetricPerSec(_buffers[0][0], _measuring_interval_s, metricpersec)){
		outSensor->storeReading(metricpersec);
	}
}

274 275
void SMUCNGPerfOperator::computeLOADS_TO_STORES(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr& outSensor,
		const uint64_t timestamp) {
Carla Guillen Carias's avatar
Carla Guillen Carias committed
276 277 278 279 280
	std::vector<reading_t> & loads = _buffers[0];
	std::vector<reading_t> & stores = _buffers[1];
	query(inputs[_metricToPosition[SMUCSensorBase::MEM_INST_RETIRED_ALL_LOADS]]->getName(), timestamp, loads);
	query(inputs[_metricToPosition[SMUCSensorBase::MEM_INST_RETIRED_ALL_STORES]]->getName(), timestamp, stores);
	reading_t loadToStoreRatio;
281
	if(loads.size() > 0 && stores.size() > 0 && calculateMetricRatio(loads[0], stores[0], loadToStoreRatio)){
Carla Guillen Carias's avatar
Carla Guillen Carias committed
282 283
		outSensor->storeReading(loadToStoreRatio);
	}
284 285 286 287
}

void SMUCNGPerfOperator::computeLOADS_TOL3MISS_RATIO(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr& outSensor,
		const uint64_t timestamp) {
Carla Guillen Carias's avatar
Carla Guillen Carias committed
288 289 290 291 292 293
	std::vector<reading_t> & loads = _buffers[0];
	std::vector<reading_t> & l3_misses = _buffers[1];
	query(inputs[_metricToPosition[SMUCSensorBase::MEM_INST_RETIRED_ALL_LOADS]]->getName(), timestamp, loads);
	query(inputs[_metricToPosition[SMUCSensorBase::MEM_LOAD_UOPS_RETIRED_L3_MISS]]->getName(), timestamp, l3_misses);
	reading_t loads_to_l3misses;
	if (loads.size() > 0 && l3_misses.size() > 0
294
			&& calculateMetricRatio(loads[0], l3_misses[0], loads_to_l3misses)) {
Carla Guillen Carias's avatar
Carla Guillen Carias committed
295 296
		outSensor->storeReading(loads_to_l3misses);
	}
297 298
}

Carla Guillen Carias's avatar
Carla Guillen Carias committed
299
void SMUCNGPerfOperator::computeBRANCH_PER_INSTRUCTIONS(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr& outSensor, const uint64_t timestamp) {
Carla Guillen's avatar
Carla Guillen committed
300 301
	std::vector<reading_t> & missedbranches = _buffers[0];
	std::vector<reading_t> & instructions = _buffers[1];
Carla Guillen Carias's avatar
Carla Guillen Carias committed
302 303 304 305
	query(inputs[_metricToPosition[SMUCSensorBase::PERF_COUNT_HW_BRANCH_MISSES]]->getName(), timestamp, missedbranches);
	query(inputs[_metricToPosition[SMUCSensorBase::INSTRUCTIONS]]->getName(), timestamp, instructions);
	reading_t branchPerInstructions;
	if (missedbranches.size() > 0 && instructions.size() > 0
306
			&& calculateMetricRatio(missedbranches[0], instructions[0], branchPerInstructions)) {
Carla Guillen Carias's avatar
Carla Guillen Carias committed
307 308
		outSensor->storeReading(branchPerInstructions);
	}
309 310 311 312
}

void SMUCNGPerfOperator::computeMISSBRANCHES_TO_TOTAL_BRANCH_RATIO(std::vector<SMUCNGPtr>& inputs,
		SMUCNGPtr& outSensor, const uint64_t timestamp) {
Carla Guillen's avatar
Carla Guillen committed
313 314
	std::vector<reading_t> & missedbranches = _buffers[0];
	std::vector<reading_t> & totalbranches = _buffers[1];
Carla Guillen Carias's avatar
Carla Guillen Carias committed
315 316 317 318
	query(inputs[_metricToPosition[SMUCSensorBase::PERF_COUNT_HW_BRANCH_MISSES]]->getName(), timestamp, missedbranches);
	query(inputs[_metricToPosition[SMUCSensorBase::PERF_COUNT_HW_BRANCH_INSTRUCTIONS]]->getName(), timestamp, totalbranches);
	reading_t missbranchesPerTotal;
	if(missedbranches.size() > 0 && totalbranches.size() > 0 &&
319
			calculateMetricRatio(missedbranches[0], totalbranches[0], missbranchesPerTotal)){
Carla Guillen Carias's avatar
Carla Guillen Carias committed
320 321
		outSensor->storeReading(missbranchesPerTotal);
	}
322 323 324 325
}

void SMUCNGPerfOperator::computeMEMORY_BANDWIDTH(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr& outSensor,
		const uint64_t timestamp) {
Carla Guillen's avatar
Carla Guillen committed
326
	std::vector<reading_t> mem_counters; //ToDo how do I get them?
327
}
Carla Guillen's avatar
Carla Guillen committed
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347

bool SMUCNGPerfOperator::isAMetricPerSecond(SMUCSensorBase::Metric_t comp){
	if(comp == SMUCSensorBase::INSTRUCTIONS_PER_SECOND ||
		comp == SMUCSensorBase::EXPENSIVE_INSTRUCTIONS_PER_SECOND || comp == SMUCSensorBase::L2_HITS_PER_SECOND ||
		comp == SMUCSensorBase::L2_MISSES_PER_SECOND ||
		comp == SMUCSensorBase::L3_HITS_PER_SECOND ||
		comp == SMUCSensorBase::L3_MISSES_PER_SECOND ||
		comp == SMUCSensorBase::MISSBRANCHES_PER_SECOND ||
		comp == SMUCSensorBase::NETWORK_BYTES_XMIT_PER_SECOND ||
		comp == SMUCSensorBase::NETWORK_BYTES_RCVD_PER_SECOND ||
		comp == SMUCSensorBase::IOOPENS_PER_SECOND ||
		comp == SMUCSensorBase::IOCLOSES_PER_SECOND ||
		comp == SMUCSensorBase::IOBYTESREAD_PER_SECOND ||
		comp == SMUCSensorBase::IOBYTESWRITE_PER_SECOND ||
		comp == SMUCSensorBase::IOREADS_PER_SECOND ||
		comp == SMUCSensorBase::IOWRITES_PER_SECOND  ){
		return true;
	}
	return false;
}