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

Commit a144b71c authored by Carla Guillen Carias's avatar Carla Guillen Carias
Browse files

Adding scaling_factor to sensor.

parent c9249c22
......@@ -23,16 +23,34 @@ void SMUCNGPerfAnalyzer::printConfig(LOG_LEVEL ll) {
void SMUCNGPerfAnalyzer::compute(U_Ptr unit) {
auto inputs = unit->getInputs();
auto timestamp = getTimestamp(); //ToDo timestamp minus some time...
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
reading_t clockspersecond;
bool wascalced = calculateMetricRatio(*(bufferClocks->begin()),*(bufferInstructions->begin()), 1, clockspersecond);
delete bufferInstructions;
delete bufferClocks;
if(wascalced) {
auto outputs = unit->getOutputs();
outputs[0]->storeReading(clockspersecond);
auto outputs = unit->getOutputs();
for(auto& outSensor : outputs){
if(outSensor->getName().find('cpi') != std::string::npos){
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
reading_t clockspersecond;
bool wascalced = calculateMetricRatio(*(bufferClocks->begin()),*(bufferInstructions->begin()), outSensor->getScalingFactor(), clockspersecond);
delete bufferInstructions;
delete bufferClocks;
if(wascalced) {
outSensor->storeReading(clockspersecond);
}
} else if(outSensor->getName().find('frequency') != std::string::npos){
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::INSTRUCTIONS]]->getName(), timestamp, timestamp, bufferClocks, false); //use absolute timestamp
vector<reading_t> * bufferClockRef = nullptr;
bufferClockRef = _queryEngine.querySensor(inputs[_metricToPosition[SMUCSensorBase::CLOCKS]]->getName(), timestamp, timestamp, bufferClockRef, false); //use absolute timestamp
reading_t frequency;
bool wascalced = calculateFrequency(*(bufferClockRef->begin()),*(bufferClocks->begin()), MIN_FREQ_MHZ, MAX_FREQ_MHZ, frequency);
delete bufferClocks;
delete bufferClockRef;
if(wascalced) {
outSensor->storeReading(frequency);
}
}
}
}
......@@ -19,11 +19,18 @@ void SMUCNGPerfConfigurator::sensorBase(SMUCSensorBase& s, CFG_VAL config) {
BOOST_FOREACH(boost::property_tree::iptree::value_type &val, config)
{
if (boost::iequals(val.first, "position")) {
int position = std::stoi(val.second.data());
std::string name = s.getName();
if(name.compare("instructions")==0){
_metricToPosition[SMUCSensorBase::INSTRUCTIONS] = position;
}
int position = std::stoi(val.second.data());
std::string name = s.getName();
if(name.compare("instructions")==0){
_metricToPosition[SMUCSensorBase::INSTRUCTIONS] = position;
} else if(name.compare("clocks") == 0){
_metricToPosition[SMUCSensorBase::CLOCKS] = position;
} else if(name.compare("clocksref") == 0){
_metricToPosition[SMUCSensorBase::CLOCKS_REF] = position;
}
} else if (boost::iequals(val.first, "scaling_factor")){
unsigned int scaling_factor = std::stoul(val.second.data());
s.setScalingFactor(scaling_factor);
}
}
}
......
......@@ -14,11 +14,23 @@ class SMUCSensorBase : public SensorBase {
public:
enum Metrics {
INSTRUCTIONS,
CLOCKS
CLOCKS,
CLOCKS_REF
};
public:
SMUCSensorBase(const std::string& name): SensorBase(name){}
SMUCSensorBase(const std::string& name): SensorBase(name), _scaling_factor(1){}
virtual ~SMUCSensorBase(){}
unsigned int getScalingFactor() const {
return _scaling_factor;
}
void setScalingFactor(unsigned int scalingFactor) {
_scaling_factor = scalingFactor;
}
private:
unsigned int _scaling_factor;
};
using SMUCNGPtr = std::shared_ptr<SMUCSensorBase>;
......
......@@ -14,29 +14,27 @@
* For CPI, LoadsToStore, Branch rate, miss branch ratio, etc..
*/
bool calculateMetricRatio(reading_t & dividend, reading_t & divisor,
unsigned int resolution, reading_t & result) {
unsigned int scaling_factor, reading_t & result) {
if(divisor.value > 0){
result.value = (dividend.value / static_cast<float>(divisor.value))*resolution;
result.value = (dividend.value / static_cast<float>(divisor.value))*scaling_factor;
result.timestamp = dividend.timestamp;
return true;
}
return false;
return false; //Division by zero
}
/** Any generic metric per second. For instance: instructions per second, l2 misses per second **/
bool calculateMetricPerSec(reading_t & metric, uint64_t interval, unsigned int resolution, reading_t & result) {
bool calculateMetricPerSec(reading_t & metric, uint64_t interval, unsigned int scaling_factor, reading_t & result) {
if(interval > 0) {
result.value = (metric.value / static_cast<float>(interval))*resolution;
result.value = (metric.value / static_cast<float>(interval))*scaling_factor;
result.timestamp = metric.timestamp;
return true;
}
return false;
return false; //Division by zero
}
bool calculateFrequency(reading_t & unhaltedRef, reading_t & unhaltedClocks,
unsigned int min_freq, unsigned int max_freq, reading_t & result) {
//const unsigned int MAX_FREQ_MHZ = 2700;
//const unsigned int MIN_FREQ_MHZ = 1000; //ToDo check minimum in SKX
if(unhaltedRef.value > 0){
result.value = (unhaltedClocks.value / static_cast<float>(unhaltedRef.value)) * max_freq;
if(result.value > (max_freq * 1.1) || result.value < (min_freq*0.9)) { //There is something wrong here...
......@@ -44,7 +42,7 @@ bool calculateFrequency(reading_t & unhaltedRef, reading_t & unhaltedClocks,
}
return true;
}
return false;
return false; //Division by zero
}
#endif /* ANALYTICS_COMMONDERIVEDMETRICS_DERIVEDMETRICS_H_ */
......@@ -2,52 +2,38 @@ global {
mqttPrefix /test
}
template_aggregator def1 {
template_smucperf def1 {
interval 1000
minValues 3
duplicate false
streaming true
}
aggregator avg1 {
smucperf cpi {
default def1
window 2000
input {
sensor "<topdown 1>col_user" {
sensor "<bottomup 1> clocks"{
position 0
}
sensor "<bottomup 1>MemFree" {
sensor "<bottomup 1> ref_clocks"{
position 1
}
sensor "<bottomup 1> iobytesread " {
position 2
}
sensor "<bottomup 1> ioreadoperations"{
position 3
}
sensor "<bottomup 1> instructions" {
position 4
}
sensor "<bottomup 1> clocks"{
position 5
position 2
}
}
output {
sensor "<bottomup, filter cpu250>sum" {
mqttsuffix /sum
operation sum
sensor "<bottomup 1> cpi" {
mqttsuffix /cpi
scaling_factor 100
}
sensor "<bottomup 1> frequency" {
mqttsuffix /cpi
scaling_factor 1
}
}
}
\ No newline at end of file
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