diff --git a/level_zero/api/driver_experimental/public/zex_metric.cpp b/level_zero/api/driver_experimental/public/zex_metric.cpp index e4484543d5..e090d54d0b 100644 --- a/level_zero/api/driver_experimental/public/zex_metric.cpp +++ b/level_zero/api/driver_experimental/public/zex_metric.cpp @@ -127,6 +127,21 @@ ze_result_t ZE_APICALL zetIntelMetricScopeGetPropertiesExp(zet_intel_metric_scop return L0::metricScopeGetProperties(hMetricScope, pMetricScopeProperties); } +ze_result_t ZE_APICALL +zetIntelMetricTracerDecodeExp2( + 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_exp_t *phMetricEntries) { + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + ze_result_t ZE_APICALL zetIntelMetricSupportedScopesGetExp(zet_metric_handle_t *phMetric, uint32_t *pCount, zet_intel_metric_scope_exp_handle_t *phScopes) { return L0::getMetricSupportedScopes(phMetric, pCount, phScopes); } @@ -273,6 +288,31 @@ ze_result_t ZE_APICALL zetIntelMetricScopeGetPropertiesExp(zet_intel_metric_scop return L0::zetIntelMetricScopeGetPropertiesExp(hMetricScope, pMetricScopeProperties); } +ze_result_t ZE_APICALL +zetIntelMetricTracerDecodeExp2( + 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_exp_t *phMetricEntries) { + return L0::zetIntelMetricTracerDecodeExp2( + 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) { return L0::getMetricSupportedScopes(phMetric, pCount, phScopes); } diff --git a/level_zero/core/source/driver/driver_handle_imp_helper.cpp b/level_zero/core/source/driver/driver_handle_imp_helper.cpp index be565fcae4..d78fff98a8 100644 --- a/level_zero/core/source/driver/driver_handle_imp_helper.cpp +++ b/level_zero/core/source/driver/driver_handle_imp_helper.cpp @@ -66,6 +66,8 @@ const std::vector> DriverHandleImp::extensionsS {ZET_METRICS_RUNTIME_ENABLE_DISABLE_EXP_NAME, ZET_METRICS_RUNTIME_ENABLE_DISABLE_EXP_VERSION_CURRENT}, {ZET_INTEL_METRIC_SCOPES_EXP_NAME, ZET_INTEL_METRIC_SCOPES_EXP_VERSION_CURRENT}, {ZET_INTEL_METRIC_HW_BUFFER_SIZE_EXP_NAME, ZET_INTEL_METRIC_HW_BUFFER_SIZE_EXP_VERSION_CURRENT}, + {ZET_INTEL_METRIC_TRACER_DECODE_EXP2_NAME, ZET_INTEL_METRIC_TRACER_DECODE_EXP2_VERSION_CURRENT}, + #include "additional_extensions_support.inl" }; } // namespace L0 diff --git a/level_zero/core/source/driver/extension_function_address.cpp b/level_zero/core/source/driver/extension_function_address.cpp index 684360a541..6990704daa 100644 --- a/level_zero/core/source/driver/extension_function_address.cpp +++ b/level_zero/core/source/driver/extension_function_address.cpp @@ -126,6 +126,7 @@ void *ExtensionFunctionAddressHelper::getExtensionFunctionAddress(const std::str RETURN_FUNC_PTR_IF_EXIST(zetIntelMetricCalculationOperationGetReportFormatExp); RETURN_FUNC_PTR_IF_EXIST(zetIntelMetricDecodeCalculateMultipleValuesExp); RETURN_FUNC_PTR_IF_EXIST(zetIntelMetricCalculateValuesExp); + RETURN_FUNC_PTR_IF_EXIST(zetIntelMetricTracerDecodeExp2); RETURN_FUNC_PTR_IF_EXIST(zetIntelMetricSupportedScopesGetExp); // Graphs 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 84a53fdd10..922659ab8b 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,50 @@ zetIntelMetricCalculateValuesExp( zet_intel_metric_result_exp_t *pMetricResults); ///< [in,out][optional][range(0, *pTotalMetricResultsCount)] buffer of calculated ///< metrics results. +#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" +#endif // ZET_INTEL_METRIC_TRACER_DECODE_EXP2_NAME +//////////////////////////////////////////////////////////////////////////////// +/// @brief Metric Tracer Decode extension Version(s) +typedef enum _zet_intel_metric_tracer_decode_exp2_version_t { + ZET_INTEL_METRIC_TRACER_DECODE_EXP2_VERSION_1_0 = ZE_MAKE_VERSION(1, 0), ///< version 1.0 + ZET_INTEL_METRIC_TRACER_DECODE_EXP2_VERSION_CURRENT = ZET_INTEL_METRIC_TRACER_DECODE_EXP2_VERSION_1_0, ///< latest known version + ZET_INTEL_METRIC_TRACER_DECODE_EXP2_VERSION_FORCE_UINT32 = 0x7fffffff +} zet_intel_metric_tracer_decode_exp2_version_t; + +ze_result_t ZE_APICALL +zetIntelMetricTracerDecodeExp2( + zet_metric_decoder_exp_handle_t phMetricDecoder, ///< [in] handle of the metric decoder object + const size_t rawDataSize, ///< [in] size in bytes of raw data buffer. + const uint8_t *pRawData, ///< [in][range(0, *rawDataSize)] buffer containing tracer data in raw format + uint32_t metricCount, ///< [in] number of decodable metrics in the tracer for which the + ///< phMetricDecoder handle was provided. See + ///< ::zetMetricDecoderGetDecodableMetricsExp(). If metricCount is greater + ///< than zero but less than the number decodable metrics available in the raw data buffer, + ///< then driver shall only decode those. + zet_metric_handle_t *phMetric, ///< [in] [range(0, metricsCount)] array of handles of decodable metrics in + ///< the decoder for which the phMetricDecoder handle was + ///< provided. Metrics handles are expected to be for decodable metrics, + ///< see ::zetMetricDecoderGetDecodableMetricsExp() + ///< If a reduced list of decodable metrics is provided, only entries + ///< for those decodable metrics will be present in the output. + uint32_t metricScopeCount, ///< [in] number of metric scopes in metric scopes in phMetricScopes. See ::zetMetricScopesGet() + zet_intel_metric_scope_exp_handle_t *phMetricScopes, ///< [in] [range (0, metricScopeCount)] array of metric scopes handles. + ///< If a reduced list of metric scopes is provided, + ///< only entries for those metrics scopes will be present in the output. + size_t *usedDataSize, ///< [out] The number raw bytes processed. User is expected to advance pRawData + ///< pointer by this amount if calling this function subsequently with the same data. + ///< Note that appending new data to existing is allowed. + uint32_t *pTotalMetricEntriesCount, ///< [in,out] pointer to the total number of metric entries decoded. If count is zero, then the + ///< driver shall update the value with the total number of metric entries to be decoded. + ///< If count is greater than zero but less than the total number of metric entries available + ///< 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 + ///< decoded metric entries + #ifndef ZET_INTEL_METRICS_RUNTIME_ENABLE_DISABLE_EXP_NAME /// @brief Extension name for enabling and disabling Intel Metrics collection #define ZET_INTEL_METRICS_RUNTIME_ENABLE_DISABLE_EXP_NAME "ZET_intel_metrics_runtime_enable_disable" diff --git a/level_zero/tools/test/unit_tests/sources/metrics/test_metric_tracer.cpp b/level_zero/tools/test/unit_tests/sources/metrics/test_metric_tracer.cpp index 1d7f01a74d..533f87b3a0 100644 --- a/level_zero/tools/test/unit_tests/sources/metrics/test_metric_tracer.cpp +++ b/level_zero/tools/test/unit_tests/sources/metrics/test_metric_tracer.cpp @@ -30,6 +30,7 @@ TEST(MetricTracerTest, WhenTracerRelatedApisAreCalledThenReturnUnsupportedFeatur EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zetIntelMetricDecodeCalculateMultipleValuesExp(nullptr, rawDataSize, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr)); + EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zetIntelMetricTracerDecodeExp2(nullptr, rawDataSize, nullptr, 0, nullptr, 0, nullptr, 0, 0, nullptr)); } } // namespace ult