meric.cpp 3.69 KB
Newer Older
Ondrej Meca's avatar
Ondrej Meca committed
1
2
3
4
5
6
7

#include "meric.h"

using namespace meric;

SharedMeric::SharedMeric()
{
8
9
10
	if (Meric::MODE == MODE_HDEEM || Meric::MODE == MODE_BOTH)
	{
		HDEEM::init();
11
12
		HDEEM::start(_startTime);

13
14
		if (Meric::DEBUG)
		{
15
			_storeList.push_back(new TimeEnergyStore(Meric::SAMPLES));
Ondrej Meca's avatar
Ondrej Meca committed
16
		} else {
17
			if (Meric::CONTINUAL)
18
			{
19
				if (Meric::DETAILED) {
20
					_storeList.push_back(new DetailedTimeStore(Meric::SAMPLES));
21
				} else {
22
					_storeList.push_back(new TimeStore<HDEEM>(Meric::SAMPLES));
23
				}
24
			} else {
25
26
				if (Meric::DETAILED)
				{
27
					_storeList.push_back(new DetailedEnergyStore(Meric::SAMPLES));
28
				} else {
29
30
					//_storeList.push_back(new EnergyStore(Meric::SAMPLES));
					_storeList.push_back(new CountersStore<HDEEM, double>(Meric::SAMPLES));
31
				}
32
			}
Ondrej Meca's avatar
Ondrej Meca committed
33
34
		}
	}
35

xvysoc01's avatar
xvysoc01 committed
36
37
	if (Meric::MODE == MODE_RAPL || Meric::MODE == MODE_BOTH)
	{
38
		_storeList.push_back(new CountersStore<RAPL, unsigned long long int>(Meric::SAMPLES));
xvysoc01's avatar
xvysoc01 committed
39
40
	}
	
41
	if (Meric::MODE == MODE_JETSON && Meric::CONTINUAL)
42
	{
43
		_storeList.push_back(new TimeStore<JETSON>(Meric::SAMPLES));
Ondrej Vysocky's avatar
Ondrej Vysocky committed
44
	}
45
46
47
48
	else if (Meric::MODE == MODE_THUNDER && Meric::CONTINUAL)
	{
		_storeList.push_back(new TimeStore<THUNDER>(Meric::SAMPLES));
	}
49
50
51
52
	else if (Meric::MODE == MODE_DAVIDE && Meric::CONTINUAL)
	{
		_storeList.push_back(new TimeStore<DAVIDE>(Meric::SAMPLES));
	}
53
	
54
	if (Meric::COUNTERS != "none")
xvysoc01's avatar
xvysoc01 committed
55
	{
56
57

		if (Meric::COUNTERS == "perfevent")
58
			_storeList.push_back(new CountersStore<PERFEVENT, unsigned long long int>(Meric::SAMPLES));
59
		else if (Meric::COUNTERS == "papi")
60
			_storeList.push_back(new CountersStore<PAPI, unsigned long long int>(Meric::SAMPLES));
xvysoc01's avatar
xvysoc01 committed
61
	}
62
	
63
64
65
	if (_storeList.size() > 0 || Meric::MODE == MODE_TIME)
		_storeList.insert(_storeList.begin(), new InfoStore());
	
66
67
	for (int i=0; i<_storeList.size(); i++)
		_storeList[i]->setMPIWrite(true);
68

69
	if (Meric::MODE == MODE_JETSON)
70
71
72
		Environment::init(SYS_JETSON,  defaultParameter, 0);
	else if (Meric::MODE == MODE_THUNDER)
		Environment::init(SYS_THUNDER, defaultParameter, 0);
73
74
//	else if (Meric::MODE == MODE_DAVIDE)
//		Environment::init(SYS_DAVIDE, defaultParameter, 0);
Lubomir Riha's avatar
Lubomir Riha committed
75
	else 
76
77
		Environment::init(SYS_OTHER, defaultParameter, 0);
//		Environment::init(SYS_HASWELL, defaultParameter, 0); //this default settings must persist due to many nodes with min uncore frequency limit set to maximum - now it is fixed
78

79
	
80
	for (int socket=0; socket < Environment::NODE_SIZE_SOCKET; socket++)
81
82
		currentState.socket[socket] = defaultParameter;

83
84

	//wrappers must be initialized after meric instantiation
85
	//RAPL counter expects that environment::init() was already called
86
87
88
89
90
91
92
93
94
95
	if (Meric::COUNTERS == "perfevent")
		PERFEVENT::init();
	if (Meric::COUNTERS == "papi")
		PAPI::init();
	if (Meric::MODE == MODE_RAPL || Meric::MODE == MODE_BOTH)
	{
		if (Meric::DETAILED)
			RAPL::detailed();
		RAPL::init();
	}
96
	if (Meric::MODE == MODE_JETSON && Meric::CONTINUAL)
97
		JETSON::init();
98
99
	else if (Meric::MODE == MODE_THUNDER && Meric::CONTINUAL)
		THUNDER::init();
100
101
	else if (Meric::MODE == MODE_DAVIDE && Meric::CONTINUAL)
	{
102
		DAVIDE::init();
Lubomir Riha's avatar
Lubomir Riha committed
103
104
		DAVIDE::start(_startTime);
	}
105
106
107
108
109
110
111
112
113
114
	
	std::string applicationMainRegion = std::string(program_invocation_name);
	size_t n = applicationMainRegion.find_last_of("/");
	if (n != std::string::npos)
		applicationMainRegion = applicationMainRegion.substr(n+1);
	n = applicationMainRegion.find_first_of(".");
	if (n != std::string::npos)
		applicationMainRegion = applicationMainRegion.substr(0,n);
	applicationMainRegion +="_static";
	start(applicationMainRegion.c_str());
Ondrej Meca's avatar
Ondrej Meca committed
115
116
}

Ondrej Meca's avatar
Ondrej Meca committed
117
SharedMeric::~SharedMeric()
Ondrej Meca's avatar
Ondrej Meca committed
118
{
119
	Environment::close();
xvysoc01's avatar
xvysoc01 committed
120
	if (Meric::MODE == MODE_HDEEM || Meric::MODE == MODE_BOTH)
Ondrej Vysocky's avatar
Ondrej Vysocky committed
121
122
123
	{
		HDEEM::close();
	}
124
125
126
127
	else if (Meric::MODE == MODE_DAVIDE && Meric::CONTINUAL)
	{
		DAVIDE::close();
	}
128
129
130
	
	for(int i=0;i<_storeList.size(); i++)
		delete _storeList[i];
Ondrej Meca's avatar
Ondrej Meca committed
131
132
133
134
}