Commit 0380961c authored by Carla Guillen's avatar Carla Guillen
Browse files

Adding position to output sensors for a faster search.

parent 1ffc6ba1
......@@ -26,11 +26,13 @@ default def1
output {
sensor "<bottomup, filter /login08/cpu>cpi" {
mqttsuffix /cpi
position 3
scaling_factor 100
}
sensor "<bottomup, filter /login08/cpu>frequency" {
mqttsuffix /frequency
position 4
scaling_factor 1
}
}
......
......@@ -19,7 +19,8 @@ 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());
unsigned int position = std::stoul(val.second.data());
s.setPosition(position);
std::string name = s.getName();
if(name.compare("instructions")==0){
_metricToPosition[SMUCSensorBase::INSTRUCTIONS] = position;
......@@ -27,7 +28,11 @@ void SMUCNGPerfConfigurator::sensorBase(SMUCSensorBase& s, CFG_VAL config) {
_metricToPosition[SMUCSensorBase::CLOCKS] = position;
} else if(name.compare("ref_clocks") == 0){
_metricToPosition[SMUCSensorBase::CLOCKS_REF] = position;
}
} else if(name.compare("cpi") == 0){
_metricToPosition[SMUCSensorBase::CPI] = position;
} else if(name.compare("frequency") == 0){
_metricToPosition[SMUCSensorBase::FREQUENCY] = position;
}
} else if (boost::iequals(val.first, "scaling_factor")){
unsigned int scaling_factor = std::stoul(val.second.data());
s.setScalingFactor(scaling_factor);
......
......@@ -19,7 +19,7 @@ private:
void sensorBase(SMUCSensorBase& s, CFG_VAL config) override;
void operatorAttributes(SMUCNGPerfOperator& op, CFG_VAL config) override;
bool unit(UnitTemplate<SMUCSensorBase>& u) override;
std::map<SMUCSensorBase::Metrics, int> _metricToPosition;
std::map<SMUCSensorBase::Metrics, unsigned int> _metricToPosition;
};
extern "C" OperatorConfiguratorInterface* create() {
......
......@@ -25,7 +25,7 @@ void SMUCNGPerfOperator::compute(U_Ptr unit) {
auto timestamp = getTimestamp(); //ToDo timestamp minus some time...
auto outputs = unit->getOutputs();
for(auto& outSensor : outputs){
if(outSensor->getName().find("cpi") != std::string::npos){
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;
......@@ -37,7 +37,7 @@ void SMUCNGPerfOperator::compute(U_Ptr unit) {
if(wascalced) {
outSensor->storeReading(clockspersecond);
}
} else if(outSensor->getName().find("frequency") != std::string::npos){
} 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;
......
......@@ -14,14 +14,14 @@
class SMUCNGPerfOperator: virtual public OperatorTemplate<SMUCSensorBase>{
private:
std::map<SMUCSensorBase::Metrics, int> _metricToPosition;
std::map<SMUCSensorBase::Metrics, unsigned int> _metricToPosition;
public:
SMUCNGPerfOperator(const std::string& name);
virtual ~SMUCNGPerfOperator();
void printConfig(LOG_LEVEL ll) override;
void setMetricToPosition(const std::map<SMUCSensorBase::Metrics,int>&metricToPosition) {
void setMetricToPosition(const std::map<SMUCSensorBase::Metrics,unsigned int>&metricToPosition) {
_metricToPosition = metricToPosition;
}
......
......@@ -15,7 +15,9 @@ public:
enum Metrics {
INSTRUCTIONS,
CLOCKS,
CLOCKS_REF
CLOCKS_REF,
CPI,
FREQUENCY
};
public:
SMUCSensorBase(const std::string& name): SensorBase(name), _scaling_factor(1){}
......@@ -29,7 +31,17 @@ public:
_scaling_factor = scalingFactor;
}
unsigned int getPosition(){
return _position;
}
void setPosition(unsigned int position){
_position = position;
}
private:
unsigned int _position;
unsigned int _scaling_factor;
};
......
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