From d6ea88f2667836379cba2f89410c3329d991e04c Mon Sep 17 00:00:00 2001 From: Shreyas Kunder Date: Wed, 24 Sep 2025 13:34:59 +0000 Subject: [PATCH] feature: Metric Decoder API's supports scopes Related-To: NEO-15833 Signed-off-by: Shreyas Kunder --- .../driver_experimental/public/zex_metric.cpp | 6 +++--- .../include/level_zero/zet_intel_gpu_metric.h | 16 +++++++++++++++- level_zero/tools/source/metrics/metric.h | 5 +++++ .../metrics/metric_device_context_create.cpp | 14 ++++++++++++++ 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/level_zero/api/driver_experimental/public/zex_metric.cpp b/level_zero/api/driver_experimental/public/zex_metric.cpp index e090d54d0b..ba63745abe 100644 --- a/level_zero/api/driver_experimental/public/zex_metric.cpp +++ b/level_zero/api/driver_experimental/public/zex_metric.cpp @@ -138,8 +138,8 @@ zetIntelMetricTracerDecodeExp2( zet_intel_metric_scope_exp_handle_t *phMetricScopes, size_t *usedDataSize, uint32_t *pTotalMetricEntriesCount, - zet_metric_entry_exp_t *phMetricEntries) { - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + zet_metric_entry_exp2_t *phMetricEntries) { + return L0::metricTracerDecode2(phMetricDecoder, rawDataSize, pRawData, metricCount, phMetric, metricScopeCount, phMetricScopes, usedDataSize, pTotalMetricEntriesCount, phMetricEntries); } ze_result_t ZE_APICALL zetIntelMetricSupportedScopesGetExp(zet_metric_handle_t *phMetric, uint32_t *pCount, zet_intel_metric_scope_exp_handle_t *phScopes) { @@ -299,7 +299,7 @@ zetIntelMetricTracerDecodeExp2( zet_intel_metric_scope_exp_handle_t *phMetricScopes, size_t *usedDataSize, uint32_t *pTotalMetricEntriesCount, - zet_metric_entry_exp_t *phMetricEntries) { + zet_metric_entry_exp2_t *phMetricEntries) { return L0::zetIntelMetricTracerDecodeExp2( phMetricDecoder, rawDataSize, diff --git a/level_zero/include/level_zero/zet_intel_gpu_metric.h b/level_zero/include/level_zero/zet_intel_gpu_metric.h index 922659ab8b..5a305426da 100644 --- a/level_zero/include/level_zero/zet_intel_gpu_metric.h +++ b/level_zero/include/level_zero/zet_intel_gpu_metric.h @@ -460,6 +460,20 @@ zetIntelMetricCalculateValuesExp( zet_intel_metric_result_exp_t *pMetricResults); ///< [in,out][optional][range(0, *pTotalMetricResultsCount)] buffer of calculated ///< metrics results. +/////////////////////////////////////////////////////////////////////////////// +/// @brief Decoded metric entry +typedef struct _zet_metric_entry_exp2_t { + zet_value_t value; ///< [out] value of the decodable metric entry or event. Number is + ///< meaningful based on the metric type. + uint64_t timeStamp; ///< [out] timestamp at which the event happened. + uint32_t metricIndex; ///< [out] index to the decodable metric handle in the input array + ///< (phMetric) in ::zetMetricTracerDecodeExp(). + uint32_t metricScopeID; ///< [out] ID index of the scope for which the entry is meaningful. + ///< If the array of metrics scopes submitted to ::zetMetricTracerDecode() + ///< is the same as the one returned by zetMetricScopesGet(), then expect + ///< the ID to be equal to the index of the metric scope in the array. +} zet_metric_entry_exp2_t; + #ifndef ZET_INTEL_METRIC_TRACER_DECODE_EXP2_NAME /// @brief Extension name to decode Intel Metric Tracer data with metric scopes #define ZET_INTEL_METRIC_TRACER_DECODE_EXP2_NAME "ZET_intel_metric_tracer_decode_exp2" @@ -501,7 +515,7 @@ zetIntelMetricTracerDecodeExp2( ///< in the raw data, then only that number of entries will be decoded. If count is greater ///< than the number available in the raw data buffer, then the driver shall update the value ///< with the actual number of decodable metric entries decoded. - zet_metric_entry_exp_t *phMetricEntries); ///< [in,out][optional][range(0, *pTotalMetricEntriesCount)] buffer containing + zet_metric_entry_exp2_t *phMetricEntries); ///< [in,out][optional][range(0, *pTotalMetricEntriesCount)] buffer containing ///< decoded metric entries #ifndef ZET_INTEL_METRICS_RUNTIME_ENABLE_DISABLE_EXP_NAME diff --git a/level_zero/tools/source/metrics/metric.h b/level_zero/tools/source/metrics/metric.h index ba2c3bd92f..62d9f4b484 100644 --- a/level_zero/tools/source/metrics/metric.h +++ b/level_zero/tools/source/metrics/metric.h @@ -600,6 +600,11 @@ ze_result_t metricTracerDecode(zet_metric_decoder_exp_handle_t hMetricDecoder, s uint32_t metricsCount, zet_metric_handle_t *phMetrics, uint32_t *pSetCount, uint32_t *pMetricEntriesCountPerSet, uint32_t *pMetricEntriesCount, zet_metric_entry_exp_t *pMetricEntries); +ze_result_t metricTracerDecode2(zet_metric_decoder_exp_handle_t phMetricDecoder, const size_t rawDataSize, const uint8_t *pRawData, + uint32_t metricCount, zet_metric_handle_t *phMetric, uint32_t metricScopeCount, + zet_intel_metric_scope_exp_handle_t *phMetricScopes, size_t *usedDataSize, + uint32_t *pTotalMetricEntriesCount, zet_metric_entry_exp2_t *phMetricEntries); + ze_result_t metricCalculationOperationCreate(zet_context_handle_t hContext, zet_device_handle_t hDevice, zet_intel_metric_calculation_exp_desc_t *pCalculationDesc, zet_intel_metric_calculation_operation_exp_handle_t *phCalculationOperation); diff --git a/level_zero/tools/source/metrics/metric_device_context_create.cpp b/level_zero/tools/source/metrics/metric_device_context_create.cpp index 0b6e0c26fd..868eee62ad 100644 --- a/level_zero/tools/source/metrics/metric_device_context_create.cpp +++ b/level_zero/tools/source/metrics/metric_device_context_create.cpp @@ -82,6 +82,20 @@ ze_result_t metricTracerDecode( return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; } +ze_result_t metricTracerDecode2( + zet_metric_decoder_exp_handle_t phMetricDecoder, + const size_t rawDataSize, + const uint8_t *pRawData, + uint32_t metricCount, + zet_metric_handle_t *phMetric, + uint32_t metricScopeCount, + zet_intel_metric_scope_exp_handle_t *phMetricScopes, + size_t *usedDataSize, + uint32_t *pTotalMetricEntriesCount, + zet_metric_entry_exp2_t *phMetricEntries) { + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + ze_result_t metricDecodeCalculateMultipleValues( zet_intel_metric_decoder_exp_handle_t hMetricDecoder, const size_t rawDataSize,