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

Adding nullptr checks to sensors

parent 1fa777cf
......@@ -8,7 +8,7 @@
#include "SMUCNGPerfConfigurator.h"
SMUCNGPerfConfigurator::SMUCNGPerfConfigurator() : OperatorConfiguratorTemplate(){
_operatorName = "supermucngperf";
_operatorName = "supermucngperf";
_baseName = "sensor";
}
......
......@@ -16,8 +16,11 @@ SMUCNGPerfOperator::~SMUCNGPerfOperator() {
}
void SMUCNGPerfOperator::printConfig(LOG_LEVEL ll) {
LOG_VAR(ll) << " No Window: ";
OperatorTemplate<SMUCSensorBase>::printConfig(ll);
OperatorTemplate<SMUCSensorBase>::printConfig(ll);
LOG_VAR(ll) << " metric to position map: ";
for(auto &kv : _metricToPosition){
LOG_VAR(ll) << "Metric = " << kv.first << "Position = " << kv.second;
}
}
void SMUCNGPerfOperator::compute(U_Ptr unit) {
......@@ -31,7 +34,10 @@ void SMUCNGPerfOperator::compute(U_Ptr unit) {
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);
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) {
......@@ -43,9 +49,12 @@ void SMUCNGPerfOperator::compute(U_Ptr unit) {
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
bufferClockRef = _queryEngine.querySensor(inputs[_metricToPosition[SMUCSensorBase::CLOCKS_REF]]->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);
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) {
......
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