SMUCNGPerfConfigurator.cpp 11.1 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
38
39
	_operatorName = "supermucngperf";
	_baseName     = "sensor";
	_metricMap["INSTRUCTIONS"]=SMUCSensorBase::INSTRUCTIONS;
	_metricMap["CLOCKS"]=SMUCSensorBase::CLOCKS;
	_metricMap["CLOCKS_REF"]=SMUCSensorBase::CLOCKS_REF;
	_metricMap["USERPCT"]=SMUCSensorBase::USERPCT;
	_metricMap["SYSTEMPCT"]=SMUCSensorBase::SYSTEMPCT;
	_metricMap["IOWAITPCT"]=SMUCSensorBase::IOWAITPCT;
Carla Guillen Carias's avatar
Carla Guillen Carias committed
40
	_metricMap["MEMUSED"]=SMUCSensorBase::MEMUSED;
41
42
43
44
45
46
	_metricMap["IOBYTESREAD"]=SMUCSensorBase::IOBYTESREAD;
	_metricMap["IOBYTESWRITE"]=SMUCSensorBase::IOBYTESWRITE;
	_metricMap["IOOPENS"]=SMUCSensorBase::IOOPENS;
	_metricMap["IOCLOSES"]=SMUCSensorBase::IOCLOSES;
	_metricMap["IOREADS"]=SMUCSensorBase::IOREADS;
	_metricMap["IOWRITES"]=SMUCSensorBase::IOWRITES;
47
48
	_metricMap["NETWORK_XMIT_BYTES"]=SMUCSensorBase::NETWORK_XMIT_BYTES;
	_metricMap["NETWORK_RCVD_BYTES"]=SMUCSensorBase::NETWORK_RCVD_BYTES;
49
50
51
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
84
85
86
	_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;
	_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;
87
	_metricMap["VECTORIZATION_RATIO"]=SMUCSensorBase::VECTORIZATION_RATIO;
88
89
	_metricMap["SINGLE_PRECISION_TO_TOTAL_RATIO"]=SMUCSensorBase::SINGLE_PRECISION_TO_TOTAL_RATIO;
	_metricMap["EXPENSIVE_INSTRUCTIONS_PER_SECOND"]=SMUCSensorBase::EXPENSIVE_INSTRUCTIONS_PER_SECOND;
90
91
	_metricMap["INTRA_NODE_LOADIMBALANCE"]=SMUCSensorBase::INTRA_NODE_LOADIMBALANCE;
	_metricMap["INTER_NODE_LOADIMBALANCE"]=SMUCSensorBase::INTER_NODE_LOADIMBALANCE;
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
	_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;
111
	_metricMap["NETWORK_XMIT_BYTES_PER_PKT"]=SMUCSensorBase::NETWORK_XMIT_BYTES_PER_PKT;
112
	_metricMap["NETWORK_BYTES_XMIT_PER_SECOND"]=SMUCSensorBase::NETWORK_BYTES_XMIT_PER_SECOND;
113
	_metricMap["NETWORK_RCV_BYTES_PER_PKT"]=SMUCSensorBase::NETWORK_RCV_BYTES_PER_PKT;
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
	_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;
129
130
131
132
133
	_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;
134
135
136
137
138
}

SMUCNGPerfConfigurator::~SMUCNGPerfConfigurator() {
}

139
bool endsWith (std::string const &fullString, std::string const &ending) {
Carla Guillen Carias's avatar
Carla Guillen Carias committed
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
	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;
164
165
}

166
void SMUCNGPerfConfigurator::sensorBase(SMUCSensorBase& s, CFG_VAL config) {
167
	std::string name = s.getName();
168
	bool found = false;
169
170
	for (auto & kv : _metricMap) {
		if(endsWith(name,kv.first)) {
171
			found = true;
172
173
174
			_metricToPosition[kv.second] = _vector_position;
			s.setMetric(kv.second);
			break;
175
		}
176
	}
177
178
179
	if(!found){
		LOG(error) << "Unable to configure sensor "<< name << " no match in _metricMap found."; 
	}
180
	_vector_position++;
181
182
}

183
184
void SMUCNGPerfConfigurator::operatorAttributes(SMUCNGPerfOperator& op, CFG_VAL config){
	op.setMetricToPosition(_metricToPosition);
185
    _vector_position = 0;
186
    BOOST_FOREACH(boost::property_tree::iptree::value_type &val, config)
187
    {
188
    	if (boost::iequals(val.first, "measuring_interval")){
189
190
191
192
193
194
    		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
195
    	} else if(boost::iequals(val.first, "go_back_ms")) {
196
197
198
199
200
201
    		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();
    		}
202
    	}
203
    }
204
	_metricToPosition.clear();
205
206
207
}

bool SMUCNGPerfConfigurator::unit(UnitTemplate<SMUCSensorBase>& u) {
208
	if(u.isTopUnit()) {
209
		LOG(error) << "    " << _operatorName << ": This operator type only supports flat units!";
210
211
212
		return false;
	}
	if(u.getOutputs().empty()) {
213
		LOG(error) << "    " << _operatorName << ": At least one output sensor per unit must be defined!";
214
215
		return false;
	}
216
217
	return true;
}