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