From 87f846d62496adb7d0f5abb340dc8bff8a4e9b3f Mon Sep 17 00:00:00 2001 From: Vishnu Khanth Date: Thu, 19 Dec 2024 13:10:06 +0000 Subject: [PATCH] test: Add Sysman VF Management CTS (#87) * test: Add Sysman VF Management CTS Related-To: VLCLJ-2312 Signed-off-by: Vishnu Khanth * test: Add Sysman VF Management CTS Related-To: VLCLJ-2312 Signed-off-by: Vishnu Khanth * test: Add Sysman VF Management CTS Related-To: VLCLJ-2312 Signed-off-by: Vishnu Khanth * test: Add Sysman VF Management CTS Related-To: VLCLJ-2312 Signed-off-by: Vishnu Khanth * test: Add Sysman VF Management CTS Related-To: VLCLJ-2312 Signed-off-by: Vishnu Khanth * test: Add Sysman VF Management CTS Related-To: VLCLJ-2312 Signed-off-by: Vishnu Khanth * test: Add Sysman VF Management CTS Related-To: VLCLJ-2312 Signed-off-by: Vishnu Khanth * test: Add Sysman VF Management CTS Related-To: VLCLJ-2312 Signed-off-by: Vishnu Khanth * test: Add Sysman VF Management CTS Related-To: VLCLJ-2312 Signed-off-by: Vishnu Khanth * test: Add Sysman VF Management CTS Related-To: VLCLJ-2312 Signed-off-by: Vishnu Khanth * test: Add Sysman VF Management CTS Related-To: VLCLJ-2312 Signed-off-by: Vishnu Khanth --------- Signed-off-by: Vishnu Khanth --- conformance_tests/sysman/CMakeLists.txt | 3 +- .../test_sysman_vf_management/CMakeLists.txt | 25 + .../test_sysman_vf_management/README.md | 3 + .../test_sysman_vf_management/src/main.cpp | 53 +++ .../src/test_sysman_vf_management.cpp | 430 ++++++++++++++++++ scripts/level_zero_report_utils.py | 4 + utils/test_harness/CMakeLists.txt | 3 +- .../sysman/include/test_harness_sysman.hpp | 3 +- .../test_harness_sysman_vf_management.hpp | 29 ++ .../src/test_harness_sysman_vf_management.cpp | 78 ++++ 10 files changed, 628 insertions(+), 3 deletions(-) create mode 100644 conformance_tests/sysman/test_sysman_vf_management/CMakeLists.txt create mode 100644 conformance_tests/sysman/test_sysman_vf_management/README.md create mode 100644 conformance_tests/sysman/test_sysman_vf_management/src/main.cpp create mode 100644 conformance_tests/sysman/test_sysman_vf_management/src/test_sysman_vf_management.cpp create mode 100644 utils/test_harness/sysman/include/test_harness_sysman_vf_management.hpp create mode 100644 utils/test_harness/sysman/src/test_harness_sysman_vf_management.cpp diff --git a/conformance_tests/sysman/CMakeLists.txt b/conformance_tests/sysman/CMakeLists.txt index 136b132e..03a7c8b6 100755 --- a/conformance_tests/sysman/CMakeLists.txt +++ b/conformance_tests/sysman/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2020-2022 Intel Corporation +# Copyright (C) 2020-2024 Intel Corporation # # SPDX-License-Identifier: MIT # @@ -25,3 +25,4 @@ add_subdirectory(test_sysman_overclocking) add_subdirectory(test_sysman_scheduler) add_subdirectory(test_sysman_performance) add_subdirectory(test_sysman_ecc) +add_subdirectory(test_sysman_vf_management) diff --git a/conformance_tests/sysman/test_sysman_vf_management/CMakeLists.txt b/conformance_tests/sysman/test_sysman_vf_management/CMakeLists.txt new file mode 100644 index 00000000..7b70c36d --- /dev/null +++ b/conformance_tests/sysman/test_sysman_vf_management/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: MIT + +add_lzt_test( + NAME test_sysman_vf_management + GROUP "/conformance_tests/tools/sysman" + SOURCES + src/test_sysman_vf_management.cpp + src/main.cpp + LINK_LIBRARIES + level_zero_tests::logging + level_zero_tests::utils +) + +add_lzt_test( + NAME test_sysman_vf_management_zesinit + GROUP "/conformance_tests/tools/sysman" + SOURCES + src/test_sysman_vf_management.cpp + src/main.cpp + LINK_LIBRARIES + level_zero_tests::logging + level_zero_tests::utils + DEFINES USE_ZESINIT +) \ No newline at end of file diff --git a/conformance_tests/sysman/test_sysman_vf_management/README.md b/conformance_tests/sysman/test_sysman_vf_management/README.md new file mode 100644 index 00000000..5d4ce2a2 --- /dev/null +++ b/conformance_tests/sysman/test_sysman_vf_management/README.md @@ -0,0 +1,3 @@ +# testSysmanVfManagement + +This test suite is for validating Sysman VF management APIs provided in L0 sysman Spec. \ No newline at end of file diff --git a/conformance_tests/sysman/test_sysman_vf_management/src/main.cpp b/conformance_tests/sysman/test_sysman_vf_management/src/main.cpp new file mode 100644 index 00000000..27265ae5 --- /dev/null +++ b/conformance_tests/sysman/test_sysman_vf_management/src/main.cpp @@ -0,0 +1,53 @@ +/* + * + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "gmock/gmock.h" +#include "logging/logging.hpp" +#include "utils/utils.hpp" +#include + +int main(int argc, char **argv) { + ::testing::InitGoogleMock(&argc, argv); + std::vector command_line(argv + 1, argv + argc); + level_zero_tests::init_logging(command_line); +#ifdef USE_ZESINIT + ze_result_t result = zesInit(0); + if (result) { + throw std::runtime_error("zesInit failed: " + + level_zero_tests::to_string(result)); + } + LOG_TRACE << "Sysman initialized"; + return RUN_ALL_TESTS(); +#else // USE_ZESINIT + static char sys_env[] = "ZES_ENABLE_SYSMAN=1"; + putenv(sys_env); + static char device_hierachy_env[] = "ZE_FLAT_DEVICE_HIERARCHY=COMPOSITE"; + putenv(device_hierachy_env); + + auto is_sysman_enabled = getenv("ZES_ENABLE_SYSMAN"); + if (is_sysman_enabled == nullptr) { + LOG_INFO << "Sysman is not Enabled"; + exit(0); + } else { + auto is_sysman_enabled_int = atoi(is_sysman_enabled); + if (is_sysman_enabled_int == 1) { + ze_result_t result = zeInit(0); + if (result) { + throw std::runtime_error("zeInit failed: " + + level_zero_tests::to_string(result)); + } + LOG_TRACE << "Driver initialized"; + + return RUN_ALL_TESTS(); + } else { + LOG_INFO << "Sysman is not Enabled"; + exit(0); + } + } +#endif // USE_ZESINIT +} diff --git a/conformance_tests/sysman/test_sysman_vf_management/src/test_sysman_vf_management.cpp b/conformance_tests/sysman/test_sysman_vf_management/src/test_sysman_vf_management.cpp new file mode 100644 index 00000000..4edb5a51 --- /dev/null +++ b/conformance_tests/sysman/test_sysman_vf_management/src/test_sysman_vf_management.cpp @@ -0,0 +1,430 @@ +/* + * + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "test_harness/test_harness.hpp" + +namespace lzt = level_zero_tests; + +namespace { + +#ifdef USE_ZESINIT +class VfManagementZesTest : public lzt::ZesSysmanCtsClass { +public: + bool is_vf_enabled = false; +}; +#define VF_MANAGEMENT_TEST VfManagementZesTest +#else // USE_ZESINIT +class VfManagementTest : public lzt::SysmanCtsClass { +public: + bool is_vf_enabled = false; +}; +#define VF_MANAGEMENT_TEST VfManagementTest +#endif // USE_ZESINIT + +void validate_vf_capabilities(zes_vf_exp_capabilities_t &vf_capabilities, + uint32_t &vf_count) { + EXPECT_GE(vf_capabilities.address.domain, 0); + EXPECT_LE(vf_capabilities.address.domain, MAX_DOMAINs); + EXPECT_GE(vf_capabilities.address.bus, 0); + EXPECT_LE(vf_capabilities.address.bus, MAX_BUSES_PER_DOMAIN); + EXPECT_GE(vf_capabilities.address.device, 0); + EXPECT_LE(vf_capabilities.address.device, MAX_DEVICES_PER_BUS); + EXPECT_GE(vf_capabilities.address.function, 0); + EXPECT_LE(vf_capabilities.address.function, MAX_FUNCTIONS_PER_DEVICE); + EXPECT_GT(vf_capabilities.vfDeviceMemSize, 0); + EXPECT_GT(vf_capabilities.vfID, 0); + EXPECT_LE(vf_capabilities.vfID, vf_count); +} + +void compare_vf_capabilities(zes_vf_exp_capabilities_t &vf_capability_initial, + zes_vf_exp_capabilities_t &vf_capability_later) { + EXPECT_EQ(vf_capability_initial.stype, vf_capability_later.stype); + EXPECT_EQ(vf_capability_initial.pNext, vf_capability_later.pNext); + EXPECT_EQ(vf_capability_initial.address.domain, + vf_capability_later.address.domain); + EXPECT_EQ(vf_capability_initial.address.bus, vf_capability_later.address.bus); + EXPECT_EQ(vf_capability_initial.address.device, + vf_capability_later.address.device); + EXPECT_EQ(vf_capability_initial.address.function, + vf_capability_later.address.function); + EXPECT_EQ(vf_capability_initial.vfDeviceMemSize, + vf_capability_later.vfDeviceMemSize); + EXPECT_EQ(vf_capability_initial.vfID, vf_capability_later.vfID); +} + +TEST_F( + VF_MANAGEMENT_TEST, + GivenValidDeviceWhenCallingEnumEnabledVFExpThenValidVFHandlesAreReturned) { + for (auto device : devices) { + uint32_t count = lzt::get_vf_handles_count(device); + if (count > 0) { + is_vf_enabled = true; + LOG_INFO << "VF is enabled on this device!!"; + auto vf_handles = lzt::get_vf_handles(device, count); + + for (const auto &vf_handle : vf_handles) { + EXPECT_NE(vf_handle, nullptr); + } + } else { + LOG_INFO << "No VF handles found for this device!"; + } + } + + if (!is_vf_enabled) { + FAIL() << "No VF handles found in any of the devices!!"; + } +} + +TEST_F( + VF_MANAGEMENT_TEST, + GivenValidDeviceWhenRetrievingVFHandlesTwiceThenSimilarHandlesAreReturned) { + for (auto device : devices) { + std::vector vf_handles_initial; + std::vector vf_handles_later; + + uint32_t count_initial = lzt::get_vf_handles_count(device); + if (count_initial > 0) { + vf_handles_initial = lzt::get_vf_handles(device, count_initial); + } + + uint32_t count_later = lzt::get_vf_handles_count(device); + if (count_later > 0) { + vf_handles_later = lzt::get_vf_handles(device, count_later); + } + + if (count_initial > 0 && count_later > 0) { + is_vf_enabled = true; + LOG_INFO << "VF is enabled on this device!!"; + EXPECT_EQ(count_initial, count_later); + EXPECT_EQ(vf_handles_initial, vf_handles_later); + } else { + LOG_INFO << "No VF handles found for this device!"; + } + } + + if (!is_vf_enabled) { + FAIL() << "No VF handles found in any of the devices!!"; + } +} + +TEST_F( + VF_MANAGEMENT_TEST, + GivenValidDeviceWhenRetrievingVFHandlesWithCountGreaterThanActualThenExpectActualCountAndHandlesAreReturned) { + for (auto device : devices) { + uint32_t count = lzt::get_vf_handles_count(device); + if (count > 0) { + is_vf_enabled = true; + LOG_INFO << "VF is enabled on this device!!"; + uint32_t test_count = count + 1; + auto vf_handles = lzt::get_vf_handles(device, test_count); + EXPECT_EQ(count, test_count); + } else { + LOG_INFO << "No VF handles found for this device!"; + } + } + + if (!is_vf_enabled) { + FAIL() << "No VF handles found in any of the devices!!"; + } +} + +TEST_F( + VF_MANAGEMENT_TEST, + GivenValidDeviceWhenRetrievingVFHandlesWithCountLessThanActualThenExpectReducedCountAndHandlesAreReturned) { + for (auto device : devices) { + uint32_t count = lzt::get_vf_handles_count(device); + if (count > 1) { + is_vf_enabled = true; + LOG_INFO << "VF is enabled on this device!!"; + uint32_t test_count = count - 1; + auto vf_handles = lzt::get_vf_handles(device, test_count); + EXPECT_EQ(count - 1, test_count); + + for (const auto &vf_handle : vf_handles) { + EXPECT_NE(vf_handle, nullptr); + } + } else if (count == 1) { + is_vf_enabled = true; + LOG_INFO << "Insufficient number of VF handles to validate this test"; + } else { + LOG_INFO << "No VF handles found for this device!!"; + } + } + + if (!is_vf_enabled) { + FAIL() << "No VF handles found in any of the devices!!"; + } +} + +TEST_F( + VF_MANAGEMENT_TEST, + GivenValidDeviceWhenRetrievingVfCapabilitiesThenValidCapabilitiesAreReturned) { + for (auto device : devices) { + uint32_t count = lzt::get_vf_handles_count(device); + if (count > 0) { + is_vf_enabled = true; + LOG_INFO << "VF is enabled on this device!!"; + auto vf_handles = lzt::get_vf_handles(device, count); + + for (const auto &vf_handle : vf_handles) { + auto vf_capabilities = lzt::get_vf_capabilities(vf_handle); + validate_vf_capabilities(vf_capabilities, count); + } + } else { + LOG_INFO << "No VF handles found for this device!!"; + } + } + + if (!is_vf_enabled) { + FAIL() << "No VF handles found in any of the devices!!"; + } +} + +TEST_F( + VF_MANAGEMENT_TEST, + GivenValidDeviceWhenRetrievingVfCapabilitiesTwiceThenSimilarCapabilitiesAreReturned) { + for (auto device : devices) { + uint32_t count = lzt::get_vf_handles_count(device); + if (count > 0) { + is_vf_enabled = true; + LOG_INFO << "VF is enabled on this device!!"; + auto vf_handles = lzt::get_vf_handles(device, count); + + for (const auto &vf_handle : vf_handles) { + auto vf_capabilities_initial = lzt::get_vf_capabilities(vf_handle); + auto vf_capabilities_later = lzt::get_vf_capabilities(vf_handle); + compare_vf_capabilities(vf_capabilities_initial, vf_capabilities_later); + } + } else { + LOG_INFO << "No VF handles found for this device!!"; + } + } + + if (!is_vf_enabled) { + FAIL() << "No VF handles found in any of the devices!!"; + } +} + +TEST_F(VF_MANAGEMENT_TEST, + GivenValidDeviceWhenRetrievingVFCapabilitiesThenExpectVfIdIsUnique) { + for (auto device : devices) { + uint32_t count = lzt::get_vf_handles_count(device); + if (count > 1) { + std::vector vf_ids{}; + is_vf_enabled = true; + LOG_INFO << "VF is enabled on this device!!"; + auto vf_handles = lzt::get_vf_handles(device, count); + + for (const auto &vf_handle : vf_handles) { + auto vf_capabilities = lzt::get_vf_capabilities(vf_handle); + vf_ids.push_back(vf_capabilities.vfID); + } + + std::set unique_vf_ids(vf_ids.begin(), vf_ids.end()); + EXPECT_EQ(vf_ids.size(), unique_vf_ids.size()); + } else if (count == 1) { + is_vf_enabled = true; + LOG_INFO << "Insufficient number of VF handles to validate this test"; + } else { + LOG_INFO << "No VF handles found for this device!!"; + } + } + + if (!is_vf_enabled) { + FAIL() << "No VF handles found in any of the devices!!"; + } +} + +TEST_F( + VF_MANAGEMENT_TEST, + GivenValidDeviceWhenRetrievingVfMemoryUtilizationThenExpectValidUtilization) { + for (auto device : devices) { + uint32_t count = lzt::get_vf_handles_count(device); + if (count > 0) { + is_vf_enabled = true; + LOG_INFO << "VF is enabled on this device!!"; + auto vf_handles = lzt::get_vf_handles(device, count); + + for (const auto &vf_handle : vf_handles) { + auto vf_capabilities = lzt::get_vf_capabilities(vf_handle); + uint32_t mem_util_count = lzt::get_vf_mem_util_count(vf_handle); + ASSERT_GT(mem_util_count, 0); + auto vf_mem_util = lzt::get_vf_mem_util(vf_handle, mem_util_count); + + for (const auto &mem_util : vf_mem_util) { + EXPECT_GE(mem_util.vfMemLocation, ZES_MEM_LOC_SYSTEM); + EXPECT_LE(mem_util.vfMemLocation, ZES_MEM_LOC_DEVICE); + EXPECT_GT(mem_util.vfMemUtilized, 0); + EXPECT_LE(mem_util.vfMemUtilized, vf_capabilities.vfDeviceMemSize); + } + } + } else { + LOG_INFO << "No VF handles found for this device!!"; + } + } + + if (!is_vf_enabled) { + FAIL() << "No VF handles found in any of the devices!!"; + } +} + +TEST_F( + VF_MANAGEMENT_TEST, + GivenValidDeviceWhenRetrievingVfMemoryUtilizationWithCountGreaterThanActualThenExpectActualCountIsReturned) { + for (auto device : devices) { + uint32_t count = lzt::get_vf_handles_count(device); + if (count > 0) { + is_vf_enabled = true; + LOG_INFO << "VF is enabled on this device!!"; + auto vf_handles = lzt::get_vf_handles(device, count); + + for (const auto &vf_handle : vf_handles) { + uint32_t mem_util_count = lzt::get_vf_mem_util_count(vf_handle); + ASSERT_GT(mem_util_count, 0); + uint32_t test_count = mem_util_count + 1; + auto vf_mem_util = lzt::get_vf_mem_util(vf_handle, test_count); + EXPECT_EQ(test_count, mem_util_count); + } + } else { + LOG_INFO << "No VF handles found for this device!!"; + } + } + + if (!is_vf_enabled) { + FAIL() << "No VF handles found in any of the devices!!"; + } +} + +TEST_F( + VF_MANAGEMENT_TEST, + GivenValidDeviceWhenRetrievingVfMemoryUtilizationWithCountLessThanActualThenExpectReducedCountIsReturned) { + for (auto device : devices) { + uint32_t count = lzt::get_vf_handles_count(device); + if (count > 0) { + is_vf_enabled = true; + LOG_INFO << "VF is enabled on this device!!"; + auto vf_handles = lzt::get_vf_handles(device, count); + + for (const auto &vf_handle : vf_handles) { + uint32_t mem_util_count = lzt::get_vf_mem_util_count(vf_handle); + ASSERT_GT(mem_util_count, 0); + + if (mem_util_count > 1) { + uint32_t test_count = mem_util_count - 1; + auto vf_mem_util = lzt::get_vf_mem_util(vf_handle, test_count); + EXPECT_EQ(test_count, mem_util_count - 1); + } else { + LOG_INFO + << "Insufficient number of mem util count to validate this test"; + } + } + } else { + LOG_INFO << "No VF handles found for this device!!"; + } + } + + if (!is_vf_enabled) { + FAIL() << "No VF handles found in any of the devices!!"; + } +} + +TEST_F( + VF_MANAGEMENT_TEST, + GivenValidDeviceWhenRetrievingVfEngineUtilizationThenExpectValidUtilization) { + for (auto device : devices) { + uint32_t count = lzt::get_vf_handles_count(device); + if (count > 0) { + is_vf_enabled = true; + LOG_INFO << "VF is enabled on this device!!"; + auto vf_handles = lzt::get_vf_handles(device, count); + + for (const auto &vf_handle : vf_handles) { + uint32_t engine_util_count = lzt::get_vf_engine_util_count(vf_handle); + ASSERT_GT(engine_util_count, 0); + auto vf_engine_util = + lzt::get_vf_engine_util(vf_handle, engine_util_count); + + for (const auto &engine_util : vf_engine_util) { + EXPECT_GE(engine_util.vfEngineType, ZES_ENGINE_GROUP_ALL); + EXPECT_LE(engine_util.vfEngineType, + ZES_ENGINE_GROUP_MEDIA_CODEC_SINGLE); + EXPECT_GE(engine_util.activeCounterValue, 0); + EXPECT_GT(engine_util.samplingCounterValue, 0); + } + } + } else { + LOG_INFO << "No VF handles found for this device!!"; + } + } + + if (!is_vf_enabled) { + FAIL() << "No VF handles found in any of the devices!!"; + } +} + +TEST_F( + VF_MANAGEMENT_TEST, + GivenValidDeviceWhenRetrievingVfEngineUtilizationWithCountGreaterThanActualThenExpectActualCountIsReturned) { + for (auto device : devices) { + uint32_t count = lzt::get_vf_handles_count(device); + if (count > 0) { + is_vf_enabled = true; + LOG_INFO << "VF is enabled on this device!!"; + auto vf_handles = lzt::get_vf_handles(device, count); + + for (const auto &vf_handle : vf_handles) { + uint32_t engine_util_count = lzt::get_vf_engine_util_count(vf_handle); + ASSERT_GT(engine_util_count, 0); + uint32_t test_count = engine_util_count + 1; + auto vf_engine_util = lzt::get_vf_engine_util(vf_handle, test_count); + EXPECT_EQ(test_count, engine_util_count); + } + } else { + LOG_INFO << "No VF handles found for this device!!"; + } + } + + if (!is_vf_enabled) { + FAIL() << "No VF handles found in any of the devices!!"; + } +} + +TEST_F( + VF_MANAGEMENT_TEST, + GivenValidDeviceWhenRetrievingVfEngineUtilizationWithCountLessThanActualThenExpectReducedCountIsReturned) { + for (auto device : devices) { + uint32_t count = lzt::get_vf_handles_count(device); + if (count > 0) { + is_vf_enabled = true; + LOG_INFO << "VF is enabled on this device!!"; + auto vf_handles = lzt::get_vf_handles(device, count); + + for (const auto &vf_handle : vf_handles) { + uint32_t engine_util_count = lzt::get_vf_engine_util_count(vf_handle); + ASSERT_GT(engine_util_count, 0); + + if (engine_util_count > 1) { + uint32_t test_count = engine_util_count - 1; + auto vf_engine_util = lzt::get_vf_engine_util(vf_handle, test_count); + EXPECT_EQ(test_count, engine_util_count - 1); + } else { + LOG_INFO << "Insufficient number of engine util count to validate " + "this test"; + } + } + } else { + LOG_INFO << "No VF handles found for this device!!"; + } + } + + if (!is_vf_enabled) { + FAIL() << "No VF handles found in any of the devices!!"; + } +} + +} // namespace \ No newline at end of file diff --git a/scripts/level_zero_report_utils.py b/scripts/level_zero_report_utils.py index d7539577..08954785 100644 --- a/scripts/level_zero_report_utils.py +++ b/scripts/level_zero_report_utils.py @@ -288,6 +288,10 @@ def assign_tool_test_feature(test_binary: str, test_name: str): test_feature = "SysMan Firmware" elif test_binary == "test_sysman_firmware_zesinit": test_feature = "SysMan Firmware" + elif test_binary == "test_sysman_vf_management": + test_feature = "SysMan VF Management" + elif test_binary == "test_sysman_vf_management_zesinit": + test_feature = "SysMan VF Management" elif (re.search('performance', test_name, re.IGNORECASE)): test_feature = "SysMan Perf Profiles" elif test_binary == "test_metric": diff --git a/utils/test_harness/CMakeLists.txt b/utils/test_harness/CMakeLists.txt index 10ed007f..9760b122 100755 --- a/utils/test_harness/CMakeLists.txt +++ b/utils/test_harness/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2020 Intel Corporation +# Copyright (C) 2020-2024 Intel Corporation # # SPDX-License-Identifier: MIT # @@ -44,6 +44,7 @@ add_core_library(test_harness "sysman/src/test_harness_sysman_scheduler.cpp" "sysman/src/test_harness_sysman_performance.cpp" "sysman/src/test_harness_sysman_ecc.cpp" + "sysman/src/test_harness_sysman_vf_management.cpp" ) target_link_libraries(test_harness diff --git a/utils/test_harness/sysman/include/test_harness_sysman.hpp b/utils/test_harness/sysman/include/test_harness_sysman.hpp index cf6821fb..0f9f2fbe 100755 --- a/utils/test_harness/sysman/include/test_harness_sysman.hpp +++ b/utils/test_harness/sysman/include/test_harness_sysman.hpp @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2020 Intel Corporation + * Copyright (C) 2020-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -31,4 +31,5 @@ #include "test_harness_sysman_scheduler.hpp" #include "test_harness_sysman_performance.hpp" #include "test_harness_sysman_ecc.hpp" +#include "test_harness_sysman_vf_management.hpp" #endif diff --git a/utils/test_harness/sysman/include/test_harness_sysman_vf_management.hpp b/utils/test_harness/sysman/include/test_harness_sysman_vf_management.hpp new file mode 100644 index 00000000..97d90e20 --- /dev/null +++ b/utils/test_harness/sysman/include/test_harness_sysman_vf_management.hpp @@ -0,0 +1,29 @@ +/* + * + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#ifndef level_zero_tests_ZE_TEST_HARNESS_SYSMAN_VF_MANAGEMENT_HPP +#define level_zero_tests_ZE_TEST_HARNESS_SYSMAN_VF_MANAGEMENT_HPP + +#include + +namespace level_zero_tests { + +uint32_t get_vf_handles_count(zes_device_handle_t device); +std::vector get_vf_handles(zes_device_handle_t device, + uint32_t &count); +zes_vf_exp_capabilities_t get_vf_capabilities(zes_vf_handle_t vf_handle); +uint32_t get_vf_mem_util_count(zes_vf_handle_t vf_handle); +std::vector get_vf_mem_util(zes_vf_handle_t vf_handle, + uint32_t &count); +uint32_t get_vf_engine_util_count(zes_vf_handle_t vf_handle); +std::vector +get_vf_engine_util(zes_vf_handle_t vf_handle, uint32_t &count); + +} // namespace level_zero_tests + +#endif \ No newline at end of file diff --git a/utils/test_harness/sysman/src/test_harness_sysman_vf_management.cpp b/utils/test_harness/sysman/src/test_harness_sysman_vf_management.cpp new file mode 100644 index 00000000..197774ee --- /dev/null +++ b/utils/test_harness/sysman/src/test_harness_sysman_vf_management.cpp @@ -0,0 +1,78 @@ +/* + * + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "test_harness/test_harness.hpp" + +#include +#include "utils/utils.hpp" + +namespace level_zero_tests { + +uint32_t get_vf_handles_count(zes_device_handle_t device) { + uint32_t count = 0; + EXPECT_EQ(ZE_RESULT_SUCCESS, + zesDeviceEnumEnabledVFExp(device, &count, nullptr)); + return count; +} + +std::vector get_vf_handles(zes_device_handle_t device, + uint32_t &count) { + if (count == 0) { + count = get_vf_handles_count(device); + } + std::vector vf_handles(count); + EXPECT_EQ(ZE_RESULT_SUCCESS, + zesDeviceEnumEnabledVFExp(device, &count, vf_handles.data())); + return vf_handles; +} + +zes_vf_exp_capabilities_t get_vf_capabilities(zes_vf_handle_t vf_handle) { + zes_vf_exp_capabilities_t vf_capabilities{}; + EXPECT_EQ(ZE_RESULT_SUCCESS, + zesVFManagementGetVFCapabilitiesExp(vf_handle, &vf_capabilities)); + return vf_capabilities; +} + +uint32_t get_vf_mem_util_count(zes_vf_handle_t vf_handle) { + uint32_t count = 0; + EXPECT_EQ(ZE_RESULT_SUCCESS, zesVFManagementGetVFMemoryUtilizationExp2( + vf_handle, &count, nullptr)); + return count; +} + +std::vector get_vf_mem_util(zes_vf_handle_t vf_handle, + uint32_t &count) { + if (count == 0) { + count = get_vf_mem_util_count(vf_handle); + } + std::vector vf_util_mem_exp(count); + EXPECT_EQ(ZE_RESULT_SUCCESS, zesVFManagementGetVFMemoryUtilizationExp2( + vf_handle, &count, vf_util_mem_exp.data())); + return vf_util_mem_exp; +} + +uint32_t get_vf_engine_util_count(zes_vf_handle_t vf_handle) { + uint32_t count = 0; + EXPECT_EQ(ZE_RESULT_SUCCESS, zesVFManagementGetVFEngineUtilizationExp2( + vf_handle, &count, nullptr)); + return count; +} + +std::vector +get_vf_engine_util(zes_vf_handle_t vf_handle, uint32_t &count) { + if (count == 0) { + count = get_vf_engine_util_count(vf_handle); + } + std::vector vf_util_engine_exp(count); + EXPECT_EQ(ZE_RESULT_SUCCESS, + zesVFManagementGetVFEngineUtilizationExp2( + vf_handle, &count, vf_util_engine_exp.data())); + return vf_util_engine_exp; +} + +} // namespace level_zero_tests