2.12.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit 84186ee0 authored by Carla Guillen Carias's avatar Carla Guillen Carias
Browse files

Refactoring

parent 45c499c6
...@@ -13,26 +13,26 @@ supermucngperf cpi { ...@@ -13,26 +13,26 @@ supermucngperf cpi {
default def1 default def1
input { input {
sensor "<bottomup>clocks"{ sensor "<bottomup>clocks"{
position 0 position 0
} }
sensor "<bottomup>ref_clocks"{ sensor "<bottomup>ref_clocks"{
position 1 position 1
} }
sensor "<bottomup>instructions" { sensor "<bottomup>instructions" {
position 2 position 2
} }
} }
output { output {
sensor "<bottomup, filter /login08/cpu>cpi" { sensor "<bottomup, filter /login08/cpu>cpi" {
mqttsuffix /cpi mqttsuffix /cpi
position 3 position 3
scaling_factor 100 scaling_factor 100
} }
sensor "<bottomup, filter /login08/cpu>frequency" { sensor "<bottomup, filter /login08/cpu>frequency" {
mqttsuffix /frequency mqttsuffix /frequency
position 4 position 4
scaling_factor 1 scaling_factor 1
} }
} }
......
...@@ -63,7 +63,7 @@ int64_t computeStd(std::vector<reading_t> &buffer) { ...@@ -63,7 +63,7 @@ int64_t computeStd(std::vector<reading_t> &buffer) {
return acc; return acc;
} }
void computeQuantiles(const std::vector<reading_t> &data, unsigned int NUMBER_QUANTILES, std::vector<int64_t> &quantiles) { void computeEvenQuantiles(const std::vector<reading_t> &data, unsigned int NUMBER_QUANTILES, std::vector<int64_t> &quantiles) {
if (data.empty() || NUMBER_QUANTILES == 0) { if (data.empty() || NUMBER_QUANTILES == 0) {
return; return;
} }
......
...@@ -5,11 +5,11 @@ ...@@ -5,11 +5,11 @@
* Author: carla * Author: carla
*/ */
#include "../../commonderivedmetrics/DerivedMetrics.h" #include "../../includes/DerivedMetrics.h"
#include "SMUCNGPerfOperator.h" #include "SMUCNGPerfOperator.h"
SMUCNGPerfOperator::SMUCNGPerfOperator(const std::string& name): OperatorTemplate(name) { SMUCNGPerfOperator::SMUCNGPerfOperator(const std::string& name): OperatorTemplate(name) {
_buffers.resize(5);
} }
SMUCNGPerfOperator::~SMUCNGPerfOperator() { SMUCNGPerfOperator::~SMUCNGPerfOperator() {
...@@ -29,37 +29,37 @@ void SMUCNGPerfOperator::compute(U_Ptr unit) { ...@@ -29,37 +29,37 @@ void SMUCNGPerfOperator::compute(U_Ptr unit) {
auto outputs = unit->getOutputs(); auto outputs = unit->getOutputs();
for(auto& outSensor : outputs){ for(auto& outSensor : outputs){
if( outSensor->getPosition() == _metricToPosition[SMUCSensorBase::CPI]) { if( outSensor->getPosition() == _metricToPosition[SMUCSensorBase::CPI]) {
vector<reading_t> * bufferInstructions = nullptr; std::vector<reading_t> & instructions = _buffers[0];
bufferInstructions = _queryEngine.querySensor(inputs[_metricToPosition[SMUCSensorBase::INSTRUCTIONS]]->getName(), timestamp, timestamp, bufferInstructions, false); //use absolute timestamp std::vector<reading_t> & clocks = _buffers[1];
vector<reading_t> * bufferClocks = nullptr; _queryEngine.querySensor(inputs[_metricToPosition[SMUCSensorBase::INSTRUCTIONS]]->getName(), timestamp, timestamp, &instructions, false); //use absolute timestamp
bufferClocks = _queryEngine.querySensor(inputs[_metricToPosition[SMUCSensorBase::CLOCKS]]->getName(), timestamp, timestamp, bufferClocks, false); //use absolute timestamp _queryEngine.querySensor(inputs[_metricToPosition[SMUCSensorBase::CLOCKS]]->getName(), timestamp, timestamp, &clocks, false); //use absolute timestamp
reading_t clockspersecond; reading_t clockspersecond;
bool wascalced = false; bool wascalced = false;
if(bufferInstructions != nullptr && bufferClocks != nullptr && bufferInstructions->size() > 0 && bufferClocks->size() > 0) { if(instructions.size() > 0 && clocks.size() > 0) {
wascalced = calculateMetricRatio(*(bufferClocks->begin()),*(bufferInstructions->begin()), outSensor->getScalingFactor(), clockspersecond); if(calculateMetricRatio(clocks.begin(),instructions.begin(), outSensor->getScalingFactor(), clockspersecond)){
} outSensor->storeReading(clockspersecond);
delete bufferInstructions; }
delete bufferClocks;
if(wascalced) {
outSensor->storeReading(clockspersecond);
} }
} else if (outSensor->getPosition() == _metricToPosition[SMUCSensorBase::FREQUENCY]) { } else if (outSensor->getPosition() == _metricToPosition[SMUCSensorBase::FREQUENCY]) {
const unsigned int MAX_FREQ_MHZ = 2700; std::vector<reading_t> & clocks = _buffers[0];
const unsigned int MIN_FREQ_MHZ = 1200; std::vector<reading_t> & clocks_ref = _buffers[1];
vector<reading_t> * bufferClocks = nullptr; _queryEngine.querySensor(inputs[_metricToPosition[SMUCSensorBase::CLOCKS]]->getName(), timestamp, timestamp, &clocks, false); //use absolute timestamp
bufferClocks = _queryEngine.querySensor(inputs[_metricToPosition[SMUCSensorBase::CLOCKS]]->getName(), timestamp, timestamp, bufferClocks, false); //use absolute timestamp _queryEngine.querySensor(inputs[_metricToPosition[SMUCSensorBase::CLOCKS_REF]]->getName(), timestamp, timestamp, &clocks_ref, false); //use absolute timestamp
vector<reading_t> * bufferClockRef = nullptr;
bufferClockRef = _queryEngine.querySensor(inputs[_metricToPosition[SMUCSensorBase::CLOCKS_REF]]->getName(), timestamp, timestamp, bufferClockRef, false); //use absolute timestamp
reading_t frequency; reading_t frequency;
bool wascalced = false; bool wascalced = false;
if( bufferClocks != nullptr && bufferClockRef != nullptr && bufferClocks->size() > 0 && bufferClockRef->size() > 0){ if( clocks.size() > 0 && clocks_ref.size() > 0){
wascalced = calculateFrequency(*(bufferClockRef->begin()),*(bufferClocks->begin()), MIN_FREQ_MHZ, MAX_FREQ_MHZ, frequency); if(calculateFrequency(clocks_ref.begin(),clocks.begin(), MIN_FREQ_MHZ, MAX_FREQ_MHZ, frequency)) {
} outSensor->storeReading(frequency);
delete bufferClocks; }
delete bufferClockRef;
if(wascalced) {
outSensor->storeReading(frequency);
} }
} }
resetBuffers();
}
}
void SMUCNGPerfOperator::resetBuffers(){
for(auto &buffer: _buffers){
buffer.clear();
} }
} }
...@@ -27,6 +27,11 @@ public: ...@@ -27,6 +27,11 @@ public:
protected: protected:
virtual void compute(U_Ptr unit) override; virtual void compute(U_Ptr unit) override;
vector<vector<reading_t>> _buffers;
const unsigned int MAX_FREQ_MHZ = 2700;
const unsigned int MIN_FREQ_MHZ = 1200;
void resetBuffers();
}; };
#endif /* ANALYTICS_SMUCNGPERF_SMUCNGPERFOPERATOR_H_ */ #endif /* ANALYTICS_SMUCNGPERF_SMUCNGPERFOPERATOR_H_ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment