Commit 143b4024 authored by lu43jih's avatar lu43jih
Browse files

Development of analyzer for PerSyst data

parent f17b72f5
/*
* SMUCNGPerfAnalyzer.cpp
*
* Created on: Jul 20, 2019
* Author: carla
*/
#include "SMUCNGPerfAnalyzer.h"
SMUCNGPerfAnalyzer::SMUCNGPerfAnalyzer() {
}
SMUCNGPerfAnalyzer::~SMUCNGPerfAnalyzer() {
}
void SMUCNGPerfAnalyzer::printConfig(LOG_LEVELll) {
LOG_VAR(ll) << " Window: " << _window;
AnalyzerTemplate<AggregatorSensorBase>::printConfig(ll);
}
void SMUCNGPerfAnalyzer::compute(U_Ptr unit) {
auto inputs = unit->getInputs();
auto timestamp = getTimestamp(); //ToDo timestamp minus some time...
vector<reading_t> * _bufferInstructions = _queryEngine.querySensor(inputs[_metricToPosition[SMUCSensorBase::INSTRUCTIONS]]->getName(), timestamp, timestamp, _bufferInstructions, false); //use absolute timestamp
vector<reading_t> * _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()), 1, clockspersecond);
delete _bufferInstructions;
delete _bufferClocks;
if(wascalced) {
auto outputs = unit->getOutputs();
outputs[0]->storeReading(clockspersecond);
}
}
/*
* SMUCNGPerfAnalyzer.h
*
* Created on: Jul 20, 2019
* Author: carla
*/
#ifndef ANALYTICS_ANALYZERS_SMUCNGPERFANALYZER_SMUCNGPERFANALYZER_H_
#define ANALYTICS_ANALYZERS_SMUCNGPERFANALYZER_SMUCNGPERFANALYZER_H_
#include "../../includes/AnalyzerTemplate.h"
#include <map>
class SMUCNGPerfAnalyzer: virtual public AnalyzerTemplate<SMUCSensorBase>{
private:
std::map<SMUCSensorBase::Metrics, int> _metricToPosition;
public:
SMUCNGPerfAnalyzer();
virtual ~SMUCNGPerfAnalyzer();
void printConfig(LOG_LEVEL ll) override;
void setMetricToPosition(const std::map<SMUCSensorBase::Metrics,int>&metricToPosition) {
_metricToPosition = metricToPosition;
}
protected:
virtual void compute(U_Ptr unit) override;
};
#endif /* ANALYTICS_ANALYZERS_SMUCNGPERFANALYZER_SMUCNGPERFANALYZER_H_ */
/*
* SMUCNGPerfConfigurator.cpp
*
* Created on: Jul 22, 2019
* Author: carla
*/
#include "SMUCNGPerfConfigurator.h"
SMUCNGPerfConfigurator::SMUCNGPerfConfigurator() : AnalyzerConfiguratorTemplate(){
_analyzerName = "supermucngperf";
_baseName = "sensor";
}
SMUCNGPerfConfigurator::~SMUCNGPerfConfigurator() {
}
void SMUCNGPerfConfigurator::sensorBase(SMUCSensorBase& s, CFG_VAL& config) {
BOOST_FOREACH(boost::property_tree::iptree::value_type &val, config)
{
if (boost::iequals(val.first, "position")) {
int position = std::stoi(val.second.data());
std::string name = s.getName();
if(name.compare("instructions")==0){
_metricToPosition[SMUCSensorBase::INSTRUCTIONS] = position;
}
}
}
}
void SMUCNGPerfConfigurator::analyzer(SMUCNGPerfAnalyzer& a, CFG_VAL& config){
a.setMetricToPosition(_metricToPosition);
}
bool SMUCNGPerfConfigurator::unit(UnitTemplate<SMUCSensorBase>& u) {
return true;
}
/*
* SMUCNGPerfConfigurator.h
*
* Created on: Jul 22, 2019
* Author: carla
*/
#ifndef ANALYTICS_ANALYZERS_SMUCNGPERFANALYZER_SMUCNGPERFCONFIGURATOR_H_
#define ANALYTICS_ANALYZERS_SMUCNGPERFANALYZER_SMUCNGPERFCONFIGURATOR_H_
#include "../../includes/AnalyzerConfiguratorTemplate.h"
#include "SMUCNGPerfAnalyzer.h"
class SMUCNGPerfConfigurator : virtual public AnalyzerConfiguratorTemplate<SMUCNGPerfAnalyzer, SMUCSensorBase>{
public:
SMUCNGPerfConfigurator();
virtual ~SMUCNGPerfConfigurator();
private:
void sensorBase(SMUCSensorBase& s, CFG_VAL config) override;
void analyzer(SMUCNGPerfAnalyzer& a, CFG_VAL config) override;
bool unit(UnitTemplate<SMUCSensorBase>& u) override;
std::map<SMUCSensorBase::Metrics, int> _metricToPosition;
};
extern "C" AnalyzerConfiguratorInterface* create() {
return new SMUCNGPerfConfigurator;
}
extern "C" void destroy(AnalyzerConfiguratorInterface* c) {
delete c;
}
#endif /* ANALYTICS_ANALYZERS_SMUCNGPERFANALYZER_SMUCNGPERFCONFIGURATOR_H_ */
/*
* SMUCSensorBase.h
*
* Created on: Jul 22, 2019
* Author: carla
*/
#ifndef ANALYTICS_ANALYZERS_SMUCNGPERFANALYZER_SMUCSENSORBASE_H_
#define ANALYTICS_ANALYZERS_SMUCNGPERFANALYZER_SMUCSENSORBASE_H_
#include "sensorbase.h"
class SMUCSensorBase : public SensorBase {
public:
enum Metrics {
INSTRUCTIONS,
CLOCKS
};
public:
SMUCSensorBase(){}
virtual ~SMUCSensorBase(){}
};
using SMUCNGPtr = std::shared_ptr<SMUCSensorBase>;
#endif /* ANALYTICS_ANALYZERS_SMUCNGPERFANALYZER_SMUCSENSORBASE_H_ */
/*
* SKXPMUMetrics.cpp
*
* Created on: Jul 11, 2019
* Author: carla
*/
#include "../analyzers/smucngperfanalyzer/skxderivedmetrics/SKXPMUMetrics.h"
bool calculateFlops(reading_t &scalarDB, reading_t & scalarSP,
reading_t & packedDP128, reading_t & packedSP128,
reading_t & packedDP256, reading_t & packedSP256,
reading_t & packedDP512, reading_t & packedSP512,
uint64_t interval, reading_t & result) {
if(interval > 0 ){
result.value = (packedDP128.value * 2 + packedSP128.value * 4
+ packedDP256.value * 4 + packedSP256.value * 8
+ packedDP512.value * 8 + packedSP512.value * 16 + scalarDB.value
+ scalarSP.value)/ static_cast<float>(interval);
result.timestamp = packedDP128.timestamp;
return true;
}
return false;
}
bool calculateVectorizationRate(reading_t & scalarDB, reading_t & scalarSP,
reading_t & packedDP128, reading_t & packedSP128,
reading_t & packedDP256, reading_t & packedSP256,
reading_t & packedDP512, reading_t & packedSP512, reading_t & result) {
float denominator = static_cast<float>(scalarDB.value + scalarSP.value +
packedDP128.value + packedSP128.value +
packedDP256.value + packedSP256.value +
packedDP512.value + packedSP512.value);
if(denominator > 0 ){
result.value = (packedDP128.value + packedSP128.value + packedDP256.value
+ packedSP256.value + packedDP256.value + packedSP512.value + packedDP512.value)/denominator;
result.timestamp = scalarDB.timestamp;
return true;
}
return false;
}
bool calculateMemoryBandwidth(std::vector<reading_t> membw_counts, reading_t & result) {
result.value = 0;
const unsigned int SIZEPERACCESS = 64;
for(auto &rt : membw_counts){
result.value += rt.value * SIZEPERACCESS;
}
return true;
}
/*
* SKXPMUMetrics.h
*
* Created on: Jul 11, 2019
* Author: carla
*/
#ifndef ANALYTICS_ANALYZERS_SMUCNGPERFANALYZER_SKXDERIVEDMETRICS_SKXPMUMETRICS_H_
#define ANALYTICS_ANALYZERS_SMUCNGPERFANALYZER_SKXDERIVEDMETRICS_SKXPMUMETRICS_H_
#include <vector>
bool calculateFlops(reading_t &scalarDB, reading_t & scalarSP,
reading_t & packedDP128, reading_t & packedSP128,
reading_t & packedDP256, reading_t & packedSP256,
reading_t & packedDP512, reading_t & packedSP512,
uint64_t interval, reading_t & result);
bool calculateVectorizationRate(reading_t & scalarDB, reading_t & scalarSP,
reading_t & packedDP128, reading_t & packedSP128,
reading_t & packedDP256, reading_t & packedSP256,
reading_t & packedDP512, reading_t & packedSP512, reading_t & result);
bool calculateMemoryBandwidth(std::vector<reading_t> membw_counts, reading_t & result);
#endif /* ANALYTICS_ANALYZERS_SMUCNGPERFANALYZER_SKXDERIVEDMETRICS_SKXPMUMETRICS_H_ */
/*
* DerivedMetrics.h
*
* Created on: Jul 11, 2019
* Author: carla
*/
#ifndef ANALYTICS_COMMONDERIVEDMETRICS_DERIVEDMETRICS_H_
#define ANALYTICS_COMMONDERIVEDMETRICS_DERIVEDMETRICS_H_
/**
* For CPI, LoadsToStore, Branch rate, miss branch ratio, etc..
*/
bool calculateMetricRatio(reading_t & dividend, reading_t & divisor,
unsigned int resolution, reading_t & result) {
if(divisor.value > 0){
result.value = (dividend.value / static_cast<float>(divisor.value))*resolution;
result.timestamp = dividend.timestamp;
return true;
}
return false;
}
/** Any generic metric per second. For instance: instructions per second, l2 misses per second **/
bool calculateMetricPerSec(reading_t & metric, uint64_t interval, unsigned int resolution, reading_t & result) {
if(interval > 0) {
result.value = (metric.value / static_cast<float>(interval))*resolution;
result.timestamp = metric.timestamp;
return true;
}
return false;
}
bool calculateFrequency(reading_t & unhaltedRef, reading_t & unhaltedClocks,
unsigned int min_freq, unsigned int max_freq, reading_t & result) {
//const unsigned int MAX_FREQ_MHZ = 2700;
//const unsigned int MIN_FREQ_MHZ = 1000; //ToDo check minimum in SKX
if(unhaltedRef.value > 0){
result.value = (unhaltedClocks.value / static_cast<float>(unhaltedRef.value)) * max_freq;
if(result.value > (max_freq * 1.1) || result.value < (min_freq*0.9)) { //There is something wrong here...
return false;
}
return true;
}
return false;
}
#endif /* ANALYTICS_COMMONDERIVEDMETRICS_DERIVEDMETRICS_H_ */
global {
mqttPrefix /test
}
template_aggregator def1 {
interval 1000
minValues 3
duplicate false
streaming true
}
aggregator avg1 {
default def1
window 2000
input {
sensor "<topdown 1>col_user" {
position 0
}
sensor "<bottomup 1>MemFree" {
position 1
}
sensor "<bottomup 1> iobytesread " {
position 2
}
sensor "<bottomup 1> ioreadoperations"{
position 3
}
sensor "<bottomup 1> instructions" {
position 4
}
sensor "<bottomup 1> clocks"{
position 5
}
}
output {
sensor "<bottomup, filter cpu250>sum" {
mqttsuffix /sum
operation sum
}
}
}
\ No newline at end of file
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