Commit 05b7e277 authored by Carla Guillen Carias's avatar Carla Guillen Carias

Implementing more cache info to avoid doing excesive job updates. Implementing...

Implementing more cache info to avoid doing excesive job updates. Implementing all ratio metrics. Renaming some metrics which were missleading
parent 4904e57d
......@@ -167,7 +167,8 @@ bool MariaDB::getDBJobIDs(std::vector<std::string> & job_id_strings, std::map<st
}
void MariaDB::addJobToCache(std::string &job_id_string, std::string & job_id_db){
if(_jobCache.size() == JOB_CACHE_MAX_SIZE){ //remove one element before inserting
//remove one element before inserting (the last condition (_jobCache.size() > JOB_CACHE_MAX_SIZE) shouldn't really happen...
if(_jobCache.size() == JOB_CACHE_MAX_SIZE || _jobCache.size() > JOB_CACHE_MAX_SIZE){
using MyPairType = std::pair<std::string, MariaDB::Job_info_t>;
auto smallest = std::min_element(_jobCache.begin(), _jobCache.end(),
[](const MyPairType& l, const MyPairType& r) -> bool {return l.second.last_seen_timestamp < r.second.last_seen_timestamp;});
......@@ -182,41 +183,41 @@ void MariaDB::addJobToCache(std::string &job_id_string, std::string & job_id_db)
bool MariaDB::getCurrentSuffixAggregateTable(std::string & suffix){
if(_end_aggregate_timestamp){
auto now_uts = getTimestamp();
if(now_uts < _end_aggregate_timestamp) { //suffix found, don't do anything
suffix = _current_table_suffix;
return true;
}
}
auto right_now = boost::posix_time::second_clock::local_time();
auto date_time = boost::posix_time::to_iso_extended_string(right_now);
std::replace( date_time.begin(), date_time.end(), 'T', ' ');
std::stringstream build_query;
build_query << "SELECT suffix, UNIX_TIMESTAMP(end_timestamp) FROM SuffixToAggregateTable WHERE begin_timestamp < \'";
build_query << date_time << "\' AND end_timestamp > \'" << date_time << "\'";
auto query = build_query.str();
LOG(debug) << query;
if(mysql_real_query(_mysql, query.c_str(), query.size())){
print_error();
return false;
}
SQLResult result(_mysql);
if(result.get()){
MYSQL_ROW row;
while((row = result.fetch_row())){
if(row[0] && row[1]){
suffix = std::string(row[0]);
_current_table_suffix = suffix;
std::string row1(row[1]);
_end_aggregate_timestamp = std::stoull(row1) * 1e9;
return true;
} else {
return false;
}
}
}
if(now_uts < _end_aggregate_timestamp) { //suffix found, don't do anything
suffix = _current_table_suffix;
return true;
}
}
auto right_now = boost::posix_time::second_clock::local_time();
auto date_time = boost::posix_time::to_iso_extended_string(right_now);
std::replace( date_time.begin(), date_time.end(), 'T', ' ');
std::stringstream build_query;
build_query << "SELECT suffix, UNIX_TIMESTAMP(end_timestamp) FROM SuffixToAggregateTable WHERE begin_timestamp < \'";
build_query << date_time << "\' AND end_timestamp > \'" << date_time << "\'";
auto query = build_query.str();
LOG(debug) << query;
if(mysql_real_query(_mysql, query.c_str(), query.size())){
print_error();
return false;
}
SQLResult result(_mysql);
if(result.get()){
MYSQL_ROW row;
while((row = result.fetch_row())){
if(row[0] && row[1]){
suffix = std::string(row[0]);
_current_table_suffix = suffix;
std::string row1(row[1]);
_end_aggregate_timestamp = std::stoull(row1) * 1e9;
return true;
} else {
return false;
}
}
}
return false;
}
......@@ -294,19 +295,20 @@ bool MariaDB::createNewAggregate(std::string& new_suffix){
build_insert << "\', \'" << new_begin_timestamp << "\', \'" << new_end_timestamp << "\')";
auto query = build_insert.str();
LOG(debug) << query;
if (mysql_real_query(_mysql, query.c_str(), query.size())){
print_error();
return false;
}
std::stringstream build_create;
build_create << "CREATE TABLE Aggregate_" << new_suff << " LIKE Aggregate";
auto query2 = build_create.str();
LOG(debug) << query2;
if(mysql_real_query(_mysql, query2.c_str(), query2.size() )){
if(mysql_errno(_mysql) == 1050){
return true; //table exists!
}
}
print_error();
return false;
}
......@@ -317,13 +319,28 @@ bool MariaDB::createNewAggregate(std::string& new_suffix){
bool MariaDB::updateJobsLastSuffix(std::map<std::string, std::string>& job_map, std::string & suffix){
std::lock_guard<std::mutex> lock(mut);
std::vector<std::string> db_update_jobs;
for(auto &job: job_map){
auto found = _jobCache.find(job.first);
if(found != _jobCache.end()){
if(found->second.job_current_table_suffix.size() == 0 || found->second.job_current_table_suffix != suffix){
found->second.job_current_table_suffix = suffix; //set new suffix
db_update_jobs.push_back(job.second); //write on vector to update
}
}
}
if(db_update_jobs.empty()) {
return true;
}
std::stringstream build_update;
build_update << "UPDATE Accounting SET aggregate_last_suffix=\'" << suffix
<< "\' WHERE job_id IN (";
unsigned int count = 0;
for (auto & kv : job_map) {
build_update << kv.second;
if (count + 1 != job_map.size()) {
for (auto & job_db_id : db_update_jobs) {
build_update << job_db_id;
if (count + 1 != db_update_jobs.size()) {
build_update << ",";
} else {
build_update << ")";
......@@ -333,7 +350,7 @@ bool MariaDB::updateJobsLastSuffix(std::map<std::string, std::string>& job_map,
auto query = build_update.str();
LOG(debug)<< query;
std::lock_guard<std::mutex> lock(mut);
if (mysql_real_query(_mysql, query.c_str(), query.size())) {
print_error();
return false;
......@@ -352,7 +369,6 @@ bool MariaDB::getTableSuffix(std::string & table_suffix){
}
void MariaDB::getNewDates(const std::string& last_end_timestamp, std::string & begin_timestamp, std::string & end_timestamp){
begin_timestamp = last_end_timestamp;
std::tm tm = { };
std::stringstream ss(last_end_timestamp);
......
......@@ -51,6 +51,7 @@ private:
struct Job_info_t {
std::string job_id_db;
unsigned long long last_seen_timestamp;
std::string job_current_table_suffix;
};
public:
......@@ -75,7 +76,7 @@ protected:
static std::mutex mut;
static std::once_flag init_once;
bool _initialized;
std::map<std::string, Job_info_t> _jobCache;
std::map<std::string, Job_info_t> _jobCache; //< Job id string to job data
const std::size_t JOB_CACHE_MAX_SIZE = 10000;
/** print error.
......@@ -124,6 +125,8 @@ public:
/**
* Update the last suffix in the Accounting table
* @param job_id_map job_id_string to job_id (db) map
* @param suffix Aggregate table suffix
*/
bool updateJobsLastSuffix(std::map<std::string, std::string>& job_map, std::string & suffix);
......
......@@ -93,6 +93,7 @@ void PerSystSqlOperator::copy(const PerSystSqlOperator& other){
}
void PerSystSqlOperator::printConfig(LOG_LEVEL ll) {
OperatorTemplate<AggregatorSensorBase>::printConfig(ll);
LOG_VAR(ll) << "====================================";
LOG_VAR(ll) << "PerSystSQL Operator " << _name;
LOG_VAR(ll) << "====================================";
......@@ -157,7 +158,7 @@ void PerSystSqlOperator::compute(U_Ptr unit, qeJobData& jobData) {
}
}
if (!_queryEngine.querySensor(in->getName(), my_timestamp, my_timestamp, _buffer, false)) {
LOG(debug)<< "PerSystSql Operator " << _name << " cannot read from sensor " << in->getName() << "!";
//LOG(debug)<< "PerSystSql Operator " << _name << " cannot read from sensor " << in->getName() << "!";
}
}
}
......
......@@ -44,8 +44,8 @@ SMUCNGPerfConfigurator::SMUCNGPerfConfigurator() : OperatorConfiguratorTemplate(
_metricMap["IOCLOSES"]=SMUCSensorBase::IOCLOSES;
_metricMap["IOREADS"]=SMUCSensorBase::IOREADS;
_metricMap["IOWRITES"]=SMUCSensorBase::IOWRITES;
_metricMap["NETWORK_XMIT"]=SMUCSensorBase::NETWORK_XMIT;
_metricMap["NETWORK_RCVD"]=SMUCSensorBase::NETWORK_RCVD;
_metricMap["NETWORK_XMIT_BYTES"]=SMUCSensorBase::NETWORK_XMIT_BYTES;
_metricMap["NETWORK_RCVD_BYTES"]=SMUCSensorBase::NETWORK_RCVD_BYTES;
_metricMap["NETWORK_XMIT_PKTS"]=SMUCSensorBase::NETWORK_XMIT_PKTS;
_metricMap["NETWORK_RCVD_PKTS"]=SMUCSensorBase::NETWORK_RCVD_PKTS;
_metricMap["L2_RQSTS_MISS"]=SMUCSensorBase::L2_RQSTS_MISS;
......@@ -108,9 +108,9 @@ SMUCNGPerfConfigurator::SMUCNGPerfConfigurator() : OperatorConfiguratorTemplate(
_metricMap["IPMI_MEM"]=SMUCSensorBase::IPMI_MEM;
_metricMap["IPMI_DC"]=SMUCSensorBase::IPMI_DC;
_metricMap["IPMI_AC"]=SMUCSensorBase::IPMI_AC;
_metricMap["NETWORK_XMIT_BYTES_PER_OP"]=SMUCSensorBase::NETWORK_XMIT_BYTES_PER_OP;
_metricMap["NETWORK_XMIT_BYTES_PER_PKT"]=SMUCSensorBase::NETWORK_XMIT_BYTES_PER_PKT;
_metricMap["NETWORK_BYTES_XMIT_PER_SECOND"]=SMUCSensorBase::NETWORK_BYTES_XMIT_PER_SECOND;
_metricMap["NETWORK_RCV_BYTES_PER_OP"]=SMUCSensorBase::NETWORK_RCV_BYTES_PER_OP;
_metricMap["NETWORK_RCV_BYTES_PER_PKT"]=SMUCSensorBase::NETWORK_RCV_BYTES_PER_PKT;
_metricMap["NETWORK_BYTES_RCVD_PER_SECOND"]=SMUCSensorBase::NETWORK_BYTES_RCVD_PER_SECOND;
_metricMap["IOOPENS_PER_SECOND"]=SMUCSensorBase::IOOPENS_PER_SECOND;
_metricMap["IOCLOSES_PER_SECOND"]=SMUCSensorBase::IOCLOSES_PER_SECOND;
......@@ -126,7 +126,6 @@ SMUCNGPerfConfigurator::SMUCNGPerfConfigurator() : OperatorConfiguratorTemplate(
_metricMap["IOWRITES_PER_SECOND_PROF"]=SMUCSensorBase::IOWRITES_PER_SECOND_PROF;
_metricMap["IO_BYTES_READ_PER_OP_PROF"]=SMUCSensorBase::IO_BYTES_READ_PER_OP_PROF;
_metricMap["IO_BYTES_WRITE_PER_OP_PROF"]=SMUCSensorBase::IO_BYTES_WRITE_PER_OP_PROF;
}
SMUCNGPerfConfigurator::~SMUCNGPerfConfigurator() {
......
......@@ -53,14 +53,35 @@ SMUCNGPerfOperator::SMUCNGPerfOperator(const std::string& name): OperatorTemplat
_metricPerSecToId[SMUCSensorBase::L3_HITS_PER_SECOND] = SMUCSensorBase::MEM_LOAD_RETIRED_L3_HIT;
_metricPerSecToId[SMUCSensorBase::L3_MISSES_PER_SECOND] = SMUCSensorBase::MEM_LOAD_RETIRED_L3_MISS;
_metricPerSecToId[SMUCSensorBase::MISSBRANCHES_PER_SECOND] = SMUCSensorBase::PERF_COUNT_HW_BRANCH_MISSES;
_metricPerSecToId[SMUCSensorBase::NETWORK_BYTES_XMIT_PER_SECOND] = SMUCSensorBase::NETWORK_XMIT;
_metricPerSecToId[SMUCSensorBase::NETWORK_BYTES_RCVD_PER_SECOND] = SMUCSensorBase::NETWORK_RCVD;
_metricPerSecToId[SMUCSensorBase::NETWORK_BYTES_XMIT_PER_SECOND] = SMUCSensorBase::NETWORK_XMIT_BYTES;
_metricPerSecToId[SMUCSensorBase::NETWORK_BYTES_RCVD_PER_SECOND] = SMUCSensorBase::NETWORK_RCVD_BYTES;
_metricPerSecToId[SMUCSensorBase::IOOPENS_PER_SECOND] = SMUCSensorBase::IOOPENS;
_metricPerSecToId[SMUCSensorBase::IOCLOSES_PER_SECOND] = SMUCSensorBase::IOCLOSES;
_metricPerSecToId[SMUCSensorBase::IOBYTESREAD_PER_SECOND] = SMUCSensorBase::IOBYTESREAD;
_metricPerSecToId[SMUCSensorBase::IOBYTESWRITE_PER_SECOND] = SMUCSensorBase::IOBYTESWRITE;
_metricPerSecToId[SMUCSensorBase::IOREADS_PER_SECOND] = SMUCSensorBase::IOREADS;
_metricPerSecToId[SMUCSensorBase::IOWRITES_PER_SECOND] = SMUCSensorBase::IOWRITES;
_metricRatioToPair.emplace(std::piecewise_construct, std::forward_as_tuple(SMUCSensorBase::L3_TO_INSTRUCTIONS_RATIO),
std::forward_as_tuple(SMUCSensorBase::MEM_LOAD_UOPS_RETIRED_L3_MISS, SMUCSensorBase::INSTRUCTIONS));
_metricRatioToPair.emplace(std::piecewise_construct, std::forward_as_tuple(SMUCSensorBase::CPI),
std::forward_as_tuple(SMUCSensorBase::CLOCKS, SMUCSensorBase::INSTRUCTIONS));
_metricRatioToPair.emplace(std::piecewise_construct, std::forward_as_tuple(SMUCSensorBase::LOADS_TO_STORES),
std::forward_as_tuple(SMUCSensorBase::MEM_INST_RETIRED_ALL_LOADS, SMUCSensorBase::MEM_INST_RETIRED_ALL_STORES));
_metricRatioToPair.emplace(std::piecewise_construct, std::forward_as_tuple(SMUCSensorBase::BRANCH_PER_INSTRUCTIONS),
std::forward_as_tuple(SMUCSensorBase::PERF_COUNT_HW_BRANCH_MISSES, SMUCSensorBase::INSTRUCTIONS));
_metricRatioToPair.emplace(std::piecewise_construct, std::forward_as_tuple(SMUCSensorBase::MISSBRANCHES_TO_TOTAL_BRANCH_RATIO),
std::forward_as_tuple(SMUCSensorBase::PERF_COUNT_HW_BRANCH_MISSES,SMUCSensorBase::PERF_COUNT_HW_BRANCH_INSTRUCTIONS));
_metricRatioToPair.emplace(std::piecewise_construct, std::forward_as_tuple(SMUCSensorBase::LOADS_TOL3MISS_RATIO),
std::forward_as_tuple(SMUCSensorBase::MEM_INST_RETIRED_ALL_LOADS, SMUCSensorBase::MEM_LOAD_UOPS_RETIRED_L3_MISS));
_metricRatioToPair.emplace(std::piecewise_construct, std::forward_as_tuple(SMUCSensorBase::IO_BYTES_READ_PER_OP),
std::forward_as_tuple(SMUCSensorBase::IOBYTESREAD, SMUCSensorBase::IOREADS));
_metricRatioToPair.emplace(std::piecewise_construct, std::forward_as_tuple(SMUCSensorBase::IO_BYTES_WRITE_PER_OP),
std::forward_as_tuple(SMUCSensorBase::IOBYTESWRITE, SMUCSensorBase::IOWRITES));
_metricRatioToPair.emplace(std::piecewise_construct, std::forward_as_tuple(SMUCSensorBase::NETWORK_XMIT_BYTES_PER_PKT),
std::forward_as_tuple(SMUCSensorBase::NETWORK_XMIT_BYTES, SMUCSensorBase::NETWORK_XMIT_PKTS));
_metricRatioToPair.emplace(std::piecewise_construct, std::forward_as_tuple(SMUCSensorBase::NETWORK_RCV_BYTES_PER_PKT),
std::forward_as_tuple(SMUCSensorBase::NETWORK_RCVD_BYTES, SMUCSensorBase::NETWORK_RCVD_PKTS));
}
SMUCNGPerfOperator::~SMUCNGPerfOperator() {
......@@ -103,31 +124,22 @@ void SMUCNGPerfOperator::compute(U_Ptr unit) {
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) {
if (outSensor->getMetric() == SMUCSensorBase::FREQUENCY) {
computeFREQUENCY(inputs, outSensor, timestamp);
} else if (outSensor->getMetric() == SMUCSensorBase::FLOPS || outSensor->getMetric() == SMUCSensorBase::PACKED_FLOPS ||
outSensor->getMetric() == SMUCSensorBase::AVX512_TOVECTORIZED_RATIO || outSensor->getMetric() == SMUCSensorBase::VECTORIZED_RATIO ||
outSensor->getMetric() == SMUCSensorBase::SINGLE_PRECISION_TO_TOTAL_RATIO) {
computeFLOPS(inputs, outSensor, timestamp);
} else if (outSensor->getMetric() == SMUCSensorBase::L3_TO_INSTRUCTIONS_RATIO){
computeL3_TO_INSTRUCTIONS_RATIO(inputs, outSensor, timestamp);
} else if (outSensor->getMetric() == SMUCSensorBase::L3HIT_TO_L3MISS_RATIO ){
computeL3HIT_TO_L3MISS_RATIO(inputs, outSensor, timestamp);
} else if (outSensor->getMetric() == SMUCSensorBase::LOADS_TO_STORES ){
computeLOADS_TO_STORES(inputs, outSensor, timestamp);
} else if (outSensor->getMetric() == SMUCSensorBase::LOADS_TOL3MISS_RATIO ){
computeLOADS_TOL3MISS_RATIO(inputs, outSensor, timestamp);
} else if (outSensor->getMetric() == SMUCSensorBase::BRANCH_PER_INSTRUCTIONS){
computeBRANCH_PER_INSTRUCTIONS(inputs, outSensor, timestamp);
} else if (outSensor->getMetric() == SMUCSensorBase::MISSBRANCHES_TO_TOTAL_BRANCH_RATIO){
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(outSensor->getMetric(), inputs, outSensor, timestamp);
computeMetricPerSecond(inputs, outSensor, timestamp);
} else if (isAMetricRatio(outSensor->getMetric())){
computeMetricRatio(inputs, outSensor, timestamp);
} else {
LOG(error) << "Derived metric " << outSensor->getMetric() << " not implemented.";
}
resetBuffers();
}
......@@ -135,7 +147,7 @@ void SMUCNGPerfOperator::compute(U_Ptr unit) {
void SMUCNGPerfOperator::query(const std::string & sensor_name, const uint64_t timestamp, vector<reading_t> &buffer){
if(!_queryEngine.querySensor(sensor_name, timestamp, timestamp, buffer, false)) {
LOG(debug) << "SMUCNGPerf Operator " << _name << " cannot read from sensor " << sensor_name << "!";
//LOG(debug) << "SMUCNGPerf Operator " << _name << " cannot read from sensor " << sensor_name << "!";
}
}
......@@ -145,14 +157,35 @@ void SMUCNGPerfOperator::resetBuffers(){
}
}
void SMUCNGPerfOperator::computeCPI(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr &outSensor, const uint64_t timestamp){
std::vector<reading_t> & instructions = _buffers[0];
std::vector<reading_t> & clocks = _buffers[1];
query(inputs[_metricToPosition[SMUCSensorBase::INSTRUCTIONS]]->getName(), timestamp, instructions);
query(inputs[_metricToPosition[SMUCSensorBase::CLOCKS]]->getName(), timestamp, clocks);
void SMUCNGPerfOperator::computeMetricPerSecond(std::vector<SMUCNGPtr> &inputs, SMUCNGPtr& outSensor, const uint64_t timestamp) {
auto found = _metricPerSecToId.find(outSensor->getMetric());
if(found == _metricPerSecToId.end()) { //not found
LOG(error) << "Metric per second " << outSensor->getMetric() << " not implemented.";
return;
}
SMUCSensorBase::Metric_t metric = found->second;
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->getMetadata()->scale)){
outSensor->storeReading(metricpersec);
}
}
void SMUCNGPerfOperator::computeMetricRatio(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr &outSensor, const uint64_t timestamp){
std::vector<reading_t> & dividend = _buffers[0];
std::vector<reading_t> & divisor = _buffers[1];
auto found = _metricRatioToPair.find(outSensor->getMetric());
if(found == _metricRatioToPair.end()) { //not found
LOG(error) << "Metric ratio " << outSensor->getMetric() << " not implemented.";
return;
}
SMUCSensorBase::Metric_t metric_dividend = found->second.first;
SMUCSensorBase::Metric_t metric_divisor = found->second.second;
query(inputs[_metricToPosition[metric_dividend]]->getName(), timestamp, dividend);
query(inputs[_metricToPosition[metric_divisor]]->getName(), timestamp, divisor);
bool wascalced = false;
reading_t cpi;
if (instructions.size() > 0 && clocks.size() > 0 && calculateMetricRatio(clocks[0], instructions[0], cpi, outSensor->getMetadata()->scale)) {
if (dividend.size() > 0 && divisor.size() > 0 && calculateMetricRatio(dividend[0], divisor[0], cpi, outSensor->getMetadata()->scale)) {
outSensor->storeReading(cpi);
}
}
......@@ -240,18 +273,6 @@ void SMUCNGPerfOperator::computeFLOPS(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr&
SMUCNGPtr& outSensor, const uint64_t timestamp) {
}*/
void SMUCNGPerfOperator::computeL3_TO_INSTRUCTIONS_RATIO(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr& outSensor,
const uint64_t timestamp) {
std::vector<reading_t> & l3_misses = _buffers[0];
std::vector<reading_t> & instructions = _buffers[1];
query(inputs[_metricToPosition[SMUCSensorBase::MEM_LOAD_UOPS_RETIRED_L3_MISS]]->getName(), timestamp, l3_misses);
query(inputs[_metricToPosition[SMUCSensorBase::INSTRUCTIONS]]->getName(), timestamp, instructions);
reading_t l3toinstrRatio;
if (instructions.size() > 0 && l3_misses.size() > 0 && calculateMetricRatio(instructions[0], l3_misses[0], l3toinstrRatio, outSensor->getMetadata()->scale)) {
outSensor->storeReading(l3toinstrRatio);
}
}
void SMUCNGPerfOperator::computeL3_BANDWIDTH(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr& outSensor,
const uint64_t timestamp) {
}
......@@ -271,63 +292,6 @@ void SMUCNGPerfOperator::computeL3HIT_TO_L3MISS_RATIO(std::vector<SMUCNGPtr>& in
}
}
void SMUCNGPerfOperator::computeMetricPerSecond(SMUCSensorBase::Metric_t metric_ps, std::vector<SMUCNGPtr> &inputs, SMUCNGPtr& outSensor, const uint64_t timestamp) {
SMUCSensorBase::Metric_t metric = _metricPerSecToId[metric_ps];
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->getMetadata()->scale)){
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];
std::vector<reading_t> & stores = _buffers[1];
query(inputs[_metricToPosition[SMUCSensorBase::MEM_INST_RETIRED_ALL_LOADS]]->getName(), timestamp, loads);
query(inputs[_metricToPosition[SMUCSensorBase::MEM_INST_RETIRED_ALL_STORES]]->getName(), timestamp, stores);
reading_t loadToStoreRatio;
if(loads.size() > 0 && stores.size() > 0 && calculateMetricRatio(loads[0], stores[0], loadToStoreRatio, outSensor->getMetadata()->scale)){
outSensor->storeReading(loadToStoreRatio);
}
}
void SMUCNGPerfOperator::computeLOADS_TOL3MISS_RATIO(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr& outSensor, const uint64_t timestamp) {
std::vector<reading_t> & loads = _buffers[0];
std::vector<reading_t> & l3_misses = _buffers[1];
query(inputs[_metricToPosition[SMUCSensorBase::MEM_INST_RETIRED_ALL_LOADS]]->getName(), timestamp, loads);
query(inputs[_metricToPosition[SMUCSensorBase::MEM_LOAD_UOPS_RETIRED_L3_MISS]]->getName(), timestamp, l3_misses);
reading_t loads_to_l3misses;
if (loads.size() > 0 && l3_misses.size() > 0
&& calculateMetricRatio(loads[0], l3_misses[0], loads_to_l3misses, outSensor->getMetadata()->scale)) {
outSensor->storeReading(loads_to_l3misses);
}
}
void SMUCNGPerfOperator::computeBRANCH_PER_INSTRUCTIONS(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr& outSensor, const uint64_t timestamp) {
std::vector<reading_t> & missedbranches = _buffers[0];
std::vector<reading_t> & instructions = _buffers[1];
query(inputs[_metricToPosition[SMUCSensorBase::PERF_COUNT_HW_BRANCH_MISSES]]->getName(), timestamp, missedbranches);
query(inputs[_metricToPosition[SMUCSensorBase::INSTRUCTIONS]]->getName(), timestamp, instructions);
reading_t branchPerInstructions;
if (missedbranches.size() > 0 && instructions.size() > 0
&& calculateMetricRatio(missedbranches[0], instructions[0], branchPerInstructions, outSensor->getMetadata()->scale)) {
outSensor->storeReading(branchPerInstructions);
}
}
void SMUCNGPerfOperator::computeMISSBRANCHES_TO_TOTAL_BRANCH_RATIO(std::vector<SMUCNGPtr>& inputs,
SMUCNGPtr& outSensor, const uint64_t timestamp) {
std::vector<reading_t> & missedbranches = _buffers[0];
std::vector<reading_t> & totalbranches = _buffers[1];
query(inputs[_metricToPosition[SMUCSensorBase::PERF_COUNT_HW_BRANCH_MISSES]]->getName(), timestamp, missedbranches);
query(inputs[_metricToPosition[SMUCSensorBase::PERF_COUNT_HW_BRANCH_INSTRUCTIONS]]->getName(), timestamp, totalbranches);
reading_t missbranchesPerTotal;
if(missedbranches.size() > 0 && totalbranches.size() > 0 &&
calculateMetricRatio(missedbranches[0], totalbranches[0], missbranchesPerTotal, outSensor->getMetadata()->scale)){
outSensor->storeReading(missbranchesPerTotal);
}
}
void SMUCNGPerfOperator::computeMEMORY_BANDWIDTH(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr& outSensor, const uint64_t timestamp) {
std::vector<reading_t> & mem_counters = _buffers[0];
......@@ -351,14 +315,14 @@ void SMUCNGPerfOperator::computeMEMORY_BANDWIDTH(std::vector<SMUCNGPtr>& inputs,
}
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 ){
if(_metricPerSecToId.find(comp) != _metricPerSecToId.end() ){ //found
return true;
}
return false;
}
bool SMUCNGPerfOperator::isAMetricRatio(SMUCSensorBase::Metric_t comp){
if(_metricRatioToPair.find(comp) != _metricRatioToPair.end()){
return true;
}
return false;
......
......@@ -55,6 +55,7 @@ public:
protected:
std::map<SMUCSensorBase::Metric_t, unsigned int> _metricToPosition;
std::map<SMUCSensorBase::Metric_t, SMUCSensorBase::Metric_t> _metricPerSecToId;
std::map<SMUCSensorBase::Metric_t, std::pair<SMUCSensorBase::Metric_t, SMUCSensorBase::Metric_t>> _metricRatioToPair;
vector<vector<reading_t>> _buffers;
const unsigned int MAX_FREQ_MHZ = 2700;
const unsigned int MIN_FREQ_MHZ = 1200;
......@@ -68,23 +69,19 @@ protected:
void query(const std::string & sensor_name, const uint64_t timestamp, vector<reading_t> &buffer);
void copy(const SMUCNGPerfOperator& other);
void computeCPI(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr &outSensor, const uint64_t timestamp);
void computeMetricRatio(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr &outSensor, const uint64_t timestamp);
void computeMetricPerSecond(std::vector<SMUCNGPtr> &inputs, SMUCNGPtr& outSensor, const uint64_t timestamp);
void computeFREQUENCY(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr &outSensor, const uint64_t timestamp);
void computeFLOPS(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 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 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);
bool isAMetricRatio(SMUCSensorBase::Metric_t comp);
};
#endif /* ANALYTICS_SMUCNGPERF_SMUCNGPERFOPERATOR_H_ */
......@@ -46,8 +46,8 @@ public:
IOCLOSES=10,
IOREADS=11,
IOWRITES=12,
NETWORK_XMIT=13,
NETWORK_RCVD=14,
NETWORK_XMIT_BYTES=13,
NETWORK_RCVD_BYTES=14,
NETWORK_XMIT_PKTS=15,
NETWORK_RCVD_PKTS=16,
L2_RQSTS_MISS=17,
......@@ -111,9 +111,9 @@ public:
IPMI_MEM=77,
IPMI_DC=78,
IPMI_AC=79,
NETWORK_XMIT_BYTES_PER_OP=80,
NETWORK_XMIT_BYTES_PER_PKT=80,
NETWORK_BYTES_XMIT_PER_SECOND=81,
NETWORK_RCV_BYTES_PER_OP=82,
NETWORK_RCV_BYTES_PER_PKT=82,
NETWORK_BYTES_RCVD_PER_SECOND=83,
IOOPENS_PER_SECOND=84,
IOCLOSES_PER_SECOND=85,
......
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