From 4a5599b1ee99e09208fb37c3b1b36bf2e5335ee5 Mon Sep 17 00:00:00 2001 From: Piotr Maciejewski Date: Fri, 11 Dec 2020 13:11:00 +0000 Subject: [PATCH] L0 Metrics Api: multi adapter support Switching to Metrics Discovery adapter interface. --- .../linux/os_metric_enumeration_imp_linux.cpp | 66 +- .../source/metrics/metric_enumeration_imp.cpp | 57 +- .../source/metrics/metric_enumeration_imp.h | 10 +- .../os_metric_enumeration_imp_windows.cpp | 47 +- .../linux/test_metric_query_pool_linux.cpp | 280 ++- .../sources/metrics/mock_metric.cpp | 48 +- .../unit_tests/sources/metrics/mock_metric.h | 6 +- .../metrics/mock_metric_enumeration.cpp | 70 +- .../sources/metrics/mock_metric_enumeration.h | 43 +- .../metrics/test_metric_enumeration.cpp | 312 +--- .../metrics/test_metric_query_pool_2.cpp | 13 +- .../sources/metrics/test_metric_streamer.cpp | 80 +- .../source/os_interface/windows/wddm/wddm.cpp | 4 + .../source/os_interface/windows/wddm/wddm.h | 3 +- third_party/metrics_discovery/.revision | 2 +- .../metrics_discovery/metrics_discovery_api.h | 1600 +++++++++-------- 16 files changed, 1488 insertions(+), 1153 deletions(-) diff --git a/level_zero/tools/source/metrics/linux/os_metric_enumeration_imp_linux.cpp b/level_zero/tools/source/metrics/linux/os_metric_enumeration_imp_linux.cpp index 47fb496e70..c7d23440e9 100644 --- a/level_zero/tools/source/metrics/linux/os_metric_enumeration_imp_linux.cpp +++ b/level_zero/tools/source/metrics/linux/os_metric_enumeration_imp_linux.cpp @@ -1,14 +1,78 @@ /* - * Copyright (C) 2019-2020 Intel Corporation + * Copyright (C) 2020-2021 Intel Corporation * * SPDX-License-Identifier: MIT * */ +#include "shared/source/os_interface/linux/drm_neo.h" +#include "shared/source/os_interface/linux/os_interface.h" + #include "level_zero/tools/source/metrics/metric_enumeration_imp.h" +#include +#include + namespace L0 { const char *MetricEnumeration::getMetricsDiscoveryFilename() { return "libmd.so"; } +bool MetricEnumeration::getAdapterId(uint32_t &adapterMajor, uint32_t &adapterMinor) { + + auto &device = metricContext.getDevice(); + auto osInterface = device.getOsInterface().get(); + auto drm = osInterface->getDrm(); + auto drmFile = drm->getFileDescriptor(); + struct stat drmStat = {}; + + int32_t result = fstat(drmFile, &drmStat); + + adapterMajor = major(drmStat.st_rdev); + adapterMinor = minor(drmStat.st_rdev); + + return result == 0; +} + +MetricsDiscovery::IAdapter_1_8 *MetricEnumeration::getMetricsAdapter() { + + UNRECOVERABLE_IF(pAdapterGroup == nullptr); + + // Obtain drm minor / major version. + uint32_t drmMajor = 0; + uint32_t drmMinor = 0; + + UNRECOVERABLE_IF(getAdapterId(drmMajor, drmMinor) == false); + + // Driver drm major/minor version. + const int32_t drmNodePrimary = 0; // From xf86drm.h + const int32_t drmNodeRender = 2; // From xf86drm.h + const int32_t drmMaxDevices = 64; // From drm_drv.c#110 + + const int32_t drmMinorRender = drmMinor - (drmNodeRender * drmMaxDevices); + const int32_t drmMinorPrimary = drmMinor - (drmNodePrimary * drmMaxDevices); + + // Enumerate metrics discovery adapters. + for (uint32_t index = 0, count = pAdapterGroup->GetParams()->AdapterCount; + index < count; + ++index) { + + UNRECOVERABLE_IF(pAdapterGroup->GetAdapter(index) == nullptr); + UNRECOVERABLE_IF(pAdapterGroup->GetAdapter(index)->GetParams() == nullptr); + + auto adapter = pAdapterGroup->GetAdapter(index); + auto adapterParams = adapter->GetParams(); + + const bool validAdapterType = adapterParams->SystemId.Type == MetricsDiscovery::ADAPTER_ID_TYPE_MAJOR_MINOR; + const bool validAdapterMajor = adapterParams->SystemId.MajorMinor.Major == static_cast(drmMajor); + const bool validAdapterMinor = (adapterParams->SystemId.MajorMinor.Minor == drmMinorRender) || + (adapterParams->SystemId.MajorMinor.Minor == drmMinorPrimary); + + if (validAdapterType && validAdapterMajor && validAdapterMinor) { + return adapter; + } + } + + return nullptr; +} + } // namespace L0 diff --git a/level_zero/tools/source/metrics/metric_enumeration_imp.cpp b/level_zero/tools/source/metrics/metric_enumeration_imp.cpp index 2899056170..73148d5a71 100644 --- a/level_zero/tools/source/metrics/metric_enumeration_imp.cpp +++ b/level_zero/tools/source/metrics/metric_enumeration_imp.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2020 Intel Corporation + * Copyright (C) 2020-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -80,20 +80,14 @@ ze_result_t MetricEnumeration::loadMetricsDiscovery() { // Load exported functions. if (hMetricsDiscovery) { - openMetricsDevice = reinterpret_cast( - hMetricsDiscovery->getProcAddress("OpenMetricsDevice")); - closeMetricsDevice = reinterpret_cast( - hMetricsDiscovery->getProcAddress("CloseMetricsDevice")); - openMetricsDeviceFromFile = - reinterpret_cast( - hMetricsDiscovery->getProcAddress("OpenMetricsDeviceFromFile")); + openAdapterGroup = reinterpret_cast( + hMetricsDiscovery->getProcAddress("OpenAdapterGroup")); } - if (openMetricsDevice == nullptr || closeMetricsDevice == nullptr || - openMetricsDeviceFromFile == nullptr) { - PRINT_DEBUG_STRING(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "cannot load %s exported functions\n", MetricEnumeration::getMetricsDiscoveryFilename()); + if (openAdapterGroup == nullptr) { + NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "cannot load %s exported functions\n", MetricEnumeration::getMetricsDiscoveryFilename()); cleanupMetricsDiscovery(); - return ZE_RESULT_ERROR_UNKNOWN; + return ZE_RESULT_ERROR_NOT_AVAILABLE; } // Return success if exported functions have been loaded. @@ -101,14 +95,36 @@ ze_result_t MetricEnumeration::loadMetricsDiscovery() { } ze_result_t MetricEnumeration::openMetricsDiscovery() { - UNRECOVERABLE_IF(openMetricsDevice == nullptr); - UNRECOVERABLE_IF(closeMetricsDevice == nullptr); + UNRECOVERABLE_IF(openAdapterGroup == nullptr); - auto openResult = openMetricsDevice(&pMetricsDevice); - if (openResult != MetricsDiscovery::CC_OK) { + // Clean up members. + pAdapterGroup = nullptr; + pAdapter = nullptr; + pMetricsDevice = nullptr; + + // Open adapter group. + openAdapterGroup(&pAdapterGroup); + if (pAdapterGroup == nullptr) { + NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "unable to open metrics adapter groups %s\n", " "); + cleanupMetricsDiscovery(); return ZE_RESULT_ERROR_UNKNOWN; } + // Obtain metrics adapter that matches adapter used by l0. + pAdapter = getMetricsAdapter(); + if (pAdapter == nullptr) { + NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "unable to open metrics adapter %s\n", " "); + cleanupMetricsDiscovery(); + return ZE_RESULT_ERROR_NOT_AVAILABLE; + } + + pAdapter->OpenMetricsDevice(&pMetricsDevice); + if (pMetricsDevice == nullptr) { + NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "unable to open metrics device %s\n", " "); + cleanupMetricsDiscovery(); + return ZE_RESULT_ERROR_NOT_AVAILABLE; + } + return ZE_RESULT_SUCCESS; } @@ -119,16 +135,13 @@ ze_result_t MetricEnumeration::cleanupMetricsDiscovery() { metricGroups.clear(); - if (pMetricsDevice) { - closeMetricsDevice(pMetricsDevice); + if (pAdapter && pMetricsDevice) { + pAdapter->CloseMetricsDevice(pMetricsDevice); pMetricsDevice = nullptr; } if (hMetricsDiscovery != nullptr) { - openMetricsDevice = nullptr; - closeMetricsDevice = nullptr; - openMetricsDeviceFromFile = nullptr; - + openAdapterGroup = nullptr; hMetricsDiscovery.reset(); } diff --git a/level_zero/tools/source/metrics/metric_enumeration_imp.h b/level_zero/tools/source/metrics/metric_enumeration_imp.h index 90ce49e1bc..a2e9fcdbb6 100644 --- a/level_zero/tools/source/metrics/metric_enumeration_imp.h +++ b/level_zero/tools/source/metrics/metric_enumeration_imp.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2020 Intel Corporation + * Copyright (C) 2020-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -32,6 +32,8 @@ struct MetricEnumeration { ze_result_t initialize(); virtual ze_result_t openMetricsDiscovery(); + virtual bool getAdapterId(uint32_t &major, uint32_t &minor); + virtual MetricsDiscovery::IAdapter_1_8 *getMetricsAdapter(); ze_result_t cleanupMetricsDiscovery(); ze_result_t cacheMetricInformation(); @@ -57,9 +59,9 @@ struct MetricEnumeration { // Metrics Discovery API. std::unique_ptr hMetricsDiscovery = nullptr; - MetricsDiscovery::OpenMetricsDevice_fn openMetricsDevice = nullptr; - MetricsDiscovery::CloseMetricsDevice_fn closeMetricsDevice = nullptr; - MetricsDiscovery::OpenMetricsDeviceFromFile_fn openMetricsDeviceFromFile = nullptr; + MetricsDiscovery::OpenAdapterGroup_fn openAdapterGroup = nullptr; + MetricsDiscovery::IAdapterGroup_1_8 *pAdapterGroup = nullptr; + MetricsDiscovery::IAdapter_1_8 *pAdapter = nullptr; MetricsDiscovery::IMetricsDevice_1_5 *pMetricsDevice = nullptr; public: diff --git a/level_zero/tools/source/metrics/windows/os_metric_enumeration_imp_windows.cpp b/level_zero/tools/source/metrics/windows/os_metric_enumeration_imp_windows.cpp index 4b661baa85..92579c6131 100644 --- a/level_zero/tools/source/metrics/windows/os_metric_enumeration_imp_windows.cpp +++ b/level_zero/tools/source/metrics/windows/os_metric_enumeration_imp_windows.cpp @@ -1,10 +1,12 @@ /* - * Copyright (C) 2019-2020 Intel Corporation + * Copyright (C) 2020-2021 Intel Corporation * * SPDX-License-Identifier: MIT * */ +#include "shared/source/os_interface/windows/os_interface.h" + #include "level_zero/tools/source/metrics/metric_enumeration_imp.h" #if defined(_WIN64) @@ -19,4 +21,47 @@ namespace L0 { const char *MetricEnumeration::getMetricsDiscoveryFilename() { return METRICS_DISCOVERY_NAME; } +bool MetricEnumeration::getAdapterId(uint32_t &major, uint32_t &minor) { + + auto &device = metricContext.getDevice(); + auto osInterface = device.getOsInterface().get(); + auto luid = osInterface->getWddm()->getAdapterLuid(); + + major = luid.HighPart; + minor = luid.LowPart; + + return true; +} + +MetricsDiscovery::IAdapter_1_8 *MetricEnumeration::getMetricsAdapter() { + + uint32_t major = 0; + uint32_t minor = 0; + + UNRECOVERABLE_IF(pAdapterGroup == nullptr); + UNRECOVERABLE_IF(getAdapterId(major, minor) == false); + + // Enumerate metrics discovery adapters. + for (uint32_t index = 0, count = pAdapterGroup->GetParams()->AdapterCount; + index < count; + ++index) { + + UNRECOVERABLE_IF(pAdapterGroup->GetAdapter(index) == nullptr); + UNRECOVERABLE_IF(pAdapterGroup->GetAdapter(index)->GetParams() == nullptr); + + auto adapter = pAdapterGroup->GetAdapter(index); + auto adapterParams = adapter->GetParams(); + + const bool validAdapterInfo = adapterParams->SystemId.Type == MetricsDiscovery::ADAPTER_ID_TYPE_LUID; + const bool validAdapterMatch = (adapterParams->SystemId.Luid.HighPart == major) && + (adapterParams->SystemId.Luid.LowPart == minor); + + if (validAdapterInfo && validAdapterMatch) { + return adapter; + } + } + + return nullptr; +} + } // namespace L0 diff --git a/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_query_pool_linux.cpp b/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_query_pool_linux.cpp index ae6ad1ce04..83c0298492 100644 --- a/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_query_pool_linux.cpp +++ b/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_query_pool_linux.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Intel Corporation + * Copyright (C) 2020-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -58,5 +58,283 @@ TEST_F(MetricQueryPoolLinuxTest, givenCorrectArgumentsWhenGetContextDataIsCalled EXPECT_EQ(contextData.ClientData->Linux.Adapter->Type, LinuxAdapterType::DrmFileDescriptor); } +class MetricEnumerationTestLinux : public MetricContextFixture, + public ::testing::Test { + public: + void SetUp() override { + MetricContextFixture::SetUp(); + neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->osInterface = std::make_unique(); + auto osInterface = device->getOsInterface().get(); + osInterface->setDrm(new DrmMock(const_cast(neoDevice->getRootDeviceEnvironment()))); + } + + void TearDown() override { + MetricContextFixture::TearDown(); + } +}; + +TEST_F(MetricEnumerationTestLinux, givenCorrectLinuxDrmAdapterWhenGetMetricsAdapterThenReturnSuccess) { + + auto adapterGroupParams = TAdapterGroupParams_1_6{}; + auto adapterParams = TAdapterParams_1_8{}; + + adapterGroupParams.AdapterCount = 1; + adapterParams.SystemId.Type = MetricsDiscovery::TAdapterIdType::ADAPTER_ID_TYPE_MAJOR_MINOR; + adapterParams.SystemId.MajorMinor.Major = 0; + adapterParams.SystemId.MajorMinor.Minor = 0; + + openMetricsAdapterGroup(); + + EXPECT_CALL(adapterGroup, GetParams()) + .Times(1) + .WillOnce(Return(&adapterGroupParams)); + + EXPECT_CALL(adapterGroup, GetAdapter(_)) + .WillRepeatedly(Return(&adapter)); + + EXPECT_CALL(adapter, GetParams()) + .WillRepeatedly(Return(&adapterParams)); + + EXPECT_CALL(*mockMetricEnumeration, getAdapterId(_, _)) + .Times(1) + .WillOnce(DoAll(::testing::SetArgReferee<0>(adapterParams.SystemId.MajorMinor.Major), ::testing::SetArgReferee<1>(adapterParams.SystemId.MajorMinor.Minor), Return(true))); + + EXPECT_CALL(*mockMetricEnumeration, getMetricsAdapter()) + .Times(1) + .WillOnce([&]() { return mockMetricEnumeration->baseGetMetricsAdapter(); }); + + EXPECT_EQ(mockMetricEnumeration->openMetricsDiscovery(), ZE_RESULT_SUCCESS); +} + +TEST_F(MetricEnumerationTestLinux, givenCorrectLinuxMinorPrimaryNodeDrmAdapterWhenGetMetricsAdapterThenReturnSuccess) { + + const int32_t drmNodePrimary = 0; // From xf86drm.h + const int32_t drmMaxDevices = 64; // From drm_drv.c#110 + + auto adapterGroupParams = TAdapterGroupParams_1_6{}; + auto adapterParams = TAdapterParams_1_8{}; + + adapterGroupParams.AdapterCount = 1; + adapterParams.SystemId.Type = MetricsDiscovery::TAdapterIdType::ADAPTER_ID_TYPE_MAJOR_MINOR; + adapterParams.SystemId.MajorMinor.Major = 0; + adapterParams.SystemId.MajorMinor.Minor = 1000 - (drmNodePrimary * drmMaxDevices); + + uint32_t drmMajor = 0; + uint32_t drmMinor = 1000; + + openMetricsAdapterGroup(); + + EXPECT_CALL(adapterGroup, GetParams()) + .WillRepeatedly(Return(&adapterGroupParams)); + + EXPECT_CALL(adapterGroup, GetAdapter(_)) + .WillRepeatedly(Return(&adapter)); + + EXPECT_CALL(adapter, GetParams()) + .WillRepeatedly(Return(&adapterParams)); + + EXPECT_CALL(*mockMetricEnumeration, getAdapterId(_, _)) + .Times(1) + .WillOnce(DoAll(::testing::SetArgReferee<0>(drmMajor), ::testing::SetArgReferee<1>(drmMinor), Return(true))); + + EXPECT_CALL(*mockMetricEnumeration, getMetricsAdapter()) + .Times(1) + .WillOnce([&]() { return mockMetricEnumeration->baseGetMetricsAdapter(); }); + + EXPECT_EQ(mockMetricEnumeration->openMetricsDiscovery(), ZE_RESULT_SUCCESS); +} + +TEST_F(MetricEnumerationTestLinux, givenCorrectLinuxMinorRenderNodeDrmAdapterWhenGetMetricsAdapterThenReturnSuccess) { + + const int32_t drmNodeRender = 2; // From xf86drm.h + const int32_t drmMaxDevices = 64; // From drm_drv.c#110 + + auto adapterGroupParams = TAdapterGroupParams_1_6{}; + auto adapterParams = TAdapterParams_1_8{}; + + adapterGroupParams.AdapterCount = 1; + adapterParams.SystemId.Type = MetricsDiscovery::TAdapterIdType::ADAPTER_ID_TYPE_MAJOR_MINOR; + adapterParams.SystemId.MajorMinor.Major = 0; + adapterParams.SystemId.MajorMinor.Minor = 1000 - (drmNodeRender * drmMaxDevices); + + uint32_t drmMajor = 0; + uint32_t drmMinor = 1000; + + openMetricsAdapterGroup(); + + EXPECT_CALL(adapterGroup, GetParams()) + .WillRepeatedly(Return(&adapterGroupParams)); + + EXPECT_CALL(adapterGroup, GetAdapter(_)) + .WillRepeatedly(Return(&adapter)); + + EXPECT_CALL(adapter, GetParams()) + .WillRepeatedly(Return(&adapterParams)); + + EXPECT_CALL(*mockMetricEnumeration, getAdapterId(_, _)) + .Times(1) + .WillOnce(DoAll(::testing::SetArgReferee<0>(drmMajor), ::testing::SetArgReferee<1>(drmMinor), Return(true))); + + EXPECT_CALL(*mockMetricEnumeration, getMetricsAdapter()) + .Times(1) + .WillOnce([&]() { return mockMetricEnumeration->baseGetMetricsAdapter(); }); + + EXPECT_EQ(mockMetricEnumeration->openMetricsDiscovery(), ZE_RESULT_SUCCESS); +} + +TEST_F(MetricEnumerationTestLinux, givenIcorrectMetricDiscoveryAdapterTypeWhenGetMetricsAdapterThenReturnFail) { + + auto adapterGroupParams = TAdapterGroupParams_1_6{}; + auto adapterParams = TAdapterParams_1_8{}; + + adapterGroupParams.AdapterCount = 1; + adapterParams.SystemId.Type = MetricsDiscovery::TAdapterIdType::ADAPTER_ID_TYPE_LUID; + adapterParams.SystemId.MajorMinor.Major = 0; + adapterParams.SystemId.MajorMinor.Minor = 0; + + EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenAdapterGroup(_)) + .Times(1) + .WillOnce(DoAll(::testing::SetArgPointee<0>(&adapterGroup), Return(TCompletionCode::CC_OK))); + + EXPECT_CALL(adapterGroup, GetParams()) + .Times(1) + .WillOnce(Return(&adapterGroupParams)); + + EXPECT_CALL(adapterGroup, GetAdapter(_)) + .WillRepeatedly(Return(&adapter)); + + EXPECT_CALL(adapter, GetParams()) + .WillRepeatedly(Return(&adapterParams)); + + EXPECT_CALL(*mockMetricEnumeration, getAdapterId(_, _)) + .Times(1) + .WillOnce(DoAll(::testing::SetArgReferee<0>(adapterParams.SystemId.MajorMinor.Major), ::testing::SetArgReferee<1>(adapterParams.SystemId.MajorMinor.Minor), Return(true))); + + EXPECT_CALL(*mockMetricEnumeration, getMetricsAdapter()) + .Times(1) + .WillOnce([&]() { return mockMetricEnumeration->baseGetMetricsAdapter(); }); + + EXPECT_NE(mockMetricEnumeration->openMetricsDiscovery(), ZE_RESULT_SUCCESS); +} + +TEST_F(MetricEnumerationTestLinux, givenIcorrectMetricDiscoveryAdapterMajorWhenGetMetricsAdapterThenReturnFail) { + + auto adapterGroupParams = TAdapterGroupParams_1_6{}; + auto adapterParams = TAdapterParams_1_8{}; + + adapterGroupParams.AdapterCount = 1; + adapterParams.SystemId.Type = MetricsDiscovery::TAdapterIdType::ADAPTER_ID_TYPE_MAJOR_MINOR; + adapterParams.SystemId.MajorMinor.Major = 0; + adapterParams.SystemId.MajorMinor.Minor = 0; + uint32_t incorrectMajor = 1; + + EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenAdapterGroup(_)) + .Times(1) + .WillOnce(DoAll(::testing::SetArgPointee<0>(&adapterGroup), Return(TCompletionCode::CC_OK))); + + EXPECT_CALL(adapterGroup, GetParams()) + .Times(1) + .WillOnce(Return(&adapterGroupParams)); + + EXPECT_CALL(adapterGroup, GetAdapter(_)) + .WillRepeatedly(Return(&adapter)); + + EXPECT_CALL(adapter, GetParams()) + .WillRepeatedly(Return(&adapterParams)); + + EXPECT_CALL(*mockMetricEnumeration, getAdapterId(_, _)) + .Times(1) + .WillOnce(DoAll(::testing::SetArgReferee<0>(incorrectMajor), ::testing::SetArgReferee<1>(adapterParams.SystemId.MajorMinor.Minor), Return(true))); + + EXPECT_CALL(*mockMetricEnumeration, getMetricsAdapter()) + .Times(1) + .WillOnce([&]() { return mockMetricEnumeration->baseGetMetricsAdapter(); }); + + EXPECT_NE(mockMetricEnumeration->openMetricsDiscovery(), ZE_RESULT_SUCCESS); +} + +TEST_F(MetricEnumerationTestLinux, givenIcorrectMetricDiscoveryAdapterMinorWhenGetMetricsAdapterThenReturnFail) { + + auto adapterGroupParams = TAdapterGroupParams_1_6{}; + auto adapterParams = TAdapterParams_1_8{}; + + adapterGroupParams.AdapterCount = 1; + adapterParams.SystemId.Type = MetricsDiscovery::TAdapterIdType::ADAPTER_ID_TYPE_MAJOR_MINOR; + adapterParams.SystemId.MajorMinor.Major = 0; + adapterParams.SystemId.MajorMinor.Minor = 0; + uint32_t incorrectMinor = 1; + + EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenAdapterGroup(_)) + .Times(1) + .WillOnce(DoAll(::testing::SetArgPointee<0>(&adapterGroup), Return(TCompletionCode::CC_OK))); + + EXPECT_CALL(adapterGroup, GetParams()) + .Times(1) + .WillOnce(Return(&adapterGroupParams)); + + EXPECT_CALL(adapterGroup, GetAdapter(_)) + .WillRepeatedly(Return(&adapter)); + + EXPECT_CALL(adapter, GetParams()) + .WillRepeatedly(Return(&adapterParams)); + + EXPECT_CALL(*mockMetricEnumeration, getAdapterId(_, _)) + .Times(1) + .WillOnce(DoAll(::testing::SetArgReferee<0>(adapterParams.SystemId.MajorMinor.Major), ::testing::SetArgReferee<1>(incorrectMinor), Return(true))); + + EXPECT_CALL(*mockMetricEnumeration, getMetricsAdapter()) + .Times(1) + .WillOnce([&]() { return mockMetricEnumeration->baseGetMetricsAdapter(); }); + + EXPECT_NE(mockMetricEnumeration->openMetricsDiscovery(), ZE_RESULT_SUCCESS); +} + +TEST_F(MetricEnumerationTestLinux, givenIcorrectOpenMetricDeviceOnAdapterWhenGetMetricsAdapterThenReturnFail) { + + auto adapterGroupParams = TAdapterGroupParams_1_6{}; + auto adapterParams = TAdapterParams_1_8{}; + + adapterGroupParams.AdapterCount = 1; + adapterParams.SystemId.Type = MetricsDiscovery::TAdapterIdType::ADAPTER_ID_TYPE_MAJOR_MINOR; + adapterParams.SystemId.MajorMinor.Major = 0; + adapterParams.SystemId.MajorMinor.Minor = 0; + + EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenAdapterGroup(_)) + .Times(1) + .WillOnce(DoAll(::testing::SetArgPointee<0>(&adapterGroup), Return(TCompletionCode::CC_OK))); + + EXPECT_CALL(adapterGroup, GetParams()) + .Times(1) + .WillOnce(Return(&adapterGroupParams)); + + EXPECT_CALL(adapterGroup, GetAdapter(_)) + .WillRepeatedly(Return(&adapter)); + + EXPECT_CALL(adapter, GetParams()) + .WillRepeatedly(Return(&adapterParams)); + + EXPECT_CALL(*mockMetricEnumeration, getAdapterId(_, _)) + .Times(1) + .WillOnce(DoAll(::testing::SetArgReferee<0>(adapterParams.SystemId.MajorMinor.Major), ::testing::SetArgReferee<1>(adapterParams.SystemId.MajorMinor.Minor), Return(true))); + + EXPECT_CALL(*mockMetricEnumeration, getMetricsAdapter()) + .Times(1) + .WillOnce([&]() { return mockMetricEnumeration->baseGetMetricsAdapter(); }); + + EXPECT_CALL(adapter, OpenMetricsDevice(_)) + .Times(1) + .WillOnce(DoAll(::testing::SetArgPointee<0>(nullptr), Return(TCompletionCode::CC_ERROR_GENERAL))); + + EXPECT_NE(mockMetricEnumeration->openMetricsDiscovery(), ZE_RESULT_SUCCESS); +} + +TEST_F(MetricEnumerationTestLinux, givenIcorrectDrmFileForFstaWhenGetMetricsAdapterThenReturnFail) { + + uint32_t drmMajor = 0; + uint32_t drmMinor = 0; + + EXPECT_EQ(mockMetricEnumeration->baseGetAdapterId(drmMajor, drmMinor), false); +} + } // namespace ult } // namespace L0 diff --git a/level_zero/tools/test/unit_tests/sources/metrics/mock_metric.cpp b/level_zero/tools/test/unit_tests/sources/metrics/mock_metric.cpp index c6b0ddd4e9..611c9fb6bf 100644 --- a/level_zero/tools/test/unit_tests/sources/metrics/mock_metric.cpp +++ b/level_zero/tools/test/unit_tests/sources/metrics/mock_metric.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Intel Corporation + * Copyright (C) 2020-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -11,6 +11,9 @@ using namespace MetricsLibraryApi; +using ::testing::_; +using ::testing::Return; + namespace L0 { namespace ult { @@ -53,6 +56,49 @@ void MetricContextFixture::TearDown() { ContextFixture::TearDown(); } +void MetricContextFixture::openMetricsAdapter() { + + EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) + .Times(0); + + EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenAdapterGroup(_)) + .Times(1) + .WillOnce(DoAll(::testing::SetArgPointee<0>(&adapterGroup), Return(TCompletionCode::CC_OK))); + + EXPECT_CALL(adapter, OpenMetricsDevice(_)) + .Times(1) + .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); + + EXPECT_CALL(adapter, CloseMetricsDevice(_)) + .Times(1) + .WillOnce(Return(TCompletionCode::CC_OK)); + + EXPECT_CALL(adapterGroup, GetAdapter(_)) + .Times(0); + + EXPECT_CALL(*mockMetricEnumeration, getMetricsAdapter()) + .Times(1) + .WillOnce(Return(&adapter)); +} + +void MetricContextFixture::openMetricsAdapterGroup() { + + EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) + .Times(0); + + EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenAdapterGroup(_)) + .Times(1) + .WillOnce(DoAll(::testing::SetArgPointee<0>(&adapterGroup), Return(TCompletionCode::CC_OK))); + + EXPECT_CALL(adapter, OpenMetricsDevice(_)) + .Times(1) + .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); + + EXPECT_CALL(adapter, CloseMetricsDevice(_)) + .Times(1) + .WillOnce(Return(TCompletionCode::CC_OK)); +} + Mock::Mock(::L0::MetricContext &metricContext) : MetricsLibrary(metricContext) { } diff --git a/level_zero/tools/test/unit_tests/sources/metrics/mock_metric.h b/level_zero/tools/test/unit_tests/sources/metrics/mock_metric.h index f3cc27d48a..eb91a9c9c5 100644 --- a/level_zero/tools/test/unit_tests/sources/metrics/mock_metric.h +++ b/level_zero/tools/test/unit_tests/sources/metrics/mock_metric.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Intel Corporation + * Copyright (C) 2020-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -147,6 +147,8 @@ class MetricContextFixture : public ContextFixture { protected: void SetUp() override; void TearDown() override; + void openMetricsAdapter(); + void openMetricsAdapterGroup(); public: // Mocked objects. @@ -158,6 +160,8 @@ class MetricContextFixture : public ContextFixture { MockMetricsDiscoveryApi mockMetricsDiscoveryApi = {}; // Metrics discovery device + Mock adapterGroup; + Mock adapter; Mock metricsDevice; MetricsDiscovery::TMetricsDeviceParams_1_2 metricsDeviceParams = {}; }; diff --git a/level_zero/tools/test/unit_tests/sources/metrics/mock_metric_enumeration.cpp b/level_zero/tools/test/unit_tests/sources/metrics/mock_metric_enumeration.cpp index 182d690e90..47d38cb1cb 100644 --- a/level_zero/tools/test/unit_tests/sources/metrics/mock_metric_enumeration.cpp +++ b/level_zero/tools/test/unit_tests/sources/metrics/mock_metric_enumeration.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Intel Corporation + * Copyright (C) 2020-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -18,8 +18,8 @@ Mock::~Mock() { MockMetricsDiscoveryApi *Mock::g_mockApi = nullptr; -TCompletionCode MockMetricsDiscoveryApi::OpenMetricsDevice(IMetricsDevice_1_5 **device) { - return Mock::g_mockApi->MockOpenMetricsDevice(device); +TCompletionCode MockMetricsDiscoveryApi::OpenAdapterGroup(IAdapterGroup_1_8 **group) { + return Mock::g_mockApi->MockOpenAdapterGroup(group); } TCompletionCode MockMetricsDiscoveryApi::OpenMetricsDeviceFromFile(const char *fileName, void *openParams, IMetricsDevice_1_5 **device) { @@ -43,9 +43,7 @@ void Mock::setMockedApi(MockMetricsDiscoveryApi *mockedApi) { metricContext.setMetricEnumeration(*this); // Mock metrics library api functions. - openMetricsDevice = mockedApi->OpenMetricsDevice; - closeMetricsDevice = mockedApi->CloseMetricsDevice; - openMetricsDeviceFromFile = mockedApi->OpenMetricsDeviceFromFile; + openAdapterGroup = mockedApi->OpenAdapterGroup; // Mock metrics library api. Mock::g_mockApi = mockedApi; @@ -261,4 +259,64 @@ TMetricParams_1_0 *IMetric_1_0::GetParams() { return nullptr; } +IAdapter_1_8 *IAdapterGroup_1_8::GetAdapter(uint32_t index) { + UNRECOVERABLE_IF(true); + return nullptr; +} + +IAdapterGroup_1_6 ::~IAdapterGroup_1_6() { +} + +const TAdapterGroupParams_1_6 *IAdapterGroup_1_6::GetParams(void) const { + UNRECOVERABLE_IF(true); + return nullptr; +} + +IAdapter_1_6 *IAdapterGroup_1_6::GetAdapter(uint32_t index) { + UNRECOVERABLE_IF(true); + return nullptr; +} + +TCompletionCode IAdapterGroup_1_6::Close() { + UNRECOVERABLE_IF(true); + return CC_ERROR_NOT_SUPPORTED; +} + +IAdapter_1_6 ::~IAdapter_1_6() {} + +const TAdapterParams_1_6 *IAdapter_1_6 ::GetParams(void) const { + UNRECOVERABLE_IF(true); + return nullptr; +} + +const TAdapterParams_1_8 *IAdapter_1_8::GetParams(void) const { + UNRECOVERABLE_IF(true); + return nullptr; +} + +TCompletionCode IAdapter_1_6 ::Reset() { + UNRECOVERABLE_IF(true); + return CC_ERROR_NOT_SUPPORTED; +} + +TCompletionCode IAdapter_1_6 ::OpenMetricsDevice(IMetricsDevice_1_5 **metricsDevice) { + UNRECOVERABLE_IF(true); + return CC_ERROR_NOT_SUPPORTED; +} + +TCompletionCode IAdapter_1_6 ::OpenMetricsDeviceFromFile(const char *fileName, void *openParams, IMetricsDevice_1_5 **metricsDevice) { + UNRECOVERABLE_IF(true); + return CC_ERROR_NOT_SUPPORTED; +} + +TCompletionCode IAdapter_1_6 ::CloseMetricsDevice(IMetricsDevice_1_5 *metricsDevice) { + UNRECOVERABLE_IF(true); + return CC_ERROR_NOT_SUPPORTED; +} + +TCompletionCode IAdapter_1_6 ::SaveMetricsDeviceToFile(const char *fileName, void *saveParams, IMetricsDevice_1_5 *metricsDevice) { + UNRECOVERABLE_IF(true); + return CC_ERROR_NOT_SUPPORTED; +} + } // namespace MetricsDiscovery diff --git a/level_zero/tools/test/unit_tests/sources/metrics/mock_metric_enumeration.h b/level_zero/tools/test/unit_tests/sources/metrics/mock_metric_enumeration.h index 6f612e7874..65bfa000cb 100644 --- a/level_zero/tools/test/unit_tests/sources/metrics/mock_metric_enumeration.h +++ b/level_zero/tools/test/unit_tests/sources/metrics/mock_metric_enumeration.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Intel Corporation + * Copyright (C) 2020-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -24,6 +24,10 @@ struct WhiteBox<::L0::MetricGroup> : public ::L0::MetricGroup { using MetricGroup = WhiteBox<::L0::MetricGroup>; +using MetricsDiscovery::IAdapter_1_6; +using MetricsDiscovery::IAdapter_1_8; +using MetricsDiscovery::IAdapterGroup_1_6; +using MetricsDiscovery::IAdapterGroup_1_8; using MetricsDiscovery::IConcurrentGroup_1_5; using MetricsDiscovery::IInformation_1_0; using MetricsDiscovery::IMetric_1_0; @@ -31,6 +35,9 @@ using MetricsDiscovery::IMetricsDevice_1_5; using MetricsDiscovery::IMetricSet_1_0; using MetricsDiscovery::IMetricSet_1_5; using MetricsDiscovery::IOverride_1_2; +using MetricsDiscovery::TAdapterGroupParams_1_6; +using MetricsDiscovery::TAdapterParams_1_6; +using MetricsDiscovery::TAdapterParams_1_8; using MetricsDiscovery::TCompletionCode; using MetricsDiscovery::TConcurrentGroupParams_1_0; using MetricsDiscovery::TGlobalSymbol_1_0; @@ -43,16 +50,39 @@ using MetricsDiscovery::TTypedValue_1_0; struct MockMetricsDiscoveryApi { // Original api functions. - static TCompletionCode MD_STDCALL OpenMetricsDevice(IMetricsDevice_1_5 **device); static TCompletionCode MD_STDCALL OpenMetricsDeviceFromFile(const char *fileName, void *openParams, IMetricsDevice_1_5 **device); static TCompletionCode MD_STDCALL CloseMetricsDevice(IMetricsDevice_1_5 *device); static TCompletionCode MD_STDCALL SaveMetricsDeviceToFile(const char *fileName, void *saveParams, IMetricsDevice_1_5 *device); + static TCompletionCode MD_STDCALL OpenAdapterGroup(IAdapterGroup_1_8 **adapterGroup); // Mocked api functions. - MOCK_METHOD(TCompletionCode, MockOpenMetricsDevice, (IMetricsDevice_1_5 **)); MOCK_METHOD(TCompletionCode, MockOpenMetricsDeviceFromFile, (const char *, void *, IMetricsDevice_1_5 **)); MOCK_METHOD(TCompletionCode, MockCloseMetricsDevice, (IMetricsDevice_1_5 *)); MOCK_METHOD(TCompletionCode, MockSaveMetricsDeviceToFile, (const char *, void *, IMetricsDevice_1_5 *)); + MOCK_METHOD(TCompletionCode, MockOpenAdapterGroup, (IAdapterGroup_1_8 * *adapterGroup)); +}; + +template <> +class Mock : public IAdapterGroup_1_8 { + public: + Mock(){}; + + MOCK_METHOD(IAdapter_1_8 *, GetAdapter, (uint32_t), (override)); + MOCK_METHOD(const TAdapterGroupParams_1_6 *, GetParams, (), (const, override)); + MOCK_METHOD(TCompletionCode, Close, (), (override)); +}; + +template <> +class Mock : public IAdapter_1_8 { + public: + Mock(){}; + + MOCK_METHOD(const TAdapterParams_1_8 *, GetParams, (), (const, override)); + MOCK_METHOD(TCompletionCode, Reset, (), (override)); + MOCK_METHOD(TCompletionCode, OpenMetricsDevice, (IMetricsDevice_1_5 **), (override)); + MOCK_METHOD(TCompletionCode, OpenMetricsDeviceFromFile, (const char *, void *, IMetricsDevice_1_5 **), (override)); + MOCK_METHOD(TCompletionCode, CloseMetricsDevice, (IMetricsDevice_1_5 *), (override)); + MOCK_METHOD(TCompletionCode, SaveMetricsDeviceToFile, (const char *, void *, IMetricsDevice_1_5 *), (override)); }; template <> @@ -118,6 +148,8 @@ struct Mock : public MetricEnumeration { using MetricEnumeration::hMetricsDiscovery; using MetricEnumeration::initializationState; + using MetricEnumeration::openAdapterGroup; + using MetricEnumeration::openMetricsDiscovery; // Api mock enable/disable. void setMockedApi(MockMetricsDiscoveryApi *mockedApi); @@ -125,9 +157,14 @@ struct Mock : public MetricEnumeration { // Mock metric enumeration functions. MOCK_METHOD(bool, isInitialized, (), (override)); MOCK_METHOD(ze_result_t, loadMetricsDiscovery, (), (override)); + MOCK_METHOD(MetricsDiscovery::IAdapter_1_8 *, getMetricsAdapter, (), (override)); + MOCK_METHOD(bool, getAdapterId, (uint32_t & drmMajor, uint32_t &drmMinor), (override)); // Not mocked metrics enumeration functions. bool baseIsInitialized() { return MetricEnumeration::isInitialized(); } + IAdapter_1_8 *baseGetMetricsAdapter() { return MetricEnumeration::getMetricsAdapter(); } + bool baseGetAdapterId(uint32_t &adapterMajor, uint32_t &adapterMinor) { return MetricEnumeration::getAdapterId(adapterMajor, adapterMinor); } + ze_result_t baseLoadMetricsDiscovery() { return MetricEnumeration::loadMetricsDiscovery(); } // Mock metrics discovery api. static MockMetricsDiscoveryApi *g_mockApi; diff --git a/level_zero/tools/test/unit_tests/sources/metrics/test_metric_enumeration.cpp b/level_zero/tools/test/unit_tests/sources/metrics/test_metric_enumeration.cpp index ad68b07d98..cef49b975a 100644 --- a/level_zero/tools/test/unit_tests/sources/metrics/test_metric_enumeration.cpp +++ b/level_zero/tools/test/unit_tests/sources/metrics/test_metric_enumeration.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Intel Corporation + * Copyright (C) 2020-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -27,7 +27,7 @@ TEST_F(MetricEnumerationTest, givenIncorrectMetricsDiscoveryDeviceWhenZetGetMetr EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) .Times(0); - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) + EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenAdapterGroup(_)) .Times(1) .WillOnce(DoAll(::testing::SetArgPointee<0>(nullptr), Return(TCompletionCode::CC_ERROR_GENERAL))); @@ -41,16 +41,7 @@ TEST_F(MetricEnumerationTest, givenIncorrectMetricsDiscoveryInterfaceVersionWhen metricsDeviceParams.Version.MajorNumber = 0; metricsDeviceParams.Version.MinorNumber = 1; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .Times(1) @@ -63,16 +54,7 @@ TEST_F(MetricEnumerationTest, givenIncorrectMetricsDiscoveryInterfaceVersionWhen TEST_F(MetricEnumerationTest, givenNoConcurrentMetricGroupsWhenZetGetMetricGroupIsCalledThenReturnsZeroMetricsGroups) { - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .Times(1) @@ -101,16 +83,7 @@ TEST_F(MetricEnumerationTest, givenTwoConcurrentMetricGroupsWhenZetGetMetricGrou MetricsDiscovery::TMetricSetParams_1_4 metricsSetParams = {}; metricsSetParams.ApiMask = MetricsDiscovery::API_TYPE_OCL; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -169,16 +142,7 @@ TEST_F(MetricEnumerationTest, givenInvalidArgumentsWhenZetGetMetricGroupProperti // One api: metric group handle. zet_metric_group_handle_t metricGroupHandle = {}; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -235,16 +199,7 @@ TEST_F(MetricEnumerationTest, givenValidArgumentsWhenZetGetMetricGroupProperties zet_metric_group_handle_t metricGroupHandle = {}; zet_metric_group_properties_t metricGroupProperties = {}; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -308,16 +263,7 @@ TEST_F(MetricEnumerationTest, givenInvalidArgumentsWhenZetMetricGetIsCalledThenR // One api: metric group handle. zet_metric_group_handle_t metricGroupHandle = {}; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -378,16 +324,7 @@ TEST_F(MetricEnumerationTest, givenValidArgumentsWhenZetMetricGetIsCalledThenRet // One api: metric group handle. zet_metric_group_handle_t metricGroupHandle = {}; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -461,16 +398,7 @@ TEST_F(MetricEnumerationTest, givenValidArgumentsWhenZetMetricGetIsCalledThenRet // One api: metric group handle. zet_metric_group_handle_t metricGroupHandle = {}; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -547,16 +475,7 @@ TEST_F(MetricEnumerationTest, givenInvalidArgumentsWhenZetMetricGetPropertiestIs // One api: metric group handle. zet_metric_group_handle_t metricGroupHandle = {}; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -639,16 +558,7 @@ TEST_F(MetricEnumerationTest, givenValidArgumentsWhenZetMetricGetPropertiestIsCa // One api: metric group handle. zet_metric_group_handle_t metricGroupHandle = {}; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -738,16 +648,7 @@ TEST_F(MetricEnumerationTest, givenValidArgumentsWhenZetMetricGetPropertiestIsCa // One api: metric group handle. zet_metric_group_handle_t metricGroupHandle = {}; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -836,16 +737,7 @@ TEST_F(MetricEnumerationTest, givenInvalidArgumentsWhenzetContextActivateMetricG // One api: metric group handle. zet_metric_group_handle_t metricGroupHandle = {}; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -919,16 +811,7 @@ TEST_F(MetricEnumerationTest, givenValidEventBasedMetricGroupWhenzetContextActiv // One api: metric group handle. zet_metric_group_handle_t metricGroupHandle = {}; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -1005,16 +888,7 @@ TEST_F(MetricEnumerationTest, givenValidEventBasedMetricGroupWhenZetContextActiv // One api: metric group handle. zet_metric_group_handle_t metricGroupHandle = {}; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -1091,16 +965,7 @@ TEST_F(MetricEnumerationTest, givenValidTimeBasedMetricGroupWhenzetContextActiva // One api: metric group handle. zet_metric_group_handle_t metricGroupHandle = {}; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -1177,16 +1042,7 @@ TEST_F(MetricEnumerationTest, givenActivateTheSameMetricGroupTwiceWhenzetContext // One api: metric group handle. zet_metric_group_handle_t metricGroupHandle = {}; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -1255,16 +1111,7 @@ TEST_F(MetricEnumerationTest, givenActivateTwoMetricGroupsWithDifferentDomainsWh zet_metric_group_handle_t metricGroupHandle[2] = {}; zet_metric_group_properties_t metricGroupProperties[2] = {}; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -1334,16 +1181,7 @@ TEST_F(MetricEnumerationTest, givenActivateTwoMetricGroupsWithDifferentDomainsAt zet_metric_group_handle_t metricGroupHandle[2] = {}; zet_metric_group_properties_t metricGroupProperties[2] = {}; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -1411,16 +1249,7 @@ TEST_F(MetricEnumerationTest, givenActivateTwoMetricGroupsWithTheSameDomainsWhen zet_metric_group_handle_t metricGroupHandle[2] = {}; zet_metric_group_properties_t metricGroupProperties[2] = {}; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -1490,16 +1319,7 @@ TEST_F(MetricEnumerationTest, givenDeactivateTestsWhenzetContextActivateMetricGr zet_metric_group_handle_t metricGroupHandle[2] = {}; zet_metric_group_properties_t metricGroupProperties[2] = {}; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -1580,16 +1400,7 @@ TEST_F(MetricEnumerationTest, givenInvalidArgumentsWhenZetMetricGroupCalculateMe // One api: metric group. zet_metric_group_handle_t metricGroupHandle = {}; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -1639,16 +1450,7 @@ TEST_F(MetricEnumerationTest, givenIncorrectRawReportSizeWhenZetMetricGroupCalcu // One api: metric group. zet_metric_group_handle_t metricGroupHandle = {}; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -1717,16 +1519,7 @@ TEST_F(MetricEnumerationTest, givenCorrectRawReportSizeWhenZetMetricGroupCalcula // One api: metric group. zet_metric_group_handle_t metricGroupHandle = {}; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -1807,16 +1600,7 @@ TEST_F(MetricEnumerationTest, givenCorrectRawReportSizeAndLowerProvidedCalculate // One api: metric group. zet_metric_group_handle_t metricGroupHandle = {}; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -1895,16 +1679,7 @@ TEST_F(MetricEnumerationTest, givenCorrectRawReportSizeAndCorrectCalculatedRepor // One api: metric group. zet_metric_group_handle_t metricGroupHandle = {}; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -1981,16 +1756,7 @@ TEST_F(MetricEnumerationTest, givenCorrectRawReportSizeAndCorrectCalculatedRepor // One api: metric group. zet_metric_group_handle_t metricGroupHandle = {}; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -2067,16 +1833,7 @@ TEST_F(MetricEnumerationTest, givenIncorrectCalculationTypeWhenZetMetricGroupCal // One api: metric group. zet_metric_group_handle_t metricGroupHandle = {}; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -2148,16 +1905,7 @@ TEST_F(MetricEnumerationTest, givenNotInitializedMetricEnumerationWhenIsInitiali Mock metric; MetricsDiscovery::TMetricParams_1_0 metricParams = {}; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); diff --git a/level_zero/tools/test/unit_tests/sources/metrics/test_metric_query_pool_2.cpp b/level_zero/tools/test/unit_tests/sources/metrics/test_metric_query_pool_2.cpp index 7e56e9ce82..3a933ae91a 100644 --- a/level_zero/tools/test/unit_tests/sources/metrics/test_metric_query_pool_2.cpp +++ b/level_zero/tools/test/unit_tests/sources/metrics/test_metric_query_pool_2.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Intel Corporation + * Copyright (C) 2020-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -152,16 +152,7 @@ TEST_F(MetricQueryPoolTest, givenCorrectArgumentsWhenStreamerIsOpenThenQueryPool EXPECT_CALL(*mockMetricsLibrary, load()) .Times(0); - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); diff --git a/level_zero/tools/test/unit_tests/sources/metrics/test_metric_streamer.cpp b/level_zero/tools/test/unit_tests/sources/metrics/test_metric_streamer.cpp index b972c53649..6818d77efc 100644 --- a/level_zero/tools/test/unit_tests/sources/metrics/test_metric_streamer.cpp +++ b/level_zero/tools/test/unit_tests/sources/metrics/test_metric_streamer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Intel Corporation + * Copyright (C) 2020-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -90,16 +90,7 @@ TEST_F(MetricStreamerTest, givenValidArgumentsWhenZetMetricStreamerOpenIsCalledT metricsSetParams.ShortName = "Metric set description"; metricsSetParams.RawReportSize = 256; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -200,16 +191,7 @@ TEST_F(MetricStreamerTest, givenValidArgumentsWhenZetMetricStreamerOpenIsCalledT metricsSetParams.ShortName = "Metric set description"; metricsSetParams.RawReportSize = 256; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -395,17 +377,7 @@ TEST_F(MetricStreamerTest, givenInvalidArgumentsWhenZetMetricStreamerReadDataIsC metricsSetParams.ShortName = "Metric set description"; metricsSetParams.RawReportSize = 256; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); - + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -503,16 +475,7 @@ TEST_F(MetricStreamerTest, givenValidArgumentsWhenZetMetricStreamerReadDataIsCal metricsSetParams.ShortName = "Metric set description"; metricsSetParams.RawReportSize = 256; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -625,16 +588,7 @@ TEST_F(MetricStreamerTest, givenInvalidArgumentsWhenZetCommandListAppendMetricSt metricsSetParams.ShortName = "Metric set description"; metricsSetParams.RawReportSize = 256; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); + openMetricsAdapter(); EXPECT_CALL(metricsDevice, GetParams()) .WillRepeatedly(Return(&metricsDeviceParams)); @@ -757,8 +711,7 @@ TEST_F(MetricStreamerTest, givenValidArgumentsWhenZetCommandListAppendMetricStre uint32_t markerValue = 0x12345678; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); + openMetricsAdapter(); EXPECT_CALL(*mockMetricEnumeration, isInitialized()) .Times(1) @@ -768,14 +721,6 @@ TEST_F(MetricStreamerTest, givenValidArgumentsWhenZetCommandListAppendMetricStre .Times(1) .WillOnce(Return(true)); - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); - EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockContextCreate(_, _, _)) .Times(1) .WillOnce(DoAll(::testing::SetArgPointee<2>(contextHandle), Return(StatusCode::Success))); @@ -905,8 +850,7 @@ TEST_F(MetricStreamerTest, givenMultipleMarkerInsertionsWhenZetCommandListAppend CommandBufferSize_1_0 commandBufferSize = {}; commandBufferSize.GpuMemorySize = 100; - EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery()) - .Times(0); + openMetricsAdapter(); EXPECT_CALL(*mockMetricEnumeration, isInitialized()) .Times(1) @@ -916,14 +860,6 @@ TEST_F(MetricStreamerTest, givenMultipleMarkerInsertionsWhenZetCommandListAppend .Times(1) .WillOnce(Return(true)); - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenMetricsDevice(_)) - .Times(1) - .WillOnce(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK))); - - EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockCloseMetricsDevice(_)) - .Times(1) - .WillOnce(Return(TCompletionCode::CC_OK)); - EXPECT_CALL(*mockMetricsLibrary->g_mockApi, MockContextCreate(_, _, _)) .Times(1) .WillOnce(DoAll(::testing::SetArgPointee<2>(contextHandle), Return(StatusCode::Success))); diff --git a/shared/source/os_interface/windows/wddm/wddm.cpp b/shared/source/os_interface/windows/wddm/wddm.cpp index 08381d7d87..2e8854080a 100644 --- a/shared/source/os_interface/windows/wddm/wddm.cpp +++ b/shared/source/os_interface/windows/wddm/wddm.cpp @@ -937,6 +937,10 @@ bool Wddm::verifyAdapterLuid(LUID adapterLuid) const { return adapterLuid.HighPart == hwDeviceId->getAdapterLuid().HighPart && adapterLuid.LowPart == hwDeviceId->getAdapterLuid().LowPart; } +LUID Wddm::getAdapterLuid() const { + return hwDeviceId->getAdapterLuid(); +} + VOID *Wddm::registerTrimCallback(PFND3DKMT_TRIMNOTIFICATIONCALLBACK callback, WddmResidencyController &residencyController) { if (DebugManager.flags.DoNotRegisterTrimCallback.get()) { return nullptr; diff --git a/shared/source/os_interface/windows/wddm/wddm.h b/shared/source/os_interface/windows/wddm/wddm.h index 159a9e2b5b..38246e6e21 100644 --- a/shared/source/os_interface/windows/wddm/wddm.h +++ b/shared/source/os_interface/windows/wddm/wddm.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2020 Intel Corporation + * Copyright (C) 2017-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -118,6 +118,7 @@ class Wddm { D3DKMT_HANDLE getPagingQueueSyncObject() const { return pagingQueueSyncObject; } inline Gdi *getGdi() const { return hwDeviceId->getGdi(); } MOCKABLE_VIRTUAL bool verifyAdapterLuid(LUID adapterLuid) const; + LUID getAdapterLuid() const; PFND3DKMT_ESCAPE getEscapeHandle() const; diff --git a/third_party/metrics_discovery/.revision b/third_party/metrics_discovery/.revision index 7ba7c122e5..7c3227197e 100644 --- a/third_party/metrics_discovery/.revision +++ b/third_party/metrics_discovery/.revision @@ -1 +1 @@ -0928b82f6242217637c3a89d01eb630c55a52ce7 \ No newline at end of file +17f4240027df2dd8981200f6d8cf5e20f8015fd3 \ No newline at end of file diff --git a/third_party/metrics_discovery/metrics_discovery_api.h b/third_party/metrics_discovery/metrics_discovery_api.h index 5c98e290a7..336bec7b48 100644 --- a/third_party/metrics_discovery/metrics_discovery_api.h +++ b/third_party/metrics_discovery/metrics_discovery_api.h @@ -1,80 +1,94 @@ -/*****************************************************************************\ +////////////////////////////////////////////////////////////////////////////// +// +// Copyright © 2019-2021, Intel Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// File Name: metrics_discovery_api.h +// +// Abstract: Interface for metrics discovery DLL +// +// Notes: +// +////////////////////////////////////////////////////////////////////////////// +#pragma once - Copyright © 2019, Intel Corporation - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the "Software"), - to deal in the Software without restriction, including without limitation - the rights to use, copy, modify, merge, publish, distribute, sublicense, - and/or sell copies of the Software, and to permit persons to whom the - Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - IN THE SOFTWARE. - - File Name: metrics_discovery_api.h - - Abstract: Interface for metrics discovery DLL - - Notes: - -\*****************************************************************************/ #include -#ifndef __METRICS_DISCOVERY_H_ -#define __METRICS_DISCOVERY_H_ - #ifdef _MSC_VER - #define MD_STDCALL __stdcall + #define MD_STDCALL __stdcall #else - #define MD_STDCALL + #define MD_STDCALL #endif // _MSC_VER +////////////////////////////////////////////////////////////////////////////////// +// Helper macro to check required API version. +// Combines major and minor into one, comparable 64bit value. +////////////////////////////////////////////////////////////////////////////////// +#define MD_API_VERSION_COMBINE_MAJOR_MINOR( version ) \ + ( ( uint64_t )( version ).MajorNumber << 32 | ( uint64_t )( version ).MinorNumber ) + +////////////////////////////////////////////////////////////////////////////////// +// Macro to check required API version. +// Uses TApiVersion_1_0 struct. +////////////////////////////////////////////////////////////////////////////////// +#define MD_API_VERSION_AT_LEAST( requiredVersion, currentVersion ) \ + ( MD_API_VERSION_COMBINE_MAJOR_MINOR( ( currentVersion ) ) > MD_API_VERSION_COMBINE_MAJOR_MINOR( ( requiredVersion ) ) || MD_API_VERSION_COMBINE_MAJOR_MINOR( ( currentVersion ) ) == MD_API_VERSION_COMBINE_MAJOR_MINOR( ( requiredVersion ) ) && ( currentVersion ).BuildNumber >= ( requiredVersion ).BuildNumber ) + +////////////////////////////////////////////////////////////////////////////////// +// API build number: +////////////////////////////////////////////////////////////////////////////////// +#define MD_API_BUILD_NUMBER_CURRENT 131 + namespace MetricsDiscovery { -//*****************************************************************************/ -// API major version number: -//*****************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // API major version number: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EMD_API_MAJOR_VERSION { MD_API_MAJOR_NUMBER_1 = 1, MD_API_MAJOR_NUMBER_CURRENT = MD_API_MAJOR_NUMBER_1, MD_API_MAJOR_NUMBER_CEIL = 0xFFFFFFFF - } MD_API_MAJOR_VERSION; -//*****************************************************************************/ -// API minor version number: -//*****************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // API minor version number: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EMD_API_MINOR_VERSION { MD_API_MINOR_NUMBER_0 = 0, - MD_API_MINOR_NUMBER_1 = 1, // CalculationAPI - MD_API_MINOR_NUMBER_2 = 2, // OverridesAPI - MD_API_MINOR_NUMBER_3 = 3, // BatchBuffer Sampling (aka DMA Sampling) - MD_API_MINOR_NUMBER_4 = 4, // GT dependent MetricSets - MD_API_MINOR_NUMBER_5 = 5, // MaxValue calculation for CalculationAPI - MD_API_MINOR_NUMBER_CURRENT = MD_API_MINOR_NUMBER_5, + MD_API_MINOR_NUMBER_1 = 1, // CalculationAPI + MD_API_MINOR_NUMBER_2 = 2, // OverridesAPI + MD_API_MINOR_NUMBER_3 = 3, // BatchBuffer Sampling (aka DMA Sampling) + MD_API_MINOR_NUMBER_4 = 4, // GT dependent MetricSets + MD_API_MINOR_NUMBER_5 = 5, // MaxValue calculation for CalculationAPI + MD_API_MINOR_NUMBER_6 = 6, // Multi adapter support + MD_API_MINOR_NUMBER_7 = 7, + MD_API_MINOR_NUMBER_8 = 8, // TAdapterParams update + MD_API_MINOR_NUMBER_CURRENT = MD_API_MINOR_NUMBER_8, MD_API_MINOR_NUMBER_CEIL = 0xFFFFFFFF - } MD_API_MINOR_VERSION; -//*****************************************************************************/ -// API build number: -//*****************************************************************************/ - #define MD_API_BUILD_NUMBER_CURRENT 115 - -//*****************************************************************************/ -// Completion codes: -//*****************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Completion codes: + ////////////////////////////////////////////////////////////////////////////////// typedef enum ECompletionCode { CC_OK = 0, @@ -85,70 +99,65 @@ namespace MetricsDiscovery CC_WAIT_TIMEOUT = 5, CC_TRY_AGAIN = 6, CC_INTERRUPTED = 7, - // ... CC_ERROR_INVALID_PARAMETER = 40, CC_ERROR_NO_MEMORY = 41, CC_ERROR_GENERAL = 42, CC_ERROR_FILE_NOT_FOUND = 43, CC_ERROR_NOT_SUPPORTED = 44, - // ... CC_LAST_1_0 = 45 - } TCompletionCode; + /* Forward declarations */ -/* Forward declarations */ - -//*******************************************************************************/ -// Abstract interface for the GPU metrics root object. -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Abstract interface for the GPU metrics root object. + ////////////////////////////////////////////////////////////////////////////////// class IMetricsDevice_1_0; class IMetricsDevice_1_1; class IMetricsDevice_1_2; class IMetricsDevice_1_5; -//*******************************************************************************/ -// Abstract interface for Metrics Device overrides. -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Abstract interface for Metrics Device overrides. + ////////////////////////////////////////////////////////////////////////////////// class IOverride_1_2; -//*******************************************************************************/ -// Abstract interface for the metrics groups that can be collected concurrently -// to another group. -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Abstract interface for the metrics groups that can be collected concurrently + // to another group. + ////////////////////////////////////////////////////////////////////////////////// class IConcurrentGroup_1_0; class IConcurrentGroup_1_1; class IConcurrentGroup_1_5; -//*******************************************************************************/ -// Abstract interface for the metric sets mapping to different HW configuration -// that should be used exclusively to each other metric set in the concurrent -// group. -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Abstract interface for the metric sets mapping to different HW configuration + // that should be used exclusively to each other metric set in the concurrent + // group. + ////////////////////////////////////////////////////////////////////////////////// class IMetricSet_1_0; class IMetricSet_1_1; class IMetricSet_1_4; class IMetricSet_1_5; -//*******************************************************************************/ -// Abstract interface for the metric that is sampled. -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Abstract interface for the metric that is sampled. + ////////////////////////////////////////////////////////////////////////////////// class IMetric_1_0; -//*******************************************************************************/ -// Abstract interface for the measurement information (report reason, etc.). -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Abstract interface for the measurement information (report reason, etc.). + ////////////////////////////////////////////////////////////////////////////////// class IInformation_1_0; -//*******************************************************************************/ -// Abstract interface for the metric read and normalization equation. -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Abstract interface for the metric read and normalization equation. + ////////////////////////////////////////////////////////////////////////////////// class IEquation_1_0; - -//*******************************************************************************/ -// Value types: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Value types: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EValueType { VALUE_TYPE_UINT32, @@ -158,16 +167,25 @@ namespace MetricsDiscovery VALUE_TYPE_CSTRING, // ... VALUE_TYPE_LAST, - } TValueType; -//*******************************************************************************/ -// Typed value: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Byte Array: + ////////////////////////////////////////////////////////////////////////////////// + typedef struct SByteArray_1_0 + { + uint32_t Size; + uint8_t* Data; + } TByteArray_1_0; + + ////////////////////////////////////////////////////////////////////////////////// + // Typed value: + ////////////////////////////////////////////////////////////////////////////////// typedef struct STypedValue_1_0 { TValueType ValueType; - union { + union + { uint32_t ValueUInt32; uint64_t ValueUInt64; struct @@ -175,306 +193,366 @@ namespace MetricsDiscovery uint32_t Low; uint32_t High; } ValueUInt64Fields; - float ValueFloat; - bool ValueBool; - char* ValueCString; + float ValueFloat; + bool ValueBool; + char* ValueCString; }; - } TTypedValue_1_0; -//*******************************************************************************/ -// Global symbol: -// Global symbols will be available to describe SKU specific information. -// Example global symbols: -// "EuCoresTotalCount", "EuThreadsCount", "EuSlicesTotalCount", "EuSubslicesTotalCount", -// "SamplersTotalCount", "PciDeviceId", "NumberOfShadingUnits", "GpuTimestampFrequency", -// "MaxTimestamp", "GpuMinFrequencyMHz", "GpuMaxFrequencyMHz" -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Global symbol: + // Global symbols will be available to describe SKU specific information. + // Example global symbols: + // "EuCoresTotalCount", "EuThreadsCount", "EuSlicesTotalCount", "EuSubslicesTotalCount", + // "SamplersTotalCount", "PciDeviceId", "NumberOfShadingUnits", "GpuTimestampFrequency", + // "MaxTimestamp", "GpuMinFrequencyMHz", "GpuMaxFrequencyMHz" + ////////////////////////////////////////////////////////////////////////////////// typedef struct SGlobalSymbol_1_0 { const char* SymbolName; TTypedValue_1_0 SymbolTypedValue; - } TGlobalSymbol_1_0; -//*******************************************************************************/ -// Global parameters of Metrics Device: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // API version: + ////////////////////////////////////////////////////////////////////////////////// + typedef struct SApiVersion_1_0 + { + uint32_t MajorNumber; + uint32_t MinorNumber; + uint32_t BuildNumber; + } TApiVersion_1_0; + + ////////////////////////////////////////////////////////////////////////////////// + // Global parameters of Metrics Device: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SMetricsDeviceParams_1_0 { // API version - struct SApiVersion - { - uint32_t MajorNumber; - uint32_t MinorNumber; - uint32_t BuildNumber; - } Version; - - uint32_t ConcurrentGroupsCount; - - uint32_t GlobalSymbolsCount; - uint32_t DeltaFunctionsCount; - uint32_t EquationElementTypesCount; - uint32_t EquationOperationsCount; - - const char* DeviceName; - + TApiVersion_1_0 Version; + uint32_t ConcurrentGroupsCount; + uint32_t GlobalSymbolsCount; + uint32_t DeltaFunctionsCount; + uint32_t EquationElementTypesCount; + uint32_t EquationOperationsCount; + const char* DeviceName; } TMetricsDeviceParams_1_0; -//*******************************************************************************/ -// Global parameters of Metrics Device 1.2: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Global parameters of Metrics Device 1.2: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SMetricsDeviceParams_1_2 : public SMetricsDeviceParams_1_0 { uint32_t OverrideCount; - } TMetricsDeviceParams_1_2; -//*******************************************************************************/ -// Metric API types: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Metric API types: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EMetricApiType { - API_TYPE_IOSTREAM = 0x00000001, // API independent method - API_TYPE_DX9 = 0x00000002, - API_TYPE_DX10 = 0x00000004, - API_TYPE_DX11 = 0x00000008, - API_TYPE_OGL = 0x00000010, - API_TYPE_OGL4_X = 0x00000020, - API_TYPE_OCL = 0x00000040, - API_TYPE_MEDIA = 0x00000080, // Only option would be using DmaBuffer sampling - API_TYPE_DX12 = 0x00000100, - API_TYPE_BBSTREAM = 0x00000200, - API_TYPE_VULKAN = 0x00000400, - API_TYPE_RESERVED = 0x00000800, - API_TYPE_ALL = 0xffffffff - + API_TYPE_IOSTREAM = 0x00000001, // API independent method + API_TYPE_DX9 = 0x00000002, + API_TYPE_DX10 = 0x00000004, + API_TYPE_DX11 = 0x00000008, + API_TYPE_OGL = 0x00000010, + API_TYPE_OGL4_X = 0x00000020, + API_TYPE_OCL = 0x00000040, + API_TYPE_MEDIA = 0x00000080, // Only option would be using DmaBuffer sampling + API_TYPE_DX12 = 0x00000100, + API_TYPE_BBSTREAM = 0x00000200, + API_TYPE_VULKAN = 0x00000400, + API_TYPE_RESERVED = 0x00000800, + API_TYPE_ALL = 0xffffffff } TMetricApiType; -//*******************************************************************************/ -// Measurement types: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Measurement types: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EMeasurementType { MEASUREMENT_TYPE_SNAPSHOT_IO = 0x00000001, MEASUREMENT_TYPE_SNAPSHOT_QUERY = 0x00000002, MEASUREMENT_TYPE_DELTA_QUERY = 0x00000004, MEASUREMENT_TYPE_ALL = 0x0000ffff, - } TMeasurementType; -//*******************************************************************************/ -// Usage flags: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Usage flags: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EMetricUsageFlag { - USAGE_FLAG_OVERVIEW = 0x00000001, // GPU system overview metric - // Useful for high level workload characterization - USAGE_FLAG_INDICATE = 0x00000002, // Metric indicating a performance problem - // Useful when comparing with threshold - USAGE_FLAG_CORRELATE = 0x00000004, // Metric correlating with performance problem - // Useful for proving to false only - //... - USAGE_FLAG_SYSTEM = 0x00000020, // Metric useful at system level - USAGE_FLAG_FRAME = 0x00000040, // Metric useful at frame level - USAGE_FLAG_BATCH = 0x00000080, // Metric useful at batch level - USAGE_FLAG_DRAW = 0x00000100, // Metric useful at draw level - - // ... - USAGE_FLAG_TIER_1 = 0x00000400, - USAGE_FLAG_TIER_2 = 0x00000800, - USAGE_FLAG_TIER_3 = 0x00001000, - USAGE_FLAG_TIER_4 = 0x00002000, - USAGE_FLAG_GLASS_JAW = 0x00004000, - - USAGE_FLAG_ALL = 0x0000ffff, - + USAGE_FLAG_OVERVIEW = 0x00000001, // GPU system overview metric, useful for high level workload characterization + USAGE_FLAG_INDICATE = 0x00000002, // Metric indicating a performance problem, useful when comparing with threshold + USAGE_FLAG_CORRELATE = 0x00000004, // Metric correlating with performance problem, useful for proving to false only + USAGE_FLAG_SYSTEM = 0x00000020, // Metric useful at system level + USAGE_FLAG_FRAME = 0x00000040, // Metric useful at frame level + USAGE_FLAG_BATCH = 0x00000080, // Metric useful at batch level + USAGE_FLAG_DRAW = 0x00000100, // Metric useful at draw level + USAGE_FLAG_TIER_1 = 0x00000400, + USAGE_FLAG_TIER_2 = 0x00000800, + USAGE_FLAG_TIER_3 = 0x00001000, + USAGE_FLAG_TIER_4 = 0x00002000, + USAGE_FLAG_GLASS_JAW = 0x00004000, + USAGE_FLAG_ALL = 0x0000ffff, } TMetricUsageFlag; -//*******************************************************************************/ -// Sampling types: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Sampling types: + ////////////////////////////////////////////////////////////////////////////////// typedef enum ESamplingType { - SAMPLING_TYPE_OA_TIMER = 0x00000001, - SAMPLING_TYPE_OA_EVENT = 0x00000002, - SAMPLING_TYPE_GPU_QUERY = 0x00000004, - SAMPLING_TYPE_DMA_BUFFER = 0x00000008,// Possible future extension for media - SAMPLING_TYPE_ALL = 0x0000ffff, - + SAMPLING_TYPE_OA_TIMER = 0x00000001, + SAMPLING_TYPE_OA_EVENT = 0x00000002, + SAMPLING_TYPE_GPU_QUERY = 0x00000004, + SAMPLING_TYPE_DMA_BUFFER = 0x00000008, // Possible future extension for media + SAMPLING_TYPE_ALL = 0x0000ffff, } TSamplingType; -//*******************************************************************************/ -// Metric categories: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Metric categories: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EMetricCategory { GPU_RENDER = 0x0001, GPU_COMPUTE = 0x0002, GPU_MEDIA = 0x0004, - GPU_GENERIC = 0x0008, // Does not belong to any specific category like memory traffic - + GPU_GENERIC = 0x0008, // Does not belong to any specific category like memory traffic } TMetricCategory; -//*******************************************************************************/ -// IoStream read flags: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // IoStream read flags: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EIoReadFlag { IO_READ_FLAG_DROP_OLD_REPORTS = 0x00000001, IO_READ_FLAG_GET_CONTEXT_ID_TAGS = 0x00000002, - } TIoReadFlag; -//*******************************************************************************/ -// Override modes: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Override modes: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EOverrideMode { OVERRIDE_MODE_GLOBAL = 0x0001, OVERRIDE_MODE_LOCAL = 0x0002, - } TOverrideMode; -//*******************************************************************************/ -// Global parameters of Concurrent Group: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Adapter capability flags: + ////////////////////////////////////////////////////////////////////////////////// + typedef enum EAdapterCapability + { + ADAPTER_CAPABILITY_UNDEFINED = 0, + ADAPTER_CAPABILITY_RENDER_SUPPORTED = 1 << 0, + } TAdapterCapability; + + ////////////////////////////////////////////////////////////////////////////////// + // Adapter types: + ////////////////////////////////////////////////////////////////////////////////// + typedef enum EAdapterType + { + ADAPTER_TYPE_UNDEFINED = 0, + ADAPTER_TYPE_INTEGRATED, + ADAPTER_TYPE_DISCRETE, + } TAdapterType; + + ////////////////////////////////////////////////////////////////////////////////// + // Adapter ID types: + ////////////////////////////////////////////////////////////////////////////////// + typedef enum EAdapterIdType + { + ADAPTER_ID_TYPE_UNDEFINED = 0, + ADAPTER_ID_TYPE_LUID, + ADAPTER_ID_TYPE_MAJOR_MINOR, + } TAdapterIdType; + + ////////////////////////////////////////////////////////////////////////////////// + // LUID (locally unique identifier) adapter ID: + ////////////////////////////////////////////////////////////////////////////////// + typedef struct SAdapterIdLuid_1_6 + { + uint32_t LowPart; + int32_t HighPart; + } TAdapterIdLuid_1_6; + + ////////////////////////////////////////////////////////////////////////////////// + // Major / minor pair adapter ID: + ////////////////////////////////////////////////////////////////////////////////// + typedef struct SAdapterIdMajorMinor_1_6 + { + int32_t Major; + int32_t Minor; + } TAdapterIdMajorMinor_1_6; + + ////////////////////////////////////////////////////////////////////////////////// + // Adapter ID: + ////////////////////////////////////////////////////////////////////////////////// + typedef struct SAdapterId_1_6 + { + TAdapterIdType Type; + union + { + TAdapterIdLuid_1_6 Luid; + TAdapterIdMajorMinor_1_6 MajorMinor; + }; + } TAdapterId_1_6; + + ////////////////////////////////////////////////////////////////////////////////// + // Global parameters of GPU adapter: + ////////////////////////////////////////////////////////////////////////////////// + typedef struct SAdapterParams_1_6 + { + const char* ShortName; + TAdapterId_1_6 SystemId; // Operating system specific adapter id + uint32_t VendorId; + uint32_t SubVendorId; + uint32_t DeviceId; + uint32_t Platform; + uint32_t BusNumber; + uint32_t DeviceNumber; + uint32_t FunctionNumber; + TAdapterType Type; // Adapter type, e.g. integrated, discrete + uint32_t CapabilityMask; // Consists of TAdapterCapability flags, e.g. RENDER_SUPPORTED + } TAdapterParams_1_6; + + ////////////////////////////////////////////////////////////////////////////////// + // Global parameters of GPU adapter: + ////////////////////////////////////////////////////////////////////////////////// + typedef struct SAdapterParams_1_8 : public SAdapterParams_1_6 + { + uint32_t DomainNumber; + } TAdapterParams_1_8; + + ////////////////////////////////////////////////////////////////////////////////// + // Global parameters of Adapter Group: + ////////////////////////////////////////////////////////////////////////////////// + typedef struct SAdapterGroupParams_1_6 + { + // API version + TApiVersion_1_0 Version; + uint32_t AdapterCount; + } TAdapterGroupParams_1_6; + + ////////////////////////////////////////////////////////////////////////////////// + // Global parameters of Concurrent Group: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SConcurrentGroupParams_1_0 { - const char* SymbolName; // For example "PerfMon" or "OA" or "PipeStats" - const char* Description; // For example "PerfMon and ODLAT Uncore ring counters" - - uint32_t MeasurementTypeMask; - - uint32_t MetricSetsCount; - uint32_t IoMeasurementInformationCount; - uint32_t IoGpuContextInformationCount; + const char* SymbolName; // For example "PerfMon" or "OA" or "PipeStats" + const char* Description; // For example "PerfMon and ODLAT Uncore ring counters" + uint32_t MeasurementTypeMask; + uint32_t MetricSetsCount; + uint32_t IoMeasurementInformationCount; + uint32_t IoGpuContextInformationCount; } TConcurrentGroupParams_1_0; -//*******************************************************************************/ -// Global parameters of an Override: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Global parameters of an Override: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SOverrideParams_1_2 { - const char* SymbolName; // For example "FrequencyOverride" - const char* Description; // For example "Overrides device GPU frequency with a static value." - - uint32_t ApiMask; - uint32_t PlatformMask; - - uint32_t OverrideModeMask; + const char* SymbolName; // For example "FrequencyOverride" + const char* Description; // For example "Overrides device GPU frequency with a static value." + uint32_t ApiMask; + uint32_t PlatformMask; + uint32_t OverrideModeMask; } TOverrideParams_1_2; -//*******************************************************************************/ -// Base params of SetOverride method: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Base params of SetOverride method: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SSetOverrideParams_1_2 { bool Enable; - } TSetOverrideParams_1_2; -//*******************************************************************************/ -// Frequency override specific SetOverride params: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Frequency override specific SetOverride params: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SSetFrequencyOverrideParams_1_2 : SSetOverrideParams_1_2 { uint32_t FrequencyMhz; uint32_t Pid; - } TSetFrequencyOverrideParams_1_2; - -//*******************************************************************************/ -// Query override specific SetOverride params: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Query override specific SetOverride params: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SSetQueryOverrideParams_1_2 : SSetOverrideParams_1_2 { - uint32_t Period; // Nanoseconds - + uint32_t Period; // Nanoseconds } TSetQueryOverrideParams_1_2; -//*******************************************************************************/ -// Driver override params: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Driver override params: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SSetDriverOverrideParams_1_2 : SSetOverrideParams_1_2 { uint32_t Value; + } TSetDriverOverrideParams_1_2; - } SSetDriverOverrideParams_1_2; - -//*******************************************************************************/ -// API specific id: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // API specific id: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SApiSpecificId_1_0 { - uint32_t D3D9QueryId; // D3D9 Query ID - uint32_t D3D9Fourcc; // D3D9 FourCC - uint32_t D3D1XQueryId; // D3D1X Query ID - uint32_t D3D1XDevDependentId; // D3D1X device dependent counter ID - const char* D3D1XDevDependentName; // Device dependent counter name - uint32_t OGLQueryIntelId; // Intel OGL query extension ID - const char* OGLQueryIntelName; // Intel OGL query extension name - uint32_t OGLQueryARBTargetId; // ARB OGL Query Target ID - uint32_t OCL; // OCL configuration ID - uint32_t HwConfigId; // Config ID for IO stream - uint32_t placeholder[1]; - + uint32_t D3D9QueryId; // D3D9 Query ID + uint32_t D3D9Fourcc; // D3D9 FourCC + uint32_t D3D1XQueryId; // D3D1X Query ID + uint32_t D3D1XDevDependentId; // D3D1X device dependent counter ID + const char* D3D1XDevDependentName; // Device dependent counter name + uint32_t OGLQueryIntelId; // Intel OGL query extension ID + const char* OGLQueryIntelName; // Intel OGL query extension name + uint32_t OGLQueryARBTargetId; // ARB OGL Query Target ID + uint32_t OCL; // OCL configuration ID + uint32_t HwConfigId; // Config ID for IO stream + uint32_t placeholder[1]; } TApiSpecificId_1_0; -//*******************************************************************************/ -// Global parameters of Metric set: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Global parameters of Metric set: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SMetricSetParams_1_0 { - const char* SymbolName; // For example "Dx11Tessellation" - const char* ShortName; // For example "DX11 Tessellation Metrics Set" - - uint32_t ApiMask; - uint32_t CategoryMask; - - uint32_t RawReportSize; // As in HW - uint32_t QueryReportSize; // As in Query API - - uint32_t MetricsCount; - uint32_t InformationCount; - uint32_t ComplementarySetsCount; - - TApiSpecificId_1_0 ApiSpecificId; - - uint32_t PlatformMask; - //... - + const char* SymbolName; // For example "Dx11Tessellation" + const char* ShortName; // For example "DX11 Tessellation Metrics Set" + uint32_t ApiMask; + uint32_t CategoryMask; + uint32_t RawReportSize; // As in HW + uint32_t QueryReportSize; // As in Query API + uint32_t MetricsCount; + uint32_t InformationCount; + uint32_t ComplementarySetsCount; + TApiSpecificId_1_0 ApiSpecificId; + uint32_t PlatformMask; } TMetricSetParams_1_0; -//*******************************************************************************/ -// GT differenced MetricSet params: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // GT differenced MetricSet params: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SMetricSetParams_1_4 : SMetricSetParams_1_0 { uint32_t GtMask; - } TMetricSetParams_1_4; -//*******************************************************************************/ -// Metric result types: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Metric result types: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EMetricResultType { RESULT_UINT32, RESULT_UINT64, RESULT_BOOL, RESULT_FLOAT, - // ... RESULT_LAST - } TMetricResultType; -//*******************************************************************************/ -// Metric types: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Metric types: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EMetricType { METRIC_TYPE_DURATION, @@ -485,14 +563,12 @@ namespace MetricsDiscovery METRIC_TYPE_FLAG, METRIC_TYPE_RATIO, METRIC_TYPE_RAW, - // ... METRIC_TYPE_LAST - } TMetricType; -//*******************************************************************************/ -// Information types: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Information types: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EInformationType { INFORMATION_TYPE_REPORT_REASON, @@ -502,14 +578,12 @@ namespace MetricsDiscovery INFORMATION_TYPE_CONTEXT_ID_TAG, INFORMATION_TYPE_SAMPLE_PHASE, INFORMATION_TYPE_GPU_NODE, - // ... INFORMATION_TYPE_LAST - } TInformationType; -//*******************************************************************************/ -// Report reasons: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Report reasons: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EReportReason { REPORT_REASON_UNDEFINED = 0x0000, @@ -522,40 +596,35 @@ namespace MetricsDiscovery REPORT_REASON_QUERY_DEFAULT = 0x0100, REPORT_REASON_QUERY_INTERNAL_RESOLVE = 0x0200, REPORT_REASON_QUERY_INTERNAL_CLEAR = 0x0400, - } TReportReason; -//*******************************************************************************/ -// Sample phase: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Sample phase: + ////////////////////////////////////////////////////////////////////////////////// typedef enum ESamplePhase { SAMPLE_PHASE_END, SAMPLE_PHASE_BEGIN, - // ... SAMPLE_PHASE_LAST - } TSamplePhase; -//*******************************************************************************/ -// Gpu Node: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Gpu Node: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EInformationGpuNode { - INFORMATION_GPUNODE_3D = 0, // Available by default on all platform - INFORMATION_GPUNODE_VIDEO = 1, // Available on CTG+ - INFORMATION_GPUNODE_BLT = 2, // Available on GT - INFORMATION_GPUNODE_VE = 3, // Available on HSW+ (VideoEnhancement) - INFORMATION_GPUNODE_VCS2 = 4, // Available on BDW+ GT3+ - INFORMATION_GPUNODE_REAL_MAX = 5, // All nodes beyond this are virtual nodes - they don't have an actual GPU engine - // ... + INFORMATION_GPUNODE_3D = 0, // Available by default on all platform + INFORMATION_GPUNODE_VIDEO = 1, // Available on CTG+ + INFORMATION_GPUNODE_BLT = 2, // Available on GT + INFORMATION_GPUNODE_VE = 3, // Available on HSW+ (VideoEnhancement) + INFORMATION_GPUNODE_VCS2 = 4, // Available on BDW+ GT3+ + INFORMATION_GPUNODE_REAL_MAX = 5, // All nodes beyond this are virtual nodes - they don't have an actual GPU engine INFORMATION_GPUNODE_LAST - } TInformationGpuNode; -//*******************************************************************************/ -// Hardware unit types: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Hardware unit types: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EHwUnitType { HW_UNIT_GPU, @@ -564,71 +633,61 @@ namespace MetricsDiscovery HW_UNIT_SUBSLICE_BANK, HW_UNIT_EU_UNIT, HW_UNIT_UNCORE, - // ... + HW_UNIT_DUALSUBSLICE, HW_UNIT_LAST - } THwUnitType; -//*******************************************************************************/ -// Delta function types: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Delta function types: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EDeltaFunctionType { DELTA_FUNCTION_NULL = 0, DELTA_N_BITS, - DELTA_BOOL_OR, // Logic OR - good for exceptions - DELTA_BOOL_XOR, // Logic XOR - good to check if bits were changed - DELTA_GET_PREVIOUS, // Preserve previous value - DELTA_GET_LAST, // Preserve last value - DELTA_NS_TIME, // Delta for nanosecond timestamps (GPU timestamp wraps at 32 bits but was value multiplied by 80) + DELTA_BOOL_OR, // Logic OR - good for exceptions + DELTA_BOOL_XOR, // Logic XOR - good to check if bits were changed + DELTA_GET_PREVIOUS, // Preserve previous value + DELTA_GET_LAST, // Preserve last value + DELTA_NS_TIME, // Delta for nanosecond timestamps (GPU timestamp wraps at 32 bits but was value multiplied by 80) DELTA_FUNCTION_LAST_1_0 - } TDeltaFunctionType; -//*******************************************************************************/ -// Delta function: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Delta function: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SDeltaFunction_1_0 { - TDeltaFunctionType FunctionType; - union { - uint32_t BitsCount; // Used for DELTA_N_BITS to specify bits count + TDeltaFunctionType FunctionType; + union + { + uint32_t BitsCount; // Used for DELTA_N_BITS to specify bits count }; - } TDeltaFunction_1_0; -//*******************************************************************************/ -// Equation element types: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Equation element types: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EEquationElementType { EQUATION_ELEM_OPERATION, // See TEquationOperation enumeration - - EQUATION_ELEM_RD_BITFIELD, - EQUATION_ELEM_RD_UINT8, - EQUATION_ELEM_RD_UINT16, - EQUATION_ELEM_RD_UINT32, - EQUATION_ELEM_RD_UINT64, - EQUATION_ELEM_RD_FLOAT, - - // Extended RD operation + EQUATION_ELEM_RD_BITFIELD, // + EQUATION_ELEM_RD_UINT8, // + EQUATION_ELEM_RD_UINT16, // + EQUATION_ELEM_RD_UINT32, // + EQUATION_ELEM_RD_UINT64, // + EQUATION_ELEM_RD_FLOAT, // EQUATION_ELEM_RD_40BIT_CNTR, // Assemble 40 bit counter that is in two locations, result in unsigned integer 64b - - EQUATION_ELEM_IMM_UINT64, - EQUATION_ELEM_IMM_FLOAT, + EQUATION_ELEM_IMM_UINT64, // + EQUATION_ELEM_IMM_FLOAT, // EQUATION_ELEM_SELF_COUNTER_VALUE, // Defined by $Self token, the UINT64 result of DeltaFunction for IO or QueryReadEquation EQUATION_ELEM_GLOBAL_SYMBOL, // Defined by $"SymbolName", available in MetricsDevice SymbolTable EQUATION_ELEM_LOCAL_COUNTER_SYMBOL, // Defined by $"SymbolName", refers to counter delta value in the local set EQUATION_ELEM_OTHER_SET_COUNTER_SYMBOL, // Defined by concatenated string of $"setSymbolName/SymbolName", refers to counter // Delta value in the other set - EQUATION_ELEM_LOCAL_METRIC_SYMBOL, // Defined by $$"SymbolName", refers to metric normalized value in the local set EQUATION_ELEM_OTHER_SET_METRIC_SYMBOL, // Defined by concatenated string of $$"setSymbolName/SymbolName", refers to metric // Normalized value in the other set - EQUATION_ELEM_INFORMATION_SYMBOL, // Defined by i$"SymbolName", refers to information value type only - - // Extended types - standard normalization functions EQUATION_ELEM_STD_NORM_GPU_DURATION, // Action is $Self $GpuCoreClocks FDIV 100 FMUL EQUATION_ELEM_STD_NORM_EU_AGGR_DURATION, // Action is $Self $GpuCoreClocks $EuCoresTotalCount UMUL FDIV 100 FMUL @@ -636,536 +695,585 @@ namespace MetricsDiscovery } TEquationElementType; -//*******************************************************************************/ -// Equation operations: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Equation operations: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EEquationOperation { - EQUATION_OPER_RSHIFT, // 64b unsigned integer right shift - EQUATION_OPER_LSHIFT, // 64b unsigned integer left shift - EQUATION_OPER_AND, // Bitwise AND of two unsigned integers, 64b each - EQUATION_OPER_OR, // Bitwise OR of two unsigned integers, 64b each - EQUATION_OPER_XOR, // Bitwise XOR of two unsigned integers, 64b each - EQUATION_OPER_XNOR, // Bitwise XNOR of two unsigned integers, 64b each - EQUATION_OPER_AND_L, // Logical AND (C-like "&&") of two unsigned integers, 64b each, result is true(1) if both values are true(greater than 0) - EQUATION_OPER_EQUALS, // Equality (C-like "==") of two unsigned integers, 64b each, result is true(1) or false(0) - EQUATION_OPER_UADD, // Unsigned integer add, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b - EQUATION_OPER_USUB, // Unsigned integer subtract, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b - EQUATION_OPER_UMUL, // Unsigned integer mul, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b - EQUATION_OPER_UDIV, // Unsigned integer div, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b - EQUATION_OPER_FADD, // Floating point add, arguments are casted to be 32b floating points, result is a 32b float - EQUATION_OPER_FSUB, // Floating point subtract, arguments are casted to be 32b floating points, result is a 32b float - EQUATION_OPER_FMUL, // Floating point multiply, arguments are casted to be 32b floating points, result is a 32b float - EQUATION_OPER_FDIV, // Floating point divide, arguments are casted to be 32b floating points, result is a 32b float - - EQUATION_OPER_UGT, // 64b unsigned integers comparison of is greater than, result is bool true(1) or false(0) - EQUATION_OPER_ULT, // 64b unsigned integers comparison of is less than, result is bool true(1) or false(0) - EQUATION_OPER_UGTE, // 64b unsigned integers comparison of is greater than or equal, result is bool true(1) or false(0) - EQUATION_OPER_ULTE, // 64b unsigned integers comparison of is less than or equal, result is bool true(1) or false(0) - - EQUATION_OPER_FGT, // 32b floating point numbers comparison of is greater than, result is bool true(1) or false(0) - EQUATION_OPER_FLT, // 32b floating point numbers comparison of is less than, result is bool true(1) or false(0) - EQUATION_OPER_FGTE, // 32b floating point numbers comparison of is greater than or equal, result is bool true(1) or false(0) - EQUATION_OPER_FLTE, // 32b floating point numbers comparison of is less than or equal, result is bool true(1) or false(0) - - EQUATION_OPER_UMIN, // Unsigned integer MIN function, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b - EQUATION_OPER_UMAX, // Unsigned integer MAX function, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b - - EQUATION_OPER_FMIN, // Floating point MIN function, arguments are casted to be 32b floating points, result is a 32b float - EQUATION_OPER_FMAX, // Floating point MAX function, arguments are casted to be 32b floating points, result is a 32b float - + EQUATION_OPER_RSHIFT, // 64b unsigned integer right shift + EQUATION_OPER_LSHIFT, // 64b unsigned integer left shift + EQUATION_OPER_AND, // Bitwise AND of two unsigned integers, 64b each + EQUATION_OPER_OR, // Bitwise OR of two unsigned integers, 64b each + EQUATION_OPER_XOR, // Bitwise XOR of two unsigned integers, 64b each + EQUATION_OPER_XNOR, // Bitwise XNOR of two unsigned integers, 64b each + EQUATION_OPER_AND_L, // Logical AND (C-like "&&") of two unsigned integers, 64b each, result is true(1) if both values are true(greater than 0) + EQUATION_OPER_EQUALS, // Equality (C-like "==") of two unsigned integers, 64b each, result is true(1) or false(0) + EQUATION_OPER_UADD, // Unsigned integer add, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b + EQUATION_OPER_USUB, // Unsigned integer subtract, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b + EQUATION_OPER_UMUL, // Unsigned integer mul, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b + EQUATION_OPER_UDIV, // Unsigned integer div, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b + EQUATION_OPER_FADD, // Floating point add, arguments are casted to be 32b floating points, result is a 32b float + EQUATION_OPER_FSUB, // Floating point subtract, arguments are casted to be 32b floating points, result is a 32b float + EQUATION_OPER_FMUL, // Floating point multiply, arguments are casted to be 32b floating points, result is a 32b float + EQUATION_OPER_FDIV, // Floating point divide, arguments are casted to be 32b floating points, result is a 32b float + EQUATION_OPER_UGT, // 64b unsigned integers comparison of is greater than, result is bool true(1) or false(0) + EQUATION_OPER_ULT, // 64b unsigned integers comparison of is less than, result is bool true(1) or false(0) + EQUATION_OPER_UGTE, // 64b unsigned integers comparison of is greater than or equal, result is bool true(1) or false(0) + EQUATION_OPER_ULTE, // 64b unsigned integers comparison of is less than or equal, result is bool true(1) or false(0) + EQUATION_OPER_FGT, // 32b floating point numbers comparison of is greater than, result is bool true(1) or false(0) + EQUATION_OPER_FLT, // 32b floating point numbers comparison of is less than, result is bool true(1) or false(0) + EQUATION_OPER_FGTE, // 32b floating point numbers comparison of is greater than or equal, result is bool true(1) or false(0) + EQUATION_OPER_FLTE, // 32b floating point numbers comparison of is less than or equal, result is bool true(1) or false(0) + EQUATION_OPER_UMIN, // Unsigned integer MIN function, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b + EQUATION_OPER_UMAX, // Unsigned integer MAX function, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b + EQUATION_OPER_FMIN, // Floating point MIN function, arguments are casted to be 32b floating points, result is a 32b float + EQUATION_OPER_FMAX, // Floating point MAX function, arguments are casted to be 32b floating points, result is a 32b float EQUATION_OPER_LAST_1_0 - } TEquationOperation; -//*******************************************************************************/ -// Read params: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Read params: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SReadParams_1_0 { - uint32_t ByteOffset; - uint32_t BitOffset; - uint32_t BitsCount; - uint32_t ByteOffsetExt; - + uint32_t ByteOffset; + uint32_t BitOffset; + uint32_t BitsCount; + uint32_t ByteOffsetExt; } TReadParams_1_0; -//*******************************************************************************/ -// Equation element: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Equation element: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SEquationElement_1_0 { - TEquationElementType Type; + TEquationElementType Type; union { - uint64_t ImmediateUInt64; - float ImmediateFloat; - TEquationOperation Operation; - TReadParams_1_0 ReadParams; + uint64_t ImmediateUInt64; + float ImmediateFloat; + TEquationOperation Operation; + TReadParams_1_0 ReadParams; }; - char* SymbolName; - + char* SymbolName; } TEquationElement_1_0; -/*****************************************************************************\ - -Class: - IEquation_1_0 - -Description: - Abstract interface for the equation object. - -\*****************************************************************************/ + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IEquation_1_0 + // + // Description: + // Abstract interface for the equation object. + // + /////////////////////////////////////////////////////////////////////////////// class IEquation_1_0 { public: virtual ~IEquation_1_0(); - virtual uint32_t GetEquationElementsCount( void ); virtual TEquationElement_1_0* GetEquationElement( uint32_t index ); }; -//*******************************************************************************/ -// Global parameters of Metric: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Global parameters of Metric: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SMetricParams_1_0 { - uint32_t IdInSet; // Position in the set - uint32_t GroupId; // Specific metric group id - const char* SymbolName; // Symbol name, used in equations - const char* ShortName; // Consistent metric name, not changed platform to platform - const char* GroupName; // VertexShader for example - const char* LongName; // Hint about the metric shown to users - - const char* DxToOglAlias; // To replace DX pixels with OGL fragments - - uint32_t UsageFlagsMask; - uint32_t ApiMask; - - TMetricResultType ResultType; - const char* MetricResultUnits; - TMetricType MetricType; - - uint64_t LowWatermark; // Low watermark for hotspot indication (USAGE_FLAG_INDICATE only) - uint64_t HighWatermark; // High watermark for hotspot indication (USAGE_FLAG_INDICATE only) - - THwUnitType HwUnitType; - - // Read equation specification for IO stream (accessing raw values potentially spread in report in several locations) - IEquation_1_0* IoReadEquation; - // Read equation specification for query (accessing calculated delta values) - IEquation_1_0* QueryReadEquation; - - TDeltaFunction_1_0 DeltaFunction; - - // Normalization equation to get normalized value to bytes transfered or to a percentage of utilization - IEquation_1_0* NormEquation; - - // To calculate metrics max value as a function of other metrics and device parameters (e.g. 100 for percentage) - IEquation_1_0* MaxValueEquation; - + uint32_t IdInSet; // Position in the set + uint32_t GroupId; // Specific metric group id + const char* SymbolName; // Symbol name, used in equations + const char* ShortName; // Consistent metric name, not changed platform to platform + const char* GroupName; // VertexShader for example + const char* LongName; // Hint about the metric shown to users + const char* DxToOglAlias; // To replace DX pixels with OGL fragments + uint32_t UsageFlagsMask; // + uint32_t ApiMask; // + TMetricResultType ResultType; // + const char* MetricResultUnits; // + TMetricType MetricType; // + uint64_t LowWatermark; // Low watermark for hotspot indication (USAGE_FLAG_INDICATE only) + uint64_t HighWatermark; // High watermark for hotspot indication (USAGE_FLAG_INDICATE only) + THwUnitType HwUnitType; // + IEquation_1_0* IoReadEquation; // Read equation specification for IO stream (accessing raw values potentially spread in report in several locations) + IEquation_1_0* QueryReadEquation; // Read equation specification for query (accessing calculated delta values) + TDeltaFunction_1_0 DeltaFunction; // + IEquation_1_0* NormEquation; // Normalization equation to get normalized value to bytes transfered or to a percentage of utilization + IEquation_1_0* MaxValueEquation; // To calculate metrics max value as a function of other metrics and device parameters (e.g. 100 for percentage) } TMetricParams_1_0; -//*******************************************************************************/ -// Global parameters of Information: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Global parameters of Information: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SInformationParams_1_0 { - uint32_t IdInSet; // Position in the set - const char* SymbolName; // Symbol name, used in equations - const char* ShortName; // Consistent name, not changed platform to platform - const char* GroupName; // Some more global context of the information - const char* LongName; // Hint about the information shown to users - - uint32_t ApiMask; - - TInformationType InfoType; - const char* InfoUnits; - - // Read equation specification for IO stream (accessing raw values potentially spread in report in several locations) - IEquation_1_0* IoReadEquation; - // Read equation specification for query (accessing calculated delta values) - IEquation_1_0* QueryReadEquation; - - TDeltaFunction_1_0 OverflowFunction; - + uint32_t IdInSet; // Position in the set + const char* SymbolName; // Symbol name, used in equations + const char* ShortName; // Consistent name, not changed platform to platform + const char* GroupName; // Some more global context of the information + const char* LongName; // Hint about the information shown to users + uint32_t ApiMask; // + TInformationType InfoType; // + const char* InfoUnits; // + IEquation_1_0* IoReadEquation; // Read equation specification for IO stream (accessing raw values potentially spread in report in several locations) + IEquation_1_0* QueryReadEquation; // Read equation specification for query (accessing calculated delta values) + TDeltaFunction_1_0 OverflowFunction; // } TInformationParams_1_0; -/*****************************************************************************\ - -Class: - IInformation_1_0 - -Description: - Abstract interface for the measurement information parameter. - -\*****************************************************************************/ + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IInformation_1_0 + // + // Descriptions: + // Abstract interface for the measurement information parameter. + // + /////////////////////////////////////////////////////////////////////////////// class IInformation_1_0 { public: virtual ~IInformation_1_0(); - virtual TInformationParams_1_0* GetParams(); }; -/*****************************************************************************\ - -Class: - IMetric_1_0 - -Description: - Abstract interface for the metric that is sampled. - -\*****************************************************************************/ + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IMetric_1_0 + // + // Description: + // Abstract interface for the metric that is sampled. + // + /////////////////////////////////////////////////////////////////////////////// class IMetric_1_0 { public: virtual ~IMetric_1_0(); - - virtual TMetricParams_1_0* GetParams(); + virtual TMetricParams_1_0* GetParams(); }; -/*****************************************************************************\ - -Class: - IMetricSet_1_0 - -Description: - Abstract interface for the metric sets mapping to different HW configuration that should be used - exclusively to each other metric set in the concurrent group. - -\*****************************************************************************/ + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IMetricSet_1_0 + // + // Description: + // Abstract interface for the metric sets mapping to different HW + // configuration that should be used exclusively to each other + // metric set in the concurrent group. + // + // New: + // - GetParams: + // - GetMetric: To get particular metric + // - GetInformation: To get particular information about measurement + // - GetComplementaryMetricSet: Below proposal to address multi-passes at the set level + // - Activate: To enable this configuration before query instance is created + // - Deactivate: To disable this configuration after query instance is created + // - AddCustomMetric: To add an additional custom metric to this set + // + /////////////////////////////////////////////////////////////////////////////// class IMetricSet_1_0 { public: virtual ~IMetricSet_1_0(); virtual TMetricSetParams_1_0* GetParams( void ); - - // To get particular metric virtual IMetric_1_0* GetMetric( uint32_t index ); - - // To get particular information about measurement virtual IInformation_1_0* GetInformation( uint32_t index ); - - // Below proposal to address multi-passes at the set level virtual IMetricSet_1_0* GetComplementaryMetricSet( uint32_t index ); - - // To enable this configuration before query instance is created virtual TCompletionCode Activate( void ); - - // To disable this configuration after query instance is created virtual TCompletionCode Deactivate( void ); - - // To add an additional custom metric to this set virtual IMetric_1_0* AddCustomMetric( - const char* symbolName, const char* shortName, const char* groupName, const char* longName, const char* dxToOglAlias, - uint32_t usageFlagsMask, uint32_t apiMask, TMetricResultType resultType, const char* resultUnits, TMetricType metricType, - int64_t loWatermark, int64_t hiWatermark, THwUnitType hwType, const char* ioReadEquation, const char* deltaFunction, - const char* queryReadEquation, const char* normalizationEquation, const char* maxValueEquation, const char* signalName ); + const char* symbolName, + const char* shortName, + const char* groupName, + const char* longName, + const char* dxToOglAlias, + uint32_t usageFlagsMask, + uint32_t apiMask, + TMetricResultType resultType, + const char* resultUnits, + TMetricType metricType, + int64_t loWatermark, + int64_t hiWatermark, + THwUnitType hwType, + const char* ioReadEquation, + const char* deltaFunction, + const char* queryReadEquation, + const char* normalizationEquation, + const char* maxValueEquation, + const char* signalName ); }; -/*****************************************************************************\ - -Class: - IMetricSet_1_1 - -Description: - Updated 1.0 version to use with 1.1 interface version. - Introduces an ability to calculate metrics from raw data. - - New: - - SetApiFiltering - - CalculateMetrics - - CalculateIoMeasurementInformation - -\*****************************************************************************/ + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IMetricSet_1_1 + // + // Description: + // Updated 1.0 version to use with 1.1 interface version. + // Introduces an ability to calculate metrics from raw data. + // + // New: + // - SetApiFiltering: To filter available metrics/information for the given API. Use TMetricApiType to build the mask. + // - CalculateMetrics: To calculate normalized metrics/information from the raw data. + // - CalculateIoMeasurementInformation: To calculate additional information for stream measurements. + // + /////////////////////////////////////////////////////////////////////////////// class IMetricSet_1_1 : public IMetricSet_1_0 { public: virtual ~IMetricSet_1_1(); - - // To filter available metrics/information for the given API. Use TMetricApiType to build the mask. - virtual TCompletionCode SetApiFiltering( uint32_t apiMask ); - - // To calculate normalized metrics/information from the raw data. - virtual TCompletionCode CalculateMetrics( const unsigned char* rawData, uint32_t rawDataSize, TTypedValue_1_0* out, - uint32_t outSize, uint32_t* outReportCount, bool enableContextFiltering ); - - // To calculate additional information for stream measurements. - virtual TCompletionCode CalculateIoMeasurementInformation( TTypedValue_1_0* out, uint32_t outSize ); + virtual TCompletionCode SetApiFiltering( uint32_t apiMask ); + virtual TCompletionCode CalculateMetrics( const uint8_t* rawData, uint32_t rawDataSize, TTypedValue_1_0* out, uint32_t outSize, uint32_t* outReportCount, bool enableContextFiltering ); + virtual TCompletionCode CalculateIoMeasurementInformation( TTypedValue_1_0* out, uint32_t outSize ); }; -/*****************************************************************************\ - -Class: - IMetricSet_1_4 - -Description: - Updated 1.1 version to use with 1.4 interface version. - Extends set params with gtType information. - - Updates: - - GetParams - -\*****************************************************************************/ + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IMetricSet_1_4 + // + // Description: + // Updated 1.1 version to use with 1.4 interface version. + // Extends set params with gtType information. + // + // Updates: + // - GetParams + // + /////////////////////////////////////////////////////////////////////////////// class IMetricSet_1_4 : public IMetricSet_1_1 { public: virtual ~IMetricSet_1_4(); - virtual TMetricSetParams_1_4* GetParams( void ); }; -/*****************************************************************************\ - -Class: - IMetricSet_1_5 - -Description: - Updated 1.4 version to use with 1.5 interface version. - Adds an ability to calculate MaxValueEquations (maximal value) for each metric. - Param 'enableContextFiltering' becomes deprecated. - - Updates: - - GetComplementaryMetricSet - - CalculateMetrics - -\*****************************************************************************/ + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IMetricSet_1_5 + // + // Description: + // Updated 1.4 version to use with 1.5 interface version. + // Adds an ability to calculate MaxValueEquations (maximal value) for each metric. + // Param 'enableContextFiltering' becomes deprecated. + // + // Updates: + // - GetComplementaryMetricSet: Update to 1.5 interface + // - CalculateMetrics: CalculateMetrics extended with max values calculation. + // ptional param 'outMaxValues' should have a memory + // for at least 'MetricCount * RawReportCount' values, can be NULL. + // + /////////////////////////////////////////////////////////////////////////////// class IMetricSet_1_5 : public IMetricSet_1_4 { public: - // To avoid hiding by 1.5 interface function - using IMetricSet_1_1::CalculateMetrics; - - // Update to 1.5 interface - virtual IMetricSet_1_5* GetComplementaryMetricSet( uint32_t index ); - - // CalculateMetrics extended with max values calculation. - // Optional param 'outMaxValues' should have a memory for at least 'MetricCount * RawReportCount' values, can be NULL. - virtual TCompletionCode CalculateMetrics( const unsigned char* rawData, uint32_t rawDataSize, TTypedValue_1_0* out, - uint32_t outSize, uint32_t* outReportCount, TTypedValue_1_0* outMaxValues, uint32_t outMaxValuesSize ); + using IMetricSet_1_1::CalculateMetrics; // To avoid hiding by 1.5 interface function + virtual IMetricSet_1_5* GetComplementaryMetricSet( uint32_t index ); + virtual TCompletionCode CalculateMetrics( + const uint8_t* rawData, + uint32_t rawDataSize, + TTypedValue_1_0* out, + uint32_t outSize, + uint32_t* outReportCount, + TTypedValue_1_0* outMaxValues, + uint32_t outMaxValuesSize ); }; -/*****************************************************************************\ - -Class: - IConcurrentGroup_1_0 - -Description: - Abstract interface for the metrics groups that can be collected concurrently to another group. - -\*****************************************************************************/ + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IConcurrentGroup_1_0 + // + // Description: + // Abstract interface for the metrics groups that can be collected + // concurrently to another group. + // + /////////////////////////////////////////////////////////////////////////////// class IConcurrentGroup_1_0 { public: virtual ~IConcurrentGroup_1_0(); - virtual TConcurrentGroupParams_1_0* GetParams( void ); - virtual IMetricSet_1_0* GetMetricSet( uint32_t index ); - - virtual TCompletionCode OpenIoStream( IMetricSet_1_0* metricSet, uint32_t processId, uint32_t* nsTimerPeriod, uint32_t* oaBufferSize ); - virtual TCompletionCode ReadIoStream( uint32_t* reportsCount, char* reportData, uint32_t readFlags ); - virtual TCompletionCode CloseIoStream( void ); - virtual TCompletionCode WaitForReports( uint32_t milliseconds ); - virtual IInformation_1_0* GetIoMeasurementInformation( uint32_t index ); - virtual IInformation_1_0* GetIoGpuContextInformation( uint32_t index ); + virtual IMetricSet_1_0* GetMetricSet( uint32_t index ); + virtual TCompletionCode OpenIoStream( IMetricSet_1_0* metricSet, uint32_t processId, uint32_t* nsTimerPeriod, uint32_t* oaBufferSize ); + virtual TCompletionCode ReadIoStream( uint32_t* reportsCount, char* reportData, uint32_t readFlags ); + virtual TCompletionCode CloseIoStream( void ); + virtual TCompletionCode WaitForReports( uint32_t milliseconds ); + virtual IInformation_1_0* GetIoMeasurementInformation( uint32_t index ); + virtual IInformation_1_0* GetIoGpuContextInformation( uint32_t index ); }; -/*****************************************************************************\ - -Class: - IConcurrentGroup_1_1 - -Description: - Updated 1.0 version to use with 1.1 interface version. - - Updates: - - GetMetricSet - -\*****************************************************************************/ + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IConcurrentGroup_1_1 + // + // Description: + // Updated 1.0 version to use with 1.1 interface version. + // + // Updates: + // - GetMetricSet: Update to 1.1 interface + // + /////////////////////////////////////////////////////////////////////////////// class IConcurrentGroup_1_1 : public IConcurrentGroup_1_0 { public: - // Update to 1.1 interface - virtual IMetricSet_1_1* GetMetricSet( uint32_t index ); + virtual IMetricSet_1_1* GetMetricSet( uint32_t index ); }; -/*****************************************************************************\ - -Class: - IConcurrentGroup_1_3 - -Description: - Updated 1.1 version to use with 1.3 interface version. - Introduces setting Stream Sampling Type. - - New: - - SetIoStreamSamplingType - -\*****************************************************************************/ + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IConcurrentGroup_1_3 + // + // Description: + // Updated 1.1 version to use with 1.3 interface version.Introduces setting Stream Sampling Type. + // + // New: + // - SetIoStreamSamplingType: To set sampling type during IoStream measurements + // + /////////////////////////////////////////////////////////////////////////////// class IConcurrentGroup_1_3 : public IConcurrentGroup_1_1 { public: - // To set sampling type during IoStream measurements - virtual TCompletionCode SetIoStreamSamplingType( TSamplingType type ); + virtual TCompletionCode SetIoStreamSamplingType( TSamplingType type ); }; -/*****************************************************************************\ - -Class: - IConcurrentGroup_1_5 - -Description: - Updated 1.3 version to use with 1.5 interface version. - - Updates: - - GetMetricSet - -\*****************************************************************************/ + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IConcurrentGroup_1_5 + // + // Description: + // Updated 1.3 version to use with 1.5 interface version. + // + // Updates: + // - GetMetricSet: Update to 1.5 interface + // + /////////////////////////////////////////////////////////////////////////////// class IConcurrentGroup_1_5 : public IConcurrentGroup_1_3 { public: - // Update to 1.5 interface - virtual IMetricSet_1_5* GetMetricSet( uint32_t index ); + virtual IMetricSet_1_5* GetMetricSet( uint32_t index ); }; -/*****************************************************************************\ - -Class: - IOverride_1_2 - -Description: - Abstract interface for Metrics Device overrides. - -\*****************************************************************************/ + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IOverride_1_2 + // + // Description: + // Abstract interface for Metrics Device overrides. + // + // New: + // - GetParams: To get this Override params + // - SetOverride: To enable/disable this Override + // + /////////////////////////////////////////////////////////////////////////////// class IOverride_1_2 { public: virtual ~IOverride_1_2(); - - // To get this Override params - virtual TOverrideParams_1_2* GetParams( void ); - - // To enable/disable this Override - virtual TCompletionCode SetOverride( TSetOverrideParams_1_2* params, uint32_t paramsSize ); + virtual TOverrideParams_1_2* GetParams( void ); + virtual TCompletionCode SetOverride( TSetOverrideParams_1_2* params, uint32_t paramsSize ); }; -/*****************************************************************************\ - -Class: - IMetricsDevice_1_0 - -Description: - Abstract interface for the GPU metrics root object. - -\*****************************************************************************/ + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IMetricsDevice_1_0 + // + // Description: + // Abstract interface for the GPU metrics root object. + // + // New: + // - GetParams: To get MetricsDevice params + // - GetConcurrentGroup: Child objects are of IConcurrentGroup + // - GetGlobalSymbol: To get GlobalSymbol at the given index + // - GetGlobalSymbolValueByName: To get GlobalSymbol with the given name + // - GetLastError: To get last error from TCompletionCode enum + // - GetGpuCpuTimestamps: To get both GPU and CPU timestamp at the same time + // + /////////////////////////////////////////////////////////////////////////////// class IMetricsDevice_1_0 { public: virtual ~IMetricsDevice_1_0(); - - // To get MetricsDevice params virtual TMetricsDeviceParams_1_0* GetParams( void ); - - // Child objects are of IConcurrentGroup - virtual IConcurrentGroup_1_0* GetConcurrentGroup( uint32_t index ); - - // To get GlobalSymbol at the given index - virtual TGlobalSymbol_1_0* GetGlobalSymbol( uint32_t index ); - - // To get GlobalSymbol with the given name - virtual TTypedValue_1_0* GetGlobalSymbolValueByName( const char* name ); - - // To get last error from TCompletionCode enum - virtual TCompletionCode GetLastError( void ); - - // To get both GPU and CPU timestamp at the same time - virtual TCompletionCode GetGpuCpuTimestamps( uint64_t* gpuTimestampNs, uint64_t* cpuTimestampNs, - uint32_t* cpuId ); + virtual IConcurrentGroup_1_0* GetConcurrentGroup( uint32_t index ); + virtual TGlobalSymbol_1_0* GetGlobalSymbol( uint32_t index ); + virtual TTypedValue_1_0* GetGlobalSymbolValueByName( const char* name ); + virtual TCompletionCode GetLastError( void ); + virtual TCompletionCode GetGpuCpuTimestamps( uint64_t* gpuTimestampNs, uint64_t* cpuTimestampNs, uint32_t* cpuId ); }; -/*****************************************************************************\ - -Class: - IMetricsDevice_1_1 - -Description: - Updated 1.0 version to use with 1.1 interface version. - - Updates: - - GetConcurrentGroup - -\*****************************************************************************/ + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IMetricsDevice_1_1 + // + // Description: + // Updated 1.0 version to use with 1.1 interface version. + // + // Updates: + // - GetConcurrentGroup: Update to 1.1 interface + // + /////////////////////////////////////////////////////////////////////////////// class IMetricsDevice_1_1 : public IMetricsDevice_1_0 { public: - // Update to 1.1 interface virtual IConcurrentGroup_1_1* GetConcurrentGroup( uint32_t index ); }; -/*****************************************************************************\ - -Class: - IMetricsDevice_1_2 - -Description: - Updated 1.1 version to use with 1.2 interface version. - Introduces an interface for getting overrides. - - Updates: - - GetParams - New: - - GetOverride - - GetOverrideByName - -\*****************************************************************************/ + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IMetricsDevice_1_2 + // + // Description: + // Updated 1.1 version to use with 1.2 interface version. + // Introduces an interface for getting overrides. + // + // Updates: + // - GetParams: Update to 1.2 interface + // + // New: + // - GetOverride: To get override at the given index + // - GetOverrideByName: To get override with the given name + // + /////////////////////////////////////////////////////////////////////////////// class IMetricsDevice_1_2 : public IMetricsDevice_1_1 { public: - // Update returned params virtual TMetricsDeviceParams_1_2* GetParams( void ); - - // To get override at the given index - virtual IOverride_1_2* GetOverride( uint32_t index ); - - // To get override with the given name - virtual IOverride_1_2* GetOverrideByName( const char* symbolName ); + virtual IOverride_1_2* GetOverride( uint32_t index ); + virtual IOverride_1_2* GetOverrideByName( const char* symbolName ); }; -/*****************************************************************************\ - -Class: - IMetricsDevice_1_5 - -Description: - Updated 1.2 version to use with 1.5 interface version. - - Updates: - - GetConcurrentGroup - -\*****************************************************************************/ + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IMetricsDevice_1_5 + // + // Description: + // Updated 1.2 version to use with 1.5 interface version. + // + // New: + // - GetConcurrentGroup: Update to 1.5 interface + // + /////////////////////////////////////////////////////////////////////////////// class IMetricsDevice_1_5 : public IMetricsDevice_1_2 { public: - // Update to 1.5 interface virtual IConcurrentGroup_1_5* GetConcurrentGroup( uint32_t index ); }; + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IAdapter_1_6 + // + // Description: + // Abstract interface for GPU adapter. + // + // New: + // - GetParams: To get this adapter params + // - Reset: To reset this adapter state + // - OpenMetricsDevice + // - OpenMetricsDeviceFromFile + // - CloseMetricsDevice + // - SaveMetricsDeviceToFile + // + /////////////////////////////////////////////////////////////////////////////// + class IAdapter_1_6 + { + public: + virtual ~IAdapter_1_6(); + virtual const TAdapterParams_1_6* GetParams( void ) const; + virtual TCompletionCode Reset(); + virtual TCompletionCode OpenMetricsDevice( IMetricsDevice_1_5** metricsDevice ); + virtual TCompletionCode OpenMetricsDeviceFromFile( const char* fileName, void* openParams, IMetricsDevice_1_5** metricsDevice ); + virtual TCompletionCode CloseMetricsDevice( IMetricsDevice_1_5* metricsDevice ); + virtual TCompletionCode SaveMetricsDeviceToFile( const char* fileName, void* saveParams, IMetricsDevice_1_5* metricsDevice ); + }; + + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IAdapter_1_8 + // + // Description: + // Abstract interface for GPU adapter. + // + // New: + // - GetParams: To get this adapter params + // + /////////////////////////////////////////////////////////////////////////////// + class IAdapter_1_8 : public IAdapter_1_6 + { + public: + virtual const TAdapterParams_1_8* GetParams( void ) const; + }; + + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IAdapterGroup_1_6 + // + // Description: + // Abstract interface for the GPU adapters root object. + // + // New: + // - GetParams: To get this adapter group params + // - GetAdapter: To enumerate available GPU adapters + // - Close: To close this adapter group + // + /////////////////////////////////////////////////////////////////////////////// + class IAdapterGroup_1_6 + { + public: + virtual ~IAdapterGroup_1_6(); + virtual const TAdapterGroupParams_1_6* GetParams( void ) const; + virtual IAdapter_1_6* GetAdapter( uint32_t index ); + virtual TCompletionCode Close(); + }; + + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IAdapterGroup_1_8 + // + // Description: + // Abstract interface for the GPU adapters root object. + // + // New: + // - GetAdapter: To enumerate available GPU adapters + // + /////////////////////////////////////////////////////////////////////////////// + class IAdapterGroup_1_8 : public IAdapterGroup_1_6 + { + public: + virtual IAdapter_1_8* GetAdapter( uint32_t index ); + }; + #ifdef __cplusplus - extern "C" { + extern "C" + { #endif - // Factory functions - typedef TCompletionCode (MD_STDCALL *OpenMetricsDevice_fn)(IMetricsDevice_1_5** device); - typedef TCompletionCode (MD_STDCALL *OpenMetricsDeviceFromFile_fn)(const char* fileName, void* openParams, IMetricsDevice_1_5** device); - typedef TCompletionCode (MD_STDCALL *CloseMetricsDevice_fn)(IMetricsDevice_1_5* device); - typedef TCompletionCode (MD_STDCALL *SaveMetricsDeviceToFile_fn)(const char* fileName, void* saveParams, IMetricsDevice_1_5* device); + // [Current] Factory functions + typedef TCompletionCode( MD_STDCALL* OpenAdapterGroup_fn )( IAdapterGroup_1_8** adapterGroup ); + + // [Legacy] Factory functions + typedef TCompletionCode( MD_STDCALL* OpenMetricsDevice_fn )( IMetricsDevice_1_5** metricsDevice ); + typedef TCompletionCode( MD_STDCALL* OpenMetricsDeviceFromFile_fn )( const char* fileName, void* openParams, IMetricsDevice_1_5** metricsDevice ); + typedef TCompletionCode( MD_STDCALL* CloseMetricsDevice_fn )( IMetricsDevice_1_5* metricsDevice ); + typedef TCompletionCode( MD_STDCALL* SaveMetricsDeviceToFile_fn )( const char* fileName, void* saveParams, IMetricsDevice_1_5* metricsDevice ); #ifdef __cplusplus } #endif -}; -#endif // __METRICS_DISCOVERY_H_ - +}; // namespace MetricsDiscovery