Commit f1314feb authored by lu43jih's avatar lu43jih
Browse files

1. Check for nullptr if metadata is set. 2. Changing scaling_factor to be...

1. Check for nullptr if metadata is set. 2. Changing scaling_factor to be multiplied instead of divided (dcdb nomenclature).
parent 22f89a88
......@@ -100,9 +100,6 @@ void PerSystSqlConfigurator::operatorAttributes(PerSystSqlOperator& op, CFG_VAL
} else if(val.second.data() == "mariadb") {
op.setBackend(PerSystSqlOperator::MARIADB);
}
} else if(boost::iequals(val.first, "scaling_factor")){
auto scaling_factor = std::stoull(val.second.data());
op.setScalingFactor(scaling_factor);
} else if(boost::iequals(val.first, "property_id")){
auto property_id = std::stoi(val.second.data());
op.setPropertyId(property_id);
......
......@@ -188,7 +188,7 @@ void PerSystSqlOperator::compute(U_Ptr unit, qeJobData& jobData) {
void PerSystSqlOperator::convertToDoubles(std::vector<reading_t> &buffer, std::vector<double> &douBuffer){
for(auto &reading: buffer){
double value = reading.value/_scaling_factor;
double value = reading.value * _scaling_factor;
douBuffer.push_back(value);
}
}
......@@ -210,7 +210,7 @@ void PerSystSqlOperator::compute_internal(U_Ptr& unit, vector<reading_t>& buffer
switch (op) {
case AggregatorSensorBase::AVG:
if (_backend == CASSANDRA) {
reading.value = std::accumulate(douBuffer.begin(), douBuffer.end(), 0.0)/douBuffer.size() * _scaling_factor;
reading.value = std::accumulate(douBuffer.begin(), douBuffer.end(), 0.0)/(douBuffer.size() * _scaling_factor);
} else {
agg_info.average = std::accumulate(douBuffer.begin(), douBuffer.end(), 0.0)/douBuffer.size();
}
......@@ -244,7 +244,7 @@ void PerSystSqlOperator::compute_internal(U_Ptr& unit, vector<reading_t>& buffer
computeEvenQuantiles(douBuffer, _number_of_even_quantiles, quantiles);
if (_backend == CASSANDRA) {
for (unsigned idx = 0; idx < quantiles.size(); idx++) {
reading.value = quantiles[idx]*_scaling_factor;
reading.value = quantiles[idx] / _scaling_factor;
_quantileSensors[idx]->storeReading(reading);
}
} else {
......
......@@ -97,10 +97,6 @@ public:
_backend = backend;
}
void setScalingFactor(unsigned long long scalingFactor) {
_scaling_factor = scalingFactor;
}
void setMariaDBConnection(const std::string & host, const std::string & user, const std::string & password, const std::string & database_name, int port, PerSystDB::Rotation_t rotation, unsigned int every_x_days=0){
_conn.host = host;
_conn.user = user;
......
......@@ -36,10 +36,10 @@ bool calculateFlopsPerSec(reading_t &scalarDB, reading_t & scalarSP,
reading_t & result, double scaling_factor, double measuring_interval_s) {
if(!measuring_interval_s) return false;
result.value = scaling_factor * (packedDP128.value * 2 + packedSP128.value * 4
result.value = (packedDP128.value * 2 + packedSP128.value * 4
+ packedDP256.value * 4 + packedSP256.value * 8
+ packedDP512.value * 8 + packedSP512.value * 16 + scalarDB.value
+ scalarSP.value)/measuring_interval_s;
+ scalarSP.value)/(scaling_factor * measuring_interval_s);
return getTimestampFromReadings(result.timestamp, scalarDB, scalarSP, packedDP128, packedSP128, packedDP256, packedSP256, packedDP512, packedSP512);
}
......@@ -47,9 +47,9 @@ bool calculatePackedFlopsPerSec(reading_t & packedDP128, reading_t & packedSP128
reading_t & packedDP256, reading_t & packedSP256,
reading_t & packedDP512, reading_t & packedSP512,
reading_t & result, double scaling_factor, double measuring_interval_s) {
result.value = scaling_factor * (packedDP128.value * 2 + packedSP128.value * 4
result.value = (packedDP128.value * 2 + packedSP128.value * 4
+ packedDP256.value * 4 + packedSP256.value * 8
+ packedDP512.value * 8 + packedSP512.value * 16)/measuring_interval_s;
+ packedDP512.value * 8 + packedSP512.value * 16)/(scaling_factor * measuring_interval_s);
return getTimestampFromReadings(result.timestamp, packedDP128, packedSP128, packedDP256, packedSP256, packedDP512, packedSP512);
}
......@@ -62,8 +62,8 @@ bool calculateVectorizationRatio(reading_t & scalarDB, reading_t & scalarSP,
packedDP256.value + packedSP256.value +
packedDP512.value + packedSP512.value);
if(denominator > 0 ){
result.value = scaling_factor*((packedDP128.value + packedSP128.value + packedDP256.value
+ packedSP256.value + packedDP256.value + packedSP512.value + packedDP512.value)/denominator);
result.value = (packedDP128.value + packedSP128.value + packedDP256.value
+ packedSP256.value + packedDP256.value + packedSP512.value + packedDP512.value)/(scaling_factor * denominator);
return getTimestampFromReadings(result.timestamp, scalarDB, scalarSP,
packedDP128, packedSP128, packedDP256, packedSP256, packedDP512,
packedSP512);
......@@ -79,7 +79,7 @@ bool calculateAVX512FlopsToVectorizedRatio(reading_t & packedDP128, reading_t &
packedDP256.value + packedSP256.value +
packedDP512.value + packedSP512.value);
if(denominator > 0){
result.value = scaling_factor* ((packedDP512.value * 8 + packedSP512.value * 16)/denominator);
result.value = (packedDP512.value * 8 + packedSP512.value * 16)/( scaling_factor * denominator);
return getTimestampFromReadings(result.timestamp, packedDP128, packedSP128, packedDP256, packedSP256, packedDP512, packedSP512);
}
return false;
......@@ -95,7 +95,7 @@ bool calculateSP_TO_TOTAL_RATIO(reading_t &scalarDB, reading_t & scalarSP,
+ packedSP512.value * 16 + scalarSP.value;
double total = single_precision = packedDP128.value * 2 + packedDP256.value * 4 + packedDP512.value * 8 + scalarDB.value;
if(total > 0){
result.value = scaling_factor * (single_precision/total);
result.value = single_precision/(scaling_factor * total);
return getTimestampFromReadings(result.timestamp, scalarDB, scalarSP,
packedDP128, packedSP128, packedDP256, packedSP256, packedDP512,
packedSP512);
......@@ -107,7 +107,7 @@ bool calculateL3HitToL3MissRatio(reading_t & l3_misses, reading_t& l3_load_hits,
reading_t & l3_load_misses, reading_t & result, double scaling_factor){
double denominator = static_cast<double>(l3_load_hits.value + l3_load_misses.value);
if(denominator > 0){
result.value = scaling_factor*(l3_misses.value/denominator);
result.value = l3_misses.value/(scaling_factor * denominator);
return getTimestampFromReadings(result.timestamp, l3_misses, l3_load_hits, l3_load_misses);
}
return false;
......@@ -124,7 +124,7 @@ bool calculateMemoryBandwidth(std::vector<reading_t> membw_counts, reading_t & r
ret_val = true;
}
}
result.value = scaling_factor * (result.value/measuring_interval_s);
result.value = result.value/ ( scaling_factor * measuring_interval_s);
return ret_val;
}
......@@ -134,7 +134,7 @@ bool calculateMemoryBandwidth(std::vector<reading_t> membw_counts, reading_t & r
*/
bool calculateMetricRatio(reading_t & dividend, reading_t & divisor, reading_t & result, double scaling_factor) {
if(divisor.value > 0){
result.value = scaling_factor * (dividend.value / static_cast<double>(divisor.value));
result.value = dividend.value / (scaling_factor * static_cast<double>(divisor.value));
return getTimestampFromReadings(result.timestamp, dividend, divisor);
}
return false; //Division by zero
......@@ -143,7 +143,7 @@ bool calculateMetricRatio(reading_t & dividend, reading_t & divisor, reading_t &
/** Any generic metric per second. For instance: instructions per second, l2 misses per second **/
bool calculateMetricPerSec(reading_t & metric, double measuring_interval_s, reading_t & result, double scaling_factor) {
if(measuring_interval_s > 0) {
result.value = scaling_factor * (metric.value / measuring_interval_s);
result.value = metric.value / (scaling_factor * measuring_interval_s);
return getTimestampFromReadings(result.timestamp, metric);
}
return false; //Division by zero
......@@ -156,7 +156,7 @@ bool calculateFrequency(reading_t & unhaltedRef, reading_t & unhaltedClocks,
if(resValue > (max_freq * 1.1) || resValue < (min_freq*0.9)) { //There is something wrong here...
return false;
}
result.value = scaling_factor * resValue;
result.value = resValue/scaling_factor;
return getTimestampFromReadings(result.timestamp, unhaltedRef, unhaltedClocks);
}
return false; //Division by zero
......
......@@ -98,6 +98,11 @@ void SMUCNGPerfOperator::compute(U_Ptr unit) {
auto inputs = unit->getInputs();
auto timestamp = getTimestamp() - _go_back_ns;
for(auto& outSensor : unit->getOutputs()){
if(outSensor->getMetadata() == nullptr){
LOG(error) << "No metadata defined, sensor " << outSensor->getName() << " can't compute anything.";
continue;
}
if( outSensor->getMetric() == SMUCSensorBase::CPI) {
computeCPI(inputs, outSensor, timestamp);
} else if (outSensor->getMetric() == SMUCSensorBase::FREQUENCY) {
......
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