Skip to content

Commit 389ff53

Browse files
matcabralpbg-intel
authored andcommitted
Metric Tracer Decode support for sub-devices
Signed-off-by: Cabral, Matias A <matias.a.cabral@intel.com>
1 parent 82a9f1d commit 389ff53

2 files changed

Lines changed: 60 additions & 40 deletions

File tree

scripts/tools/EXT_Exp_MetricTracer.rst

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -147,42 +147,49 @@ The following pseudo-code demonstrates how to enumerate Tracer based metric grou
147147
${t}MetricTracerReadDataExp(hMetricTracer, &rawDataSize, rawData.data());
148148
149149
// decode
150-
uint32_t numEntries =0;
151-
${t}MetricTracerDecodeExp(hMetricDecoder, &rawDataSize, rawData.data(), numDecodableMetrics, decodableMetrics.data(), &numEntries, nullptr);
152-
std::vector<ze_metric_entry_exp_t> decodedEntries(numEntries)
153-
${t}MetricTracerDecodeExp(hMetricDecoder, &rawDataSize, rawData.data(), numDecodableMetrics, decodableMetrics.data(), &numEntries, decodedEntries.data());
154-
155-
for (uint32_t index = 0; index < numEntries; index++) {
156-
${t}_metric_entry_exp_t metricEntry = decodedEntries[index];
157-
${t}_metric_properties_t metricProperties = {};
158-
${t}MetricGetProperties(decodableMetrics[metricEntry.metricIndex], &metricProperties);
159-
std::cout << "Component: " << metricProperties.component ". Decodable metric name: " << metricProperties.name;
160-
switch (metricProperties.resultType) {
161-
case ${T}_VALUE_TYPE_UINT32:
162-
case ${T}_VALUE_TYPE_UINT8:
163-
case ${T}_VALUE_TYPE_UINT16:
164-
std::cout << ".\t value: " << metricEntry.value.ui32 << std::endl;
165-
break;
166-
case ${T}_VALUE_TYPE_UINT64:
167-
std::cout << ".\t value: " << metricEntry.value.ui64 << std::endl;
168-
break;
169-
case ${T}_VALUE_TYPE_FLOAT32:
170-
std::cout << ".\t value: " << metricEntry.value.fp32 << std::endl;
171-
break;
172-
case ${T}_VALUE_TYPE_FLOAT64:
173-
std::cout << ".\t value: " << metricEntry.value.fp64 << std::endl;
174-
break;
175-
case ${T}_VALUE_TYPE_BOOL8:
176-
if( metricEntry.value.b8 ){
177-
std::cout << ".\t value: true" << std::endl;
178-
else
179-
std::cout << ".\t value: false" << std::endl;
150+
uint32_t totalNumEntries = 0;
151+
uint32_t setCount = 0;
152+
${t}MetricTracerDecodeExp(hMetricDecoder, &rawDataSize, rawData.data(), numDecodableMetrics, decodableMetrics.data(), &setCount, nullptr, &totalNumEntries, nullptr);
153+
std::vector<ze_metric_entry_exp_t> decodedEntries(totalNumEntries)
154+
std::vector<uint32_t> metricEntriesCountPerSet(setCount);
155+
${t}MetricTracerDecodeExp(hMetricDecoder, &rawDataSize, rawData.data(), numDecodableMetrics, decodableMetrics.data(), &setCount, metricEntriesCountPerSet.data(), &totalNumEntries, decodedEntries.data());
156+
157+
uint32_t setEntryStart = 0;
158+
for (uint8_t setIndex = 0; setIndex < setCount; setIndex++) {
159+
for (uint32_t index = setEntryStart; index < metricEntriesCountPerSet[setIndex]; index++) {
160+
${t}_metric_entry_exp_t metricEntry = decodedEntries[index];
161+
${t}_metric_properties_t metricProperties = {};
162+
${t}MetricGetProperties(decodableMetrics[metricEntry.metricIndex], &metricProperties);
163+
std::cout << "Component: " << metricProperties.component ". Decodable metric name: " << metricProperties.name;
164+
switch (metricProperties.resultType) {
165+
case ${T}_VALUE_TYPE_UINT8:
166+
case ${T}_VALUE_TYPE_UINT16:
167+
case ${T}_VALUE_TYPE_UINT32:
168+
std::cout << ".\t value: " << metricEntry.value.ui32 << std::endl;
169+
break;
170+
case ${T}_VALUE_TYPE_UINT64:
171+
std::cout << ".\t value: " << metricEntry.value.ui64 << std::endl;
172+
break;
173+
case ${T}_VALUE_TYPE_FLOAT32:
174+
std::cout << ".\t value: " << metricEntry.value.fp32 << std::endl;
175+
break;
176+
case ${T}_VALUE_TYPE_FLOAT64:
177+
std::cout << ".\t value: " << metricEntry.value.fp64 << std::endl;
178+
break;
179+
case ${T}_VALUE_TYPE_BOOL8:
180+
if( metricEntry.value.b8 ){
181+
std::cout << ".\t value: true" << std::endl;
182+
else
183+
std::cout << ".\t value: false" << std::endl;
184+
}
185+
break;
186+
default:
187+
break;
180188
}
181-
break;
182-
default:
183-
break;
189+
190+
setEntryStart = metricEntriesCountPerSet[setIndex];
184191
}
185-
}
192+
}
186193
187194
// Close metric tracer
188195
${t}MetricTracerDisableExp(hMetricTracer, true);

scripts/tools/metricTracer.yml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ members:
6565
desc: "[out] timestamp at which the event happened."
6666
- type: uint32_t
6767
name: "metricIndex"
68-
desc: "[out] index to the decodable metric handle in the input array (phMetric) in $tMetricTracerDecode()."
68+
desc: "[out] index to the decodable metric handle in the input array (phMetric) in $tMetricTracerDecodeExp()."
6969
- type: $x_bool_t
7070
name: "onSubdevice"
7171
desc: "[out] True if the event occurred on a sub-device; false means the device on which the metric tracer was opened does not have sub-devices."
@@ -268,13 +268,26 @@ params:
268268
desc: |
269269
[in] [range(0, metricsCount)] array of handles of decodable metrics in the decoder for which the hMetricDecoder handle was
270270
provided. Metrics handles are expected to be for decodable metrics, see $tMetricDecoderGetDecodableMetrics()
271+
- type: uint32_t*
272+
name: pSetCount
273+
desc: |
274+
[in,out] pointer to number of metric sets. If count is zero, then the driver shall update the value with the total
275+
number of metric sets to be decoded. If count is greater than the number available in the raw data buffer, then the
276+
driver shall update the value with the actual number of metric sets to be decoded. There is a 1:1 relation between
277+
the number of sets and sub-devices returned in the decoded entries.
278+
- type: uint32_t*
279+
name: pMetricEntriesCountPerSet
280+
desc: |
281+
[in,out][optional][range(0, *pSetCount)] buffer of metric entries counts per metric set, one value per set.
271282
- type: uint32_t*
272283
name: pMetricEntriesCount
273284
desc: |
274-
[in,out] pointer to number of decodable metric entries to be decoded. If count is zero, then the driver shall update the value
275-
with the total number of decodable metric entries to be decoded. If count is greater than zero but less than the total number
276-
available in the raw data, then only that number of results will be decoded. if count is greater than the number available in
277-
the raw data buffer, then the driver shall update the value with the actual number of decodable metric entries to be decoded.
285+
[in,out] pointer to the total number of metric entries decoded, for all metric sets. If count is zero, then the
286+
driver shall update the value with the total number of metric entries to be decoded. If count is greater than zero
287+
but less than the total number of metric entries available in the raw data, then user provided number will be decoded.
288+
If count is greater than the number available in the raw data buffer, then the driver shall update the value with
289+
the actual number of decodable metric entries decoded. If set to null, then driver will only update the value of
290+
pSetCount.
278291
- type: $t_metric_entry_exp_t*
279292
name: pMetricEntries
280-
desc: "[in,out][optional][range(0, *pMetricEntriesCount)] buffer containing decoded metric entries"
293+
desc: "[in,out][optional][range(0, *pMetricEntriesCount)] buffer containing decoded metric entries"

0 commit comments

Comments
 (0)