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

Adding metrics per second

parent c98e5434
......@@ -260,6 +260,9 @@ bool PerSystDB::createNewAggregate(std::string& new_suffix){
std::cout << query2 << std::endl;
#endif
if(mysql_real_query(_mysql, query2.c_str(), query2.size() )){
if(mysql_errno(_mysql) == 1050){
return true; //table exists!
}
print_error();
return false;
}
......
......@@ -76,11 +76,14 @@ void PerSystSqlConfigurator::operatorAttributes(PerSystSqlOperator& op, CFG_VAL
if (boost::iequals(val.first, "number_quantiles")) {
unsigned int num_quantiles = std::stoul(val.second.data());
op.setNumberOfEvenQuantiles(num_quantiles);
}else if (boost::iequals(val.first, "severity_threshold")){
auto threshold = std::stof(val.second.data());
} else if (boost::iequals(val.first, "go_back_ms")) {
auto go_back_ms = std::stoi(val.second.data());
op.setGoBackInMs(go_back_ms);
} else if (boost::iequals(val.first, "severity_threshold")){
auto threshold = std::stod(val.second.data());
op.setSeverityThreshold(threshold);
} else if (boost::iequals(val.first, "severity_exponent")){
auto exponent = std::stof(val.second.data());
auto exponent = std::stod(val.second.data());
op.setSeverityThreshold(exponent);
} else if (boost::iequals(val.first, "severity_formula")){
std::string formula = val.second.data();
......
......@@ -48,7 +48,7 @@
PerSystSqlOperator::PerSystSqlOperator(const std::string& name) :
OperatorTemplate(name), JobOperatorTemplate(name), _number_of_even_quantiles(0),
_severity_formula(NOFORMULA), _severity_threshold(0), _severity_exponent(0),
_severity_max_memory(0) {
_severity_max_memory(0), _go_back_ns(0) {
}
PerSystSqlOperator::~PerSystSqlOperator() {
......@@ -58,7 +58,7 @@ void PerSystSqlOperator::compute(U_Ptr unit, qeJobData& jobData) {
// Clearing the buffer, if already allocated
_buffer.clear();
size_t elCtr=0;
uint64_t my_timestamp = getTimestamp(); //TODO minus 10 seconds or so...
uint64_t my_timestamp = getTimestamp() - _go_back_ns;
// Making sure that the aggregation boundaries do not go past the job start/end time
uint64_t jobEnd = jobData.endTime!=0 && my_timestamp > jobData.endTime ? jobData.endTime : my_timestamp;
uint64_t jobStart = jobEnd-my_timestamp < jobData.startTime ? jobData.startTime : jobEnd-my_timestamp;
......@@ -82,7 +82,7 @@ void PerSystSqlOperator::compute_internal(U_Ptr unit, vector<reading_t>& buffer)
_quantileSensors.clear();
reading_t reading;
AggregatorSensorBase::aggregationOps_t op;
reading.timestamp = getTimestamp() - 10e9;
reading.timestamp = getTimestamp() - _go_back_ns;
std::vector<double> douBuffer;
punToDoubles(buffer, douBuffer);
......@@ -110,7 +110,7 @@ void PerSystSqlOperator::compute_internal(U_Ptr unit, vector<reading_t>& buffer)
}
out->storeReading(reading);
} else {
_quantileSensors.push_back(out);
_quantileSensors.push_back(out);
}
}
......
......@@ -76,20 +76,25 @@ public:
_severity_threshold = severityThreshold;
}
void setGoBackInMs(int go_back_ms){
_go_back_ns = go_back_ms * 1e6;
}
private:
std::vector<reading_t> _buffer;
std::vector<double> _severities;
protected:
virtual void compute(U_Ptr unit) override;
void compute_internal(U_Ptr unit, vector<reading_t>& buffer);
double computeSeverityAverage(vector<double> & buffer);
std::vector<AggregatorSBPtr> _quantileSensors;
unsigned int _number_of_even_quantiles;
Formula _severity_formula;
double _severity_threshold;
double _severity_exponent;
double _severity_max_memory;
std::vector<double> _severities;
int _go_back_ns;
protected:
virtual void compute(U_Ptr unit) override;
void compute_internal(U_Ptr unit, vector<reading_t>& buffer);
double computeSeverityAverage(vector<double> & buffer);
};
double severity_formula1(double metric, double threshold, double exponent);
......
......@@ -82,7 +82,7 @@ bool calculateMemoryBandwidth(std::vector<reading_t> membw_counts, reading_t & r
bool calculateMetricRatio(reading_t & dividend, reading_t & divisor, reading_t & result);
/** Any generic metric per second. For instance: instructions per second, l2 misses per second **/
bool calculateMetricPerSec(reading_t & metric, double measuring_interval_s, unsigned int scaling_factor, reading_t & result) ;
bool calculateMetricPerSec(reading_t & metric, double measuring_interval_s, reading_t & result) ;
bool calculateFrequency(reading_t & unhaltedRef, reading_t & unhaltedClocks,
unsigned int min_freq, unsigned int max_freq, reading_t & result);
......
......@@ -72,7 +72,10 @@ void SMUCNGPerfConfigurator::operatorAttributes(SMUCNGPerfOperator& op, CFG_VAL
if (boost::iequals(val.first, "measuring_interval")){
auto measurementInterval_s = std::stod(val.second.data())/1000.0; //miliseconds to seconds
op.setMeasuringInterval(measurementInterval_s);
}
} else if(boost::iequals(val.first, "go_back_ms")) {
auto go_back_ms = std::stod(val.second.data());
op.setGoBackMs(go_back_ms);
}
}
}
......
......@@ -44,8 +44,23 @@
#include "../../includes/UnitTemplate.h"
#include "SKXPMUMetrics.h"
SMUCNGPerfOperator::SMUCNGPerfOperator(const std::string& name): OperatorTemplate(name) {
SMUCNGPerfOperator::SMUCNGPerfOperator(const std::string& name): OperatorTemplate(name), _go_back_ns(0), _measuring_interval_s(1) {
_buffers.resize(64);
_metricToPerSecId[SMUCSensorBase::INSTRUCTIONS] = SMUCSensorBase::INSTRUCTIONS_PER_SECOND;
_metricToPerSecId[SMUCSensorBase::ARITH_FPU_DIVIDER_ACTIVE] = SMUCSensorBase::EXPENSIVE_INSTRUCTIONS_PER_SECOND;
// _metricToPerSecId[SMUCSensorBase::L2_HITS] = SMUCSensorBase::L2_HITS_PER_SECOND;
_metricToPerSecId[SMUCSensorBase::L2_RQSTS_MISS] = SMUCSensorBase::L2_MISSES_PER_SECOND;
_metricToPerSecId[SMUCSensorBase::MEM_LOAD_RETIRED_L3_HIT] = SMUCSensorBase::L3_HITS_PER_SECOND;
_metricToPerSecId[SMUCSensorBase::MEM_LOAD_RETIRED_L3_MISS] = SMUCSensorBase::L3_MISSES_PER_SECOND;
_metricToPerSecId[SMUCSensorBase::PERF_COUNT_HW_BRANCH_MISSES] = SMUCSensorBase::MISSBRANCHES_PER_SECOND;
_metricToPerSecId[SMUCSensorBase::NETWORK_XMIT] = SMUCSensorBase::NETWORK_BYTES_XMIT_PER_SECOND;
_metricToPerSecId[SMUCSensorBase::NETWORK_RCVD] = SMUCSensorBase::NETWORK_BYTES_RCVD_PER_SECOND;
_metricToPerSecId[SMUCSensorBase::IOOPENS] = SMUCSensorBase::IOOPENS_PER_SECOND;
_metricToPerSecId[SMUCSensorBase::IOCLOSES] = SMUCSensorBase::IOCLOSES_PER_SECOND;
_metricToPerSecId[SMUCSensorBase::IOBYTESREAD] = SMUCSensorBase::IOBYTESREAD_PER_SECOND;
_metricToPerSecId[SMUCSensorBase::IOBYTESWRITE] = SMUCSensorBase::IOBYTESWRITE_PER_SECOND;
_metricToPerSecId[SMUCSensorBase::IOREADS] = SMUCSensorBase::IOREADS_PER_SECOND;
_metricToPerSecId[SMUCSensorBase::IOWRITES] = SMUCSensorBase::IOWRITES_PER_SECOND;
}
SMUCNGPerfOperator::~SMUCNGPerfOperator() {
......@@ -64,7 +79,9 @@ SMUCNGPerfOperator& SMUCNGPerfOperator::operator=(const SMUCNGPerfOperator& othe
void SMUCNGPerfOperator::copy(const SMUCNGPerfOperator& other){
this->_buffers = other._buffers;
this->_metricToPosition = other._metricToPosition;
//this->_measurement_interval = other._measurement_interval;
this->_measuring_interval_s = other._measuring_interval_s;
this->_go_back_ns = other._go_back_ns;
this->_metricToPerSecId = other._metricToPerSecId;
}
void SMUCNGPerfOperator::printConfig(LOG_LEVEL ll) {
......@@ -73,11 +90,13 @@ void SMUCNGPerfOperator::printConfig(LOG_LEVEL ll) {
for(auto &kv : _metricToPosition){
LOG_VAR(ll) << "Metric = " << kv.first << " Position = " << kv.second;
}
LOG_VAR(ll) << "_measuring_interval_s = " << _measuring_interval_s;
LOG_VAR(ll) << "_go_back_ns = " << _go_back_ns;
}
void SMUCNGPerfOperator::compute(U_Ptr unit) {
auto inputs = unit->getInputs();
auto timestamp = getTimestamp() - 10e9;
auto timestamp = getTimestamp() - _go_back_ns;
for(auto& outSensor : unit->getOutputs()){
if( outSensor->getMetric() == SMUCSensorBase::CPI) {
computeCPI(inputs, outSensor, timestamp);
......@@ -101,6 +120,8 @@ void SMUCNGPerfOperator::compute(U_Ptr unit) {
computeMISSBRANCHES_TO_TOTAL_BRANCH_RATIO(inputs, outSensor, timestamp);
} else if (outSensor->getMetric() == SMUCSensorBase::MEMORY_BANDWIDTH) {
computeMEMORY_BANDWIDTH(inputs, outSensor, timestamp);
} else if (isAMetricPerSecond(outSensor->getMetric())){
computeMetricPerSecond(_metricToPerSecId[outSensor->getMetric()], inputs, outSensor, timestamp);
}
resetBuffers();
}
......@@ -240,6 +261,14 @@ void SMUCNGPerfOperator::computeL3HIT_TO_L3MISS_RATIO(std::vector<SMUCNGPtr>& in
}
}
void SMUCNGPerfOperator::computeMetricPerSecond(SMUCSensorBase::Metric_t metric, std::vector<SMUCNGPtr> &inputs, SMUCNGPtr& outSensor, const uint64_t timestamp) {
query(inputs[_metricToPosition[metric]]->getName(), timestamp, _buffers[0]);
reading_t metricpersec;
if(_buffers[0].size() > 0 && calculateMetricPerSec(_buffers[0][0], _measuring_interval_s, metricpersec)){
outSensor->storeReading(metricpersec);
}
}
void SMUCNGPerfOperator::computeLOADS_TO_STORES(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr& outSensor,
const uint64_t timestamp) {
std::vector<reading_t> & loads = _buffers[0];
......@@ -294,3 +323,23 @@ void SMUCNGPerfOperator::computeMEMORY_BANDWIDTH(std::vector<SMUCNGPtr>& inputs,
const uint64_t timestamp) {
std::vector<reading_t> mem_counters; //ToDo how do I get them?
}
bool SMUCNGPerfOperator::isAMetricPerSecond(SMUCSensorBase::Metric_t comp){
if(comp == SMUCSensorBase::INSTRUCTIONS_PER_SECOND ||
comp == SMUCSensorBase::EXPENSIVE_INSTRUCTIONS_PER_SECOND || comp == SMUCSensorBase::L2_HITS_PER_SECOND ||
comp == SMUCSensorBase::L2_MISSES_PER_SECOND ||
comp == SMUCSensorBase::L3_HITS_PER_SECOND ||
comp == SMUCSensorBase::L3_MISSES_PER_SECOND ||
comp == SMUCSensorBase::MISSBRANCHES_PER_SECOND ||
comp == SMUCSensorBase::NETWORK_BYTES_XMIT_PER_SECOND ||
comp == SMUCSensorBase::NETWORK_BYTES_RCVD_PER_SECOND ||
comp == SMUCSensorBase::IOOPENS_PER_SECOND ||
comp == SMUCSensorBase::IOCLOSES_PER_SECOND ||
comp == SMUCSensorBase::IOBYTESREAD_PER_SECOND ||
comp == SMUCSensorBase::IOBYTESWRITE_PER_SECOND ||
comp == SMUCSensorBase::IOREADS_PER_SECOND ||
comp == SMUCSensorBase::IOWRITES_PER_SECOND ){
return true;
}
return false;
}
......@@ -48,13 +48,19 @@ public:
void setMeasuringInterval(double measurement_interval_s){
_measuring_interval_s = measurement_interval_s;
}
void setGoBackMs(int go_back_ms){
_go_back_ns = go_back_ms * 1e6;
}
protected:
std::map<SMUCSensorBase::Metric_t, unsigned int> _metricToPosition;
std::map<SMUCSensorBase::Metric_t, SMUCSensorBase::Metric_t> _metricToPerSecId;
vector<vector<reading_t>> _buffers;
const unsigned int MAX_FREQ_MHZ = 2700;
const unsigned int MIN_FREQ_MHZ = 1200;
double _go_back_ns;
double _measuring_interval_s;
virtual void compute(U_Ptr unit) override;
......@@ -64,25 +70,21 @@ protected:
void copy(const SMUCNGPerfOperator& other);
void computeCPI(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr &outSensor, const uint64_t timestamp);
void computeFREQUENCY(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr &outSensor, const uint64_t timestamp);
//void computeINSTRUCTIONS_PER_SECOND(SMUCNGPtr &outSensor, const uint64_t timestamp);
void computeFLOPS(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr &outSensor, const uint64_t timestamp);
//void computeEXPENSIVE_INSTRUCTIONS_PER_SECOND(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr &outSensor, const uint64_t timestamp);
//void computeINSTR_INTRA_NODE_LOADIMBALANCE(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr &outSensor, const uint64_t timestamp);
//void computeINSTR_INTER_NODE_LOADIMBALANCE((SMUCNGPtr &outSensor); //needs to be donejob plugin
//void computeL2_HITS_PER_SECOND(SMUCNGPtr &outSensor, const uint64_t timestamp);
//void computeL2_MISSES_PER_SECOND(SMUCNGPtr &outSensor, const uint64_t timestamp);
//void computeL3_HITS_PER_SECOND(SMUCNGPtr &outSensor, const uint64_t timestamp);
//void computeL3_MISSES_PER_SECOND(SMUCNGPtr &outSensor, const uint64_t timestamp);
void computeL3_TO_INSTRUCTIONS_RATIO(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr &outSensor, const uint64_t timestamp);
void computeL3_BANDWIDTH(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr &outSensor, const uint64_t timestamp);
void computeL3HIT_TO_L3MISS_RATIO(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr &outSensor, const uint64_t timestamp);
void computeLOADS_TO_STORES(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr &outSensor, const uint64_t timestamp);
void computeLOADS_TOL3MISS_RATIO(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr &outSensor, const uint64_t timestamp);
//void computeMISSBRANCHES_PER_SECOND(SMUCNGPtr &outSensor, const uint64_t timestamp);
void computeBRANCH_PER_INSTRUCTIONS(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr &outSensor, const uint64_t timestamp);
void computeMISSBRANCHES_TO_TOTAL_BRANCH_RATIO(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr &outSensor, const uint64_t timestamp);
void computeMEMORY_BANDWIDTH(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr &outSensor, const uint64_t timestamp);
void computeMetricPerSecond(SMUCSensorBase::Metric_t metric, std::vector<SMUCNGPtr> &inputs, SMUCNGPtr& outSensor, const uint64_t timestamp);
bool isAMetricPerSecond(SMUCSensorBase::Metric_t comp);
};
#endif /* ANALYTICS_SMUCNGPERF_SMUCNGPERFOPERATOR_H_ */
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