16.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
......@@ -63,7 +63,7 @@ int64_t computeStd(std::vector<reading_t> &buffer) {
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) {
return;
}
......
......@@ -5,11 +5,11 @@
* Author: carla
*/
#include "../../commonderivedmetrics/DerivedMetrics.h"
#include "../../includes/DerivedMetrics.h"
#include "SMUCNGPerfOperator.h"
SMUCNGPerfOperator::SMUCNGPerfOperator(const std::string& name): OperatorTemplate(name) {
_buffers.resize(5);
}
SMUCNGPerfOperator::~SMUCNGPerfOperator() {
......@@ -29,37 +29,37 @@ void SMUCNGPerfOperator::compute(U_Ptr unit) {
auto outputs = unit->getOutputs();
for(auto& outSensor : outputs){
if( outSensor->getPosition() == _metricToPosition[SMUCSensorBase::CPI]) {
vector<reading_t> * bufferInstructions = nullptr;
bufferInstructions = _queryEngine.querySensor(inputs[_metricToPosition[SMUCSensorBase::INSTRUCTIONS]]->getName(), timestamp, timestamp, bufferInstructions, false); //use absolute timestamp
vector<reading_t> * bufferClocks = nullptr;
bufferClocks = _queryEngine.querySensor(inputs[_metricToPosition[SMUCSensorBase::CLOCKS]]->getName(), timestamp, timestamp, bufferClocks, false); //use absolute timestamp
std::vector<reading_t> & instructions = _buffers[0];
std::vector<reading_t> & clocks = _buffers[1];
_queryEngine.querySensor(inputs[_metricToPosition[SMUCSensorBase::INSTRUCTIONS]]->getName(), timestamp, timestamp, &instructions, false); //use absolute timestamp
_queryEngine.querySensor(inputs[_metricToPosition[SMUCSensorBase::CLOCKS]]->getName(), timestamp, timestamp, &clocks, false); //use absolute timestamp
reading_t clockspersecond;
bool wascalced = false;
if(bufferInstructions != nullptr && bufferClocks != nullptr && bufferInstructions->size() > 0 && bufferClocks->size() > 0) {
wascalced = calculateMetricRatio(*(bufferClocks->begin()),*(bufferInstructions->begin()), outSensor->getScalingFactor(), clockspersecond);
}
delete bufferInstructions;
delete bufferClocks;
if(wascalced) {
if(instructions.size() > 0 && clocks.size() > 0) {
if(calculateMetricRatio(clocks.begin(),instructions.begin(), outSensor->getScalingFactor(), clockspersecond)){
outSensor->storeReading(clockspersecond);
}
}
} else if (outSensor->getPosition() == _metricToPosition[SMUCSensorBase::FREQUENCY]) {
const unsigned int MAX_FREQ_MHZ = 2700;
const unsigned int MIN_FREQ_MHZ = 1200;
vector<reading_t> * bufferClocks = nullptr;
bufferClocks = _queryEngine.querySensor(inputs[_metricToPosition[SMUCSensorBase::CLOCKS]]->getName(), timestamp, timestamp, bufferClocks, 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
std::vector<reading_t> & clocks = _buffers[0];
std::vector<reading_t> & clocks_ref = _buffers[1];
_queryEngine.querySensor(inputs[_metricToPosition[SMUCSensorBase::CLOCKS]]->getName(), timestamp, timestamp, &clocks, false); //use absolute timestamp
_queryEngine.querySensor(inputs[_metricToPosition[SMUCSensorBase::CLOCKS_REF]]->getName(), timestamp, timestamp, &clocks_ref, false); //use absolute timestamp
reading_t frequency;
bool wascalced = false;
if( bufferClocks != nullptr && bufferClockRef != nullptr && bufferClocks->size() > 0 && bufferClockRef->size() > 0){
wascalced = calculateFrequency(*(bufferClockRef->begin()),*(bufferClocks->begin()), MIN_FREQ_MHZ, MAX_FREQ_MHZ, frequency);
}
delete bufferClocks;
delete bufferClockRef;
if(wascalced) {
if( clocks.size() > 0 && clocks_ref.size() > 0){
if(calculateFrequency(clocks_ref.begin(),clocks.begin(), MIN_FREQ_MHZ, MAX_FREQ_MHZ, frequency)) {
outSensor->storeReading(frequency);
}
}
}
resetBuffers();
}
}
void SMUCNGPerfOperator::resetBuffers(){
for(auto &buffer: _buffers){
buffer.clear();
}
}
......@@ -27,6 +27,11 @@ public:
protected:
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_ */
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