SMUCNGPerfConfigurator.cpp 11.6 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//================================================================================
// Name        : SMUCNGPerfConfigurator.cpp
// Author      : Carla Guillen
// Contact     : info@dcdb.it
// Copyright   : Leibniz Supercomputing Centre
// Description : Template implementing features to use Units in Operators.
//================================================================================

//================================================================================
// This file is part of DCDB (DataCenter DataBase)
// Copyright (C) 2018-2019 Leibniz Supercomputing Centre
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
//================================================================================
27
28
29

#include "SMUCNGPerfConfigurator.h"

Carla Guillen's avatar
Carla Guillen committed
30

31
SMUCNGPerfConfigurator::SMUCNGPerfConfigurator() : OperatorConfiguratorTemplate(), _vector_position(0) {
32
33
34
35
36
37
	_operatorName = "supermucngperf";
	_baseName     = "sensor";
	_metricMap["INSTRUCTIONS"]=SMUCSensorBase::INSTRUCTIONS;
	_metricMap["CLOCKS"]=SMUCSensorBase::CLOCKS;
	_metricMap["CLOCKS_REF"]=SMUCSensorBase::CLOCKS_REF;
	_metricMap["USERPCT"]=SMUCSensorBase::USERPCT;
38
	_metricMap["USERPCT0"]=SMUCSensorBase::USERPCT0;
39
	_metricMap["SYSTEMPCT"]=SMUCSensorBase::SYSTEMPCT;
40
	_metricMap["SYSTEMPCT0"]=SMUCSensorBase::SYSTEMPCT0;
41
	_metricMap["IOWAITPCT"]=SMUCSensorBase::IOWAITPCT;
42
	_metricMap["IOWAITPCT0"]=SMUCSensorBase::IOWAITPCT0;
Carla Guillen Carias's avatar
Carla Guillen Carias committed
43
	_metricMap["MEMUSED"]=SMUCSensorBase::MEMUSED;
44
45
46
47
48
49
	_metricMap["IOBYTESREAD"]=SMUCSensorBase::IOBYTESREAD;
	_metricMap["IOBYTESWRITE"]=SMUCSensorBase::IOBYTESWRITE;
	_metricMap["IOOPENS"]=SMUCSensorBase::IOOPENS;
	_metricMap["IOCLOSES"]=SMUCSensorBase::IOCLOSES;
	_metricMap["IOREADS"]=SMUCSensorBase::IOREADS;
	_metricMap["IOWRITES"]=SMUCSensorBase::IOWRITES;
50
51
	_metricMap["NETWORK_XMIT_BYTES"]=SMUCSensorBase::NETWORK_XMIT_BYTES;
	_metricMap["NETWORK_RCVD_BYTES"]=SMUCSensorBase::NETWORK_RCVD_BYTES;
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
	_metricMap["NETWORK_XMIT_PKTS"]=SMUCSensorBase::NETWORK_XMIT_PKTS;
	_metricMap["NETWORK_RCVD_PKTS"]=SMUCSensorBase::NETWORK_RCVD_PKTS;
	_metricMap["L2_RQSTS_MISS"]=SMUCSensorBase::L2_RQSTS_MISS;
	_metricMap["ARITH_FPU_DIVIDER_ACTIVE"]=SMUCSensorBase::ARITH_FPU_DIVIDER_ACTIVE;
	_metricMap["FP_ARITH_SCALAR_DOUBLE"]=SMUCSensorBase::FP_ARITH_SCALAR_DOUBLE;
	_metricMap["FP_ARITH_SCALAR_SINGLE"]=SMUCSensorBase::FP_ARITH_SCALAR_SINGLE;
	_metricMap["FP_ARITH_128B_PACKED_DOUBLE"]=SMUCSensorBase::FP_ARITH_128B_PACKED_DOUBLE;
	_metricMap["FP_ARITH_128B_PACKED_SINGLE"]=SMUCSensorBase::FP_ARITH_128B_PACKED_SINGLE;
	_metricMap["FP_ARITH_256B_PACKED_DOUBLE"]=SMUCSensorBase::FP_ARITH_256B_PACKED_DOUBLE;
	_metricMap["FP_ARITH_256B_PACKED_SINGLE"]=SMUCSensorBase::FP_ARITH_256B_PACKED_SINGLE;
	_metricMap["FP_ARITH_512B_PACKED_DOUBLE"]=SMUCSensorBase::FP_ARITH_512B_PACKED_DOUBLE;
	_metricMap["FP_ARITH_512B_PACKED_SINGLE"]=SMUCSensorBase::FP_ARITH_512B_PACKED_SINGLE;
	_metricMap["MEM_INST_RETIRED_ALL_LOADS"]=SMUCSensorBase::MEM_INST_RETIRED_ALL_LOADS;
	_metricMap["MEM_INST_RETIRED_ALL_STORES"]=SMUCSensorBase::MEM_INST_RETIRED_ALL_STORES;
	_metricMap["MEM_LOAD_UOPS_RETIRED_L3_MISS"]=SMUCSensorBase::MEM_LOAD_UOPS_RETIRED_L3_MISS;
	_metricMap["MEM_LOAD_RETIRED_L3_HIT"]=SMUCSensorBase::MEM_LOAD_RETIRED_L3_HIT;
	_metricMap["MEM_LOAD_RETIRED_L3_MISS"]=SMUCSensorBase::MEM_LOAD_RETIRED_L3_MISS;
	_metricMap["PERF_COUNT_HW_BRANCH_INSTRUCTIONS"]=SMUCSensorBase::PERF_COUNT_HW_BRANCH_INSTRUCTIONS;
	_metricMap["PERF_COUNT_HW_BRANCH_MISSES"]=SMUCSensorBase::PERF_COUNT_HW_BRANCH_MISSES;
	_metricMap["CORE_TEMPERATURE"]=SMUCSensorBase::CORE_TEMPERATURE;
	_metricMap["CAS_COUNT_READ0"]=SMUCSensorBase::CAS_COUNT_READ0;
	_metricMap["CAS_COUNT_READ1"]=SMUCSensorBase::CAS_COUNT_READ1;
	_metricMap["CAS_COUNT_READ2"]=SMUCSensorBase::CAS_COUNT_READ2;
	_metricMap["CAS_COUNT_READ3"]=SMUCSensorBase::CAS_COUNT_READ3;
	_metricMap["CAS_COUNT_READ4"]=SMUCSensorBase::CAS_COUNT_READ4;
	_metricMap["CAS_COUNT_READ5"]=SMUCSensorBase::CAS_COUNT_READ5;
	_metricMap["CAS_COUNT_WRITE0"]=SMUCSensorBase::CAS_COUNT_WRITE0;
	_metricMap["CAS_COUNT_WRITE1"]=SMUCSensorBase::CAS_COUNT_WRITE1;
	_metricMap["CAS_COUNT_WRITE2"]=SMUCSensorBase::CAS_COUNT_WRITE2;
	_metricMap["CAS_COUNT_WRITE3"]=SMUCSensorBase::CAS_COUNT_WRITE3;
	_metricMap["CAS_COUNT_WRITE4"]=SMUCSensorBase::CAS_COUNT_WRITE4;
	_metricMap["CAS_COUNT_WRITE5"]=SMUCSensorBase::CAS_COUNT_WRITE5;
Carla Guillen's avatar
Carla Guillen committed
84
85
86
87
	_metricMap["PKG0_ENERGY"]=SMUCSensorBase::PKG0_ENERGY;
	_metricMap["PKG1_ENERGY"]=SMUCSensorBase::PKG1_ENERGY;
	_metricMap["DRAM0_ENERGY"]=SMUCSensorBase::DRAM0_ENERGY;
	_metricMap["DRAM1_ENERGY"]=SMUCSensorBase::DRAM1_ENERGY;
88
89
90
91
92
93
	_metricMap["CPI"]=SMUCSensorBase::CPI;
	_metricMap["FREQUENCY"]=SMUCSensorBase::FREQUENCY;
	_metricMap["INSTRUCTIONS_PER_SECOND"]=SMUCSensorBase::INSTRUCTIONS_PER_SECOND;
	_metricMap["FLOPS"]=SMUCSensorBase::FLOPS;
	_metricMap["PACKED_FLOPS"]=SMUCSensorBase::PACKED_FLOPS;
	_metricMap["AVX512_TOVECTORIZED_RATIO"]=SMUCSensorBase::AVX512_TOVECTORIZED_RATIO;
94
	_metricMap["VECTORIZATION_RATIO"]=SMUCSensorBase::VECTORIZATION_RATIO;
95
96
	_metricMap["SINGLE_PRECISION_TO_TOTAL_RATIO"]=SMUCSensorBase::SINGLE_PRECISION_TO_TOTAL_RATIO;
	_metricMap["EXPENSIVE_INSTRUCTIONS_PER_SECOND"]=SMUCSensorBase::EXPENSIVE_INSTRUCTIONS_PER_SECOND;
97
98
	_metricMap["INTRA_NODE_LOADIMBALANCE"]=SMUCSensorBase::INTRA_NODE_LOADIMBALANCE;
	_metricMap["INTER_NODE_LOADIMBALANCE"]=SMUCSensorBase::INTER_NODE_LOADIMBALANCE;
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
	_metricMap["L2_HITS_PER_SECOND"]=SMUCSensorBase::L2_HITS_PER_SECOND;
	_metricMap["L2_MISSES_PER_SECOND"]=SMUCSensorBase::L2_MISSES_PER_SECOND;
	_metricMap["L3_HITS_PER_SECOND"]=SMUCSensorBase::L3_HITS_PER_SECOND;
	_metricMap["L3_MISSES_PER_SECOND"]=SMUCSensorBase::L3_MISSES_PER_SECOND;
	_metricMap["L3_TO_INSTRUCTIONS_RATIO"]=SMUCSensorBase::L3_TO_INSTRUCTIONS_RATIO;
	_metricMap["L3_BANDWIDTH"]=SMUCSensorBase::L3_BANDWIDTH;
	_metricMap["L3HIT_TO_L3MISS_RATIO"]=SMUCSensorBase::L3HIT_TO_L3MISS_RATIO;
	_metricMap["LOADS_TO_STORES"]=SMUCSensorBase::LOADS_TO_STORES;
	_metricMap["LOADS_TOL3MISS_RATIO"]=SMUCSensorBase::LOADS_TOL3MISS_RATIO;
	_metricMap["MISSBRANCHES_PER_SECOND"]=SMUCSensorBase::MISSBRANCHES_PER_SECOND;
	_metricMap["BRANCH_PER_INSTRUCTIONS"]=SMUCSensorBase::BRANCH_PER_INSTRUCTIONS;
	_metricMap["MISSBRANCHES_TO_TOTAL_BRANCH_RATIO"]=SMUCSensorBase::MISSBRANCHES_TO_TOTAL_BRANCH_RATIO;
	_metricMap["MEMORY_BANDWIDTH"]=SMUCSensorBase::MEMORY_BANDWIDTH;
	_metricMap["RAPL_PKG"]=SMUCSensorBase::RAPL_PKG;
	_metricMap["RAPL_MEM"]=SMUCSensorBase::RAPL_MEM;
	_metricMap["IPMI_CPU"]=SMUCSensorBase::IPMI_CPU;
	_metricMap["IPMI_MEM"]=SMUCSensorBase::IPMI_MEM;
	_metricMap["IPMI_DC"]=SMUCSensorBase::IPMI_DC;
	_metricMap["IPMI_AC"]=SMUCSensorBase::IPMI_AC;
118
	_metricMap["NETWORK_XMIT_BYTES_PER_PKT"]=SMUCSensorBase::NETWORK_XMIT_BYTES_PER_PKT;
119
	_metricMap["NETWORK_BYTES_XMIT_PER_SECOND"]=SMUCSensorBase::NETWORK_BYTES_XMIT_PER_SECOND;
120
	_metricMap["NETWORK_RCV_BYTES_PER_PKT"]=SMUCSensorBase::NETWORK_RCV_BYTES_PER_PKT;
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
	_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;
	_metricMap["IOBYTESREAD_PER_SECOND"]=SMUCSensorBase::IOBYTESREAD_PER_SECOND;
	_metricMap["IOBYTESWRITE_PER_SECOND"]=SMUCSensorBase::IOBYTESWRITE_PER_SECOND;
	_metricMap["IOREADS_PER_SECOND"]=SMUCSensorBase::IOREADS_PER_SECOND;
	_metricMap["IOWRITES_PER_SECOND"]=SMUCSensorBase::IOWRITES_PER_SECOND;
	_metricMap["IO_BYTES_READ_PER_OP"]=SMUCSensorBase::IO_BYTES_READ_PER_OP;
	_metricMap["IO_BYTES_WRITE_PER_OP"]=SMUCSensorBase::IO_BYTES_WRITE_PER_OP;
	_metricMap["IOBYTESREAD_PER_SECOND_PROF"]=SMUCSensorBase::IOBYTESREAD_PER_SECOND_PROF;
	_metricMap["IOBYTESWRITE_PER_SECOND_PROF"]=SMUCSensorBase::IOBYTESWRITE_PER_SECOND_PROF;
	_metricMap["IOREADS_PER_SECOND_PROF"]=SMUCSensorBase::IOREADS_PER_SECOND_PROF;
	_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;
136
137
138
139
140
	_metricMap["PACKED128_FLOPS"] = SMUCSensorBase::PACKED128_FLOPS;
	_metricMap["PACKED256_FLOPS"] = SMUCSensorBase::PACKED256_FLOPS;
	_metricMap["PACKED512_FLOPS"] = SMUCSensorBase::PACKED512_FLOPS;
	_metricMap["SINGLE_PRECISION_FLOPS"] = SMUCSensorBase::SINGLE_PRECISION_FLOPS;
	_metricMap["DOUBLE_PRECISION_FLOPS"] = SMUCSensorBase::DOUBLE_PRECISION_FLOPS;
Carla Guillen's avatar
Carla Guillen committed
141
142
	_metricMap["PKG_POWER"] = SMUCSensorBase::PKG_POWER;
	_metricMap["DRAM_POWER"] = SMUCSensorBase::DRAM_POWER;
143
144
145
146
147
}

SMUCNGPerfConfigurator::~SMUCNGPerfConfigurator() {
}

148
bool endsWith (std::string const &fullString, std::string const &ending) {
Carla Guillen Carias's avatar
Carla Guillen Carias committed
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
	if(ending.size() > fullString.size()){
		return false;
	}
	std::size_t last_forward = fullString.find_last_of('/');
	std::size_t last_greaterthan = fullString.find_last_of('>');
	std::size_t max_pos;
	if(last_greaterthan == std::string::npos){ //no >
		if(last_forward == std::string::npos) { // no /
			return fullString.compare(ending)==0;
		} else { // we have /
			max_pos = last_forward;
		}
	} else { // > is present
		if(last_forward == std::string::npos) { // no /
			max_pos = last_greaterthan;
		} else {
			max_pos = last_forward > last_greaterthan ? last_forward : last_greaterthan;
		}
	}
	max_pos++; //increment so that we compare the next char.
	if(max_pos < fullString.length()){
		return 0 == fullString.compare(max_pos, fullString.size() - max_pos, ending);
	}
	return false;
173
174
}

175
void SMUCNGPerfConfigurator::sensorBase(SMUCSensorBase& s, CFG_VAL config) {
176
	std::string name = s.getName();
177
	bool found = false;
178
179
	for (auto & kv : _metricMap) {
		if(endsWith(name,kv.first)) {
180
			found = true;
181
182
183
			_metricToPosition[kv.second] = _vector_position;
			s.setMetric(kv.second);
			break;
184
		}
185
	}
186
187
188
	if(!found){
		LOG(error) << "Unable to configure sensor "<< name << " no match in _metricMap found."; 
	}
189
	_vector_position++;
190
191
}

192
193
void SMUCNGPerfConfigurator::operatorAttributes(SMUCNGPerfOperator& op, CFG_VAL config){
	op.setMetricToPosition(_metricToPosition);
194
    _vector_position = 0;
195
    BOOST_FOREACH(boost::property_tree::iptree::value_type &val, config)
196
    {
197
    	if (boost::iequals(val.first, "measuring_interval")){
198
199
200
201
202
203
    		try {
    			auto measurementInterval_s = std::stod(val.second.data())/1000.0; //miliseconds to seconds
    			op.setMeasuringInterval(measurementInterval_s);
    		} catch (const std::exception &e) {
    			LOG(error) << "  Error parsing measuring_interval \"" << val.second.data() << "\": " << e.what();
    		}
Carla Guillen's avatar
Carla Guillen committed
204
    	} else if(boost::iequals(val.first, "go_back_ms")) {
205
206
207
208
209
210
    		try {
    			auto go_back_ms = std::stod(val.second.data());
    			op.setGoBackMs(go_back_ms);
    		} catch (const std::exception &e) {
    			LOG(error) << "  Error parsing go_back_ms \"" << val.second.data() << "\": " << e.what();
    		}
211
    	}
212
    }
213
	_metricToPosition.clear();
214
215
216
}

bool SMUCNGPerfConfigurator::unit(UnitTemplate<SMUCSensorBase>& u) {
217
	if(u.isTopUnit()) {
218
		LOG(error) << "    " << _operatorName << ": This operator type only supports flat units!";
219
220
221
		return false;
	}
	if(u.getOutputs().empty()) {
222
		LOG(error) << "    " << _operatorName << ": At least one output sensor per unit must be defined!";
223
224
		return false;
	}
225
226
	return true;
}