Commit be0defe1 authored by Carla Guillen's avatar Carla Guillen
Browse files

fixing bugs

parent de8e771e
...@@ -42,19 +42,19 @@ void SMUCNGPerfConfigurator::sensorBase(SMUCSensorBase& s, CFG_VAL config) { ...@@ -42,19 +42,19 @@ void SMUCNGPerfConfigurator::sensorBase(SMUCSensorBase& s, CFG_VAL config) {
unsigned int position = std::stoul(val.second.data()); unsigned int position = std::stoul(val.second.data());
s.setPosition(position); s.setPosition(position);
std::string name = s.getName(); std::string name = s.getName();
if(name.compare("instructions")==0){ if(name.find("instructions") != std::string::npos){
_metricToPosition[SMUCSensorBase::INSTRUCTIONS] = position; _metricToPosition[SMUCSensorBase::INSTRUCTIONS] = position;
s.setMetric(SMUCSensorBase::INSTRUCTIONS); s.setMetric(SMUCSensorBase::INSTRUCTIONS);
} else if(name.compare("clocks") == 0){ } else if(name.find("clocks") != std::string::npos){
_metricToPosition[SMUCSensorBase::CLOCKS] = position; _metricToPosition[SMUCSensorBase::CLOCKS] = position;
s.setMetric(SMUCSensorBase::CLOCKS); s.setMetric(SMUCSensorBase::CLOCKS);
} else if(name.compare("ref_clocks") == 0){ } else if(name.find("ref_clocks") != std::string::npos){
_metricToPosition[SMUCSensorBase::CLOCKS_REF] = position; _metricToPosition[SMUCSensorBase::CLOCKS_REF] = position;
s.setMetric(SMUCSensorBase::CLOCKS_REF); s.setMetric(SMUCSensorBase::CLOCKS_REF);
} else if(name.compare("cpi") == 0){ } else if(name.find("cpi") != std::string::npos){
_metricToPosition[SMUCSensorBase::CPI] = position; _metricToPosition[SMUCSensorBase::CPI] = position;
s.setMetric(SMUCSensorBase::CPI); s.setMetric(SMUCSensorBase::CPI);
} else if(name.compare("frequency") == 0){ } else if(name.find("frequency") != std::string::npos){
_metricToPosition[SMUCSensorBase::FREQUENCY] = position; _metricToPosition[SMUCSensorBase::FREQUENCY] = position;
s.setMetric(SMUCSensorBase::FREQUENCY); s.setMetric(SMUCSensorBase::FREQUENCY);
} }
......
...@@ -29,20 +29,22 @@ ...@@ -29,20 +29,22 @@
#include "SMUCNGPerfOperator.h" #include "SMUCNGPerfOperator.h"
SMUCNGPerfOperator::SMUCNGPerfOperator(const std::string& name): OperatorTemplate(name) { SMUCNGPerfOperator::SMUCNGPerfOperator(const std::string& name): OperatorTemplate(name) {
_buffers.resize(10); _buffers.resize(10);
} }
SMUCNGPerfOperator::~SMUCNGPerfOperator() { SMUCNGPerfOperator::~SMUCNGPerfOperator() {
} }
SMUCNGPerfOperator::SMUCNGPerfOperator(const SMUCNGPerfOperator& other) : OperatorTemplate(other){ SMUCNGPerfOperator::SMUCNGPerfOperator(const SMUCNGPerfOperator& other) : OperatorTemplate(other){
this->_buffers = other._buffers; this->_buffers = other._buffers;
this->_metricToPosition = other._metricToPosition;
} }
SMUCNGPerfOperator& SMUCNGPerfOperator::operator=(const SMUCNGPerfOperator& other){ SMUCNGPerfOperator& SMUCNGPerfOperator::operator=(const SMUCNGPerfOperator& other){
OperatorTemplate::operator =(other); OperatorTemplate::operator =(other);
this->_buffers = other._buffers; this->_buffers = other._buffers;
return *this; this->_metricToPosition = other._metricToPosition;
return *this;
} }
void SMUCNGPerfOperator::printConfig(LOG_LEVEL ll) { void SMUCNGPerfOperator::printConfig(LOG_LEVEL ll) {
...@@ -67,7 +69,6 @@ void SMUCNGPerfOperator::compute(U_Ptr unit) { ...@@ -67,7 +69,6 @@ void SMUCNGPerfOperator::compute(U_Ptr unit) {
for(auto& outSensor : unit->getOutputs()){ for(auto& outSensor : unit->getOutputs()){
if( outSensor->getMetric() == SMUCSensorBase::CPI) { if( outSensor->getMetric() == SMUCSensorBase::CPI) {
std::cout << "CPI found!";
std::vector<reading_t> & instructions = _buffers[0]; std::vector<reading_t> & instructions = _buffers[0];
std::vector<reading_t> & clocks = _buffers[1]; std::vector<reading_t> & clocks = _buffers[1];
query(inputs[_metricToPosition[SMUCSensorBase::INSTRUCTIONS]]->getName(), timestamp, instructions); query(inputs[_metricToPosition[SMUCSensorBase::INSTRUCTIONS]]->getName(), timestamp, instructions);
...@@ -78,7 +79,6 @@ void SMUCNGPerfOperator::compute(U_Ptr unit) { ...@@ -78,7 +79,6 @@ void SMUCNGPerfOperator::compute(U_Ptr unit) {
outSensor->storeReading(cpi); outSensor->storeReading(cpi);
} }
} else if (outSensor->getMetric() == SMUCSensorBase::FREQUENCY) { } else if (outSensor->getMetric() == SMUCSensorBase::FREQUENCY) {
std::cout << "Frequency found!";
std::vector<reading_t> & clocks = _buffers[0]; std::vector<reading_t> & clocks = _buffers[0];
std::vector<reading_t> & clocks_ref = _buffers[1]; std::vector<reading_t> & clocks_ref = _buffers[1];
query(inputs[_metricToPosition[SMUCSensorBase::CLOCKS]]->getName(), timestamp, clocks); query(inputs[_metricToPosition[SMUCSensorBase::CLOCKS]]->getName(), timestamp, clocks);
......
...@@ -37,24 +37,24 @@ private: ...@@ -37,24 +37,24 @@ private:
std::map<SMUCSensorBase::Metric_t, unsigned int> _metricToPosition; std::map<SMUCSensorBase::Metric_t, unsigned int> _metricToPosition;
public: public:
SMUCNGPerfOperator(const std::string& name); SMUCNGPerfOperator(const std::string& name);
virtual ~SMUCNGPerfOperator(); virtual ~SMUCNGPerfOperator();
SMUCNGPerfOperator(const SMUCNGPerfOperator& other); SMUCNGPerfOperator(const SMUCNGPerfOperator& other);
SMUCNGPerfOperator& operator=(const SMUCNGPerfOperator& other); SMUCNGPerfOperator& operator=(const SMUCNGPerfOperator& other);
void printConfig(LOG_LEVEL ll) override; void printConfig(LOG_LEVEL ll) override;
void setMetricToPosition(const std::map<SMUCSensorBase::Metric_t,unsigned int>&metricToPosition) { void setMetricToPosition(const std::map<SMUCSensorBase::Metric_t,unsigned int>&metricToPosition) {
_metricToPosition = metricToPosition; _metricToPosition = metricToPosition;
} }
protected: protected:
virtual void compute(U_Ptr unit) override; virtual void compute(U_Ptr unit) override;
vector<vector<reading_t>> _buffers; vector<vector<reading_t>> _buffers;
const unsigned int MAX_FREQ_MHZ = 2700; const unsigned int MAX_FREQ_MHZ = 2700;
const unsigned int MIN_FREQ_MHZ = 1200; const unsigned int MIN_FREQ_MHZ = 1200;
void resetBuffers(); void resetBuffers();
void query(const std::string & sensor_name, const uint64_t timestamp, vector<reading_t> &buffer); void query(const std::string & sensor_name, const uint64_t timestamp, vector<reading_t> &buffer);
}; };
#endif /* ANALYTICS_SMUCNGPERF_SMUCNGPERFOPERATOR_H_ */ #endif /* ANALYTICS_SMUCNGPERF_SMUCNGPERFOPERATOR_H_ */
...@@ -48,6 +48,7 @@ public: ...@@ -48,6 +48,7 @@ public:
SMUCSensorBase& operator=(const SMUCSensorBase& other){ SMUCSensorBase& operator=(const SMUCSensorBase& other){
SensorBase::operator=(other); SensorBase::operator=(other);
copy(other); copy(other);
return *this;
} }
virtual ~SMUCSensorBase(){} virtual ~SMUCSensorBase(){}
......
Supports Markdown
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