From 3f4c5eb2c60c4888561a6771d523492a3be10c98 Mon Sep 17 00:00:00 2001 From: viki435 Date: Tue, 12 Aug 2025 15:16:48 +0530 Subject: [PATCH 01/15] Primary JIRA: VLCLJ-2513 Sub-tasks: VLCLJ-2570, VLCLJ-2568, VLCLJ-2577 Fix: Handling GTEST_FAIL logic for multi-device scenario for power, performance and scheduler modules. Signed-off-by: viki435 --- .../src/test_sysman_performance.cpp | 355 +-- .../src/test_sysman_power.cpp | 1918 +++++++++-------- .../src/test_sysman_scheduler.cpp | 519 +++-- 3 files changed, 1528 insertions(+), 1264 deletions(-) diff --git a/conformance_tests/sysman/test_sysman_performance/src/test_sysman_performance.cpp b/conformance_tests/sysman/test_sysman_performance/src/test_sysman_performance.cpp index 0eab4827..11e87514 100644 --- a/conformance_tests/sysman/test_sysman_performance/src/test_sysman_performance.cpp +++ b/conformance_tests/sysman/test_sysman_performance/src/test_sysman_performance.cpp @@ -18,10 +18,16 @@ namespace lzt = level_zero_tests; namespace { #ifdef USE_ZESINIT -class PerformanceModuleZesTest : public lzt::ZesSysmanCtsClass {}; +class PerformanceModuleZesTest : public lzt::ZesSysmanCtsClass { +public: + bool is_performance_supported = false; +}; #define PERFORMANCE_TEST PerformanceModuleZesTest #else // USE_ZESINIT -class PerformanceModuleTest : public lzt::SysmanCtsClass {}; +class PerformanceModuleTest : public lzt::SysmanCtsClass { +public: + bool is_performance_supported = false; +}; #define PERFORMANCE_TEST PerformanceModuleTest #endif // USE_ZESINIT @@ -31,11 +37,16 @@ LZT_TEST_F( for (auto device : devices) { uint32_t count = 0; count = lzt::get_performance_handle_count(device); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + if (count > 0) { + is_performance_supported = true; + LOG_INFO << "Performance handles are available on this device! "; + } else { + LOG_INFO << "No performance handles found for this device! "; } } + if (!is_performance_supported) { + FAIL() << "No performance handles found on any of the devices! "; + } } LZT_TEST_F( @@ -43,17 +54,22 @@ LZT_TEST_F( GivenComponentCountZeroWhenRetrievingSysmanPerformanceThenNotNullPerformanceHandlesAreReturned) { for (auto device : devices) { uint32_t count = 0; - auto performance_handles = lzt::get_performance_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - ASSERT_EQ(performance_handles.size(), count); - for (auto performance_handle : performance_handles) { - ASSERT_NE(nullptr, performance_handle); + count = lzt::get_performance_handle_count(device); + if (count > 0) { + is_performance_supported = true; + LOG_INFO << "Performance handles are available on this device! "; + auto performance_handles = lzt::get_performance_handles(device, count); + ASSERT_EQ(performance_handles.size(), count); + for (auto performance_handle : performance_handles) { + ASSERT_NE(nullptr, performance_handle); + } + } else { + LOG_INFO << "No performance handles found for this device! "; } } + if (!is_performance_supported) { + FAIL() << "No performance handles found on any of the devices! "; + } } LZT_TEST_F( @@ -61,15 +77,20 @@ LZT_TEST_F( GivenInvalidComponentCountWhenRetrievingPerformanceHandlesThenActualComponentCountIsUpdated) { for (auto device : devices) { uint32_t actual_count = 0; - lzt::get_performance_handles(device, actual_count); - if (actual_count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + actual_count = lzt::get_performance_handle_count(device); + if (actual_count > 0) { + is_performance_supported = true; + LOG_INFO << "Performance handles are available on this device! "; + lzt::get_performance_handles(device, actual_count); + uint32_t test_count = actual_count + 1; + lzt::get_performance_handles(device, test_count); + EXPECT_EQ(test_count, actual_count); + } else { + LOG_INFO << "No performance handles found for this device! "; } - - uint32_t test_count = actual_count + 1; - lzt::get_performance_handles(device, test_count); - EXPECT_EQ(test_count, actual_count); + } + if (!is_performance_supported) { + FAIL() << "No performance handles found on any of the devices! "; } } @@ -78,24 +99,28 @@ LZT_TEST_F( GivenValidComponentCountWhenCallingApiTwiceThenSimilarPerformanceHandlesReturned) { for (auto device : devices) { uint32_t count = 0; - auto performance_handles_initial = - lzt::get_performance_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto performance_handle : performance_handles_initial) { - ASSERT_NE(nullptr, performance_handle); - } - - count = 0; - auto performance_handles_later = - lzt::get_performance_handles(device, count); - for (auto performance_handle : performance_handles_later) { - ASSERT_NE(nullptr, performance_handle); + count = lzt::get_performance_handle_count(device); + if (count > 0) { + is_performance_supported = true; + LOG_INFO << "Performance handles are available on this device! "; + auto performance_handles_initial = + lzt::get_performance_handles(device, count); + for (auto performance_handle : performance_handles_initial) { + ASSERT_NE(nullptr, performance_handle); + } + count = 0; + auto performance_handles_later = + lzt::get_performance_handles(device, count); + for (auto performance_handle : performance_handles_later) { + ASSERT_NE(nullptr, performance_handle); + } + EXPECT_EQ(performance_handles_initial, performance_handles_later); + } else { + LOG_INFO << "No performance handles found for this device! "; } - EXPECT_EQ(performance_handles_initial, performance_handles_later); + } + if (!is_performance_supported) { + FAIL() << "No performance handles found on any of the devices! "; } } @@ -105,26 +130,30 @@ LZT_TEST_F( for (auto device : devices) { auto deviceProperties = lzt::get_sysman_device_properties(device); uint32_t count = 0; - auto performance_handles = lzt::get_performance_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto performance_handle : performance_handles) { - ASSERT_NE(nullptr, performance_handle); - auto properties = lzt::get_performance_properties(performance_handle); - - if (properties.onSubdevice) { - EXPECT_LT(properties.subdeviceId, deviceProperties.numSubdevices); + count = lzt::get_performance_handle_count(device); + if (count > 0) { + is_performance_supported = true; + LOG_INFO << "Performance handles are available on this device! "; + auto performance_handles = lzt::get_performance_handles(device, count); + for (auto performance_handle : performance_handles) { + ASSERT_NE(nullptr, performance_handle); + auto properties = lzt::get_performance_properties(performance_handle); + if (properties.onSubdevice) { + EXPECT_LT(properties.subdeviceId, deviceProperties.numSubdevices); + } + EXPECT_GE(properties.engines, 0); + EXPECT_LE(properties.engines, + ZES_ENGINE_TYPE_FLAG_OTHER | ZES_ENGINE_TYPE_FLAG_COMPUTE | + ZES_ENGINE_TYPE_FLAG_3D | ZES_ENGINE_TYPE_FLAG_MEDIA | + ZES_ENGINE_TYPE_FLAG_DMA); } - EXPECT_GE(properties.engines, 0); - EXPECT_LE(properties.engines, - ZES_ENGINE_TYPE_FLAG_OTHER | ZES_ENGINE_TYPE_FLAG_COMPUTE | - ZES_ENGINE_TYPE_FLAG_3D | ZES_ENGINE_TYPE_FLAG_MEDIA | - ZES_ENGINE_TYPE_FLAG_DMA); + } else { + LOG_INFO << "No performance handles found for this device! "; } } + if (!is_performance_supported) { + FAIL() << "No performance handles found on any of the devices! "; + } } LZT_TEST_F( @@ -132,25 +161,30 @@ LZT_TEST_F( GivenValidPerformanceHandleWhenRetrievingPerformancePropertiesThenExpectSamePropertiesReturnedTwice) { for (auto device : devices) { uint32_t count = 0; - auto performance_handles = lzt::get_performance_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto performance_handle : performance_handles) { - ASSERT_NE(nullptr, performance_handle); - auto properties_initial = - lzt::get_performance_properties(performance_handle); - auto properties_later = - lzt::get_performance_properties(performance_handle); - - if (properties_initial.onSubdevice && properties_later.onSubdevice) { - EXPECT_EQ(properties_initial.subdeviceId, properties_later.subdeviceId); + count = lzt::get_performance_handle_count(device); + if (count > 0) { + is_performance_supported = true; + LOG_INFO << "Performance handles are available on this device! "; + auto performance_handles = lzt::get_performance_handles(device, count); + for (auto performance_handle : performance_handles) { + ASSERT_NE(nullptr, performance_handle); + auto properties_initial = + lzt::get_performance_properties(performance_handle); + auto properties_later = + lzt::get_performance_properties(performance_handle); + if (properties_initial.onSubdevice && properties_later.onSubdevice) { + EXPECT_EQ(properties_initial.subdeviceId, + properties_later.subdeviceId); + } + EXPECT_EQ(properties_initial.engines, properties_later.engines); } - EXPECT_EQ(properties_initial.engines, properties_later.engines); + } else { + LOG_INFO << "No performance handles found for this device! "; } } + if (!is_performance_supported) { + FAIL() << "No performance handles found on any of the devices! "; + } } LZT_TEST_F( @@ -158,23 +192,28 @@ LZT_TEST_F( GivenValidPerformanceHandleWhenSettingPerformanceConfigurationThenSuccessIsReturned) { for (auto device : devices) { uint32_t count = 0; - auto performance_handles = lzt::get_performance_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto performance_handle : performance_handles) { - ASSERT_NE(nullptr, performance_handle); - auto initialFactor = lzt::get_performance_config(performance_handle); - double factor = 50; // Check with a random factor value within its range - lzt::set_performance_config(performance_handle, factor); - auto getFactor = lzt::get_performance_config(performance_handle); - EXPECT_GE(getFactor, 0); - EXPECT_LE(getFactor, 100); - lzt::set_performance_config(performance_handle, initialFactor); + count = lzt::get_performance_handle_count(device); + if (count > 0) { + is_performance_supported = true; + LOG_INFO << "Performance handles are available on this device! "; + auto performance_handles = lzt::get_performance_handles(device, count); + for (auto performance_handle : performance_handles) { + ASSERT_NE(nullptr, performance_handle); + auto initialFactor = lzt::get_performance_config(performance_handle); + double factor = 50; // Check with a random factor value within its range + lzt::set_performance_config(performance_handle, factor); + auto getFactor = lzt::get_performance_config(performance_handle); + EXPECT_GE(getFactor, 0); + EXPECT_LE(getFactor, 100); + lzt::set_performance_config(performance_handle, initialFactor); + } + } else { + LOG_INFO << "No performance handles found for this device! "; } } + if (!is_performance_supported) { + FAIL() << "No performance handles found on any of the devices! "; + } } static double set_performance_factor(zes_perf_handle_t pHandle, @@ -189,44 +228,50 @@ LZT_TEST_F( GivenValidPerformanceHandleWhenSettingMultiplePerformanceConfigurationsForMediaThenValidPerformanceFactorIsReturned) { for (auto device : devices) { uint32_t count = 0; - auto performance_handles = lzt::get_performance_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - for (auto performance_handle : performance_handles) { - ASSERT_NE(nullptr, performance_handle); - zes_perf_properties_t perfProperties = {}; - perfProperties = lzt::get_performance_properties(performance_handle); - if (perfProperties.engines & ZES_ENGINE_TYPE_FLAG_MEDIA) { - auto initialFactor = lzt::get_performance_config(performance_handle); - // Verify that performance factor is equal to 50 if value set is 1-50 - // and equal to 100 if value set is 51-100 - // value 25 - double pFactor = set_performance_factor(performance_handle, 25); - EXPECT_EQ(pFactor, 50); - // value 49 - pFactor = set_performance_factor(performance_handle, 49); - EXPECT_EQ(pFactor, 50); - // value 50 - pFactor = set_performance_factor(performance_handle, 50); - EXPECT_EQ(pFactor, 50); - // value 51 - pFactor = set_performance_factor(performance_handle, 51); - EXPECT_EQ(pFactor, 100); - // value 75 - pFactor = set_performance_factor(performance_handle, 75); - EXPECT_EQ(pFactor, 100); - // value 99 - pFactor = set_performance_factor(performance_handle, 99); - EXPECT_EQ(pFactor, 100); - // value 100 - pFactor = set_performance_factor(performance_handle, 100); - EXPECT_EQ(pFactor, 100); - lzt::set_performance_config(performance_handle, initialFactor); + count = lzt::get_performance_handle_count(device); + if (count > 0) { + is_performance_supported = true; + LOG_INFO << "Performance handles are available on this device! "; + auto performance_handles = lzt::get_performance_handles(device, count); + for (auto performance_handle : performance_handles) { + ASSERT_NE(nullptr, performance_handle); + zes_perf_properties_t perfProperties = {}; + perfProperties = lzt::get_performance_properties(performance_handle); + if (perfProperties.engines & ZES_ENGINE_TYPE_FLAG_MEDIA) { + auto initialFactor = lzt::get_performance_config(performance_handle); + // Verify that performance factor is equal to 50 if value set is 1-50 + // and equal to 100 if value set is 51-100 + // value 25 + double pFactor = set_performance_factor(performance_handle, 25); + EXPECT_EQ(pFactor, 50); + // value 49 + pFactor = set_performance_factor(performance_handle, 49); + EXPECT_EQ(pFactor, 50); + // value 50 + pFactor = set_performance_factor(performance_handle, 50); + EXPECT_EQ(pFactor, 50); + // value 51 + pFactor = set_performance_factor(performance_handle, 51); + EXPECT_EQ(pFactor, 100); + // value 75 + pFactor = set_performance_factor(performance_handle, 75); + EXPECT_EQ(pFactor, 100); + // value 99 + pFactor = set_performance_factor(performance_handle, 99); + EXPECT_EQ(pFactor, 100); + // value 100 + pFactor = set_performance_factor(performance_handle, 100); + EXPECT_EQ(pFactor, 100); + lzt::set_performance_config(performance_handle, initialFactor); + } } + } else { + LOG_INFO << "No performance handles found for this device! "; } } + if (!is_performance_supported) { + FAIL() << "No performance handles found on any of the devices! "; + } } LZT_TEST_F( @@ -234,19 +279,24 @@ LZT_TEST_F( GivenValidPerformanceHandleWhenGettingPerformanceConfigurationThenValidPerformanceFactorIsReturned) { for (auto device : devices) { uint32_t count = 0; - auto performance_handles = lzt::get_performance_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto performance_handle : performance_handles) { - ASSERT_NE(nullptr, performance_handle); - auto getFactor = lzt::get_performance_config(performance_handle); - EXPECT_GE(getFactor, 0); - EXPECT_LE(getFactor, 100); + count = lzt::get_performance_handle_count(device); + if (count > 0) { + is_performance_supported = true; + LOG_INFO << "Performance handles are available on this device! "; + auto performance_handles = lzt::get_performance_handles(device, count); + for (auto performance_handle : performance_handles) { + ASSERT_NE(nullptr, performance_handle); + auto getFactor = lzt::get_performance_config(performance_handle); + EXPECT_GE(getFactor, 0); + EXPECT_LE(getFactor, 100); + } + } else { + LOG_INFO << "No performance handles found for this device! "; } } + if (!is_performance_supported) { + FAIL() << "No performance handles found on any of the devices! "; + } } #ifdef USE_ZESINIT @@ -266,27 +316,34 @@ class PerformanceModuleParamComputePerformanceFactorTest LZT_TEST_P( PERFORMANCE_COMPUTE_TEST, GivenValidPerformanceHandleWhenSettingMultiplePerformanceFactorForComputeThenValidPerformanceFactorIsReturned) { + bool is_perf_supported = false; for (auto device : devices) { uint32_t count = 0; - auto performance_handles = lzt::get_performance_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - for (auto performance_handle : performance_handles) { - ASSERT_NE(nullptr, performance_handle); - zes_perf_properties_t perfProperties = {}; - perfProperties = lzt::get_performance_properties(performance_handle); - if (perfProperties.engines & ZES_ENGINE_TYPE_FLAG_COMPUTE) { - auto initialFactor = lzt::get_performance_config(performance_handle); - double input_pfactor = static_cast(GetParam()); - double pFactor = - set_performance_factor(performance_handle, input_pfactor); - EXPECT_EQ(std::round(pFactor), input_pfactor); - lzt::set_performance_config(performance_handle, initialFactor); + count = lzt::get_performance_handle_count(device); + if (count > 0) { + is_perf_supported = true; + LOG_INFO << "Performance handles are available on this device! "; + auto performance_handles = lzt::get_performance_handles(device, count); + for (auto performance_handle : performance_handles) { + ASSERT_NE(nullptr, performance_handle); + zes_perf_properties_t perfProperties = {}; + perfProperties = lzt::get_performance_properties(performance_handle); + if (perfProperties.engines & ZES_ENGINE_TYPE_FLAG_COMPUTE) { + auto initialFactor = lzt::get_performance_config(performance_handle); + double input_pfactor = static_cast(GetParam()); + double pFactor = + set_performance_factor(performance_handle, input_pfactor); + EXPECT_EQ(std::round(pFactor), input_pfactor); + lzt::set_performance_config(performance_handle, initialFactor); + } } + } else { + LOG_INFO << "No performance handles found for this device! "; } } + if (!is_perf_supported) { + FAIL() << "No performance handles found on any of the devices! "; + } } INSTANTIATE_TEST_CASE_P(TestCasesforComputePerformanceFactorVerification, diff --git a/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp b/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp index 0612cee0..4b597a7e 100644 --- a/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp +++ b/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp @@ -21,12 +21,14 @@ namespace { class PowerModuleZesTest : public lzt::ZesSysmanCtsClass { public: bool power_handles_available = false; + bool is_power_supported = false; }; #define POWER_TEST PowerModuleZesTest #else // USE_ZESINIT class PowerModuleTest : public lzt::SysmanCtsClass { public: bool power_handles_available = false; + bool is_power_supported = false; }; #define POWER_TEST PowerModuleTest #endif // USE_ZESINIT @@ -36,16 +38,21 @@ LZT_TEST_F( GivenValidDeviceWhenRetrievingPowerHandlesThenNonZeroCountAndValidPowerHandlesAreReturned) { for (auto device : devices) { uint32_t count = 0; - auto p_power_handles = lzt::get_power_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); + count = lzt::get_power_handle_count(device); + if (count > 0) { + is_power_supported = true; + LOG_INFO << "Power handles are available on this device! "; + auto p_power_handles = lzt::get_power_handles(device, count); + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); + } + } else { + LOG_INFO << "No power handles found for this device! "; } } + if (!is_power_supported) { + FAIL() << "No power handles found on any of the devices! "; + } } LZT_TEST_F( POWER_TEST, @@ -53,14 +60,19 @@ LZT_TEST_F( for (auto device : devices) { uint32_t icount = 0; uint32_t lcount = 0; - auto p_power_handlesInitial = lzt::get_power_handles(device, icount); - if (icount == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + icount = lzt::get_power_handle_count(device); + if (icount > 0) { + is_power_supported = true; + LOG_INFO << "Power handles are available on this device! "; + auto p_power_handlesInitial = lzt::get_power_handles(device, icount); + auto p_power_handlesLater = lzt::get_power_handles(device, lcount); + EXPECT_EQ(p_power_handlesInitial, p_power_handlesLater); + } else { + LOG_INFO << "No power handles found for this device! "; } - - auto p_power_handlesLater = lzt::get_power_handles(device, lcount); - EXPECT_EQ(p_power_handlesInitial, p_power_handlesLater); + } + if (!is_power_supported) { + FAIL() << "No power handles found on any of the devices! "; } } LZT_TEST_F( @@ -69,55 +81,62 @@ LZT_TEST_F( for (auto device : devices) { uint32_t p_count = lzt::get_power_handle_count(device); - if (p_count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - uint32_t tcount = p_count + 1; - lzt::get_power_handles(device, tcount); - EXPECT_EQ(tcount, p_count); - if (p_count > 1) { - tcount = p_count - 1; - auto p_power_handles = lzt::get_power_handles(device, tcount); - EXPECT_EQ(static_cast(p_power_handles.size()), tcount); + if (p_count > 0) { + is_power_supported = true; + LOG_INFO << "Power handles are available on this device! "; + uint32_t tcount = p_count + 1; + lzt::get_power_handles(device, tcount); + EXPECT_EQ(tcount, p_count); + if (p_count > 1) { + tcount = p_count - 1; + auto p_power_handles = lzt::get_power_handles(device, tcount); + EXPECT_EQ(static_cast(p_power_handles.size()), tcount); + } + } else { + LOG_INFO << "No power handles found for this device! "; } } + if (!is_power_supported) { + FAIL() << "No power handles found on any of the devices! "; + } } LZT_TEST_F( POWER_TEST, GivenSamePowerHandleWhenRequestingPowerPropertiesThenCheckPowerLimitsAreInRange) { for (auto device : devices) { uint32_t count = 0; - auto p_power_handles = lzt::get_power_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); - auto pProperties = lzt::get_power_properties(p_power_handle); - if (pProperties.maxLimit != -1) { - EXPECT_GT(pProperties.maxLimit, 0); - EXPECT_GE(pProperties.maxLimit, pProperties.minLimit); - } else { - LOG_INFO << "maxLimit unsupported: "; - } - - if (pProperties.minLimit != -1) { - EXPECT_GE(pProperties.minLimit, 0); - } else { - LOG_INFO << "minlimit unsupported: "; - } - - if (pProperties.defaultLimit != -1) { - EXPECT_GT(pProperties.defaultLimit, 0); - } else { - LOG_INFO << "defaultLimit unsupported: "; + count = lzt::get_power_handle_count(device); + if (count > 0) { + is_power_supported = true; + LOG_INFO << "Power handles are available on this device! "; + auto p_power_handles = lzt::get_power_handles(device, count); + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); + auto pProperties = lzt::get_power_properties(p_power_handle); + if (pProperties.maxLimit != -1) { + EXPECT_GT(pProperties.maxLimit, 0); + EXPECT_GE(pProperties.maxLimit, pProperties.minLimit); + } else { + LOG_INFO << "maxLimit unsupported: "; + } + if (pProperties.minLimit != -1) { + EXPECT_GE(pProperties.minLimit, 0); + } else { + LOG_INFO << "minlimit unsupported: "; + } + if (pProperties.defaultLimit != -1) { + EXPECT_GT(pProperties.defaultLimit, 0); + } else { + LOG_INFO << "defaultLimit unsupported: "; + } } + } else { + LOG_INFO << "No power handles found for this device! "; } } + if (!is_power_supported) { + FAIL() << "No power handles found on any of the devices! "; + } } LZT_TEST_F( @@ -125,30 +144,37 @@ LZT_TEST_F( GivenSamePowerHandleWhenRequestingPowerPropertiesThenExpectSamePropertiesTwice) { for (auto device : devices) { uint32_t count = 0; - auto p_power_handles = lzt::get_power_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); - auto pproperties_initial = lzt::get_power_properties(p_power_handle); - if (pproperties_initial.maxLimit == -1) { - LOG_INFO << "maxlimit unsupported: "; + count = lzt::get_power_handle_count(device); + if (count > 0) { + is_power_supported = true; + LOG_INFO << "Power handles are available on this device! "; + auto p_power_handles = lzt::get_power_handles(device, count); + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); + auto pproperties_initial = lzt::get_power_properties(p_power_handle); + if (pproperties_initial.maxLimit == -1) { + LOG_INFO << "maxlimit unsupported: "; + } + auto pproperties_later = lzt::get_power_properties(p_power_handle); + EXPECT_EQ(pproperties_initial.onSubdevice, + pproperties_later.onSubdevice); + EXPECT_EQ(pproperties_initial.subdeviceId, + pproperties_later.subdeviceId); + EXPECT_EQ(pproperties_initial.canControl, pproperties_later.canControl); + EXPECT_EQ(pproperties_initial.isEnergyThresholdSupported, + pproperties_later.isEnergyThresholdSupported); + EXPECT_EQ(pproperties_initial.maxLimit, pproperties_later.maxLimit); + EXPECT_EQ(pproperties_initial.minLimit, pproperties_later.minLimit); + EXPECT_EQ(pproperties_initial.defaultLimit, + pproperties_later.defaultLimit); } - auto pproperties_later = lzt::get_power_properties(p_power_handle); - EXPECT_EQ(pproperties_initial.onSubdevice, pproperties_later.onSubdevice); - EXPECT_EQ(pproperties_initial.subdeviceId, pproperties_later.subdeviceId); - EXPECT_EQ(pproperties_initial.canControl, pproperties_later.canControl); - EXPECT_EQ(pproperties_initial.isEnergyThresholdSupported, - pproperties_later.isEnergyThresholdSupported); - EXPECT_EQ(pproperties_initial.maxLimit, pproperties_later.maxLimit); - EXPECT_EQ(pproperties_initial.minLimit, pproperties_later.minLimit); - EXPECT_EQ(pproperties_initial.defaultLimit, - pproperties_later.defaultLimit); + } else { + LOG_INFO << "No power handles found for this device! "; } } + if (!is_power_supported) { + FAIL() << "No power handles found on any of the devices! "; + } } LZT_TEST_F( @@ -156,428 +182,563 @@ LZT_TEST_F( GivenValidPowerHandleWhenRequestingPowerLimitsThenExpectZesSysmanPowerGetLimitsToReturnValidPowerLimits) { for (auto device : devices) { uint32_t count = 0; - auto p_power_handles = lzt::get_power_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); - zes_power_sustained_limit_t pSustained = {}; - zes_power_burst_limit_t pBurst = {}; - zes_power_peak_limit_t pPeak = {}; - auto status = - lzt::get_power_limits(p_power_handle, &pSustained, &pBurst, &pPeak); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - auto pProperties = lzt::get_power_properties(p_power_handle); - if ((pBurst.enabled != 0) && (pSustained.enabled != 0)) { - EXPECT_LE(pSustained.power, pBurst.power); - } - if ((pPeak.powerAC != -1) && (pBurst.enabled != 0)) { - EXPECT_LE(pBurst.power, pPeak.powerAC); + count = lzt::get_power_handle_count(device); + if (count > 0) { + is_power_supported = true; + LOG_INFO << "Power handles are available on this device! "; + auto p_power_handles = lzt::get_power_handles(device, count); + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); + zes_power_sustained_limit_t pSustained = {}; + zes_power_burst_limit_t pBurst = {}; + zes_power_peak_limit_t pPeak = {}; + auto status = + lzt::get_power_limits(p_power_handle, &pSustained, &pBurst, &pPeak); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + auto pProperties = lzt::get_power_properties(p_power_handle); + if ((pBurst.enabled != 0) && (pSustained.enabled != 0)) { + EXPECT_LE(pSustained.power, pBurst.power); + } + if ((pPeak.powerAC != -1) && (pBurst.enabled != 0)) { + EXPECT_LE(pBurst.power, pPeak.powerAC); + } } + } else { + LOG_INFO << "No power handles found for this device! "; } } + if (!is_power_supported) { + FAIL() << "No power handles found on any of the devices! "; + } } LZT_TEST_F( POWER_TEST, GivenValidPowerHandleWhenRequestingPowerLimitsThenExpectzesSysmanPowerGetLimitsToReturnSameValuesTwice) { for (auto device : devices) { uint32_t count = 0; - auto p_power_handles = lzt::get_power_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); - zes_power_sustained_limit_t pSustainedInitial = {}; - zes_power_burst_limit_t pBurstInitial = {}; - zes_power_peak_limit_t pPeakInitial = {}; - auto status = lzt::get_power_limits(p_power_handle, &pSustainedInitial, - &pBurstInitial, &pPeakInitial); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - zes_power_sustained_limit_t pSustainedLater = {}; - zes_power_burst_limit_t pBurstLater = {}; - zes_power_peak_limit_t pPeakLater = {}; - status = lzt::get_power_limits(p_power_handle, &pSustainedLater, - &pBurstLater, &pPeakLater); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; + count = lzt::get_power_handle_count(device); + if (count > 0) { + is_power_supported = true; + LOG_INFO << "Power handles are available on this device! "; + auto p_power_handles = lzt::get_power_handles(device, count); + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); + zes_power_sustained_limit_t pSustainedInitial = {}; + zes_power_burst_limit_t pBurstInitial = {}; + zes_power_peak_limit_t pPeakInitial = {}; + auto status = lzt::get_power_limits(p_power_handle, &pSustainedInitial, + &pBurstInitial, &pPeakInitial); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + zes_power_sustained_limit_t pSustainedLater = {}; + zes_power_burst_limit_t pBurstLater = {}; + zes_power_peak_limit_t pPeakLater = {}; + status = lzt::get_power_limits(p_power_handle, &pSustainedLater, + &pBurstLater, &pPeakLater); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + EXPECT_EQ(pSustainedInitial.enabled, pSustainedLater.enabled); + EXPECT_EQ(pSustainedInitial.power, pSustainedLater.power); + EXPECT_EQ(pSustainedInitial.interval, pSustainedLater.interval); + EXPECT_EQ(pBurstInitial.enabled, pBurstLater.enabled); + EXPECT_EQ(pBurstInitial.power, pBurstLater.power); + EXPECT_EQ(pPeakInitial.powerAC, pPeakLater.powerAC); + EXPECT_EQ(pPeakInitial.powerDC, pPeakLater.powerDC); } - EXPECT_ZE_RESULT_SUCCESS(status); - EXPECT_EQ(pSustainedInitial.enabled, pSustainedLater.enabled); - EXPECT_EQ(pSustainedInitial.power, pSustainedLater.power); - EXPECT_EQ(pSustainedInitial.interval, pSustainedLater.interval); - EXPECT_EQ(pBurstInitial.enabled, pBurstLater.enabled); - EXPECT_EQ(pBurstInitial.power, pBurstLater.power); - EXPECT_EQ(pPeakInitial.powerAC, pPeakLater.powerAC); - EXPECT_EQ(pPeakInitial.powerDC, pPeakLater.powerDC); + } else { + LOG_INFO << "No power handles found for this device! "; } } + if (!is_power_supported) { + FAIL() << "No power handles found on any of the devices! "; + } } LZT_TEST_F( POWER_TEST, GivenValidPowerHandleWhenSettingPowerValuesThenExpectzesSysmanPowerSetLimitsFollowedByzesSysmanPowerGetLimitsToMatch) { for (auto device : devices) { uint32_t count = 0; - auto p_power_handles = lzt::get_power_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); - zes_power_sustained_limit_t pSustainedInitial = {}; - zes_power_burst_limit_t pBurstInitial = {}; - zes_power_peak_limit_t pPeakInitial = {}; - auto status = lzt::get_power_limits( - p_power_handle, &pSustainedInitial, &pBurstInitial, - &pPeakInitial); // get default power values - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - auto pProperties = lzt::get_power_properties(p_power_handle); - if (pProperties.maxLimit == -1) { - LOG_INFO << "maxlimit unsupported:"; - } - zes_power_sustained_limit_t pSustainedSet = {}; - zes_power_burst_limit_t pBurstSet = {}; - zes_power_peak_limit_t pPeakSet = {}; - if (pSustainedInitial.enabled) - pSustainedSet.enabled = 1; - else - pSustainedSet.enabled = 0; - pSustainedSet.interval = pSustainedInitial.interval; - if (pBurstInitial.enabled) - pBurstSet.enabled = 1; - else - pBurstSet.enabled = 0; - if (pProperties.maxLimit != -1) { - pSustainedSet.power = pProperties.maxLimit; - pBurstSet.power = pProperties.maxLimit; - pPeakSet.powerAC = pProperties.maxLimit; - } - pPeakSet.powerDC = pPeakInitial.powerDC; - if (pBurstSet.enabled && pSustainedSet.enabled) { - status = - lzt::set_power_limits(p_power_handle, &pSustainedSet, &pBurstSet, - &pPeakSet); // Set power values - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - zes_power_sustained_limit_t pSustainedGet = {}; - zes_power_burst_limit_t pBurstGet = {}; - zes_power_peak_limit_t pPeakGet = {}; - status = - lzt::get_power_limits(p_power_handle, &pSustainedGet, &pBurstGet, - &pPeakGet); // Get power values + count = lzt::get_power_handle_count(device); + if (count > 0) { + is_power_supported = true; + LOG_INFO << "Power handles are available on this device! "; + auto p_power_handles = lzt::get_power_handles(device, count); + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); + zes_power_sustained_limit_t pSustainedInitial = {}; + zes_power_burst_limit_t pBurstInitial = {}; + zes_power_peak_limit_t pPeakInitial = {}; + auto status = lzt::get_power_limits( + p_power_handle, &pSustainedInitial, &pBurstInitial, + &pPeakInitial); // get default power values if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { continue; } EXPECT_ZE_RESULT_SUCCESS(status); - EXPECT_EQ(pSustainedGet.enabled, pSustainedSet.enabled); - EXPECT_EQ(pSustainedGet.power, pSustainedSet.power); - EXPECT_EQ(pSustainedGet.interval, pSustainedSet.interval); - EXPECT_EQ(pBurstGet.enabled, pBurstSet.enabled); - EXPECT_EQ(pBurstGet.power, pBurstSet.power); - if (pPeakGet.powerAC != -1) { - EXPECT_EQ(pPeakGet.powerAC, pPeakSet.powerAC); + auto pProperties = lzt::get_power_properties(p_power_handle); + if (pProperties.maxLimit == -1) { + LOG_INFO << "maxlimit unsupported:"; } - if (pPeakGet.powerDC != -1) { - EXPECT_EQ(pPeakGet.powerDC, - pPeakSet.powerDC); // Verify whether values match or not + zes_power_sustained_limit_t pSustainedSet = {}; + zes_power_burst_limit_t pBurstSet = {}; + zes_power_peak_limit_t pPeakSet = {}; + if (pSustainedInitial.enabled) + pSustainedSet.enabled = 1; + else + pSustainedSet.enabled = 0; + pSustainedSet.interval = pSustainedInitial.interval; + if (pBurstInitial.enabled) + pBurstSet.enabled = 1; + else + pBurstSet.enabled = 0; + if (pProperties.maxLimit != -1) { + pSustainedSet.power = pProperties.maxLimit; + pBurstSet.power = pProperties.maxLimit; + pPeakSet.powerAC = pProperties.maxLimit; } - status = lzt::set_power_limits(p_power_handle, &pSustainedInitial, - &pBurstInitial, - &pPeakInitial); // Set values to default - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; + pPeakSet.powerDC = pPeakInitial.powerDC; + if (pBurstSet.enabled && pSustainedSet.enabled) { + status = + lzt::set_power_limits(p_power_handle, &pSustainedSet, &pBurstSet, + &pPeakSet); // Set power values + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + zes_power_sustained_limit_t pSustainedGet = {}; + zes_power_burst_limit_t pBurstGet = {}; + zes_power_peak_limit_t pPeakGet = {}; + status = + lzt::get_power_limits(p_power_handle, &pSustainedGet, &pBurstGet, + &pPeakGet); // Get power values + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + EXPECT_EQ(pSustainedGet.enabled, pSustainedSet.enabled); + EXPECT_EQ(pSustainedGet.power, pSustainedSet.power); + EXPECT_EQ(pSustainedGet.interval, pSustainedSet.interval); + EXPECT_EQ(pBurstGet.enabled, pBurstSet.enabled); + EXPECT_EQ(pBurstGet.power, pBurstSet.power); + if (pPeakGet.powerAC != -1) { + EXPECT_EQ(pPeakGet.powerAC, pPeakSet.powerAC); + } + if (pPeakGet.powerDC != -1) { + EXPECT_EQ(pPeakGet.powerDC, + pPeakSet.powerDC); // Verify whether values match or not + } + status = lzt::set_power_limits( + p_power_handle, &pSustainedInitial, &pBurstInitial, + &pPeakInitial); // Set values to default + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + } else { + LOG_INFO << "Set limit not supported due to burst and sustained " + "enabled flag is false"; } - EXPECT_ZE_RESULT_SUCCESS(status); - } else { - LOG_INFO << "Set limit not supported due to burst and sustained " - "enabled flag is false"; } + } else { + LOG_INFO << "No power handles found for this device! "; } } + if (!is_power_supported) { + FAIL() << "No power handles found on any of the devices! "; + } } LZT_TEST_F( POWER_TEST, GivenValidPowerHandleThenExpectzesSysmanPowerGetEnergyCounterToReturnSuccess) { for (auto device : devices) { uint32_t count = 0; - auto p_power_handles = lzt::get_power_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); - zes_power_energy_counter_t pEnergyCounter = {}; - lzt::get_power_energy_counter(p_power_handle, &pEnergyCounter); - uint64_t energy_initial = pEnergyCounter.energy; - uint64_t timestamp_initial = pEnergyCounter.timestamp; - std::this_thread::sleep_for(std::chrono::milliseconds(2)); - lzt::get_power_energy_counter(p_power_handle, &pEnergyCounter); - uint64_t energy_later = pEnergyCounter.energy; - uint64_t timestamp_later = pEnergyCounter.timestamp; - EXPECT_GE(energy_later, energy_initial); - EXPECT_NE(timestamp_later, timestamp_initial); + count = lzt::get_power_handle_count(device); + if (count > 0) { + is_power_supported = true; + LOG_INFO << "Power handles are available on this device! "; + auto p_power_handles = lzt::get_power_handles(device, count); + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); + zes_power_energy_counter_t pEnergyCounter = {}; + lzt::get_power_energy_counter(p_power_handle, &pEnergyCounter); + uint64_t energy_initial = pEnergyCounter.energy; + uint64_t timestamp_initial = pEnergyCounter.timestamp; + std::this_thread::sleep_for(std::chrono::milliseconds(2)); + lzt::get_power_energy_counter(p_power_handle, &pEnergyCounter); + uint64_t energy_later = pEnergyCounter.energy; + uint64_t timestamp_later = pEnergyCounter.timestamp; + EXPECT_GE(energy_later, energy_initial); + EXPECT_NE(timestamp_later, timestamp_initial); + } + } else { + LOG_INFO << "No power handles found for this device! "; } } + if (!is_power_supported) { + FAIL() << "No power handles found on any of the devices! "; + } } LZT_TEST_F( POWER_TEST, GivenValidPowerHandleWhenGettingEnergyThresholdThenSuccessIsReturnedAndParameterValuesAreValid) { for (auto device : devices) { uint32_t count = 0; - auto p_power_handles = lzt::get_power_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); - zes_energy_threshold_t pThreshold = {}; - auto status = - lzt::get_power_energy_threshold(p_power_handle, &pThreshold); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; + count = lzt::get_power_handle_count(device); + if (count > 0) { + is_power_supported = true; + LOG_INFO << "Power handles are available on this device! "; + auto p_power_handles = lzt::get_power_handles(device, count); + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); + zes_energy_threshold_t pThreshold = {}; + auto status = + lzt::get_power_energy_threshold(p_power_handle, &pThreshold); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + ASSERT_GE(pThreshold.threshold, 0); + if (pThreshold.threshold > 0) + EXPECT_LT(pThreshold.processId, UINT32_MAX); + else + EXPECT_EQ(pThreshold.processId, UINT32_MAX); } - EXPECT_ZE_RESULT_SUCCESS(status); - ASSERT_GE(pThreshold.threshold, 0); - if (pThreshold.threshold > 0) - EXPECT_LT(pThreshold.processId, UINT32_MAX); - else - EXPECT_EQ(pThreshold.processId, UINT32_MAX); + } else { + LOG_INFO << "No power handles found for this device! "; } } + if (!is_power_supported) { + FAIL() << "No power handles found on any of the devices! "; + } } LZT_TEST_F( POWER_TEST, GivenValidPowerHandleWhenGettingEnergyThresholdTwiceThenSameValueReturned) { for (auto device : devices) { uint32_t count = 0; - auto p_power_handles = lzt::get_power_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); - zes_energy_threshold_t pThresholdInitial = {}; - auto status = - lzt::get_power_energy_threshold(p_power_handle, &pThresholdInitial); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - zes_energy_threshold_t pThresholdLater = {}; - status = - lzt::get_power_energy_threshold(p_power_handle, &pThresholdLater); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; + count = lzt::get_power_handle_count(device); + if (count > 0) { + is_power_supported = true; + LOG_INFO << "Power handles are available on this device! "; + auto p_power_handles = lzt::get_power_handles(device, count); + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); + zes_energy_threshold_t pThresholdInitial = {}; + auto status = + lzt::get_power_energy_threshold(p_power_handle, &pThresholdInitial); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + zes_energy_threshold_t pThresholdLater = {}; + status = + lzt::get_power_energy_threshold(p_power_handle, &pThresholdLater); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + EXPECT_EQ(pThresholdInitial.enable, pThresholdLater.enable); + EXPECT_EQ(pThresholdInitial.threshold, pThresholdLater.threshold); + EXPECT_EQ(pThresholdInitial.processId, pThresholdLater.processId); } - EXPECT_ZE_RESULT_SUCCESS(status); - EXPECT_EQ(pThresholdInitial.enable, pThresholdLater.enable); - EXPECT_EQ(pThresholdInitial.threshold, pThresholdLater.threshold); - EXPECT_EQ(pThresholdInitial.processId, pThresholdLater.processId); + } else { + LOG_INFO << "No power handles found for this device! "; } } + if (!is_power_supported) { + FAIL() << "No power handles found on any of the devices! "; + } } LZT_TEST_F( POWER_TEST, GivenValidPowerHandleWhenSettingEnergyValuesThenExpectZesSysmanPowerSetEnergyThresholdFollowedByZesSysmanPowerGetEnergyThresholdToMatch) { for (auto device : devices) { uint32_t count = 0; - auto p_power_handles = lzt::get_power_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); - zes_energy_threshold_t pThresholdInitial = {}; - auto status = lzt::get_power_energy_threshold( - p_power_handle, &pThresholdInitial); // get initial value - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - double threshold = 0; - lzt::set_power_energy_threshold(p_power_handle, threshold); // set test - // value - zes_energy_threshold_t pThresholdGet = {}; - status = - lzt::get_power_energy_threshold(p_power_handle, - &pThresholdGet); // get test value - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; + count = lzt::get_power_handle_count(device); + if (count > 0) { + is_power_supported = true; + LOG_INFO << "Power handles are available on this device! "; + auto p_power_handles = lzt::get_power_handles(device, count); + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); + zes_energy_threshold_t pThresholdInitial = {}; + auto status = lzt::get_power_energy_threshold( + p_power_handle, &pThresholdInitial); // get initial value + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + double threshold = 0; + lzt::set_power_energy_threshold(p_power_handle, + threshold); // set test value + zes_energy_threshold_t pThresholdGet = {}; + status = + lzt::get_power_energy_threshold(p_power_handle, + &pThresholdGet); // get test value + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + EXPECT_EQ(pThresholdGet.threshold, threshold); // match both the values + EXPECT_EQ(pThresholdGet.processId, UINT32_MAX); + lzt::set_power_energy_threshold( + p_power_handle, + pThresholdInitial.threshold); // reset to initial value } - EXPECT_ZE_RESULT_SUCCESS(status); - EXPECT_EQ(pThresholdGet.threshold, threshold); // match both the values - EXPECT_EQ(pThresholdGet.processId, UINT32_MAX); - lzt::set_power_energy_threshold( - p_power_handle, - pThresholdInitial.threshold); // reset to initial value + } else { + LOG_INFO << "No power handles found for this device! "; } } + if (!is_power_supported) { + FAIL() << "No power handles found on any of the devices! "; + } } LZT_TEST_F( POWER_TEST, GivenValidPowerHandleWhenRequestingPowerLimitsThenExpectZesPowerGetLimitsExtToReturnSameValuesTwice) { for (auto device : devices) { uint32_t count = 0; - auto p_power_handles = lzt::get_power_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); - uint32_t count_power = 0; - - zes_power_limit_ext_desc_t power_peak_descriptor_first = {}; - zes_power_limit_ext_desc_t power_burst_descriptor_first = {}; - zes_power_limit_ext_desc_t power_sustained_descriptor_first = {}; - zes_power_limit_ext_desc_t power_instantaneous_descriptor_first = {}; - - zes_power_limit_ext_desc_t power_peak_descriptor_second = {}; - zes_power_limit_ext_desc_t power_burst_descriptor_second = {}; - zes_power_limit_ext_desc_t power_sustained_descriptor_second = {}; - zes_power_limit_ext_desc_t power_instantaneous_descriptor_second = {}; - - std::vector power_limits_descriptors_initial; - auto status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors_initial); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - for (auto power_limits_descriptor_initial : - power_limits_descriptors_initial) { - if (power_limits_descriptor_initial.level == - ZES_POWER_LEVEL_SUSTAINED) { - power_sustained_descriptor_first = power_limits_descriptor_initial; - } else if (power_limits_descriptor_initial.level == - ZES_POWER_LEVEL_PEAK) { - power_peak_descriptor_first = power_limits_descriptor_initial; - } else if (power_limits_descriptor_initial.level == - ZES_POWER_LEVEL_BURST) { - power_burst_descriptor_first = power_limits_descriptor_initial; - } else if (power_limits_descriptor_initial.level == - ZES_POWER_LEVEL_INSTANTANEOUS) { - power_instantaneous_descriptor_first = - power_limits_descriptor_initial; + count = lzt::get_power_handle_count(device); + if (count > 0) { + is_power_supported = true; + LOG_INFO << "Power handles are available on this device! "; + auto p_power_handles = lzt::get_power_handles(device, count); + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); + uint32_t count_power = 0; + zes_power_limit_ext_desc_t power_peak_descriptor_first = {}; + zes_power_limit_ext_desc_t power_burst_descriptor_first = {}; + zes_power_limit_ext_desc_t power_sustained_descriptor_first = {}; + zes_power_limit_ext_desc_t power_instantaneous_descriptor_first = {}; + + zes_power_limit_ext_desc_t power_peak_descriptor_second = {}; + zes_power_limit_ext_desc_t power_burst_descriptor_second = {}; + zes_power_limit_ext_desc_t power_sustained_descriptor_second = {}; + zes_power_limit_ext_desc_t power_instantaneous_descriptor_second = {}; + + std::vector + power_limits_descriptors_initial; + auto status = lzt::get_power_limits_ext( + p_power_handle, &count_power, power_limits_descriptors_initial); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; } - } - - std::vector power_limits_descriptors_final; - status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors_final); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - for (auto power_limits_descriptor_final : - power_limits_descriptors_final) { - if (power_limits_descriptor_final.level == ZES_POWER_LEVEL_SUSTAINED) { - power_sustained_descriptor_second = power_limits_descriptor_final; - } else if (power_limits_descriptor_final.level == - ZES_POWER_LEVEL_PEAK) { - power_peak_descriptor_second = power_limits_descriptor_final; - } else if (power_limits_descriptor_final.level == - ZES_POWER_LEVEL_BURST) { - power_burst_descriptor_second = power_limits_descriptor_final; - } else if (power_limits_descriptor_final.level == - ZES_POWER_LEVEL_INSTANTANEOUS) { - power_instantaneous_descriptor_second = power_limits_descriptor_final; + EXPECT_ZE_RESULT_SUCCESS(status); + for (auto power_limits_descriptor_initial : + power_limits_descriptors_initial) { + if (power_limits_descriptor_initial.level == + ZES_POWER_LEVEL_SUSTAINED) { + power_sustained_descriptor_first = power_limits_descriptor_initial; + } else if (power_limits_descriptor_initial.level == + ZES_POWER_LEVEL_PEAK) { + power_peak_descriptor_first = power_limits_descriptor_initial; + } else if (power_limits_descriptor_initial.level == + ZES_POWER_LEVEL_BURST) { + power_burst_descriptor_first = power_limits_descriptor_initial; + } else if (power_limits_descriptor_initial.level == + ZES_POWER_LEVEL_INSTANTANEOUS) { + power_instantaneous_descriptor_first = + power_limits_descriptor_initial; + } + } + std::vector power_limits_descriptors_final; + status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_final); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + for (auto power_limits_descriptor_final : + power_limits_descriptors_final) { + if (power_limits_descriptor_final.level == + ZES_POWER_LEVEL_SUSTAINED) { + power_sustained_descriptor_second = power_limits_descriptor_final; + } else if (power_limits_descriptor_final.level == + ZES_POWER_LEVEL_PEAK) { + power_peak_descriptor_second = power_limits_descriptor_final; + } else if (power_limits_descriptor_final.level == + ZES_POWER_LEVEL_BURST) { + power_burst_descriptor_second = power_limits_descriptor_final; + } else if (power_limits_descriptor_final.level == + ZES_POWER_LEVEL_INSTANTANEOUS) { + power_instantaneous_descriptor_second = + power_limits_descriptor_final; + } } + lzt::compare_power_descriptor_structures(power_peak_descriptor_first, + power_peak_descriptor_second); + lzt::compare_power_descriptor_structures(power_burst_descriptor_first, + power_burst_descriptor_second); + lzt::compare_power_descriptor_structures( + power_sustained_descriptor_first, + power_sustained_descriptor_second); + lzt::compare_power_descriptor_structures( + power_instantaneous_descriptor_first, + power_instantaneous_descriptor_second); } - - lzt::compare_power_descriptor_structures(power_peak_descriptor_first, - power_peak_descriptor_second); - lzt::compare_power_descriptor_structures(power_burst_descriptor_first, - power_burst_descriptor_second); - lzt::compare_power_descriptor_structures( - power_sustained_descriptor_first, power_sustained_descriptor_second); - lzt::compare_power_descriptor_structures( - power_instantaneous_descriptor_first, - power_instantaneous_descriptor_second); + } else { + LOG_INFO << "No power handles found for this device! "; } } + if (!is_power_supported) { + FAIL() << "No power handles found on any of the devices! "; + } } LZT_TEST_F( POWER_TEST, GivenValidPowerHandleWhenSettingPowerValuesForSustainedPowerThenExpectzesPowerSetLimitsExtFollowedByzesPowerGetLimitsExtToMatch) { for (auto device : devices) { uint32_t count = 0; - auto p_power_handles = lzt::get_power_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } + count = lzt::get_power_handle_count(device); + if (count > 0) { + is_power_supported = true; + LOG_INFO << "Power handles are available on this device! "; + auto p_power_handles = lzt::get_power_handles(device, count); + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); + uint32_t count_power = 0; + + zes_power_limit_ext_desc_t power_sustained_set = {}; + std::vector power_limits_descriptors; + auto status = lzt::get_power_limits_ext( + p_power_handle, &count_power, + power_limits_descriptors); // get power limits for all descriptors + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + std::vector + power_limits_descriptors_initial; // preserve initial power limit + // descriptors for restoration + // later + for (int i = 0; i < power_limits_descriptors.size(); i++) { + power_limits_descriptors[i] = { + ZES_STRUCTURE_TYPE_POWER_LIMIT_EXT_DESC, nullptr}; + power_limits_descriptors_initial.push_back( + power_limits_descriptors[i]); + + if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_SUSTAINED) { + power_sustained_set = power_limits_descriptors[i]; + power_sustained_set.limit = + power_limits_descriptors[i].limit - 1000; + power_limits_descriptors[i].limit = power_sustained_set.limit; + } + } - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); - uint32_t count_power = 0; + if (power_sustained_set.level == ZES_POWER_LEVEL_SUSTAINED) { + if (power_sustained_set.limitValueLocked == false) { + status = lzt::set_power_limits_ext( + p_power_handle, &count_power, + power_limits_descriptors + .data()); // set power limits for all descriptors + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + zes_power_limit_ext_desc_t power_sustained_get = {}; - zes_power_limit_ext_desc_t power_sustained_set = {}; + std::vector + power_limits_descriptors_get; + status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_get); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + for (const auto &p_power_limits_descriptor_get : + power_limits_descriptors_get) { + if (p_power_limits_descriptor_get.level == + ZES_POWER_LEVEL_SUSTAINED) { + power_sustained_get = p_power_limits_descriptor_get; + } + } + + EXPECT_EQ(power_sustained_get.limitValueLocked, + power_sustained_set.limitValueLocked); + EXPECT_EQ(power_sustained_get.interval, + power_sustained_set.interval); + EXPECT_EQ(power_sustained_get.limit, power_sustained_set.limit); - std::vector power_limits_descriptors; - auto status = lzt::get_power_limits_ext( - p_power_handle, &count_power, - power_limits_descriptors); // get power limits for all descriptors - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; + status = lzt::set_power_limits_ext( + p_power_handle, &count_power, + power_limits_descriptors_initial + .data()); // restore initial limits + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + } else { + LOG_INFO << "Set limit not supported due to sustained " + "limitValueLocked flag is true"; + } + } else { + LOG_INFO << "Sustained power limit not supported"; + } } - EXPECT_ZE_RESULT_SUCCESS(status); - std::vector - power_limits_descriptors_initial; // preserve initial power limit - // descriptors for restoration - // later + } else { + LOG_INFO << "No power handles found for this device! "; + } + } + if (!is_power_supported) { + FAIL() << "No power handles found on any of the devices! "; + } +} +LZT_TEST_F( + POWER_TEST, + GivenValidPowerHandleWhenSettingPowerValuesForPeakPowerThenExpectzesPowerSetLimitsExtFollowedByzesPowerGetLimitsExtToMatch) { + for (auto device : devices) { + uint32_t count = 0; + count = lzt::get_power_handle_count(device); + if (count > 0) { + is_power_supported = true; + LOG_INFO << "Power handles are available on this device! "; + auto p_power_handles = lzt::get_power_handles(device, count); + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); + uint32_t count_power = 0; - for (int i = 0; i < power_limits_descriptors.size(); i++) { - power_limits_descriptors[i] = {ZES_STRUCTURE_TYPE_POWER_LIMIT_EXT_DESC, - nullptr}; - power_limits_descriptors_initial.push_back(power_limits_descriptors[i]); + zes_power_limit_ext_desc_t power_peak_set = {}; - if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_SUSTAINED) { - power_sustained_set = power_limits_descriptors[i]; - power_sustained_set.limit = power_limits_descriptors[i].limit - 1000; - power_limits_descriptors[i].limit = power_sustained_set.limit; + std::vector power_limits_descriptors; + auto status = lzt::get_power_limits_ext( + p_power_handle, &count_power, + power_limits_descriptors); // get power limits for all descriptors + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + std::vector + power_limits_descriptors_initial; // preserve initial power limit + // descriptors for restoration + // later + for (int i = 0; i < power_limits_descriptors.size(); i++) { + power_limits_descriptors_initial.push_back( + power_limits_descriptors[i]); + + if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_PEAK) { + power_peak_set = power_limits_descriptors[i]; + power_peak_set.limit = power_limits_descriptors[i].limit - 1000; + power_limits_descriptors[i].limit = power_peak_set.limit; + } } - } - if (power_sustained_set.level == ZES_POWER_LEVEL_SUSTAINED) { - if (power_sustained_set.limitValueLocked == false) { + if (power_peak_set.limitValueLocked == false) { status = lzt::set_power_limits_ext( p_power_handle, &count_power, power_limits_descriptors .data()); // set power limits for all descriptors - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { continue; } EXPECT_ZE_RESULT_SUCCESS(status); - zes_power_limit_ext_desc_t power_sustained_get = {}; - + zes_power_limit_ext_desc_t power_peak_get = {}; std::vector power_limits_descriptors_get; status = lzt::get_power_limits_ext(p_power_handle, &count_power, power_limits_descriptors_get); @@ -587,16 +748,14 @@ LZT_TEST_F( EXPECT_ZE_RESULT_SUCCESS(status); for (const auto &p_power_limits_descriptor_get : power_limits_descriptors_get) { - if (p_power_limits_descriptor_get.level == - ZES_POWER_LEVEL_SUSTAINED) { - power_sustained_get = p_power_limits_descriptor_get; + if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_PEAK) { + power_peak_get = p_power_limits_descriptor_get; } } - - EXPECT_EQ(power_sustained_get.limitValueLocked, - power_sustained_set.limitValueLocked); - EXPECT_EQ(power_sustained_get.interval, power_sustained_set.interval); - EXPECT_EQ(power_sustained_get.limit, power_sustained_set.limit); + EXPECT_EQ(power_peak_get.limitValueLocked, + power_peak_set.limitValueLocked); + EXPECT_EQ(power_peak_get.interval, power_peak_set.interval); + EXPECT_EQ(power_peak_get.limit, power_peak_set.limit); status = lzt::set_power_limits_ext(p_power_handle, &count_power, @@ -607,98 +766,16 @@ LZT_TEST_F( } EXPECT_ZE_RESULT_SUCCESS(status); } else { - LOG_INFO << "Set limit not supported due to sustained " + LOG_INFO << "Set limit not supported due to peak " "limitValueLocked flag is true"; } - } else { - LOG_INFO << "Sustained power limit not supported"; } + } else { + LOG_INFO << "No power handles found for this device! "; } } -} -LZT_TEST_F( - POWER_TEST, - GivenValidPowerHandleWhenSettingPowerValuesForPeakPowerThenExpectzesPowerSetLimitsExtFollowedByzesPowerGetLimitsExtToMatch) { - for (auto device : devices) { - uint32_t count = 0; - auto p_power_handles = lzt::get_power_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); - uint32_t count_power = 0; - - zes_power_limit_ext_desc_t power_peak_set = {}; - - std::vector power_limits_descriptors; - auto status = lzt::get_power_limits_ext( - p_power_handle, &count_power, - power_limits_descriptors); // get power limits for all descriptors - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - std::vector - power_limits_descriptors_initial; // preserve initial power limit - // descriptors for restoration - // later - - for (int i = 0; i < power_limits_descriptors.size(); i++) { - power_limits_descriptors_initial.push_back(power_limits_descriptors[i]); - - if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_PEAK) { - power_peak_set = power_limits_descriptors[i]; - power_peak_set.limit = power_limits_descriptors[i].limit - 1000; - power_limits_descriptors[i].limit = power_peak_set.limit; - } - } - - if (power_peak_set.limitValueLocked == false) { - status = lzt::set_power_limits_ext( - p_power_handle, &count_power, - power_limits_descriptors - .data()); // set power limits for all descriptors - - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - zes_power_limit_ext_desc_t power_peak_get = {}; - - std::vector power_limits_descriptors_get; - status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors_get); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - for (const auto &p_power_limits_descriptor_get : - power_limits_descriptors_get) { - if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_PEAK) { - power_peak_get = p_power_limits_descriptor_get; - } - } - - EXPECT_EQ(power_peak_get.limitValueLocked, - power_peak_set.limitValueLocked); - EXPECT_EQ(power_peak_get.interval, power_peak_set.interval); - EXPECT_EQ(power_peak_get.limit, power_peak_set.limit); - - status = lzt::set_power_limits_ext( - p_power_handle, &count_power, - power_limits_descriptors_initial.data()); // restore initial limits - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - } else { - LOG_INFO << "Set limit not supported due to peak " - "limitValueLocked flag is true"; - } - } + if (!is_power_supported) { + FAIL() << "No power handles found on any of the devices! "; } } LZT_TEST_F( @@ -706,174 +783,181 @@ LZT_TEST_F( GivenValidPowerHandleWhenSettingPowerValuesForBurstPowerThenExpectzesPowerSetLimitsExtFollowedByzesPowerGetLimitsExtToMatch) { for (auto device : devices) { uint32_t count = 0; - auto p_power_handles = lzt::get_power_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); - uint32_t count_power = 0; - - zes_power_limit_ext_desc_t power_burst_set = {}; - - std::vector power_limits_descriptors; - auto status = lzt::get_power_limits_ext( - p_power_handle, &count_power, - power_limits_descriptors); // get power limits for all descriptors - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - std::vector - power_limits_descriptors_initial; // preserve initial power limit - // descriptors for restoration - // later - - for (int i = 0; i < power_limits_descriptors.size(); i++) { - power_limits_descriptors_initial.push_back(power_limits_descriptors[i]); - - if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_BURST) { - power_burst_set = power_limits_descriptors[i]; - power_burst_set.limit = power_limits_descriptors[i].limit - 1000; - power_limits_descriptors[i].limit = power_burst_set.limit; - } - } - - if (power_burst_set.limitValueLocked == false) { - status = lzt::set_power_limits_ext( + count = lzt::get_power_handle_count(device); + if (count > 0) { + is_power_supported = true; + LOG_INFO << "Power handles are available on this device! "; + auto p_power_handles = lzt::get_power_handles(device, count); + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); + uint32_t count_power = 0; + zes_power_limit_ext_desc_t power_burst_set = {}; + + std::vector power_limits_descriptors; + auto status = lzt::get_power_limits_ext( p_power_handle, &count_power, - power_limits_descriptors - .data()); // set power limits for all descriptors - - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - zes_power_limit_ext_desc_t power_burst_get = {}; - - std::vector power_limits_descriptors_get; - status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors_get); + power_limits_descriptors); // get power limits for all descriptors if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { continue; } EXPECT_ZE_RESULT_SUCCESS(status); - for (const auto &p_power_limits_descriptor_get : - power_limits_descriptors_get) { - if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_BURST) { - power_burst_get = p_power_limits_descriptor_get; + std::vector + power_limits_descriptors_initial; // preserve initial power limit + // descriptors for restoration + // later + + for (int i = 0; i < power_limits_descriptors.size(); i++) { + power_limits_descriptors_initial.push_back( + power_limits_descriptors[i]); + if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_BURST) { + power_burst_set = power_limits_descriptors[i]; + power_burst_set.limit = power_limits_descriptors[i].limit - 1000; + power_limits_descriptors[i].limit = power_burst_set.limit; } } + if (power_burst_set.limitValueLocked == false) { + status = lzt::set_power_limits_ext( + p_power_handle, &count_power, + power_limits_descriptors + .data()); // set power limits for all descriptors - EXPECT_EQ(power_burst_get.limitValueLocked, - power_burst_set.limitValueLocked); - EXPECT_EQ(power_burst_get.interval, power_burst_set.interval); - EXPECT_EQ(power_burst_get.limit, power_burst_set.limit); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + zes_power_limit_ext_desc_t power_burst_get = {}; - status = lzt::set_power_limits_ext( - p_power_handle, &count_power, - power_limits_descriptors_initial.data()); // restore initial limits - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; + std::vector power_limits_descriptors_get; + status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_get); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + for (const auto &p_power_limits_descriptor_get : + power_limits_descriptors_get) { + if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_BURST) { + power_burst_get = p_power_limits_descriptor_get; + } + } + EXPECT_EQ(power_burst_get.limitValueLocked, + power_burst_set.limitValueLocked); + EXPECT_EQ(power_burst_get.interval, power_burst_set.interval); + EXPECT_EQ(power_burst_get.limit, power_burst_set.limit); + status = + lzt::set_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_initial + .data()); // restore initial limits + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + } else { + LOG_INFO << "Set limit not supported due to burst " + "limitValueLocked flag is true"; } - EXPECT_ZE_RESULT_SUCCESS(status); - } else { - LOG_INFO << "Set limit not supported due to burst " - "limitValueLocked flag is true"; } + } else { + LOG_INFO << "No power handles found for this device! "; } } + if (!is_power_supported) { + FAIL() << "No power handles found on any of the devices! "; + } } LZT_TEST_F( POWER_TEST, GivenValidPowerHandleWhenSettingPowerValuesForInstantaneousPowerThenExpectzesPowerSetLimitsExtFollowedByzesPowerGetLimitsExtToMatch) { for (auto device : devices) { uint32_t count = 0; - auto p_power_handles = lzt::get_power_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); - uint32_t count_power = 0; - - zes_power_limit_ext_desc_t power_instantaneous_set = {}; - - std::vector power_limits_descriptors; - auto status = lzt::get_power_limits_ext( - p_power_handle, &count_power, - power_limits_descriptors); // get power limits for all descriptors - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - std::vector - power_limits_descriptors_initial; // preserve initial power limit - // descriptors for restoration - // later - - for (int i = 0; i < power_limits_descriptors.size(); i++) { - power_limits_descriptors_initial.push_back(power_limits_descriptors[i]); - - if (power_limits_descriptors[i].level == - ZES_POWER_LEVEL_INSTANTANEOUS) { - power_instantaneous_set = power_limits_descriptors[i]; - power_instantaneous_set.limit = - power_limits_descriptors[i].limit - 1000; - power_limits_descriptors[i].limit = power_instantaneous_set.limit; - } - } - - if (power_instantaneous_set.limitValueLocked == false) { - status = lzt::set_power_limits_ext( + count = lzt::get_power_handle_count(device); + if (count > 0) { + is_power_supported = true; + LOG_INFO << "Power handles are available on this device! "; + auto p_power_handles = lzt::get_power_handles(device, count); + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); + uint32_t count_power = 0; + zes_power_limit_ext_desc_t power_instantaneous_set = {}; + std::vector power_limits_descriptors; + auto status = lzt::get_power_limits_ext( p_power_handle, &count_power, - power_limits_descriptors - .data()); // set power limits for all descriptors - - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - zes_power_limit_ext_desc_t power_instantaneous_get = {}; - - std::vector power_limits_descriptors_get; - status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors_get); + power_limits_descriptors); // get power limits for all descriptors if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { continue; } EXPECT_ZE_RESULT_SUCCESS(status); - for (const auto &p_power_limits_descriptor_get : - power_limits_descriptors_get) { - if (p_power_limits_descriptor_get.level == + std::vector + power_limits_descriptors_initial; // preserve initial power limit + // descriptors for restoration + // later + + for (int i = 0; i < power_limits_descriptors.size(); i++) { + power_limits_descriptors_initial.push_back( + power_limits_descriptors[i]); + if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_INSTANTANEOUS) { - power_instantaneous_get = p_power_limits_descriptor_get; + power_instantaneous_set = power_limits_descriptors[i]; + power_instantaneous_set.limit = + power_limits_descriptors[i].limit - 1000; + power_limits_descriptors[i].limit = power_instantaneous_set.limit; } } - EXPECT_EQ(power_instantaneous_get.limitValueLocked, - power_instantaneous_set.limitValueLocked); - EXPECT_EQ(power_instantaneous_get.interval, - power_instantaneous_set.interval); - EXPECT_EQ(power_instantaneous_get.limit, power_instantaneous_set.limit); + if (power_instantaneous_set.limitValueLocked == false) { + status = lzt::set_power_limits_ext( + p_power_handle, &count_power, + power_limits_descriptors + .data()); // set power limits for all descriptors - status = lzt::set_power_limits_ext( - p_power_handle, &count_power, - power_limits_descriptors_initial.data()); // restore initial limits - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + zes_power_limit_ext_desc_t power_instantaneous_get = {}; + + std::vector power_limits_descriptors_get; + status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_get); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + for (const auto &p_power_limits_descriptor_get : + power_limits_descriptors_get) { + if (p_power_limits_descriptor_get.level == + ZES_POWER_LEVEL_INSTANTANEOUS) { + power_instantaneous_get = p_power_limits_descriptor_get; + } + } + + EXPECT_EQ(power_instantaneous_get.limitValueLocked, + power_instantaneous_set.limitValueLocked); + EXPECT_EQ(power_instantaneous_get.interval, + power_instantaneous_set.interval); + EXPECT_EQ(power_instantaneous_get.limit, + power_instantaneous_set.limit); + + status = + lzt::set_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_initial + .data()); // restore initial limits + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + } else { + LOG_INFO << "Set limit not supported due to instantaneous " + "limitValueLocked flag is true"; } - EXPECT_ZE_RESULT_SUCCESS(status); - } else { - LOG_INFO << "Set limit not supported due to instantaneous " - "limitValueLocked flag is true"; } + } else { + LOG_INFO << "No power handles found for this device! "; } } + if (!is_power_supported) { + FAIL() << "No power handles found on any of the devices! "; + } } LZT_TEST_F( @@ -881,24 +965,30 @@ LZT_TEST_F( GivenValidPowerHandleWhenRequestingEnergyCounterThenExpectEnergyConsumedByRootDeviceToBeGreaterThanOrEqualToEnergyConsumedBySubdevices) { for (auto device : devices) { uint32_t count = 0; - auto p_power_handles = lzt::get_power_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - uint64_t total_rootdevice_energy = 0; - uint64_t total_subdevices_energy = 0; - for (auto p_power_handle : p_power_handles) { - auto p_properties = lzt::get_power_properties(p_power_handle); - zes_power_energy_counter_t p_energy_counter = {}; - lzt::get_power_energy_counter(p_power_handle, &p_energy_counter); - if (p_properties.onSubdevice == false) { - total_rootdevice_energy += p_energy_counter.energy; - } else { - total_subdevices_energy += p_energy_counter.energy; + count = lzt::get_power_handle_count(device); + if (count > 0) { + is_power_supported = true; + LOG_INFO << "Power handles are available on this device! "; + auto p_power_handles = lzt::get_power_handles(device, count); + uint64_t total_rootdevice_energy = 0; + uint64_t total_subdevices_energy = 0; + for (auto p_power_handle : p_power_handles) { + auto p_properties = lzt::get_power_properties(p_power_handle); + zes_power_energy_counter_t p_energy_counter = {}; + lzt::get_power_energy_counter(p_power_handle, &p_energy_counter); + if (p_properties.onSubdevice == false) { + total_rootdevice_energy += p_energy_counter.energy; + } else { + total_subdevices_energy += p_energy_counter.energy; + } } + EXPECT_GE(total_rootdevice_energy, total_subdevices_energy); + } else { + LOG_INFO << "No power handles found for this device! "; } - EXPECT_GE(total_rootdevice_energy, total_subdevices_energy); + } + if (!is_power_supported) { + FAIL() << "No power handles found on any of the devices! "; } } @@ -907,92 +997,99 @@ LZT_TEST_F( GivenValidPowerHandlesAfterGettingMaxPowerLimitsWhenSettingValuesForSustainedPowerThenExpectzesPowerGetLimitsExtToReturnPowerLimitsLessThanMaxPowerLimits) { for (auto device : devices) { uint32_t count = 0; - auto p_power_handles = lzt::get_power_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - for (auto p_power_handle : p_power_handles) { - auto p_properties = lzt::get_power_properties(p_power_handle); - if (p_properties.onSubdevice == true) { - continue; - } - uint32_t count_power = 0; - bool sustained_limit_available = false; - zes_power_limit_ext_desc_t power_sustained_Max = {}; - zes_power_limit_ext_desc_t power_sustained_Initial = {}; - zes_power_limit_ext_desc_t power_sustained_getMax = {}; - zes_power_limit_ext_desc_t power_sustained_get = {}; - std::vector power_limits_descriptors; - auto status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - for (int i = 0; i < power_limits_descriptors.size(); i++) { - if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_SUSTAINED) { - sustained_limit_available = true; - power_sustained_Max = power_limits_descriptors[i]; - power_sustained_Initial = power_limits_descriptors[i]; - power_sustained_Max.limit = std::numeric_limits::max(); - power_sustained_Initial.limit *= 2; - - if (power_sustained_Max.limitValueLocked == false) { - status = lzt::set_power_limits_ext(p_power_handle, &count_power, - &power_sustained_Max); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - std::vector - power_limits_descriptors_getMax; - status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors_getMax); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - for (const auto &p_power_limits_descriptor_get : - power_limits_descriptors_getMax) { - if (p_power_limits_descriptor_get.level == - ZES_POWER_LEVEL_SUSTAINED) { - power_sustained_getMax = p_power_limits_descriptor_get; + count = lzt::get_power_handle_count(device); + if (count > 0) { + is_power_supported = true; + LOG_INFO << "Power handles are available on this device! "; + auto p_power_handles = lzt::get_power_handles(device, count); + for (auto p_power_handle : p_power_handles) { + auto p_properties = lzt::get_power_properties(p_power_handle); + if (p_properties.onSubdevice == true) { + continue; + } + uint32_t count_power = 0; + bool sustained_limit_available = false; + zes_power_limit_ext_desc_t power_sustained_Max = {}; + zes_power_limit_ext_desc_t power_sustained_Initial = {}; + zes_power_limit_ext_desc_t power_sustained_getMax = {}; + zes_power_limit_ext_desc_t power_sustained_get = {}; + std::vector power_limits_descriptors; + auto status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + for (int i = 0; i < power_limits_descriptors.size(); i++) { + if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_SUSTAINED) { + sustained_limit_available = true; + power_sustained_Max = power_limits_descriptors[i]; + power_sustained_Initial = power_limits_descriptors[i]; + power_sustained_Max.limit = std::numeric_limits::max(); + power_sustained_Initial.limit *= 2; + if (power_sustained_Max.limitValueLocked == false) { + status = lzt::set_power_limits_ext(p_power_handle, &count_power, + &power_sustained_Max); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; } - } - status = lzt::set_power_limits_ext(p_power_handle, &count_power, - &power_sustained_Initial); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - std::vector - power_limits_descriptors_get; - status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors_get); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - for (const auto &p_power_limits_descriptor_get : - power_limits_descriptors_get) { - if (p_power_limits_descriptor_get.level == - ZES_POWER_LEVEL_SUSTAINED) { - power_sustained_get = p_power_limits_descriptor_get; + EXPECT_ZE_RESULT_SUCCESS(status); + std::vector + power_limits_descriptors_getMax; + status = + lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_getMax); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + for (const auto &p_power_limits_descriptor_get : + power_limits_descriptors_getMax) { + if (p_power_limits_descriptor_get.level == + ZES_POWER_LEVEL_SUSTAINED) { + power_sustained_getMax = p_power_limits_descriptor_get; + } + } + status = lzt::set_power_limits_ext(p_power_handle, &count_power, + &power_sustained_Initial); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; } + EXPECT_ZE_RESULT_SUCCESS(status); + std::vector + power_limits_descriptors_get; + status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_get); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + for (const auto &p_power_limits_descriptor_get : + power_limits_descriptors_get) { + if (p_power_limits_descriptor_get.level == + ZES_POWER_LEVEL_SUSTAINED) { + power_sustained_get = p_power_limits_descriptor_get; + } + } + EXPECT_LE(power_sustained_get.limit, + power_sustained_getMax.limit); + } else { + LOG_INFO << "Set limit not supported due to sustained " + "limitValueLocked flag is true"; } - EXPECT_LE(power_sustained_get.limit, power_sustained_getMax.limit); - } else { - LOG_INFO << "Set limit not supported due to sustained " - "limitValueLocked flag is true"; } } + if (!sustained_limit_available) { + LOG_INFO << "Sustained power limit not supported"; + } } - if (!sustained_limit_available) { - LOG_INFO << "Sustained power limit not supported"; - } + } else { + LOG_INFO << "No power handles found for this device! "; } } + if (!is_power_supported) { + FAIL() << "No power handles found on any of the devices! "; + } } LZT_TEST_F( @@ -1000,101 +1097,110 @@ LZT_TEST_F( GivenValidPowerHandlesAfterGettingMaxPowerLimitWhenSettingValuesForPeakPowerThenExpectZesPowerGetLimitsExtToReturnPowerLimitsLessThanMaxPowerLimits) { for (auto device : devices) { uint32_t count = 0; - auto p_power_handles = lzt::get_power_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - for (auto p_power_handle : p_power_handles) { - auto p_properties = lzt::get_power_properties(p_power_handle); - if (p_properties.onSubdevice == true) { - continue; - } - uint32_t count_power = 0; - uint32_t single_count = 1; - bool peak_limit_available = false; - - std::vector power_limits_descriptors; - auto status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - int32_t max_power_limit_first = std::numeric_limits::max(); - for (int i = 0; i < power_limits_descriptors.size(); i++) { - zes_power_limit_ext_desc_t power_peak_initial = {}; - zes_power_limit_ext_desc_t power_peak_Max = {}; - zes_power_limit_ext_desc_t power_peak_getMax = {}; - zes_power_limit_ext_desc_t power_peak_get = {}; - if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_PEAK) { - peak_limit_available = true; - zes_power_source_t power_source = power_limits_descriptors[i].source; - power_peak_Max = power_limits_descriptors[i]; - power_peak_initial = power_limits_descriptors[i]; - power_peak_Max.limit = max_power_limit_first; - - int32_t max_power_limit_second = - power_limits_descriptors[i].limit * 2; - power_peak_initial.limit = max_power_limit_second; + count = lzt::get_power_handle_count(device); + if (count > 0) { + is_power_supported = true; + LOG_INFO << "Power handles are available on this device! "; + auto p_power_handles = lzt::get_power_handles(device, count); + for (auto p_power_handle : p_power_handles) { + auto p_properties = lzt::get_power_properties(p_power_handle); + if (p_properties.onSubdevice == true) { + continue; + } + uint32_t count_power = 0; + uint32_t single_count = 1; + bool peak_limit_available = false; - if (power_limits_descriptors[i].limitValueLocked == false) { - status = lzt::set_power_limits_ext(p_power_handle, &single_count, - &power_peak_Max); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - std::vector - power_limits_descriptors_getMax; - status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors_getMax); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - for (const auto &p_power_limits_descriptor_get : - power_limits_descriptors_getMax) { - if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_PEAK && - p_power_limits_descriptor_get.source == power_source) { - power_peak_getMax = p_power_limits_descriptor_get; - EXPECT_LT(power_peak_getMax.limit, max_power_limit_first); + std::vector power_limits_descriptors; + auto status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + int32_t max_power_limit_first = std::numeric_limits::max(); + for (int i = 0; i < power_limits_descriptors.size(); i++) { + zes_power_limit_ext_desc_t power_peak_initial = {}; + zes_power_limit_ext_desc_t power_peak_Max = {}; + zes_power_limit_ext_desc_t power_peak_getMax = {}; + zes_power_limit_ext_desc_t power_peak_get = {}; + if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_PEAK) { + peak_limit_available = true; + zes_power_source_t power_source = + power_limits_descriptors[i].source; + power_peak_Max = power_limits_descriptors[i]; + power_peak_initial = power_limits_descriptors[i]; + power_peak_Max.limit = max_power_limit_first; + + int32_t max_power_limit_second = + power_limits_descriptors[i].limit * 2; + power_peak_initial.limit = max_power_limit_second; + if (power_limits_descriptors[i].limitValueLocked == false) { + status = lzt::set_power_limits_ext(p_power_handle, &single_count, + &power_peak_Max); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + std::vector + power_limits_descriptors_getMax; + status = + lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_getMax); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + for (const auto &p_power_limits_descriptor_get : + power_limits_descriptors_getMax) { + if (p_power_limits_descriptor_get.level == + ZES_POWER_LEVEL_PEAK && + p_power_limits_descriptor_get.source == power_source) { + power_peak_getMax = p_power_limits_descriptor_get; + EXPECT_LT(power_peak_getMax.limit, max_power_limit_first); + } } - } - status = lzt::set_power_limits_ext(p_power_handle, &single_count, - &power_peak_initial); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - std::vector - power_limits_descriptors_get; - status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors_get); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - for (const auto &p_power_limits_descriptor_get : - power_limits_descriptors_get) { - if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_PEAK && - p_power_limits_descriptor_get.source == power_source) { - power_peak_get = p_power_limits_descriptor_get; - EXPECT_LE(power_peak_get.limit, max_power_limit_second); + status = lzt::set_power_limits_ext(p_power_handle, &single_count, + &power_peak_initial); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + std::vector + power_limits_descriptors_get; + status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_get); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; } + EXPECT_ZE_RESULT_SUCCESS(status); + for (const auto &p_power_limits_descriptor_get : + power_limits_descriptors_get) { + if (p_power_limits_descriptor_get.level == + ZES_POWER_LEVEL_PEAK && + p_power_limits_descriptor_get.source == power_source) { + power_peak_get = p_power_limits_descriptor_get; + EXPECT_LE(power_peak_get.limit, max_power_limit_second); + } + } + } else { + LOG_INFO << "Set limit not supported due to peak " + "limitValueLocked flag is true"; } - } else { - LOG_INFO << "Set limit not supported due to peak " - "limitValueLocked flag is true"; } } + if (!peak_limit_available) { + LOG_INFO << "peak power limit not supported"; + } } - if (!peak_limit_available) { - LOG_INFO << "peak power limit not supported"; - } + } else { + LOG_INFO << "No power handles found for this device! "; } } + if (!is_power_supported) { + FAIL() << "No power handles on any of the devices! "; + } } LZT_TEST_F( @@ -1102,25 +1208,31 @@ LZT_TEST_F( GivenPowerHandleWhenRequestingExtensionPowerPropertiesThenValidPowerDomainIsReturned) { for (auto device : devices) { uint32_t count = 0; - auto p_power_handles = lzt::get_power_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - for (auto p_power_handle : p_power_handles) { - zes_power_properties_t pProperties = {ZES_STRUCTURE_TYPE_POWER_PROPERTIES, - nullptr}; - zes_power_ext_properties_t pExtProperties = { - ZES_STRUCTURE_TYPE_POWER_EXT_PROPERTIES, nullptr}; - pProperties.pNext = &pExtProperties; - - EXPECT_ZE_RESULT_SUCCESS( - zesPowerGetProperties(p_power_handle, &pProperties)); - - EXPECT_GT(pExtProperties.domain, ZES_POWER_DOMAIN_UNKNOWN); - EXPECT_LT(pExtProperties.domain, ZES_POWER_DOMAIN_FORCE_UINT32); + count = lzt::get_power_handle_count(device); + if (count > 0) { + is_power_supported = true; + LOG_INFO << "Power handles are available on this device! "; + auto p_power_handles = lzt::get_power_handles(device, count); + for (auto p_power_handle : p_power_handles) { + zes_power_properties_t pProperties = { + ZES_STRUCTURE_TYPE_POWER_PROPERTIES, nullptr}; + zes_power_ext_properties_t pExtProperties = { + ZES_STRUCTURE_TYPE_POWER_EXT_PROPERTIES, nullptr}; + pProperties.pNext = &pExtProperties; + + EXPECT_ZE_RESULT_SUCCESS( + zesPowerGetProperties(p_power_handle, &pProperties)); + + EXPECT_GT(pExtProperties.domain, ZES_POWER_DOMAIN_UNKNOWN); + EXPECT_LT(pExtProperties.domain, ZES_POWER_DOMAIN_FORCE_UINT32); + } + } else { + LOG_INFO << "No power handles found for this device! "; } } + if (!is_power_supported) { + FAIL() << "No power handles on any of the devices! "; + } } LZT_TEST_F( @@ -1128,40 +1240,48 @@ LZT_TEST_F( GivenPowerHandleWhenRequestingExtensionPowerPropertiesThenValidDefaultLimitsAreReturned) { for (auto device : devices) { uint32_t count = 0; - auto p_power_handles = lzt::get_power_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - for (auto p_power_handle : p_power_handles) { - zes_power_properties_t pProperties = {ZES_STRUCTURE_TYPE_POWER_PROPERTIES, - nullptr}; - zes_power_ext_properties_t pExtProperties = { - ZES_STRUCTURE_TYPE_POWER_EXT_PROPERTIES, nullptr}; - zes_power_limit_ext_desc_t default_limits = {}; - pExtProperties.defaultLimit = &default_limits; - pProperties.pNext = &pExtProperties; - // query extension properties - EXPECT_ZE_RESULT_SUCCESS( - zesPowerGetProperties(p_power_handle, &pProperties)); - // verify default limits - EXPECT_GE(pExtProperties.defaultLimit->level, ZES_POWER_LEVEL_UNKNOWN); - EXPECT_LE(pExtProperties.defaultLimit->level, - ZES_POWER_LEVEL_INSTANTANEOUS); - EXPECT_GE(pExtProperties.defaultLimit->source, ZES_POWER_SOURCE_ANY); - EXPECT_LE(pExtProperties.defaultLimit->source, ZES_POWER_SOURCE_BATTERY); - EXPECT_GE(pExtProperties.defaultLimit->limitUnit, ZES_LIMIT_UNIT_UNKNOWN); - EXPECT_LE(pExtProperties.defaultLimit->limitUnit, ZES_LIMIT_UNIT_POWER); - if (!pExtProperties.defaultLimit->intervalValueLocked) { - EXPECT_GE(pExtProperties.defaultLimit->interval, 0u); - EXPECT_LE(pExtProperties.defaultLimit->interval, INT32_MAX); - } - if (!pExtProperties.defaultLimit->limitValueLocked) { - EXPECT_GE(pExtProperties.defaultLimit->limit, 0u); - EXPECT_LE(pExtProperties.defaultLimit->limit, INT32_MAX); + count = lzt::get_power_handle_count(device); + if (count > 0) { + is_power_supported = true; + LOG_INFO << "Power handles are available on this device! "; + auto p_power_handles = lzt::get_power_handles(device, count); + for (auto p_power_handle : p_power_handles) { + zes_power_properties_t pProperties = { + ZES_STRUCTURE_TYPE_POWER_PROPERTIES, nullptr}; + zes_power_ext_properties_t pExtProperties = { + ZES_STRUCTURE_TYPE_POWER_EXT_PROPERTIES, nullptr}; + zes_power_limit_ext_desc_t default_limits = {}; + pExtProperties.defaultLimit = &default_limits; + pProperties.pNext = &pExtProperties; + // query extension properties + EXPECT_ZE_RESULT_SUCCESS( + zesPowerGetProperties(p_power_handle, &pProperties)); + // verify default limits + EXPECT_GE(pExtProperties.defaultLimit->level, ZES_POWER_LEVEL_UNKNOWN); + EXPECT_LE(pExtProperties.defaultLimit->level, + ZES_POWER_LEVEL_INSTANTANEOUS); + EXPECT_GE(pExtProperties.defaultLimit->source, ZES_POWER_SOURCE_ANY); + EXPECT_LE(pExtProperties.defaultLimit->source, + ZES_POWER_SOURCE_BATTERY); + EXPECT_GE(pExtProperties.defaultLimit->limitUnit, + ZES_LIMIT_UNIT_UNKNOWN); + EXPECT_LE(pExtProperties.defaultLimit->limitUnit, ZES_LIMIT_UNIT_POWER); + if (!pExtProperties.defaultLimit->intervalValueLocked) { + EXPECT_GE(pExtProperties.defaultLimit->interval, 0u); + EXPECT_LE(pExtProperties.defaultLimit->interval, INT32_MAX); + } + if (!pExtProperties.defaultLimit->limitValueLocked) { + EXPECT_GE(pExtProperties.defaultLimit->limit, 0u); + EXPECT_LE(pExtProperties.defaultLimit->limit, INT32_MAX); + } } + } else { + LOG_INFO << "No power handles found for this device! "; } } + if (!is_power_supported) { + FAIL() << "No power handles on any of the devices! "; + } } LZT_TEST_F( @@ -1169,43 +1289,51 @@ LZT_TEST_F( GivenValidPowerAndPerformanceHandlesWhenIncreasingPerformanceFactorThenExpectTotalEnergyConsumedToBeIncreased) { for (auto device : devices) { uint32_t count = 0; - auto p_power_handles = lzt::get_power_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - for (auto p_power_handle : p_power_handles) { - auto p_properties = lzt::get_power_properties(p_power_handle); - if (p_properties.onSubdevice == true) { - continue; - } - uint32_t perf_count = 0; - zes_power_energy_counter_t energy_counter_initial; - zes_power_energy_counter_t energy_counter_later; - auto p_performance_handles = - lzt::get_performance_handles(device, perf_count); - if (perf_count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - for (auto p_performance_handle : p_performance_handles) { - zes_perf_properties_t p_perf_properties = - lzt::get_performance_properties(p_performance_handle); - p_perf_properties.engines = - 1; // 1 is the equivalent value for ZES_ENGINE_TYPE_FLAG_OTHER - if (p_perf_properties.engines == ZES_ENGINE_TYPE_FLAG_OTHER) { - lzt::set_performance_config(p_performance_handle, 25); - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - lzt::get_power_energy_counter(p_power_handle, - &energy_counter_initial); - lzt::set_performance_config(p_performance_handle, 100); - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - lzt::get_power_energy_counter(p_power_handle, &energy_counter_later); - EXPECT_GE(energy_counter_later.energy, energy_counter_initial.energy); + count = lzt::get_power_handle_count(device); + if (count > 0) { + is_power_supported = true; + LOG_INFO << "Power handles are available on this device! "; + auto p_power_handles = lzt::get_power_handles(device, count); + for (auto p_power_handle : p_power_handles) { + auto p_properties = lzt::get_power_properties(p_power_handle); + if (p_properties.onSubdevice == true) { + continue; + } + uint32_t perf_count = 0; + perf_count = lzt::get_performance_handle_count(device); + zes_power_energy_counter_t energy_counter_initial; + zes_power_energy_counter_t energy_counter_later; + auto p_performance_handles = lzt::get_performance_handles(device, perf_count); + if (perf_count == 0) { + FAIL() << "No performance handles found for this device! "; + } + for (auto p_performance_handle : p_performance_handles) { + zes_perf_properties_t p_perf_properties = + lzt::get_performance_properties(p_performance_handle); + p_perf_properties.engines = + 1; // 1 is the equivalent value for ZES_ENGINE_TYPE_FLAG_OTHER + + if (p_perf_properties.engines == ZES_ENGINE_TYPE_FLAG_OTHER) { + lzt::set_performance_config(p_performance_handle, 25); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + lzt::get_power_energy_counter(p_power_handle, + &energy_counter_initial); + lzt::set_performance_config(p_performance_handle, 100); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + lzt::get_power_energy_counter(p_power_handle, + &energy_counter_later); + EXPECT_GE(energy_counter_later.energy, + energy_counter_initial.energy); + } } } + } else { + LOG_INFO << "No power handles found for this device! "; } } + if (!is_power_supported) { + FAIL() << "No power handles found on any of the devices! "; + } } #ifdef __linux__ @@ -1214,10 +1342,11 @@ LZT_TEST_F( GivenValidDeviceWhenCallingPowerGetEnergyCountersMultipleTimesThenExpectFirstCallIsSlowerThanSubsequentCalls) { for (auto device : devices) { uint32_t count = 0; + count = lzt::get_power_handle_count(device); auto power_handles = lzt::get_power_handles(device, count); - if (count > 0) { - power_handles_available = true; + is_power_supported = true; + LOG_INFO << "Power handles are found on this device! "; auto start = std::chrono::steady_clock::now(); auto energy_counters = lzt::get_power_energy_counter(power_handles); auto end = std::chrono::steady_clock::now(); @@ -1244,12 +1373,11 @@ LZT_TEST_F( EXPECT_GT(avg_time.count(), 0); EXPECT_GT(elapsed_initial.count(), avg_time.count()); } else { - LOG_WARNING << "No handles found on this device!"; + LOG_INFO << "No power handles found for this device! "; } } - if (!power_handles_available) { - FAIL() << "No handles found in any of the devices!"; + FAIL() << "No power handles found in any of the devices!"; } } #endif diff --git a/conformance_tests/sysman/test_sysman_scheduler/src/test_sysman_scheduler.cpp b/conformance_tests/sysman/test_sysman_scheduler/src/test_sysman_scheduler.cpp index 936103c0..5566dc5b 100644 --- a/conformance_tests/sysman/test_sysman_scheduler/src/test_sysman_scheduler.cpp +++ b/conformance_tests/sysman/test_sysman_scheduler/src/test_sysman_scheduler.cpp @@ -19,10 +19,16 @@ namespace lzt = level_zero_tests; namespace { #ifdef USE_ZESINIT -class SchedulerZesTest : public lzt::ZesSysmanCtsClass {}; +class SchedulerZesTest : public lzt::ZesSysmanCtsClass { +public: + bool is_scheduler_supported = false; +}; #define SCHEDULER_TEST SchedulerZesTest #else // USE_ZESINIT -class SchedulerTest : public lzt::SysmanCtsClass {}; +class SchedulerTest : public lzt::SysmanCtsClass { +public: + bool is_scheduler_supported = false; +}; #define SCHEDULER_TEST SchedulerTest #endif // USE_ZESINIT @@ -32,11 +38,16 @@ LZT_TEST_F( for (auto device : devices) { uint32_t count = 0; count = lzt::get_scheduler_handle_count(device); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + if (count > 0) { + is_scheduler_supported = true; + LOG_INFO << "Scheduler handles are available on this device! "; + } else { + LOG_INFO << "No scheduler handles found for this device! "; } } + if (!is_scheduler_supported) { + FAIL() << "No scheduler handles found on any of the devcies! "; + } } LZT_TEST_F( @@ -44,16 +55,21 @@ LZT_TEST_F( GivenComponentCountZeroWhenRetrievingSchedulerHandlesThenNotNullSchedulerHandlesAreReturned) { for (auto device : devices) { uint32_t count = 0; - auto p_sched_handles = lzt::get_scheduler_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto p_sched_handle : p_sched_handles) { - EXPECT_NE(nullptr, p_sched_handle); + count = lzt::get_scheduler_handle_count(device); + if (count > 0) { + is_scheduler_supported = true; + LOG_INFO << "Scheduler handles are available on this device! "; + auto p_sched_handles = lzt::get_scheduler_handles(device, count); + for (auto p_sched_handle : p_sched_handles) { + EXPECT_NE(nullptr, p_sched_handle); + } + } else { + LOG_INFO << "No scheduler handles found for this device! "; } } + if (!is_scheduler_supported) { + FAIL() << "No scheduler handles found on any of the devcies! "; + } } LZT_TEST_F( @@ -61,15 +77,20 @@ LZT_TEST_F( GivenComponentCountWhenRetrievingSchedulerHandlesThenActualComponentCountIsUpdated) { for (auto device : devices) { uint32_t p_count = 0; - lzt::get_scheduler_handles(device, p_count); - if (p_count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + p_count = lzt::get_scheduler_handle_count(device); + if (p_count > 0) { + is_scheduler_supported = true; + LOG_INFO << "Scheduler handles are available on this device! "; + lzt::get_scheduler_handles(device, p_count); + uint32_t test_count = p_count + 1; + lzt::get_scheduler_handles(device, test_count); + EXPECT_EQ(test_count, p_count); + } else { + LOG_INFO << "No scheduler handles found for this device! "; } - - uint32_t test_count = p_count + 1; - lzt::get_scheduler_handles(device, test_count); - EXPECT_EQ(test_count, p_count); + } + if (!is_scheduler_supported) { + FAIL() << "No scheduler handles found on any of the devcies! "; } } @@ -78,21 +99,26 @@ LZT_TEST_F( GivenValidComponentCountWhenCallingApiTwiceThenSimilarSchedulerHandlesReturned) { for (auto device : devices) { uint32_t count = 0; - auto p_sched_handles_initial = lzt::get_scheduler_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto p_sched_handle : p_sched_handles_initial) { - EXPECT_NE(nullptr, p_sched_handle); - } - count = 0; - auto p_sched_handles_later = lzt::get_scheduler_handles(device, count); - for (auto p_sched_handle : p_sched_handles_later) { - EXPECT_NE(nullptr, p_sched_handle); + count = lzt::get_scheduler_handle_count(device); + if (count > 0) { + is_scheduler_supported = true; + LOG_INFO << "Scheduler handles are available on this device! "; + auto p_sched_handles_initial = lzt::get_scheduler_handles(device, count); + for (auto p_sched_handle : p_sched_handles_initial) { + EXPECT_NE(nullptr, p_sched_handle); + } + count = 0; + auto p_sched_handles_later = lzt::get_scheduler_handles(device, count); + for (auto p_sched_handle : p_sched_handles_later) { + EXPECT_NE(nullptr, p_sched_handle); + } + EXPECT_EQ(p_sched_handles_initial, p_sched_handles_later); + } else { + LOG_INFO << "No scheduler handles found for this device! "; } - EXPECT_EQ(p_sched_handles_initial, p_sched_handles_later); + } + if (!is_scheduler_supported) { + FAIL() << "No scheduler handles found on any of the devcies! "; } } @@ -101,38 +127,48 @@ LZT_TEST_F( GivenValidSchedulerHandleWhenRetrievinCurrentModeThenSuccessIsReturned) { for (auto device : devices) { uint32_t p_count = 0; - auto p_sched_handles = lzt::get_scheduler_handles(device, p_count); - if (p_count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto p_sched_handle : p_sched_handles) { - EXPECT_NE(nullptr, p_sched_handle); - auto cur_mode = lzt::get_scheduler_current_mode(p_sched_handle); - ASSERT_GE(cur_mode, ZES_SCHED_MODE_TIMEOUT); - ASSERT_LE(cur_mode, ZES_SCHED_MODE_COMPUTE_UNIT_DEBUG); + p_count = lzt::get_scheduler_handle_count(device); + if (p_count > 0) { + is_scheduler_supported = true; + LOG_INFO << "Scheduler handles are available on this device! "; + auto p_sched_handles = lzt::get_scheduler_handles(device, p_count); + for (auto p_sched_handle : p_sched_handles) { + EXPECT_NE(nullptr, p_sched_handle); + auto cur_mode = lzt::get_scheduler_current_mode(p_sched_handle); + ASSERT_GE(cur_mode, ZES_SCHED_MODE_TIMEOUT); + ASSERT_LE(cur_mode, ZES_SCHED_MODE_COMPUTE_UNIT_DEBUG); + } + } else { + LOG_INFO << "No scheduler handles found for this device! "; } } + if (!is_scheduler_supported) { + FAIL() << "No scheduler handles found on any of the devcies! "; + } } LZT_TEST_F( SCHEDULER_TEST, GivenValidSchedulerHandleWhenRetrievingCurrentModeTwiceThenSameModeIsReturned) { for (auto device : devices) { uint32_t p_count = 0; - auto p_sched_handles = lzt::get_scheduler_handles(device, p_count); - if (p_count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto p_sched_handle : p_sched_handles) { - EXPECT_NE(nullptr, p_sched_handle); - auto cur_mode_initial = lzt::get_scheduler_current_mode(p_sched_handle); - auto cur_mode_later = lzt::get_scheduler_current_mode(p_sched_handle); - EXPECT_EQ(cur_mode_initial, cur_mode_later); + p_count = lzt::get_scheduler_handle_count(device); + if (p_count > 0) { + is_scheduler_supported = true; + LOG_INFO << "Scheduler handles are available on this device! "; + auto p_sched_handles = lzt::get_scheduler_handles(device, p_count); + for (auto p_sched_handle : p_sched_handles) { + EXPECT_NE(nullptr, p_sched_handle); + auto cur_mode_initial = lzt::get_scheduler_current_mode(p_sched_handle); + auto cur_mode_later = lzt::get_scheduler_current_mode(p_sched_handle); + EXPECT_EQ(cur_mode_initial, cur_mode_later); + } + } else { + LOG_INFO << "No scheduler handles found for this device! "; } } + if (!is_scheduler_supported) { + FAIL() << "No scheduler handles found on any of the devcies! "; + } } LZT_TEST_F( @@ -140,129 +176,152 @@ LZT_TEST_F( GivenValidSchedulerHandleWhenRetrievingSchedulerTimeOutPropertiesThenSuccessIsReturned) { for (auto device : devices) { uint32_t p_count = 0; - auto p_sched_handles = lzt::get_scheduler_handles(device, p_count); - if (p_count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto p_sched_handle : p_sched_handles) { - EXPECT_NE(nullptr, p_sched_handle); - auto cur_mode = lzt::get_scheduler_current_mode(p_sched_handle); - if (cur_mode == ZES_SCHED_MODE_TIMEOUT) { - auto timeout_properties = - lzt::get_timeout_properties(p_sched_handle, false); - EXPECT_GT(timeout_properties.watchdogTimeout, 0); + p_count = lzt::get_scheduler_handle_count(device); + if (p_count > 0) { + is_scheduler_supported = true; + LOG_INFO << "Scheduler handles are available on this device! "; + auto p_sched_handles = lzt::get_scheduler_handles(device, p_count); + for (auto p_sched_handle : p_sched_handles) { + EXPECT_NE(nullptr, p_sched_handle); + auto cur_mode = lzt::get_scheduler_current_mode(p_sched_handle); + if (cur_mode == ZES_SCHED_MODE_TIMEOUT) { + auto timeout_properties = + lzt::get_timeout_properties(p_sched_handle, false); + EXPECT_GT(timeout_properties.watchdogTimeout, 0); + } } + } else { + LOG_INFO << "No scheduler handles found for this device! "; } } + if (!is_scheduler_supported) { + FAIL() << "No scheduler handles found on any of the devcies! "; + } } LZT_TEST_F( SCHEDULER_TEST, GivenValidSchedulerHandleWhenRetrievingSchedulerTimeOutPropertiesTwiceThenSamePropertiesAreReturned) { for (auto device : devices) { uint32_t p_count = 0; - auto p_sched_handles = lzt::get_scheduler_handles(device, p_count); - if (p_count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto p_sched_handle : p_sched_handles) { - EXPECT_NE(nullptr, p_sched_handle); - auto cur_mode = lzt::get_scheduler_current_mode(p_sched_handle); - if (cur_mode == ZES_SCHED_MODE_TIMEOUT) { - auto timeout_properties_initial = - lzt::get_timeout_properties(p_sched_handle, false); - auto timeout_properties_later = - lzt::get_timeout_properties(p_sched_handle, false); - EXPECT_EQ(timeout_properties_initial.watchdogTimeout, - timeout_properties_later.watchdogTimeout); + p_count = lzt::get_scheduler_handle_count(device); + if (p_count > 0) { + is_scheduler_supported = true; + LOG_INFO << "Scheduler handles are available on this device! "; + auto p_sched_handles = lzt::get_scheduler_handles(device, p_count); + for (auto p_sched_handle : p_sched_handles) { + EXPECT_NE(nullptr, p_sched_handle); + auto cur_mode = lzt::get_scheduler_current_mode(p_sched_handle); + if (cur_mode == ZES_SCHED_MODE_TIMEOUT) { + auto timeout_properties_initial = + lzt::get_timeout_properties(p_sched_handle, false); + auto timeout_properties_later = + lzt::get_timeout_properties(p_sched_handle, false); + EXPECT_EQ(timeout_properties_initial.watchdogTimeout, + timeout_properties_later.watchdogTimeout); + } } + } else { + LOG_INFO << "No scheduler handles found for this device! "; } } + if (!is_scheduler_supported) { + FAIL() << "No scheduler handles found on any of the devcies! "; + } } LZT_TEST_F( SCHEDULER_TEST, GivenValidSchedulerHandleWhenRetrievingSchedulerTimeSlicePropertiesThenSuccessIsReturned) { for (auto device : devices) { uint32_t p_count = 0; - auto p_sched_handles = lzt::get_scheduler_handles(device, p_count); - if (p_count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto p_sched_handle : p_sched_handles) { - EXPECT_NE(nullptr, p_sched_handle); - auto cur_mode = lzt::get_scheduler_current_mode(p_sched_handle); - if (cur_mode == ZES_SCHED_MODE_TIMESLICE) { - auto timeslice_properties = - lzt::get_timeslice_properties(p_sched_handle, false); - EXPECT_GT(timeslice_properties.interval, 0); - EXPECT_GE(timeslice_properties.yieldTimeout, 0); + p_count = lzt::get_scheduler_handle_count(device); + if (p_count > 0) { + is_scheduler_supported = true; + LOG_INFO << "Scheduler handles are available on this device! "; + auto p_sched_handles = lzt::get_scheduler_handles(device, p_count); + for (auto p_sched_handle : p_sched_handles) { + EXPECT_NE(nullptr, p_sched_handle); + auto cur_mode = lzt::get_scheduler_current_mode(p_sched_handle); + if (cur_mode == ZES_SCHED_MODE_TIMESLICE) { + auto timeslice_properties = + lzt::get_timeslice_properties(p_sched_handle, false); + EXPECT_GT(timeslice_properties.interval, 0); + EXPECT_GE(timeslice_properties.yieldTimeout, 0); + } } + } else { + LOG_INFO << "No scheduler handles found for this device! "; } } + if (!is_scheduler_supported) { + FAIL() << "No scheduler handles found on any of the devcies! "; + } } LZT_TEST_F( SCHEDULER_TEST, GivenValidSchedulerHandleWhenRetrievingSchedulerTimeSlicePropertiesTwiceThenSamePropertiesAreReturned) { for (auto device : devices) { uint32_t p_count = 0; - auto p_sched_handles = lzt::get_scheduler_handles(device, p_count); - if (p_count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto p_sched_handle : p_sched_handles) { - EXPECT_NE(nullptr, p_sched_handle); - auto cur_mode = lzt::get_scheduler_current_mode(p_sched_handle); - if (cur_mode == ZES_SCHED_MODE_TIMESLICE) { - auto timeslice_properties_initial = - lzt::get_timeslice_properties(p_sched_handle, false); - auto timeslice_properties_later = - lzt::get_timeslice_properties(p_sched_handle, false); - EXPECT_EQ(timeslice_properties_initial.interval, - timeslice_properties_later.interval); - EXPECT_EQ(timeslice_properties_initial.yieldTimeout, - timeslice_properties_later.yieldTimeout); + p_count = lzt::get_scheduler_handle_count(device); + if (p_count > 0) { + is_scheduler_supported = true; + LOG_INFO << "Scheduler handles are available on this device! "; + auto p_sched_handles = lzt::get_scheduler_handles(device, p_count); + for (auto p_sched_handle : p_sched_handles) { + EXPECT_NE(nullptr, p_sched_handle); + auto cur_mode = lzt::get_scheduler_current_mode(p_sched_handle); + if (cur_mode == ZES_SCHED_MODE_TIMESLICE) { + auto timeslice_properties_initial = + lzt::get_timeslice_properties(p_sched_handle, false); + auto timeslice_properties_later = + lzt::get_timeslice_properties(p_sched_handle, false); + EXPECT_EQ(timeslice_properties_initial.interval, + timeslice_properties_later.interval); + EXPECT_EQ(timeslice_properties_initial.yieldTimeout, + timeslice_properties_later.yieldTimeout); + } } + } else { + LOG_INFO << "No scheduler handles found for this device! "; } } + if (!is_scheduler_supported) { + FAIL() << "No scheduler handles found on any of the devcies! "; + } } LZT_TEST_F( SCHEDULER_TEST, GivenValidSchedulerHandleWhenSettingSchedulerTimeOutModeThenSuccessIsReturned) { for (auto device : devices) { uint32_t p_count = 0; - auto p_sched_handles = lzt::get_scheduler_handles(device, p_count); - if (p_count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto p_sched_handle : p_sched_handles) { - EXPECT_NE(nullptr, p_sched_handle); - auto timeout_pretest_properties = - lzt::get_timeout_properties(p_sched_handle, false); - - zes_sched_timeout_properties_t timeout_set_properties = { - ZES_STRUCTURE_TYPE_SCHED_TIMEOUT_PROPERTIES, nullptr}; - uint64_t watchdogTimeoutTestValue = 50000; - timeout_set_properties.watchdogTimeout = watchdogTimeoutTestValue; - lzt::set_timeout_mode(p_sched_handle, timeout_set_properties); - auto cur_mode = lzt::get_scheduler_current_mode(p_sched_handle); - ASSERT_EQ(cur_mode, ZES_SCHED_MODE_TIMEOUT); - auto timeout_get_properties = - lzt::get_timeout_properties(p_sched_handle, false); - EXPECT_EQ(timeout_get_properties.watchdogTimeout, - timeout_set_properties.watchdogTimeout); - - lzt::set_timeout_mode(p_sched_handle, timeout_pretest_properties); + p_count = lzt::get_scheduler_handle_count(device); + if (p_count > 0) { + is_scheduler_supported = true; + LOG_INFO << "Scheduler handles are available on this device! "; + auto p_sched_handles = lzt::get_scheduler_handles(device, p_count); + for (auto p_sched_handle : p_sched_handles) { + EXPECT_NE(nullptr, p_sched_handle); + auto timeout_pretest_properties = + lzt::get_timeout_properties(p_sched_handle, false); + zes_sched_timeout_properties_t timeout_set_properties = { + ZES_STRUCTURE_TYPE_SCHED_TIMEOUT_PROPERTIES, nullptr}; + uint64_t watchdogTimeoutTestValue = 50000; + timeout_set_properties.watchdogTimeout = watchdogTimeoutTestValue; + lzt::set_timeout_mode(p_sched_handle, timeout_set_properties); + auto cur_mode = lzt::get_scheduler_current_mode(p_sched_handle); + ASSERT_EQ(cur_mode, ZES_SCHED_MODE_TIMEOUT); + auto timeout_get_properties = + lzt::get_timeout_properties(p_sched_handle, false); + EXPECT_EQ(timeout_get_properties.watchdogTimeout, + timeout_set_properties.watchdogTimeout); + lzt::set_timeout_mode(p_sched_handle, timeout_pretest_properties); + } + } else { + LOG_INFO << "No scheduler handles found for this device! "; } } + if (!is_scheduler_supported) { + FAIL() << "No scheduler handles found on any of the devcies! "; + } } LZT_TEST_F( @@ -270,62 +329,71 @@ LZT_TEST_F( GivenValidSchedulerHandleWhenSettingSchedulerTimeSliceModeThenSuccessIsReturned) { for (auto device : devices) { uint32_t p_count = 0; - auto p_sched_handles = lzt::get_scheduler_handles(device, p_count); - if (p_count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto p_sched_handle : p_sched_handles) { - EXPECT_NE(nullptr, p_sched_handle); - auto timeslice_default_properties = - lzt::get_timeslice_properties(p_sched_handle, true); - zes_sched_timeslice_properties_t timeslice_set_properties = { - ZES_STRUCTURE_TYPE_SCHED_TIMESLICE_PROPERTIES, nullptr}; - timeslice_set_properties.interval = timeslice_default_properties.interval; - timeslice_set_properties.yieldTimeout = - timeslice_default_properties.yieldTimeout; - lzt::set_timeslice_mode(p_sched_handle, timeslice_set_properties); - auto cur_mode = lzt::get_scheduler_current_mode(p_sched_handle); - ASSERT_EQ(cur_mode, ZES_SCHED_MODE_TIMESLICE); - auto timeslice_get_properties = - lzt::get_timeslice_properties(p_sched_handle, false); - EXPECT_EQ(timeslice_get_properties.interval, - timeslice_set_properties.interval); - EXPECT_EQ(timeslice_get_properties.yieldTimeout, - timeslice_set_properties.yieldTimeout); + p_count = lzt::get_scheduler_handle_count(device); + if (p_count > 0) { + is_scheduler_supported = true; + LOG_INFO << "Scheduler handles are available on this device! "; + auto p_sched_handles = lzt::get_scheduler_handles(device, p_count); + for (auto p_sched_handle : p_sched_handles) { + EXPECT_NE(nullptr, p_sched_handle); + auto timeslice_default_properties = + lzt::get_timeslice_properties(p_sched_handle, true); + zes_sched_timeslice_properties_t timeslice_set_properties = { + ZES_STRUCTURE_TYPE_SCHED_TIMESLICE_PROPERTIES, nullptr}; + timeslice_set_properties.interval = + timeslice_default_properties.interval; + timeslice_set_properties.yieldTimeout = + timeslice_default_properties.yieldTimeout; + lzt::set_timeslice_mode(p_sched_handle, timeslice_set_properties); + auto cur_mode = lzt::get_scheduler_current_mode(p_sched_handle); + ASSERT_EQ(cur_mode, ZES_SCHED_MODE_TIMESLICE); + auto timeslice_get_properties = + lzt::get_timeslice_properties(p_sched_handle, false); + EXPECT_EQ(timeslice_get_properties.interval, + timeslice_set_properties.interval); + EXPECT_EQ(timeslice_get_properties.yieldTimeout, + timeslice_set_properties.yieldTimeout); + } + } else { + LOG_INFO << "No scheduler handles found for this device! "; } } + if (!is_scheduler_supported) { + FAIL() << "No scheduler handles found on any of the devcies! "; + } } LZT_TEST_F( SCHEDULER_TEST, GivenValidSchedulerHandleWhenSettingSchedulerExclusiveModeThenSuccesseReturned) { for (auto device : devices) { uint32_t p_count = 0; - auto p_sched_handles = lzt::get_scheduler_handles(device, p_count); - if (p_count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto p_sched_handle : p_sched_handles) { - EXPECT_NE(nullptr, p_sched_handle); - auto cur_mode = lzt::get_scheduler_current_mode(p_sched_handle); - if (cur_mode != ZES_SCHED_MODE_EXCLUSIVE) { - auto timeout_pretest_properties = - lzt::get_timeout_properties(p_sched_handle, false); - auto timeslice_pretest_properties = - lzt::get_timeslice_properties(p_sched_handle, false); - - lzt::set_exclusive_mode(p_sched_handle); - auto mode = lzt::get_scheduler_current_mode(p_sched_handle); - ASSERT_EQ(mode, ZES_SCHED_MODE_EXCLUSIVE); - - lzt::set_timeout_mode(p_sched_handle, timeout_pretest_properties); - lzt::set_timeslice_mode(p_sched_handle, timeslice_pretest_properties); + p_count = lzt::get_scheduler_handle_count(device); + if (p_count > 0) { + is_scheduler_supported = true; + LOG_INFO << "Scheduler handles are available on this device! "; + auto p_sched_handles = lzt::get_scheduler_handles(device, p_count); + for (auto p_sched_handle : p_sched_handles) { + EXPECT_NE(nullptr, p_sched_handle); + auto cur_mode = lzt::get_scheduler_current_mode(p_sched_handle); + if (cur_mode != ZES_SCHED_MODE_EXCLUSIVE) { + auto timeout_pretest_properties = + lzt::get_timeout_properties(p_sched_handle, false); + auto timeslice_pretest_properties = + lzt::get_timeslice_properties(p_sched_handle, false); + lzt::set_exclusive_mode(p_sched_handle); + auto mode = lzt::get_scheduler_current_mode(p_sched_handle); + ASSERT_EQ(mode, ZES_SCHED_MODE_EXCLUSIVE); + lzt::set_timeout_mode(p_sched_handle, timeout_pretest_properties); + lzt::set_timeslice_mode(p_sched_handle, timeslice_pretest_properties); + } } + } else { + LOG_INFO << "No scheduler handles found for this device! "; } } + if (!is_scheduler_supported) { + FAIL() << "No scheduler handles found on any of the devcies! "; + } } LZT_TEST_F( @@ -334,25 +402,30 @@ LZT_TEST_F( for (auto device : devices) { auto deviceProperties = lzt::get_sysman_device_properties(device); uint32_t p_count = 0; - auto p_sched_handles = lzt::get_scheduler_handles(device, p_count); - if (p_count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto p_sched_handle : p_sched_handles) { - ASSERT_NE(nullptr, p_sched_handle); - auto properties = lzt::get_scheduler_properties(p_sched_handle); - EXPECT_GE(properties.engines, ZES_ENGINE_TYPE_FLAG_OTHER); - EXPECT_LE(properties.engines, ZES_ENGINE_TYPE_FLAG_RENDER); - EXPECT_GE(properties.supportedModes, 1); - EXPECT_LE(properties.supportedModes, - (1 << ZES_SCHED_MODE_COMPUTE_UNIT_DEBUG)); - if (properties.onSubdevice) { - EXPECT_LT(properties.subdeviceId, deviceProperties.numSubdevices); + p_count = lzt::get_scheduler_handle_count(device); + if (p_count > 0) { + is_scheduler_supported = true; + LOG_INFO << "Scheduler handles are available on this device! "; + auto p_sched_handles = lzt::get_scheduler_handles(device, p_count); + for (auto p_sched_handle : p_sched_handles) { + ASSERT_NE(nullptr, p_sched_handle); + auto properties = lzt::get_scheduler_properties(p_sched_handle); + EXPECT_GE(properties.engines, ZES_ENGINE_TYPE_FLAG_OTHER); + EXPECT_LE(properties.engines, ZES_ENGINE_TYPE_FLAG_RENDER); + EXPECT_GE(properties.supportedModes, 1); + EXPECT_LE(properties.supportedModes, + (1 << ZES_SCHED_MODE_COMPUTE_UNIT_DEBUG)); + if (properties.onSubdevice) { + EXPECT_LT(properties.subdeviceId, deviceProperties.numSubdevices); + } } + } else { + LOG_INFO << "No scheduler handles found for this device! "; } } + if (!is_scheduler_supported) { + FAIL() << "No scheduler handles found on any of the devcies! "; + } } LZT_TEST_F( @@ -360,26 +433,32 @@ LZT_TEST_F( GivenValidSchedulerHandleWhenRetrievingSchedulerPropertiesThenExpectSamePropertiesReturnedTwice) { for (auto device : devices) { uint32_t p_count = 0; - auto p_sched_handles = lzt::get_scheduler_handles(device, p_count); - if (p_count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - - for (auto p_sched_handle : p_sched_handles) { - EXPECT_NE(nullptr, p_sched_handle); - auto properties_initial = lzt::get_scheduler_properties(p_sched_handle); - auto properties_later = lzt::get_scheduler_properties(p_sched_handle); - EXPECT_EQ(properties_initial.engines, properties_later.engines); - EXPECT_EQ(properties_initial.supportedModes, - properties_later.supportedModes); - EXPECT_EQ(properties_initial.canControl, properties_later.canControl); - EXPECT_EQ(properties_initial.onSubdevice, properties_later.onSubdevice); - if (properties_initial.onSubdevice && properties_later.onSubdevice) { - EXPECT_EQ(properties_initial.subdeviceId, properties_later.subdeviceId); + p_count = lzt::get_scheduler_handle_count(device); + if (p_count > 0) { + is_scheduler_supported = true; + LOG_INFO << "Scheduler handles are available on this device! "; + auto p_sched_handles = lzt::get_scheduler_handles(device, p_count); + for (auto p_sched_handle : p_sched_handles) { + EXPECT_NE(nullptr, p_sched_handle); + auto properties_initial = lzt::get_scheduler_properties(p_sched_handle); + auto properties_later = lzt::get_scheduler_properties(p_sched_handle); + EXPECT_EQ(properties_initial.engines, properties_later.engines); + EXPECT_EQ(properties_initial.supportedModes, + properties_later.supportedModes); + EXPECT_EQ(properties_initial.canControl, properties_later.canControl); + EXPECT_EQ(properties_initial.onSubdevice, properties_later.onSubdevice); + if (properties_initial.onSubdevice && properties_later.onSubdevice) { + EXPECT_EQ(properties_initial.subdeviceId, + properties_later.subdeviceId); + } } + } else { + LOG_INFO << "No scheduler handles found for this device! "; } } + if (!is_scheduler_supported) { + FAIL() << "No scheduler handles found on any of the devcies! "; + } } } // namespace From a292569b05ecfba167c437a81d0abff89d44e29f Mon Sep 17 00:00:00 2001 From: viki435 Date: Mon, 18 Aug 2025 23:25:43 +0530 Subject: [PATCH 02/15] Primary JIRA: VLCLJ-2513 Sub-tasks: VLCLJ-2570, VLCLJ-2568, VLCLJ-2577 Fix: Handling GTEST_FAIL logic for multi-device scenario for power, performance and scheduler modules. Signed-off-by: viki435 --- .../sysman/test_sysman_power/src/test_sysman_power.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp b/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp index 4b597a7e..93e9667b 100644 --- a/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp +++ b/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp @@ -20,14 +20,12 @@ namespace { #ifdef USE_ZESINIT class PowerModuleZesTest : public lzt::ZesSysmanCtsClass { public: - bool power_handles_available = false; bool is_power_supported = false; }; #define POWER_TEST PowerModuleZesTest #else // USE_ZESINIT class PowerModuleTest : public lzt::SysmanCtsClass { public: - bool power_handles_available = false; bool is_power_supported = false; }; #define POWER_TEST PowerModuleTest @@ -1376,8 +1374,8 @@ LZT_TEST_F( LOG_INFO << "No power handles found for this device! "; } } - if (!power_handles_available) { - FAIL() << "No power handles found in any of the devices!"; + if (!is_power_supported) { + FAIL() << "No power handles found on any of the devices!"; } } #endif From d029dda6cd7d2171d7da219f17b250d6cdce6178 Mon Sep 17 00:00:00 2001 From: viki435 Date: Mon, 18 Aug 2025 23:26:50 +0530 Subject: [PATCH 03/15] Primary JIRA: VLCLJ-2513 Sub-tasks: VLCLJ-2570, VLCLJ-2568, VLCLJ-2577 Fix: Handling GTEST_FAIL logic for multi-device scenario for power, performance and scheduler modules. Signed-off-by: viki435 --- .../sysman/test_sysman_power/src/test_sysman_power.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp b/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp index 93e9667b..edcfc6e7 100644 --- a/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp +++ b/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp @@ -1298,12 +1298,13 @@ LZT_TEST_F( continue; } uint32_t perf_count = 0; - perf_count = lzt::get_performance_handle_count(device); + perf_count = lzt::get_performance_handle_count(device); zes_power_energy_counter_t energy_counter_initial; zes_power_energy_counter_t energy_counter_later; - auto p_performance_handles = lzt::get_performance_handles(device, perf_count); + auto p_performance_handles = + lzt::get_performance_handles(device, perf_count); if (perf_count == 0) { - FAIL() << "No performance handles found for this device! "; + FAIL() << "No performance handles found for this device! "; } for (auto p_performance_handle : p_performance_handles) { zes_perf_properties_t p_perf_properties = From e32b567e47f5f19b5f08d3b5ee52bb2b6407169a Mon Sep 17 00:00:00 2001 From: viki435 Date: Mon, 18 Aug 2025 23:49:12 +0530 Subject: [PATCH 04/15] Primary JIRA: VLCLJ-2513 Sub-tasks: VLCLJ-2570, VLCLJ-2568, VLCLJ-2577 Fix: Handling GTEST_FAIL logic for multi-device scenario for power, performance and scheduler modules. Signed-off-by: viki435 --- .../src/test_sysman_scheduler.cpp | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/conformance_tests/sysman/test_sysman_scheduler/src/test_sysman_scheduler.cpp b/conformance_tests/sysman/test_sysman_scheduler/src/test_sysman_scheduler.cpp index 5566dc5b..c0416189 100644 --- a/conformance_tests/sysman/test_sysman_scheduler/src/test_sysman_scheduler.cpp +++ b/conformance_tests/sysman/test_sysman_scheduler/src/test_sysman_scheduler.cpp @@ -46,7 +46,7 @@ LZT_TEST_F( } } if (!is_scheduler_supported) { - FAIL() << "No scheduler handles found on any of the devcies! "; + FAIL() << "No scheduler handles found on any of the devices! "; } } @@ -68,7 +68,7 @@ LZT_TEST_F( } } if (!is_scheduler_supported) { - FAIL() << "No scheduler handles found on any of the devcies! "; + FAIL() << "No scheduler handles found on any of the devices! "; } } @@ -90,7 +90,7 @@ LZT_TEST_F( } } if (!is_scheduler_supported) { - FAIL() << "No scheduler handles found on any of the devcies! "; + FAIL() << "No scheduler handles found on any of the devices! "; } } @@ -118,7 +118,7 @@ LZT_TEST_F( } } if (!is_scheduler_supported) { - FAIL() << "No scheduler handles found on any of the devcies! "; + FAIL() << "No scheduler handles found on any of the devices! "; } } @@ -143,7 +143,7 @@ LZT_TEST_F( } } if (!is_scheduler_supported) { - FAIL() << "No scheduler handles found on any of the devcies! "; + FAIL() << "No scheduler handles found on any of the devices! "; } } LZT_TEST_F( @@ -167,7 +167,7 @@ LZT_TEST_F( } } if (!is_scheduler_supported) { - FAIL() << "No scheduler handles found on any of the devcies! "; + FAIL() << "No scheduler handles found on any of the devices! "; } } @@ -195,7 +195,7 @@ LZT_TEST_F( } } if (!is_scheduler_supported) { - FAIL() << "No scheduler handles found on any of the devcies! "; + FAIL() << "No scheduler handles found on any of the devices! "; } } LZT_TEST_F( @@ -225,7 +225,7 @@ LZT_TEST_F( } } if (!is_scheduler_supported) { - FAIL() << "No scheduler handles found on any of the devcies! "; + FAIL() << "No scheduler handles found on any of the devices! "; } } LZT_TEST_F( @@ -253,7 +253,7 @@ LZT_TEST_F( } } if (!is_scheduler_supported) { - FAIL() << "No scheduler handles found on any of the devcies! "; + FAIL() << "No scheduler handles found on any of the devices! "; } } LZT_TEST_F( @@ -285,7 +285,7 @@ LZT_TEST_F( } } if (!is_scheduler_supported) { - FAIL() << "No scheduler handles found on any of the devcies! "; + FAIL() << "No scheduler handles found on any of the devices! "; } } LZT_TEST_F( @@ -320,7 +320,7 @@ LZT_TEST_F( } } if (!is_scheduler_supported) { - FAIL() << "No scheduler handles found on any of the devcies! "; + FAIL() << "No scheduler handles found on any of the devices! "; } } @@ -359,7 +359,7 @@ LZT_TEST_F( } } if (!is_scheduler_supported) { - FAIL() << "No scheduler handles found on any of the devcies! "; + FAIL() << "No scheduler handles found on any of the devices! "; } } LZT_TEST_F( @@ -392,7 +392,7 @@ LZT_TEST_F( } } if (!is_scheduler_supported) { - FAIL() << "No scheduler handles found on any of the devcies! "; + FAIL() << "No scheduler handles found on any of the devices! "; } } @@ -424,7 +424,7 @@ LZT_TEST_F( } } if (!is_scheduler_supported) { - FAIL() << "No scheduler handles found on any of the devcies! "; + FAIL() << "No scheduler handles found on any of the devices! "; } } @@ -457,7 +457,7 @@ LZT_TEST_F( } } if (!is_scheduler_supported) { - FAIL() << "No scheduler handles found on any of the devcies! "; + FAIL() << "No scheduler handles found on any of the devices! "; } } From d53fa3723a5cef4c1ad40ad0473f5601fcf11eb1 Mon Sep 17 00:00:00 2001 From: viki435 Date: Thu, 21 Aug 2025 00:35:16 +0530 Subject: [PATCH 05/15] Primary JIRA: VLCLJ-2513 Sub-tasks: VLCLJ-2570, VLCLJ-2568, VLCLJ-2577 Fix: Handling GTEST_FAIL logic for multi-device scenario for power, performance and scheduler modules. Signed-off-by: viki435 --- .../src/test_sysman_power.cpp | 167 ++++++++---------- 1 file changed, 78 insertions(+), 89 deletions(-) diff --git a/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp b/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp index edcfc6e7..4bee5a71 100644 --- a/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp +++ b/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp @@ -1109,79 +1109,71 @@ LZT_TEST_F( uint32_t single_count = 1; bool peak_limit_available = false; - std::vector power_limits_descriptors; - auto status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - int32_t max_power_limit_first = std::numeric_limits::max(); - for (int i = 0; i < power_limits_descriptors.size(); i++) { - zes_power_limit_ext_desc_t power_peak_initial = {}; - zes_power_limit_ext_desc_t power_peak_Max = {}; - zes_power_limit_ext_desc_t power_peak_getMax = {}; - zes_power_limit_ext_desc_t power_peak_get = {}; - if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_PEAK) { - peak_limit_available = true; - zes_power_source_t power_source = - power_limits_descriptors[i].source; - power_peak_Max = power_limits_descriptors[i]; - power_peak_initial = power_limits_descriptors[i]; - power_peak_Max.limit = max_power_limit_first; + std::vector power_limits_descriptors; + auto status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + for (int i = 0; i < power_limits_descriptors.size(); i++) { + zes_power_limit_ext_desc_t power_peak_initial = {}; + zes_power_limit_ext_desc_t power_peak_Max = {}; + zes_power_limit_ext_desc_t power_peak_getMax = {}; + zes_power_limit_ext_desc_t power_peak_get = {}; + if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_PEAK) { + peak_limit_available = true; + zes_power_source_t power_source = power_limits_descriptors[i].source; + power_peak_Max = power_limits_descriptors[i]; + power_peak_initial = power_limits_descriptors[i]; + power_peak_Max.limit = std::numeric_limits::max(); + power_peak_initial.limit *= 2; - int32_t max_power_limit_second = - power_limits_descriptors[i].limit * 2; - power_peak_initial.limit = max_power_limit_second; - if (power_limits_descriptors[i].limitValueLocked == false) { - status = lzt::set_power_limits_ext(p_power_handle, &single_count, - &power_peak_Max); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - std::vector - power_limits_descriptors_getMax; - status = - lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors_getMax); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - for (const auto &p_power_limits_descriptor_get : - power_limits_descriptors_getMax) { - if (p_power_limits_descriptor_get.level == - ZES_POWER_LEVEL_PEAK && - p_power_limits_descriptor_get.source == power_source) { - power_peak_getMax = p_power_limits_descriptor_get; - EXPECT_LT(power_peak_getMax.limit, max_power_limit_first); - } + if (power_limits_descriptors[i].limitValueLocked == false) { + status = lzt::set_power_limits_ext(p_power_handle, &single_count, + &power_peak_Max); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + std::vector + power_limits_descriptors_getMax; + status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_getMax); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + for (const auto &p_power_limits_descriptor_get : + power_limits_descriptors_getMax) { + if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_PEAK && + p_power_limits_descriptor_get.source == power_source) { + power_peak_getMax = p_power_limits_descriptor_get; } + } - status = lzt::set_power_limits_ext(p_power_handle, &single_count, - &power_peak_initial); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - std::vector - power_limits_descriptors_get; - status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors_get); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - for (const auto &p_power_limits_descriptor_get : - power_limits_descriptors_get) { - if (p_power_limits_descriptor_get.level == - ZES_POWER_LEVEL_PEAK && - p_power_limits_descriptor_get.source == power_source) { - power_peak_get = p_power_limits_descriptor_get; - EXPECT_LE(power_peak_get.limit, max_power_limit_second); - } + status = lzt::set_power_limits_ext(p_power_handle, &single_count, + &power_peak_initial); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + std::vector + power_limits_descriptors_get; + status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_get); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + for (const auto &p_power_limits_descriptor_get : + power_limits_descriptors_get) { + if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_PEAK && + p_power_limits_descriptor_get.source == power_source) { + power_peak_get = p_power_limits_descriptor_get; } + } + EXPECT_LE(power_peak_get.limit, power_peak_getMax.limit); } else { LOG_INFO << "Set limit not supported due to peak " "limitValueLocked flag is true"; @@ -1212,17 +1204,17 @@ LZT_TEST_F( LOG_INFO << "Power handles are available on this device! "; auto p_power_handles = lzt::get_power_handles(device, count); for (auto p_power_handle : p_power_handles) { - zes_power_properties_t pProperties = { - ZES_STRUCTURE_TYPE_POWER_PROPERTIES, nullptr}; - zes_power_ext_properties_t pExtProperties = { - ZES_STRUCTURE_TYPE_POWER_EXT_PROPERTIES, nullptr}; - pProperties.pNext = &pExtProperties; + zes_power_properties_t pProperties = {ZES_STRUCTURE_TYPE_POWER_PROPERTIES, + nullptr}; + zes_power_ext_properties_t pExtProperties = { + ZES_STRUCTURE_TYPE_POWER_EXT_PROPERTIES, nullptr}; + pProperties.pNext = &pExtProperties; - EXPECT_ZE_RESULT_SUCCESS( - zesPowerGetProperties(p_power_handle, &pProperties)); + EXPECT_ZE_RESULT_SUCCESS( + zesPowerGetProperties(p_power_handle, &pProperties)); - EXPECT_GT(pExtProperties.domain, ZES_POWER_DOMAIN_UNKNOWN); - EXPECT_LT(pExtProperties.domain, ZES_POWER_DOMAIN_FORCE_UINT32); + EXPECT_GT(pExtProperties.domain, ZES_POWER_DOMAIN_UNKNOWN); + EXPECT_LT(pExtProperties.domain, ZES_POWER_DOMAIN_FORCE_UINT32); } } else { LOG_INFO << "No power handles found for this device! "; @@ -1244,8 +1236,8 @@ LZT_TEST_F( LOG_INFO << "Power handles are available on this device! "; auto p_power_handles = lzt::get_power_handles(device, count); for (auto p_power_handle : p_power_handles) { - zes_power_properties_t pProperties = { - ZES_STRUCTURE_TYPE_POWER_PROPERTIES, nullptr}; + zes_power_properties_t pProperties = {ZES_STRUCTURE_TYPE_POWER_PROPERTIES, + nullptr}; zes_power_ext_properties_t pExtProperties = { ZES_STRUCTURE_TYPE_POWER_EXT_PROPERTIES, nullptr}; zes_power_limit_ext_desc_t default_limits = {}; @@ -1259,10 +1251,8 @@ LZT_TEST_F( EXPECT_LE(pExtProperties.defaultLimit->level, ZES_POWER_LEVEL_INSTANTANEOUS); EXPECT_GE(pExtProperties.defaultLimit->source, ZES_POWER_SOURCE_ANY); - EXPECT_LE(pExtProperties.defaultLimit->source, - ZES_POWER_SOURCE_BATTERY); - EXPECT_GE(pExtProperties.defaultLimit->limitUnit, - ZES_LIMIT_UNIT_UNKNOWN); + EXPECT_LE(pExtProperties.defaultLimit->source, ZES_POWER_SOURCE_BATTERY); + EXPECT_GE(pExtProperties.defaultLimit->limitUnit, ZES_LIMIT_UNIT_UNKNOWN); EXPECT_LE(pExtProperties.defaultLimit->limitUnit, ZES_LIMIT_UNIT_POWER); if (!pExtProperties.defaultLimit->intervalValueLocked) { EXPECT_GE(pExtProperties.defaultLimit->interval, 0u); @@ -1304,7 +1294,8 @@ LZT_TEST_F( auto p_performance_handles = lzt::get_performance_handles(device, perf_count); if (perf_count == 0) { - FAIL() << "No performance handles found for this device! "; + FAIL() << "No handles found: " + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); } for (auto p_performance_handle : p_performance_handles) { zes_perf_properties_t p_perf_properties = @@ -1319,10 +1310,8 @@ LZT_TEST_F( &energy_counter_initial); lzt::set_performance_config(p_performance_handle, 100); std::this_thread::sleep_for(std::chrono::milliseconds(100)); - lzt::get_power_energy_counter(p_power_handle, - &energy_counter_later); - EXPECT_GE(energy_counter_later.energy, - energy_counter_initial.energy); + lzt::get_power_energy_counter(p_power_handle, &energy_counter_later); + EXPECT_GE(energy_counter_later.energy, energy_counter_initial.energy); } } } From dc137263d01593875133f4db677ec78b30d3cc5c Mon Sep 17 00:00:00 2001 From: viki435 Date: Thu, 21 Aug 2025 00:55:36 +0530 Subject: [PATCH 06/15] Primary JIRA: VLCLJ-2513 Sub-tasks: VLCLJ-2570, VLCLJ-2568, VLCLJ-2577 Fix: Handling GTEST_FAIL logic for multi-device scenario for power, performance and scheduler modules. Signed-off-by: viki435 --- .../src/test_sysman_power.cpp | 191 +++++++++--------- 1 file changed, 99 insertions(+), 92 deletions(-) diff --git a/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp b/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp index 4bee5a71..e068a126 100644 --- a/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp +++ b/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp @@ -1096,100 +1096,107 @@ LZT_TEST_F( for (auto device : devices) { uint32_t count = 0; count = lzt::get_power_handle_count(device); - if (count > 0) { - is_power_supported = true; - LOG_INFO << "Power handles are available on this device! "; - auto p_power_handles = lzt::get_power_handles(device, count); - for (auto p_power_handle : p_power_handles) { - auto p_properties = lzt::get_power_properties(p_power_handle); - if (p_properties.onSubdevice == true) { - continue; - } - uint32_t count_power = 0; - uint32_t single_count = 1; - bool peak_limit_available = false; - - std::vector power_limits_descriptors; - auto status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - for (int i = 0; i < power_limits_descriptors.size(); i++) { - zes_power_limit_ext_desc_t power_peak_initial = {}; - zes_power_limit_ext_desc_t power_peak_Max = {}; - zes_power_limit_ext_desc_t power_peak_getMax = {}; - zes_power_limit_ext_desc_t power_peak_get = {}; - if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_PEAK) { - peak_limit_available = true; - zes_power_source_t power_source = power_limits_descriptors[i].source; - power_peak_Max = power_limits_descriptors[i]; - power_peak_initial = power_limits_descriptors[i]; - power_peak_Max.limit = std::numeric_limits::max(); - power_peak_initial.limit *= 2; - - if (power_limits_descriptors[i].limitValueLocked == false) { - status = lzt::set_power_limits_ext(p_power_handle, &single_count, - &power_peak_Max); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - std::vector - power_limits_descriptors_getMax; - status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors_getMax); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - for (const auto &p_power_limits_descriptor_get : - power_limits_descriptors_getMax) { - if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_PEAK && - p_power_limits_descriptor_get.source == power_source) { - power_peak_getMax = p_power_limits_descriptor_get; - } - } - - status = lzt::set_power_limits_ext(p_power_handle, &single_count, - &power_peak_initial); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - std::vector - power_limits_descriptors_get; - status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors_get); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - for (const auto &p_power_limits_descriptor_get : - power_limits_descriptors_get) { - if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_PEAK && - p_power_limits_descriptor_get.source == power_source) { - power_peak_get = p_power_limits_descriptor_get; - } - } - EXPECT_LE(power_peak_get.limit, power_peak_getMax.limit); - } else { - LOG_INFO << "Set limit not supported due to peak " - "limitValueLocked flag is true"; - } - } - } - if (!peak_limit_available) { - LOG_INFO << "peak power limit not supported"; - } - } - } else { - LOG_INFO << "No power handles found for this device! "; + if(count > 0) + { + is_power_supported = true; + LOG_INFO << "Power handles are available on this device! "; + auto p_power_handles = lzt::get_power_handles(device, count); + if (count == 0) { + FAIL() << "No handles found: " << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + } + for (auto p_power_handle : p_power_handles) { + auto p_properties = lzt::get_power_properties(p_power_handle); + if (p_properties.onSubdevice == true) { + continue; + } + uint32_t count_power = 0; + uint32_t single_count = 1; + bool peak_limit_available = false; + + std::vector power_limits_descriptors; + auto status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + for (int i = 0; i < power_limits_descriptors.size(); i++) { + zes_power_limit_ext_desc_t power_peak_initial = {}; + zes_power_limit_ext_desc_t power_peak_Max = {}; + zes_power_limit_ext_desc_t power_peak_getMax = {}; + zes_power_limit_ext_desc_t power_peak_get = {}; + if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_PEAK) { + peak_limit_available = true; + zes_power_source_t power_source = power_limits_descriptors[i].source; + power_peak_Max = power_limits_descriptors[i]; + power_peak_initial = power_limits_descriptors[i]; + power_peak_Max.limit = std::numeric_limits::max(); + power_peak_initial.limit *= 2; + + if (power_limits_descriptors[i].limitValueLocked == false) { + status = lzt::set_power_limits_ext(p_power_handle, &single_count, + &power_peak_Max); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + std::vector + power_limits_descriptors_getMax; + status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_getMax); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + for (const auto &p_power_limits_descriptor_get : + power_limits_descriptors_getMax) { + if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_PEAK && + p_power_limits_descriptor_get.source == power_source) { + power_peak_getMax = p_power_limits_descriptor_get; + } + } + + status = lzt::set_power_limits_ext(p_power_handle, &single_count, + &power_peak_initial); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + std::vector + power_limits_descriptors_get; + status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_get); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + for (const auto &p_power_limits_descriptor_get : + power_limits_descriptors_get) { + if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_PEAK && + p_power_limits_descriptor_get.source == power_source) { + power_peak_get = p_power_limits_descriptor_get; + } + } + EXPECT_LE(power_peak_get.limit, power_peak_getMax.limit); + } else { + LOG_INFO << "Set limit not supported due to peak " + "limitValueLocked flag is true"; + } + } + } + if (!peak_limit_available) { + LOG_INFO << "peak power limit not supported"; + } + } + } + else + { + LOG_INFO << "No power handles found for this device! "; } } - if (!is_power_supported) { - FAIL() << "No power handles on any of the devices! "; + if(!is_power_supported) + { + FAIL() << "No power handles found on any of the devices! "; } } From b8f0f5212c10cb548c630353ac8fcc51a0b1545f Mon Sep 17 00:00:00 2001 From: viki435 Date: Thu, 21 Aug 2025 01:03:27 +0530 Subject: [PATCH 07/15] Primary JIRA: VLCLJ-2513 Sub-tasks: VLCLJ-2570, VLCLJ-2568, VLCLJ-2577 Fix: Handling GTEST_FAIL logic for multi-device scenario for power, performance and scheduler modules. Signed-off-by: viki435 --- .../src/test_sysman_power.cpp | 233 +++++++++--------- 1 file changed, 117 insertions(+), 116 deletions(-) diff --git a/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp b/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp index e068a126..9907fe94 100644 --- a/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp +++ b/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp @@ -1096,107 +1096,104 @@ LZT_TEST_F( for (auto device : devices) { uint32_t count = 0; count = lzt::get_power_handle_count(device); - if(count > 0) - { - is_power_supported = true; - LOG_INFO << "Power handles are available on this device! "; - auto p_power_handles = lzt::get_power_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - for (auto p_power_handle : p_power_handles) { - auto p_properties = lzt::get_power_properties(p_power_handle); - if (p_properties.onSubdevice == true) { - continue; - } - uint32_t count_power = 0; - uint32_t single_count = 1; - bool peak_limit_available = false; - - std::vector power_limits_descriptors; - auto status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - for (int i = 0; i < power_limits_descriptors.size(); i++) { - zes_power_limit_ext_desc_t power_peak_initial = {}; - zes_power_limit_ext_desc_t power_peak_Max = {}; - zes_power_limit_ext_desc_t power_peak_getMax = {}; - zes_power_limit_ext_desc_t power_peak_get = {}; - if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_PEAK) { - peak_limit_available = true; - zes_power_source_t power_source = power_limits_descriptors[i].source; - power_peak_Max = power_limits_descriptors[i]; - power_peak_initial = power_limits_descriptors[i]; - power_peak_Max.limit = std::numeric_limits::max(); - power_peak_initial.limit *= 2; - - if (power_limits_descriptors[i].limitValueLocked == false) { - status = lzt::set_power_limits_ext(p_power_handle, &single_count, - &power_peak_Max); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - std::vector - power_limits_descriptors_getMax; - status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors_getMax); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - for (const auto &p_power_limits_descriptor_get : - power_limits_descriptors_getMax) { - if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_PEAK && - p_power_limits_descriptor_get.source == power_source) { - power_peak_getMax = p_power_limits_descriptor_get; - } - } - - status = lzt::set_power_limits_ext(p_power_handle, &single_count, - &power_peak_initial); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - std::vector - power_limits_descriptors_get; - status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors_get); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - for (const auto &p_power_limits_descriptor_get : - power_limits_descriptors_get) { - if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_PEAK && - p_power_limits_descriptor_get.source == power_source) { - power_peak_get = p_power_limits_descriptor_get; - } - } - EXPECT_LE(power_peak_get.limit, power_peak_getMax.limit); - } else { - LOG_INFO << "Set limit not supported due to peak " - "limitValueLocked flag is true"; - } - } - } - if (!peak_limit_available) { - LOG_INFO << "peak power limit not supported"; - } - } - } - else - { - LOG_INFO << "No power handles found for this device! "; + if (count > 0) { + is_power_supported = true; + LOG_INFO << "Power handles are available on this device! "; + auto p_power_handles = lzt::get_power_handles(device, count); + for (auto p_power_handle : p_power_handles) { + auto p_properties = lzt::get_power_properties(p_power_handle); + if (p_properties.onSubdevice == true) { + continue; + } + uint32_t count_power = 0; + uint32_t single_count = 1; + bool peak_limit_available = false; + + std::vector power_limits_descriptors; + auto status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + for (int i = 0; i < power_limits_descriptors.size(); i++) { + zes_power_limit_ext_desc_t power_peak_initial = {}; + zes_power_limit_ext_desc_t power_peak_Max = {}; + zes_power_limit_ext_desc_t power_peak_getMax = {}; + zes_power_limit_ext_desc_t power_peak_get = {}; + if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_PEAK) { + peak_limit_available = true; + zes_power_source_t power_source = + power_limits_descriptors[i].source; + power_peak_Max = power_limits_descriptors[i]; + power_peak_initial = power_limits_descriptors[i]; + power_peak_Max.limit = std::numeric_limits::max(); + power_peak_initial.limit *= 2; + + if (power_limits_descriptors[i].limitValueLocked == false) { + status = lzt::set_power_limits_ext(p_power_handle, &single_count, + &power_peak_Max); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + std::vector + power_limits_descriptors_getMax; + status = + lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_getMax); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + for (const auto &p_power_limits_descriptor_get : + power_limits_descriptors_getMax) { + if (p_power_limits_descriptor_get.level == + ZES_POWER_LEVEL_PEAK && + p_power_limits_descriptor_get.source == power_source) { + power_peak_getMax = p_power_limits_descriptor_get; + } + } + + status = lzt::set_power_limits_ext(p_power_handle, &single_count, + &power_peak_initial); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + std::vector + power_limits_descriptors_get; + status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_get); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + for (const auto &p_power_limits_descriptor_get : + power_limits_descriptors_get) { + if (p_power_limits_descriptor_get.level == + ZES_POWER_LEVEL_PEAK && + p_power_limits_descriptor_get.source == power_source) { + power_peak_get = p_power_limits_descriptor_get; + } + } + EXPECT_LE(power_peak_get.limit, power_peak_getMax.limit); + } else { + LOG_INFO << "Set limit not supported due to peak " + "limitValueLocked flag is true"; + } + } + } + if (!peak_limit_available) { + LOG_INFO << "peak power limit not supported"; + } + } + } else { + LOG_INFO << "No power handles found for this device! "; } } - if(!is_power_supported) - { - FAIL() << "No power handles found on any of the devices! "; + if (!is_power_supported) { + FAIL() << "No power handles found on any of the devices! "; } } @@ -1211,17 +1208,17 @@ LZT_TEST_F( LOG_INFO << "Power handles are available on this device! "; auto p_power_handles = lzt::get_power_handles(device, count); for (auto p_power_handle : p_power_handles) { - zes_power_properties_t pProperties = {ZES_STRUCTURE_TYPE_POWER_PROPERTIES, - nullptr}; - zes_power_ext_properties_t pExtProperties = { - ZES_STRUCTURE_TYPE_POWER_EXT_PROPERTIES, nullptr}; - pProperties.pNext = &pExtProperties; + zes_power_properties_t pProperties = { + ZES_STRUCTURE_TYPE_POWER_PROPERTIES, nullptr}; + zes_power_ext_properties_t pExtProperties = { + ZES_STRUCTURE_TYPE_POWER_EXT_PROPERTIES, nullptr}; + pProperties.pNext = &pExtProperties; - EXPECT_ZE_RESULT_SUCCESS( - zesPowerGetProperties(p_power_handle, &pProperties)); + EXPECT_ZE_RESULT_SUCCESS( + zesPowerGetProperties(p_power_handle, &pProperties)); - EXPECT_GT(pExtProperties.domain, ZES_POWER_DOMAIN_UNKNOWN); - EXPECT_LT(pExtProperties.domain, ZES_POWER_DOMAIN_FORCE_UINT32); + EXPECT_GT(pExtProperties.domain, ZES_POWER_DOMAIN_UNKNOWN); + EXPECT_LT(pExtProperties.domain, ZES_POWER_DOMAIN_FORCE_UINT32); } } else { LOG_INFO << "No power handles found for this device! "; @@ -1243,8 +1240,8 @@ LZT_TEST_F( LOG_INFO << "Power handles are available on this device! "; auto p_power_handles = lzt::get_power_handles(device, count); for (auto p_power_handle : p_power_handles) { - zes_power_properties_t pProperties = {ZES_STRUCTURE_TYPE_POWER_PROPERTIES, - nullptr}; + zes_power_properties_t pProperties = { + ZES_STRUCTURE_TYPE_POWER_PROPERTIES, nullptr}; zes_power_ext_properties_t pExtProperties = { ZES_STRUCTURE_TYPE_POWER_EXT_PROPERTIES, nullptr}; zes_power_limit_ext_desc_t default_limits = {}; @@ -1258,8 +1255,10 @@ LZT_TEST_F( EXPECT_LE(pExtProperties.defaultLimit->level, ZES_POWER_LEVEL_INSTANTANEOUS); EXPECT_GE(pExtProperties.defaultLimit->source, ZES_POWER_SOURCE_ANY); - EXPECT_LE(pExtProperties.defaultLimit->source, ZES_POWER_SOURCE_BATTERY); - EXPECT_GE(pExtProperties.defaultLimit->limitUnit, ZES_LIMIT_UNIT_UNKNOWN); + EXPECT_LE(pExtProperties.defaultLimit->source, + ZES_POWER_SOURCE_BATTERY); + EXPECT_GE(pExtProperties.defaultLimit->limitUnit, + ZES_LIMIT_UNIT_UNKNOWN); EXPECT_LE(pExtProperties.defaultLimit->limitUnit, ZES_LIMIT_UNIT_POWER); if (!pExtProperties.defaultLimit->intervalValueLocked) { EXPECT_GE(pExtProperties.defaultLimit->interval, 0u); @@ -1301,8 +1300,8 @@ LZT_TEST_F( auto p_performance_handles = lzt::get_performance_handles(device, perf_count); if (perf_count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + FAIL() << "No handles found: " + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); } for (auto p_performance_handle : p_performance_handles) { zes_perf_properties_t p_perf_properties = @@ -1317,8 +1316,10 @@ LZT_TEST_F( &energy_counter_initial); lzt::set_performance_config(p_performance_handle, 100); std::this_thread::sleep_for(std::chrono::milliseconds(100)); - lzt::get_power_energy_counter(p_power_handle, &energy_counter_later); - EXPECT_GE(energy_counter_later.energy, energy_counter_initial.energy); + lzt::get_power_energy_counter(p_power_handle, + &energy_counter_later); + EXPECT_GE(energy_counter_later.energy, + energy_counter_initial.energy); } } } From 125964d9aaf495271182dfb8090f903a9ae00d53 Mon Sep 17 00:00:00 2001 From: viki435 Date: Thu, 21 Aug 2025 01:33:21 +0530 Subject: [PATCH 08/15] Primary JIRA: VLCLJ-2513 Sub-tasks: VLCLJ-2570, VLCLJ-2568, VLCLJ-2577 Fix: Handling GTEST_FAIL logic for multi-device scenario for power, performance and scheduler modules. Signed-off-by: viki435 --- .../src/test_sysman_power.cpp | 44 ++++++++----------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp b/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp index b84e3e1b..fc58d9ef 100644 --- a/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp +++ b/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp @@ -1095,6 +1095,11 @@ LZT_TEST_F( GivenValidPowerHandlesAfterGettingMaxPowerLimitWhenSettingValuesForPeakPowerThenExpectZesPowerGetLimitsExtToReturnPowerLimitsLessThanMaxPowerLimits) { for (auto device : devices) { uint32_t count = 0; + count = lzt::get_power_handle_count(device); + if(count > 0) + { + is_poower_supported = true; + LOG_INFO << "Power handles are available on this device! "; auto p_power_handles = lzt::get_power_handles(device, count); if (count == 0) { FAIL() << "No handles found: " @@ -1150,7 +1155,7 @@ LZT_TEST_F( p_power_limits_descriptor_get.source == power_source) { power_peak_getMax = p_power_limits_descriptor_get; } - + } status = lzt::set_power_limits_ext(p_power_handle, &single_count, &power_peak_initial); @@ -1171,39 +1176,28 @@ LZT_TEST_F( if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_PEAK && p_power_limits_descriptor_get.source == power_source) { power_peak_get = p_power_limits_descriptor_get; - - } - EXPECT_ZE_RESULT_SUCCESS(status); - for (const auto &p_power_limits_descriptor_get : - power_limits_descriptors_get) { - if (p_power_limits_descriptor_get.level == - ZES_POWER_LEVEL_PEAK && - p_power_limits_descriptor_get.source == power_source) { - power_peak_get = p_power_limits_descriptor_get; - } } - EXPECT_LE(power_peak_get.limit, power_peak_getMax.limit); - } else { - LOG_INFO << "Set limit not supported due to peak " - "limitValueLocked flag is true"; } - EXPECT_LE(power_peak_get.limit, power_peak_getMax.limit); } else { LOG_INFO << "Set limit not supported due to peak " "limitValueLocked flag is true"; } } - if (!peak_limit_available) { - LOG_INFO << "peak power limit not supported"; - } } - } else { - LOG_INFO << "No power handles found for this device! "; + if (!peak_limit_available) { + LOG_INFO << "peak power limit not supported"; + } } } - if (!is_power_supported) { - FAIL() << "No power handles found on any of the devices! "; + else + { + LOG_INFO << "No power handles found for this device! "; + } + } + if(!is_power_supported) + { + FAIL() << "No power handles found on any of the devices! "; } } @@ -1235,7 +1229,7 @@ LZT_TEST_F( } } if (!is_power_supported) { - FAIL() << "No power handles on any of the devices! "; + FAIL() << "No power handles found on any of the devices! "; } } @@ -1284,7 +1278,7 @@ LZT_TEST_F( } } if (!is_power_supported) { - FAIL() << "No power handles on any of the devices! "; + FAIL() << "No power handles found on any of the devices! "; } } From 38648aa469a8601e785a70098707ec9263294440 Mon Sep 17 00:00:00 2001 From: viki435 Date: Thu, 21 Aug 2025 01:38:05 +0530 Subject: [PATCH 09/15] Primary JIRA: VLCLJ-2513 Sub-tasks: VLCLJ-2570, VLCLJ-2568, VLCLJ-2577 Fix: Handling GTEST_FAIL logic for multi-device scenario for power, performance and scheduler modules. Signed-off-by: viki435 --- .../src/test_sysman_power.cpp | 180 +++++++++--------- 1 file changed, 90 insertions(+), 90 deletions(-) diff --git a/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp b/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp index fc58d9ef..12c3836f 100644 --- a/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp +++ b/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp @@ -1096,108 +1096,108 @@ LZT_TEST_F( for (auto device : devices) { uint32_t count = 0; count = lzt::get_power_handle_count(device); - if(count > 0) - { - is_poower_supported = true; - LOG_INFO << "Power handles are available on this device! "; - auto p_power_handles = lzt::get_power_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } - for (auto p_power_handle : p_power_handles) { - auto p_properties = lzt::get_power_properties(p_power_handle); - if (p_properties.onSubdevice == true) { - continue; + if (count > 0) { + is_poower_supported = true; + LOG_INFO << "Power handles are available on this device! "; + auto p_power_handles = lzt::get_power_handles(device, count); + if (count == 0) { + FAIL() << "No handles found: " + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); } - uint32_t count_power = 0; - uint32_t single_count = 1; - bool peak_limit_available = false; + for (auto p_power_handle : p_power_handles) { + auto p_properties = lzt::get_power_properties(p_power_handle); + if (p_properties.onSubdevice == true) { + continue; + } + uint32_t count_power = 0; + uint32_t single_count = 1; + bool peak_limit_available = false; - std::vector power_limits_descriptors; - auto status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - for (int i = 0; i < power_limits_descriptors.size(); i++) { - zes_power_limit_ext_desc_t power_peak_initial = {}; - zes_power_limit_ext_desc_t power_peak_Max = {}; - zes_power_limit_ext_desc_t power_peak_getMax = {}; - zes_power_limit_ext_desc_t power_peak_get = {}; - if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_PEAK) { - peak_limit_available = true; - zes_power_source_t power_source = power_limits_descriptors[i].source; - power_peak_Max = power_limits_descriptors[i]; - power_peak_initial = power_limits_descriptors[i]; - power_peak_Max.limit = std::numeric_limits::max(); - power_peak_initial.limit *= 2; + std::vector power_limits_descriptors; + auto status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + for (int i = 0; i < power_limits_descriptors.size(); i++) { + zes_power_limit_ext_desc_t power_peak_initial = {}; + zes_power_limit_ext_desc_t power_peak_Max = {}; + zes_power_limit_ext_desc_t power_peak_getMax = {}; + zes_power_limit_ext_desc_t power_peak_get = {}; + if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_PEAK) { + peak_limit_available = true; + zes_power_source_t power_source = + power_limits_descriptors[i].source; + power_peak_Max = power_limits_descriptors[i]; + power_peak_initial = power_limits_descriptors[i]; + power_peak_Max.limit = std::numeric_limits::max(); + power_peak_initial.limit *= 2; - if (power_limits_descriptors[i].limitValueLocked == false) { - status = lzt::set_power_limits_ext(p_power_handle, &single_count, - &power_peak_Max); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - std::vector - power_limits_descriptors_getMax; - status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors_getMax); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - for (const auto &p_power_limits_descriptor_get : - power_limits_descriptors_getMax) { - if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_PEAK && - p_power_limits_descriptor_get.source == power_source) { - power_peak_getMax = p_power_limits_descriptor_get; + if (power_limits_descriptors[i].limitValueLocked == false) { + status = lzt::set_power_limits_ext(p_power_handle, &single_count, + &power_peak_Max); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + std::vector + power_limits_descriptors_getMax; + status = + lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_getMax); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + for (const auto &p_power_limits_descriptor_get : + power_limits_descriptors_getMax) { + if (p_power_limits_descriptor_get.level == + ZES_POWER_LEVEL_PEAK && + p_power_limits_descriptor_get.source == power_source) { + power_peak_getMax = p_power_limits_descriptor_get; + } } - } - status = lzt::set_power_limits_ext(p_power_handle, &single_count, - &power_peak_initial); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - std::vector - power_limits_descriptors_get; - status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors_get); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - for (const auto &p_power_limits_descriptor_get : - power_limits_descriptors_get) { - if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_PEAK && - p_power_limits_descriptor_get.source == power_source) { - power_peak_get = p_power_limits_descriptor_get; + status = lzt::set_power_limits_ext(p_power_handle, &single_count, + &power_peak_initial); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + std::vector + power_limits_descriptors_get; + status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_get); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + for (const auto &p_power_limits_descriptor_get : + power_limits_descriptors_get) { + if (p_power_limits_descriptor_get.level == + ZES_POWER_LEVEL_PEAK && + p_power_limits_descriptor_get.source == power_source) { + power_peak_get = p_power_limits_descriptor_get; + } } + EXPECT_LE(power_peak_get.limit, power_peak_getMax.limit); + } else { + LOG_INFO << "Set limit not supported due to peak " + "limitValueLocked flag is true"; } - EXPECT_LE(power_peak_get.limit, power_peak_getMax.limit); - } else { - LOG_INFO << "Set limit not supported due to peak " - "limitValueLocked flag is true"; } } + if (!peak_limit_available) { + LOG_INFO << "peak power limit not supported"; + } } - if (!peak_limit_available) { - LOG_INFO << "peak power limit not supported"; - } - } - } - else - { - LOG_INFO << "No power handles found for this device! "; + } else { + LOG_INFO << "No power handles found for this device! "; } } - if(!is_power_supported) - { - FAIL() << "No power handles found on any of the devices! "; + if (!is_power_supported) { + FAIL() << "No power handles found on any of the devices! "; } } From 3115eedafaf4c816ba17f04362325d3282ade69d Mon Sep 17 00:00:00 2001 From: viki435 Date: Thu, 21 Aug 2025 01:41:26 +0530 Subject: [PATCH 10/15] Primary JIRA: VLCLJ-2513 Sub-tasks: VLCLJ-2570, VLCLJ-2568, VLCLJ-2577 Fix: Handling GTEST_FAIL logic for multi-device scenario for power, performance and scheduler modules. Signed-off-by: viki435 --- .../sysman/test_sysman_power/src/test_sysman_power.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp b/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp index 12c3836f..df6b3fe0 100644 --- a/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp +++ b/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp @@ -1097,7 +1097,7 @@ LZT_TEST_F( uint32_t count = 0; count = lzt::get_power_handle_count(device); if (count > 0) { - is_poower_supported = true; + is_power_supported = true; LOG_INFO << "Power handles are available on this device! "; auto p_power_handles = lzt::get_power_handles(device, count); if (count == 0) { From e26691c6bd55036ea82d094dc27ff53f15fddb61 Mon Sep 17 00:00:00 2001 From: viki435 Date: Fri, 22 Aug 2025 13:56:13 +0530 Subject: [PATCH 11/15] Primary JIRA: VLCLJ-2513 Sub-tasks: VLCLJ-2570, VLCLJ-2568, VLCLJ-2577 Fix: Handling GTEST_FAIL logic for multi-device scenario for power, performance and scheduler modules. Signed-off-by: viki435 --- .../sysman/test_sysman_power/src/test_sysman_power.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp b/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp index df6b3fe0..4db093fd 100644 --- a/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp +++ b/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp @@ -1100,10 +1100,6 @@ LZT_TEST_F( is_power_supported = true; LOG_INFO << "Power handles are available on this device! "; auto p_power_handles = lzt::get_power_handles(device, count); - if (count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); - } for (auto p_power_handle : p_power_handles) { auto p_properties = lzt::get_power_properties(p_power_handle); if (p_properties.onSubdevice == true) { @@ -1304,8 +1300,7 @@ LZT_TEST_F( auto p_performance_handles = lzt::get_performance_handles(device, perf_count); if (perf_count == 0) { - FAIL() << "No handles found: " - << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + FAIL() << "No performance handles found for this device! "; } for (auto p_performance_handle : p_performance_handles) { zes_perf_properties_t p_perf_properties = From d43887be77805559afeed3a6060233a7327e182c Mon Sep 17 00:00:00 2001 From: viki435 Date: Fri, 22 Aug 2025 14:04:58 +0530 Subject: [PATCH 12/15] Primary JIRA: VLCLJ-2513 Sub-tasks: VLCLJ-2570, VLCLJ-2568, VLCLJ-2577 Fix: Handling GTEST_FAIL logic for multi-device scenario for power, performance and scheduler modules. Signed-off-by: viki435 --- .../sysman/test_sysman_power/src/test_sysman_power.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp b/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp index 4db093fd..c7c3829b 100644 --- a/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp +++ b/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp @@ -1341,7 +1341,7 @@ LZT_TEST_F( auto power_handles = lzt::get_power_handles(device, count); if (count > 0) { is_power_supported = true; - LOG_INFO << "Power handles are found on this device! "; + LOG_INFO << "Power handles are available on this device! "; auto start = std::chrono::steady_clock::now(); auto energy_counters = lzt::get_power_energy_counter(power_handles); auto end = std::chrono::steady_clock::now(); From c5cf96927d0e118fc0ba304c7116521ace20d0cb Mon Sep 17 00:00:00 2001 From: viki435 Date: Fri, 22 Aug 2025 16:18:41 +0530 Subject: [PATCH 13/15] Fix: Handling GTEST_FAIL logic for multi-device scenario for power, performance and scheduler modules. Primary JIRA: VLCLJ-2513 Sub-tasks: VLCLJ-2570, VLCLJ-2568, VLCLJ-2577 Signed-off-by: viki435 --- .../src/test_sysman_performance.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/conformance_tests/sysman/test_sysman_performance/src/test_sysman_performance.cpp b/conformance_tests/sysman/test_sysman_performance/src/test_sysman_performance.cpp index 11e87514..4b6c9523 100644 --- a/conformance_tests/sysman/test_sysman_performance/src/test_sysman_performance.cpp +++ b/conformance_tests/sysman/test_sysman_performance/src/test_sysman_performance.cpp @@ -302,13 +302,19 @@ LZT_TEST_F( #ifdef USE_ZESINIT class PerformanceModuleParamComputePerformanceFactorZesTest : public lzt::ZesSysmanCtsClass, - public ::testing::WithParamInterface {}; + public ::testing::WithParamInterface { +public: + bool is_performance_supported = false; +}; #define PERFORMANCE_COMPUTE_TEST \ PerformanceModuleParamComputePerformanceFactorZesTest #else // USE_ZESINIT class PerformanceModuleParamComputePerformanceFactorTest : public lzt::SysmanCtsClass, - public ::testing::WithParamInterface {}; + public ::testing::WithParamInterface { +public: + bool is_performance_supported = false; +}; #define PERFORMANCE_COMPUTE_TEST \ PerformanceModuleParamComputePerformanceFactorTest #endif // USE_ZESINIT @@ -316,12 +322,11 @@ class PerformanceModuleParamComputePerformanceFactorTest LZT_TEST_P( PERFORMANCE_COMPUTE_TEST, GivenValidPerformanceHandleWhenSettingMultiplePerformanceFactorForComputeThenValidPerformanceFactorIsReturned) { - bool is_perf_supported = false; for (auto device : devices) { uint32_t count = 0; count = lzt::get_performance_handle_count(device); if (count > 0) { - is_perf_supported = true; + is_performance_supported = true; LOG_INFO << "Performance handles are available on this device! "; auto performance_handles = lzt::get_performance_handles(device, count); for (auto performance_handle : performance_handles) { @@ -341,7 +346,7 @@ LZT_TEST_P( LOG_INFO << "No performance handles found for this device! "; } } - if (!is_perf_supported) { + if (!is_performance_supported) { FAIL() << "No performance handles found on any of the devices! "; } } From 9a74f27860044d60f29b14427af9ea798cd8b788 Mon Sep 17 00:00:00 2001 From: viki435 Date: Fri, 22 Aug 2025 17:11:49 +0530 Subject: [PATCH 14/15] Fix: Handling GTEST_FAIL logic for multi-device scenario for power, performance and scheduler modules. Primary JIRA: VLCLJ-2513 Sub-tasks: VLCLJ-2570, VLCLJ-2568, VLCLJ-2577 Signed-off-by: viki435 From 58d06c2ad6b3b9791f3c1ba887b52ea9f571d15d Mon Sep 17 00:00:00 2001 From: viki435 Date: Mon, 25 Aug 2025 11:44:01 +0530 Subject: [PATCH 15/15] Reverting the code as conflicts are seen. Signed-off-by: viki435 --- .../src/test_sysman_power.cpp | 1919 ++++++++--------- 1 file changed, 898 insertions(+), 1021 deletions(-) diff --git a/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp b/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp index c7c3829b..0612cee0 100644 --- a/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp +++ b/conformance_tests/sysman/test_sysman_power/src/test_sysman_power.cpp @@ -20,13 +20,13 @@ namespace { #ifdef USE_ZESINIT class PowerModuleZesTest : public lzt::ZesSysmanCtsClass { public: - bool is_power_supported = false; + bool power_handles_available = false; }; #define POWER_TEST PowerModuleZesTest #else // USE_ZESINIT class PowerModuleTest : public lzt::SysmanCtsClass { public: - bool is_power_supported = false; + bool power_handles_available = false; }; #define POWER_TEST PowerModuleTest #endif // USE_ZESINIT @@ -36,20 +36,15 @@ LZT_TEST_F( GivenValidDeviceWhenRetrievingPowerHandlesThenNonZeroCountAndValidPowerHandlesAreReturned) { for (auto device : devices) { uint32_t count = 0; - count = lzt::get_power_handle_count(device); - if (count > 0) { - is_power_supported = true; - LOG_INFO << "Power handles are available on this device! "; - auto p_power_handles = lzt::get_power_handles(device, count); - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); - } - } else { - LOG_INFO << "No power handles found for this device! "; + auto p_power_handles = lzt::get_power_handles(device, count); + if (count == 0) { + FAIL() << "No handles found: " + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + } + + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); } - } - if (!is_power_supported) { - FAIL() << "No power handles found on any of the devices! "; } } LZT_TEST_F( @@ -58,19 +53,14 @@ LZT_TEST_F( for (auto device : devices) { uint32_t icount = 0; uint32_t lcount = 0; - icount = lzt::get_power_handle_count(device); - if (icount > 0) { - is_power_supported = true; - LOG_INFO << "Power handles are available on this device! "; - auto p_power_handlesInitial = lzt::get_power_handles(device, icount); - auto p_power_handlesLater = lzt::get_power_handles(device, lcount); - EXPECT_EQ(p_power_handlesInitial, p_power_handlesLater); - } else { - LOG_INFO << "No power handles found for this device! "; + auto p_power_handlesInitial = lzt::get_power_handles(device, icount); + if (icount == 0) { + FAIL() << "No handles found: " + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); } - } - if (!is_power_supported) { - FAIL() << "No power handles found on any of the devices! "; + + auto p_power_handlesLater = lzt::get_power_handles(device, lcount); + EXPECT_EQ(p_power_handlesInitial, p_power_handlesLater); } } LZT_TEST_F( @@ -79,23 +69,19 @@ LZT_TEST_F( for (auto device : devices) { uint32_t p_count = lzt::get_power_handle_count(device); - if (p_count > 0) { - is_power_supported = true; - LOG_INFO << "Power handles are available on this device! "; - uint32_t tcount = p_count + 1; - lzt::get_power_handles(device, tcount); - EXPECT_EQ(tcount, p_count); - if (p_count > 1) { - tcount = p_count - 1; - auto p_power_handles = lzt::get_power_handles(device, tcount); - EXPECT_EQ(static_cast(p_power_handles.size()), tcount); - } - } else { - LOG_INFO << "No power handles found for this device! "; + if (p_count == 0) { + FAIL() << "No handles found: " + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + } + + uint32_t tcount = p_count + 1; + lzt::get_power_handles(device, tcount); + EXPECT_EQ(tcount, p_count); + if (p_count > 1) { + tcount = p_count - 1; + auto p_power_handles = lzt::get_power_handles(device, tcount); + EXPECT_EQ(static_cast(p_power_handles.size()), tcount); } - } - if (!is_power_supported) { - FAIL() << "No power handles found on any of the devices! "; } } LZT_TEST_F( @@ -103,38 +89,35 @@ LZT_TEST_F( GivenSamePowerHandleWhenRequestingPowerPropertiesThenCheckPowerLimitsAreInRange) { for (auto device : devices) { uint32_t count = 0; - count = lzt::get_power_handle_count(device); - if (count > 0) { - is_power_supported = true; - LOG_INFO << "Power handles are available on this device! "; - auto p_power_handles = lzt::get_power_handles(device, count); - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); - auto pProperties = lzt::get_power_properties(p_power_handle); - if (pProperties.maxLimit != -1) { - EXPECT_GT(pProperties.maxLimit, 0); - EXPECT_GE(pProperties.maxLimit, pProperties.minLimit); - } else { - LOG_INFO << "maxLimit unsupported: "; - } - if (pProperties.minLimit != -1) { - EXPECT_GE(pProperties.minLimit, 0); - } else { - LOG_INFO << "minlimit unsupported: "; - } - if (pProperties.defaultLimit != -1) { - EXPECT_GT(pProperties.defaultLimit, 0); - } else { - LOG_INFO << "defaultLimit unsupported: "; - } + auto p_power_handles = lzt::get_power_handles(device, count); + if (count == 0) { + FAIL() << "No handles found: " + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + } + + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); + auto pProperties = lzt::get_power_properties(p_power_handle); + if (pProperties.maxLimit != -1) { + EXPECT_GT(pProperties.maxLimit, 0); + EXPECT_GE(pProperties.maxLimit, pProperties.minLimit); + } else { + LOG_INFO << "maxLimit unsupported: "; + } + + if (pProperties.minLimit != -1) { + EXPECT_GE(pProperties.minLimit, 0); + } else { + LOG_INFO << "minlimit unsupported: "; + } + + if (pProperties.defaultLimit != -1) { + EXPECT_GT(pProperties.defaultLimit, 0); + } else { + LOG_INFO << "defaultLimit unsupported: "; } - } else { - LOG_INFO << "No power handles found for this device! "; } } - if (!is_power_supported) { - FAIL() << "No power handles found on any of the devices! "; - } } LZT_TEST_F( @@ -142,37 +125,30 @@ LZT_TEST_F( GivenSamePowerHandleWhenRequestingPowerPropertiesThenExpectSamePropertiesTwice) { for (auto device : devices) { uint32_t count = 0; - count = lzt::get_power_handle_count(device); - if (count > 0) { - is_power_supported = true; - LOG_INFO << "Power handles are available on this device! "; - auto p_power_handles = lzt::get_power_handles(device, count); - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); - auto pproperties_initial = lzt::get_power_properties(p_power_handle); - if (pproperties_initial.maxLimit == -1) { - LOG_INFO << "maxlimit unsupported: "; - } - auto pproperties_later = lzt::get_power_properties(p_power_handle); - EXPECT_EQ(pproperties_initial.onSubdevice, - pproperties_later.onSubdevice); - EXPECT_EQ(pproperties_initial.subdeviceId, - pproperties_later.subdeviceId); - EXPECT_EQ(pproperties_initial.canControl, pproperties_later.canControl); - EXPECT_EQ(pproperties_initial.isEnergyThresholdSupported, - pproperties_later.isEnergyThresholdSupported); - EXPECT_EQ(pproperties_initial.maxLimit, pproperties_later.maxLimit); - EXPECT_EQ(pproperties_initial.minLimit, pproperties_later.minLimit); - EXPECT_EQ(pproperties_initial.defaultLimit, - pproperties_later.defaultLimit); + auto p_power_handles = lzt::get_power_handles(device, count); + if (count == 0) { + FAIL() << "No handles found: " + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + } + + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); + auto pproperties_initial = lzt::get_power_properties(p_power_handle); + if (pproperties_initial.maxLimit == -1) { + LOG_INFO << "maxlimit unsupported: "; } - } else { - LOG_INFO << "No power handles found for this device! "; + auto pproperties_later = lzt::get_power_properties(p_power_handle); + EXPECT_EQ(pproperties_initial.onSubdevice, pproperties_later.onSubdevice); + EXPECT_EQ(pproperties_initial.subdeviceId, pproperties_later.subdeviceId); + EXPECT_EQ(pproperties_initial.canControl, pproperties_later.canControl); + EXPECT_EQ(pproperties_initial.isEnergyThresholdSupported, + pproperties_later.isEnergyThresholdSupported); + EXPECT_EQ(pproperties_initial.maxLimit, pproperties_later.maxLimit); + EXPECT_EQ(pproperties_initial.minLimit, pproperties_later.minLimit); + EXPECT_EQ(pproperties_initial.defaultLimit, + pproperties_later.defaultLimit); } } - if (!is_power_supported) { - FAIL() << "No power handles found on any of the devices! "; - } } LZT_TEST_F( @@ -180,207 +156,186 @@ LZT_TEST_F( GivenValidPowerHandleWhenRequestingPowerLimitsThenExpectZesSysmanPowerGetLimitsToReturnValidPowerLimits) { for (auto device : devices) { uint32_t count = 0; - count = lzt::get_power_handle_count(device); - if (count > 0) { - is_power_supported = true; - LOG_INFO << "Power handles are available on this device! "; - auto p_power_handles = lzt::get_power_handles(device, count); - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); - zes_power_sustained_limit_t pSustained = {}; - zes_power_burst_limit_t pBurst = {}; - zes_power_peak_limit_t pPeak = {}; - auto status = - lzt::get_power_limits(p_power_handle, &pSustained, &pBurst, &pPeak); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - auto pProperties = lzt::get_power_properties(p_power_handle); - if ((pBurst.enabled != 0) && (pSustained.enabled != 0)) { - EXPECT_LE(pSustained.power, pBurst.power); - } - if ((pPeak.powerAC != -1) && (pBurst.enabled != 0)) { - EXPECT_LE(pBurst.power, pPeak.powerAC); - } + auto p_power_handles = lzt::get_power_handles(device, count); + if (count == 0) { + FAIL() << "No handles found: " + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + } + + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); + zes_power_sustained_limit_t pSustained = {}; + zes_power_burst_limit_t pBurst = {}; + zes_power_peak_limit_t pPeak = {}; + auto status = + lzt::get_power_limits(p_power_handle, &pSustained, &pBurst, &pPeak); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + auto pProperties = lzt::get_power_properties(p_power_handle); + if ((pBurst.enabled != 0) && (pSustained.enabled != 0)) { + EXPECT_LE(pSustained.power, pBurst.power); + } + if ((pPeak.powerAC != -1) && (pBurst.enabled != 0)) { + EXPECT_LE(pBurst.power, pPeak.powerAC); } - } else { - LOG_INFO << "No power handles found for this device! "; } } - if (!is_power_supported) { - FAIL() << "No power handles found on any of the devices! "; - } } LZT_TEST_F( POWER_TEST, GivenValidPowerHandleWhenRequestingPowerLimitsThenExpectzesSysmanPowerGetLimitsToReturnSameValuesTwice) { for (auto device : devices) { uint32_t count = 0; - count = lzt::get_power_handle_count(device); - if (count > 0) { - is_power_supported = true; - LOG_INFO << "Power handles are available on this device! "; - auto p_power_handles = lzt::get_power_handles(device, count); - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); - zes_power_sustained_limit_t pSustainedInitial = {}; - zes_power_burst_limit_t pBurstInitial = {}; - zes_power_peak_limit_t pPeakInitial = {}; - auto status = lzt::get_power_limits(p_power_handle, &pSustainedInitial, - &pBurstInitial, &pPeakInitial); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - zes_power_sustained_limit_t pSustainedLater = {}; - zes_power_burst_limit_t pBurstLater = {}; - zes_power_peak_limit_t pPeakLater = {}; - status = lzt::get_power_limits(p_power_handle, &pSustainedLater, - &pBurstLater, &pPeakLater); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - EXPECT_EQ(pSustainedInitial.enabled, pSustainedLater.enabled); - EXPECT_EQ(pSustainedInitial.power, pSustainedLater.power); - EXPECT_EQ(pSustainedInitial.interval, pSustainedLater.interval); - EXPECT_EQ(pBurstInitial.enabled, pBurstLater.enabled); - EXPECT_EQ(pBurstInitial.power, pBurstLater.power); - EXPECT_EQ(pPeakInitial.powerAC, pPeakLater.powerAC); - EXPECT_EQ(pPeakInitial.powerDC, pPeakLater.powerDC); + auto p_power_handles = lzt::get_power_handles(device, count); + if (count == 0) { + FAIL() << "No handles found: " + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + } + + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); + zes_power_sustained_limit_t pSustainedInitial = {}; + zes_power_burst_limit_t pBurstInitial = {}; + zes_power_peak_limit_t pPeakInitial = {}; + auto status = lzt::get_power_limits(p_power_handle, &pSustainedInitial, + &pBurstInitial, &pPeakInitial); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; } - } else { - LOG_INFO << "No power handles found for this device! "; + EXPECT_ZE_RESULT_SUCCESS(status); + zes_power_sustained_limit_t pSustainedLater = {}; + zes_power_burst_limit_t pBurstLater = {}; + zes_power_peak_limit_t pPeakLater = {}; + status = lzt::get_power_limits(p_power_handle, &pSustainedLater, + &pBurstLater, &pPeakLater); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + EXPECT_EQ(pSustainedInitial.enabled, pSustainedLater.enabled); + EXPECT_EQ(pSustainedInitial.power, pSustainedLater.power); + EXPECT_EQ(pSustainedInitial.interval, pSustainedLater.interval); + EXPECT_EQ(pBurstInitial.enabled, pBurstLater.enabled); + EXPECT_EQ(pBurstInitial.power, pBurstLater.power); + EXPECT_EQ(pPeakInitial.powerAC, pPeakLater.powerAC); + EXPECT_EQ(pPeakInitial.powerDC, pPeakLater.powerDC); } } - if (!is_power_supported) { - FAIL() << "No power handles found on any of the devices! "; - } } LZT_TEST_F( POWER_TEST, GivenValidPowerHandleWhenSettingPowerValuesThenExpectzesSysmanPowerSetLimitsFollowedByzesSysmanPowerGetLimitsToMatch) { for (auto device : devices) { uint32_t count = 0; - count = lzt::get_power_handle_count(device); - if (count > 0) { - is_power_supported = true; - LOG_INFO << "Power handles are available on this device! "; - auto p_power_handles = lzt::get_power_handles(device, count); - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); - zes_power_sustained_limit_t pSustainedInitial = {}; - zes_power_burst_limit_t pBurstInitial = {}; - zes_power_peak_limit_t pPeakInitial = {}; - auto status = lzt::get_power_limits( - p_power_handle, &pSustainedInitial, &pBurstInitial, - &pPeakInitial); // get default power values + auto p_power_handles = lzt::get_power_handles(device, count); + if (count == 0) { + FAIL() << "No handles found: " + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + } + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); + zes_power_sustained_limit_t pSustainedInitial = {}; + zes_power_burst_limit_t pBurstInitial = {}; + zes_power_peak_limit_t pPeakInitial = {}; + auto status = lzt::get_power_limits( + p_power_handle, &pSustainedInitial, &pBurstInitial, + &pPeakInitial); // get default power values + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + auto pProperties = lzt::get_power_properties(p_power_handle); + if (pProperties.maxLimit == -1) { + LOG_INFO << "maxlimit unsupported:"; + } + zes_power_sustained_limit_t pSustainedSet = {}; + zes_power_burst_limit_t pBurstSet = {}; + zes_power_peak_limit_t pPeakSet = {}; + if (pSustainedInitial.enabled) + pSustainedSet.enabled = 1; + else + pSustainedSet.enabled = 0; + pSustainedSet.interval = pSustainedInitial.interval; + if (pBurstInitial.enabled) + pBurstSet.enabled = 1; + else + pBurstSet.enabled = 0; + if (pProperties.maxLimit != -1) { + pSustainedSet.power = pProperties.maxLimit; + pBurstSet.power = pProperties.maxLimit; + pPeakSet.powerAC = pProperties.maxLimit; + } + pPeakSet.powerDC = pPeakInitial.powerDC; + if (pBurstSet.enabled && pSustainedSet.enabled) { + status = + lzt::set_power_limits(p_power_handle, &pSustainedSet, &pBurstSet, + &pPeakSet); // Set power values if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { continue; } EXPECT_ZE_RESULT_SUCCESS(status); - auto pProperties = lzt::get_power_properties(p_power_handle); - if (pProperties.maxLimit == -1) { - LOG_INFO << "maxlimit unsupported:"; + zes_power_sustained_limit_t pSustainedGet = {}; + zes_power_burst_limit_t pBurstGet = {}; + zes_power_peak_limit_t pPeakGet = {}; + status = + lzt::get_power_limits(p_power_handle, &pSustainedGet, &pBurstGet, + &pPeakGet); // Get power values + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; } - zes_power_sustained_limit_t pSustainedSet = {}; - zes_power_burst_limit_t pBurstSet = {}; - zes_power_peak_limit_t pPeakSet = {}; - if (pSustainedInitial.enabled) - pSustainedSet.enabled = 1; - else - pSustainedSet.enabled = 0; - pSustainedSet.interval = pSustainedInitial.interval; - if (pBurstInitial.enabled) - pBurstSet.enabled = 1; - else - pBurstSet.enabled = 0; - if (pProperties.maxLimit != -1) { - pSustainedSet.power = pProperties.maxLimit; - pBurstSet.power = pProperties.maxLimit; - pPeakSet.powerAC = pProperties.maxLimit; + EXPECT_ZE_RESULT_SUCCESS(status); + EXPECT_EQ(pSustainedGet.enabled, pSustainedSet.enabled); + EXPECT_EQ(pSustainedGet.power, pSustainedSet.power); + EXPECT_EQ(pSustainedGet.interval, pSustainedSet.interval); + EXPECT_EQ(pBurstGet.enabled, pBurstSet.enabled); + EXPECT_EQ(pBurstGet.power, pBurstSet.power); + if (pPeakGet.powerAC != -1) { + EXPECT_EQ(pPeakGet.powerAC, pPeakSet.powerAC); } - pPeakSet.powerDC = pPeakInitial.powerDC; - if (pBurstSet.enabled && pSustainedSet.enabled) { - status = - lzt::set_power_limits(p_power_handle, &pSustainedSet, &pBurstSet, - &pPeakSet); // Set power values - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - zes_power_sustained_limit_t pSustainedGet = {}; - zes_power_burst_limit_t pBurstGet = {}; - zes_power_peak_limit_t pPeakGet = {}; - status = - lzt::get_power_limits(p_power_handle, &pSustainedGet, &pBurstGet, - &pPeakGet); // Get power values - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - EXPECT_EQ(pSustainedGet.enabled, pSustainedSet.enabled); - EXPECT_EQ(pSustainedGet.power, pSustainedSet.power); - EXPECT_EQ(pSustainedGet.interval, pSustainedSet.interval); - EXPECT_EQ(pBurstGet.enabled, pBurstSet.enabled); - EXPECT_EQ(pBurstGet.power, pBurstSet.power); - if (pPeakGet.powerAC != -1) { - EXPECT_EQ(pPeakGet.powerAC, pPeakSet.powerAC); - } - if (pPeakGet.powerDC != -1) { - EXPECT_EQ(pPeakGet.powerDC, - pPeakSet.powerDC); // Verify whether values match or not - } - status = lzt::set_power_limits( - p_power_handle, &pSustainedInitial, &pBurstInitial, - &pPeakInitial); // Set values to default - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - } else { - LOG_INFO << "Set limit not supported due to burst and sustained " - "enabled flag is false"; + if (pPeakGet.powerDC != -1) { + EXPECT_EQ(pPeakGet.powerDC, + pPeakSet.powerDC); // Verify whether values match or not + } + status = lzt::set_power_limits(p_power_handle, &pSustainedInitial, + &pBurstInitial, + &pPeakInitial); // Set values to default + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; } + EXPECT_ZE_RESULT_SUCCESS(status); + } else { + LOG_INFO << "Set limit not supported due to burst and sustained " + "enabled flag is false"; } - } else { - LOG_INFO << "No power handles found for this device! "; } } - if (!is_power_supported) { - FAIL() << "No power handles found on any of the devices! "; - } } LZT_TEST_F( POWER_TEST, GivenValidPowerHandleThenExpectzesSysmanPowerGetEnergyCounterToReturnSuccess) { for (auto device : devices) { uint32_t count = 0; - count = lzt::get_power_handle_count(device); - if (count > 0) { - is_power_supported = true; - LOG_INFO << "Power handles are available on this device! "; - auto p_power_handles = lzt::get_power_handles(device, count); - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); - zes_power_energy_counter_t pEnergyCounter = {}; - lzt::get_power_energy_counter(p_power_handle, &pEnergyCounter); - uint64_t energy_initial = pEnergyCounter.energy; - uint64_t timestamp_initial = pEnergyCounter.timestamp; - std::this_thread::sleep_for(std::chrono::milliseconds(2)); - lzt::get_power_energy_counter(p_power_handle, &pEnergyCounter); - uint64_t energy_later = pEnergyCounter.energy; - uint64_t timestamp_later = pEnergyCounter.timestamp; - EXPECT_GE(energy_later, energy_initial); - EXPECT_NE(timestamp_later, timestamp_initial); - } - } else { - LOG_INFO << "No power handles found for this device! "; + auto p_power_handles = lzt::get_power_handles(device, count); + if (count == 0) { + FAIL() << "No handles found: " + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + } + + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); + zes_power_energy_counter_t pEnergyCounter = {}; + lzt::get_power_energy_counter(p_power_handle, &pEnergyCounter); + uint64_t energy_initial = pEnergyCounter.energy; + uint64_t timestamp_initial = pEnergyCounter.timestamp; + std::this_thread::sleep_for(std::chrono::milliseconds(2)); + lzt::get_power_energy_counter(p_power_handle, &pEnergyCounter); + uint64_t energy_later = pEnergyCounter.energy; + uint64_t timestamp_later = pEnergyCounter.timestamp; + EXPECT_GE(energy_later, energy_initial); + EXPECT_NE(timestamp_later, timestamp_initial); } - } - if (!is_power_supported) { - FAIL() << "No power handles found on any of the devices! "; } } LZT_TEST_F( @@ -388,355 +343,241 @@ LZT_TEST_F( GivenValidPowerHandleWhenGettingEnergyThresholdThenSuccessIsReturnedAndParameterValuesAreValid) { for (auto device : devices) { uint32_t count = 0; - count = lzt::get_power_handle_count(device); - if (count > 0) { - is_power_supported = true; - LOG_INFO << "Power handles are available on this device! "; - auto p_power_handles = lzt::get_power_handles(device, count); - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); - zes_energy_threshold_t pThreshold = {}; - auto status = - lzt::get_power_energy_threshold(p_power_handle, &pThreshold); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - ASSERT_GE(pThreshold.threshold, 0); - if (pThreshold.threshold > 0) - EXPECT_LT(pThreshold.processId, UINT32_MAX); - else - EXPECT_EQ(pThreshold.processId, UINT32_MAX); + auto p_power_handles = lzt::get_power_handles(device, count); + if (count == 0) { + FAIL() << "No handles found: " + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + } + + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); + zes_energy_threshold_t pThreshold = {}; + auto status = + lzt::get_power_energy_threshold(p_power_handle, &pThreshold); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; } - } else { - LOG_INFO << "No power handles found for this device! "; + EXPECT_ZE_RESULT_SUCCESS(status); + ASSERT_GE(pThreshold.threshold, 0); + if (pThreshold.threshold > 0) + EXPECT_LT(pThreshold.processId, UINT32_MAX); + else + EXPECT_EQ(pThreshold.processId, UINT32_MAX); } } - if (!is_power_supported) { - FAIL() << "No power handles found on any of the devices! "; - } } LZT_TEST_F( POWER_TEST, GivenValidPowerHandleWhenGettingEnergyThresholdTwiceThenSameValueReturned) { for (auto device : devices) { uint32_t count = 0; - count = lzt::get_power_handle_count(device); - if (count > 0) { - is_power_supported = true; - LOG_INFO << "Power handles are available on this device! "; - auto p_power_handles = lzt::get_power_handles(device, count); - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); - zes_energy_threshold_t pThresholdInitial = {}; - auto status = - lzt::get_power_energy_threshold(p_power_handle, &pThresholdInitial); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - zes_energy_threshold_t pThresholdLater = {}; - status = - lzt::get_power_energy_threshold(p_power_handle, &pThresholdLater); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - EXPECT_EQ(pThresholdInitial.enable, pThresholdLater.enable); - EXPECT_EQ(pThresholdInitial.threshold, pThresholdLater.threshold); - EXPECT_EQ(pThresholdInitial.processId, pThresholdLater.processId); + auto p_power_handles = lzt::get_power_handles(device, count); + if (count == 0) { + FAIL() << "No handles found: " + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + } + + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); + zes_energy_threshold_t pThresholdInitial = {}; + auto status = + lzt::get_power_energy_threshold(p_power_handle, &pThresholdInitial); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; } - } else { - LOG_INFO << "No power handles found for this device! "; + EXPECT_ZE_RESULT_SUCCESS(status); + zes_energy_threshold_t pThresholdLater = {}; + status = + lzt::get_power_energy_threshold(p_power_handle, &pThresholdLater); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + EXPECT_EQ(pThresholdInitial.enable, pThresholdLater.enable); + EXPECT_EQ(pThresholdInitial.threshold, pThresholdLater.threshold); + EXPECT_EQ(pThresholdInitial.processId, pThresholdLater.processId); } } - if (!is_power_supported) { - FAIL() << "No power handles found on any of the devices! "; - } } LZT_TEST_F( POWER_TEST, GivenValidPowerHandleWhenSettingEnergyValuesThenExpectZesSysmanPowerSetEnergyThresholdFollowedByZesSysmanPowerGetEnergyThresholdToMatch) { for (auto device : devices) { uint32_t count = 0; - count = lzt::get_power_handle_count(device); - if (count > 0) { - is_power_supported = true; - LOG_INFO << "Power handles are available on this device! "; - auto p_power_handles = lzt::get_power_handles(device, count); - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); - zes_energy_threshold_t pThresholdInitial = {}; - auto status = lzt::get_power_energy_threshold( - p_power_handle, &pThresholdInitial); // get initial value - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - double threshold = 0; - lzt::set_power_energy_threshold(p_power_handle, - threshold); // set test value - zes_energy_threshold_t pThresholdGet = {}; - status = - lzt::get_power_energy_threshold(p_power_handle, - &pThresholdGet); // get test value - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - EXPECT_EQ(pThresholdGet.threshold, threshold); // match both the values - EXPECT_EQ(pThresholdGet.processId, UINT32_MAX); - lzt::set_power_energy_threshold( - p_power_handle, - pThresholdInitial.threshold); // reset to initial value + auto p_power_handles = lzt::get_power_handles(device, count); + if (count == 0) { + FAIL() << "No handles found: " + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + } + + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); + zes_energy_threshold_t pThresholdInitial = {}; + auto status = lzt::get_power_energy_threshold( + p_power_handle, &pThresholdInitial); // get initial value + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; } - } else { - LOG_INFO << "No power handles found for this device! "; + EXPECT_ZE_RESULT_SUCCESS(status); + double threshold = 0; + lzt::set_power_energy_threshold(p_power_handle, threshold); // set test + // value + zes_energy_threshold_t pThresholdGet = {}; + status = + lzt::get_power_energy_threshold(p_power_handle, + &pThresholdGet); // get test value + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + EXPECT_EQ(pThresholdGet.threshold, threshold); // match both the values + EXPECT_EQ(pThresholdGet.processId, UINT32_MAX); + lzt::set_power_energy_threshold( + p_power_handle, + pThresholdInitial.threshold); // reset to initial value } } - if (!is_power_supported) { - FAIL() << "No power handles found on any of the devices! "; - } } LZT_TEST_F( POWER_TEST, GivenValidPowerHandleWhenRequestingPowerLimitsThenExpectZesPowerGetLimitsExtToReturnSameValuesTwice) { for (auto device : devices) { uint32_t count = 0; - count = lzt::get_power_handle_count(device); - if (count > 0) { - is_power_supported = true; - LOG_INFO << "Power handles are available on this device! "; - auto p_power_handles = lzt::get_power_handles(device, count); - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); - uint32_t count_power = 0; - zes_power_limit_ext_desc_t power_peak_descriptor_first = {}; - zes_power_limit_ext_desc_t power_burst_descriptor_first = {}; - zes_power_limit_ext_desc_t power_sustained_descriptor_first = {}; - zes_power_limit_ext_desc_t power_instantaneous_descriptor_first = {}; - - zes_power_limit_ext_desc_t power_peak_descriptor_second = {}; - zes_power_limit_ext_desc_t power_burst_descriptor_second = {}; - zes_power_limit_ext_desc_t power_sustained_descriptor_second = {}; - zes_power_limit_ext_desc_t power_instantaneous_descriptor_second = {}; - - std::vector - power_limits_descriptors_initial; - auto status = lzt::get_power_limits_ext( - p_power_handle, &count_power, power_limits_descriptors_initial); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - for (auto power_limits_descriptor_initial : - power_limits_descriptors_initial) { - if (power_limits_descriptor_initial.level == - ZES_POWER_LEVEL_SUSTAINED) { - power_sustained_descriptor_first = power_limits_descriptor_initial; - } else if (power_limits_descriptor_initial.level == - ZES_POWER_LEVEL_PEAK) { - power_peak_descriptor_first = power_limits_descriptor_initial; - } else if (power_limits_descriptor_initial.level == - ZES_POWER_LEVEL_BURST) { - power_burst_descriptor_first = power_limits_descriptor_initial; - } else if (power_limits_descriptor_initial.level == - ZES_POWER_LEVEL_INSTANTANEOUS) { - power_instantaneous_descriptor_first = - power_limits_descriptor_initial; - } - } - std::vector power_limits_descriptors_final; - status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors_final); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; + auto p_power_handles = lzt::get_power_handles(device, count); + if (count == 0) { + FAIL() << "No handles found: " + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + } + + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); + uint32_t count_power = 0; + + zes_power_limit_ext_desc_t power_peak_descriptor_first = {}; + zes_power_limit_ext_desc_t power_burst_descriptor_first = {}; + zes_power_limit_ext_desc_t power_sustained_descriptor_first = {}; + zes_power_limit_ext_desc_t power_instantaneous_descriptor_first = {}; + + zes_power_limit_ext_desc_t power_peak_descriptor_second = {}; + zes_power_limit_ext_desc_t power_burst_descriptor_second = {}; + zes_power_limit_ext_desc_t power_sustained_descriptor_second = {}; + zes_power_limit_ext_desc_t power_instantaneous_descriptor_second = {}; + + std::vector power_limits_descriptors_initial; + auto status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_initial); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + for (auto power_limits_descriptor_initial : + power_limits_descriptors_initial) { + if (power_limits_descriptor_initial.level == + ZES_POWER_LEVEL_SUSTAINED) { + power_sustained_descriptor_first = power_limits_descriptor_initial; + } else if (power_limits_descriptor_initial.level == + ZES_POWER_LEVEL_PEAK) { + power_peak_descriptor_first = power_limits_descriptor_initial; + } else if (power_limits_descriptor_initial.level == + ZES_POWER_LEVEL_BURST) { + power_burst_descriptor_first = power_limits_descriptor_initial; + } else if (power_limits_descriptor_initial.level == + ZES_POWER_LEVEL_INSTANTANEOUS) { + power_instantaneous_descriptor_first = + power_limits_descriptor_initial; } - EXPECT_ZE_RESULT_SUCCESS(status); - for (auto power_limits_descriptor_final : - power_limits_descriptors_final) { - if (power_limits_descriptor_final.level == - ZES_POWER_LEVEL_SUSTAINED) { - power_sustained_descriptor_second = power_limits_descriptor_final; - } else if (power_limits_descriptor_final.level == - ZES_POWER_LEVEL_PEAK) { - power_peak_descriptor_second = power_limits_descriptor_final; - } else if (power_limits_descriptor_final.level == - ZES_POWER_LEVEL_BURST) { - power_burst_descriptor_second = power_limits_descriptor_final; - } else if (power_limits_descriptor_final.level == - ZES_POWER_LEVEL_INSTANTANEOUS) { - power_instantaneous_descriptor_second = - power_limits_descriptor_final; - } + } + + std::vector power_limits_descriptors_final; + status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_final); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + for (auto power_limits_descriptor_final : + power_limits_descriptors_final) { + if (power_limits_descriptor_final.level == ZES_POWER_LEVEL_SUSTAINED) { + power_sustained_descriptor_second = power_limits_descriptor_final; + } else if (power_limits_descriptor_final.level == + ZES_POWER_LEVEL_PEAK) { + power_peak_descriptor_second = power_limits_descriptor_final; + } else if (power_limits_descriptor_final.level == + ZES_POWER_LEVEL_BURST) { + power_burst_descriptor_second = power_limits_descriptor_final; + } else if (power_limits_descriptor_final.level == + ZES_POWER_LEVEL_INSTANTANEOUS) { + power_instantaneous_descriptor_second = power_limits_descriptor_final; } - lzt::compare_power_descriptor_structures(power_peak_descriptor_first, - power_peak_descriptor_second); - lzt::compare_power_descriptor_structures(power_burst_descriptor_first, - power_burst_descriptor_second); - lzt::compare_power_descriptor_structures( - power_sustained_descriptor_first, - power_sustained_descriptor_second); - lzt::compare_power_descriptor_structures( - power_instantaneous_descriptor_first, - power_instantaneous_descriptor_second); } - } else { - LOG_INFO << "No power handles found for this device! "; + + lzt::compare_power_descriptor_structures(power_peak_descriptor_first, + power_peak_descriptor_second); + lzt::compare_power_descriptor_structures(power_burst_descriptor_first, + power_burst_descriptor_second); + lzt::compare_power_descriptor_structures( + power_sustained_descriptor_first, power_sustained_descriptor_second); + lzt::compare_power_descriptor_structures( + power_instantaneous_descriptor_first, + power_instantaneous_descriptor_second); } } - if (!is_power_supported) { - FAIL() << "No power handles found on any of the devices! "; - } } LZT_TEST_F( POWER_TEST, GivenValidPowerHandleWhenSettingPowerValuesForSustainedPowerThenExpectzesPowerSetLimitsExtFollowedByzesPowerGetLimitsExtToMatch) { for (auto device : devices) { uint32_t count = 0; - count = lzt::get_power_handle_count(device); - if (count > 0) { - is_power_supported = true; - LOG_INFO << "Power handles are available on this device! "; - auto p_power_handles = lzt::get_power_handles(device, count); - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); - uint32_t count_power = 0; - - zes_power_limit_ext_desc_t power_sustained_set = {}; - std::vector power_limits_descriptors; - auto status = lzt::get_power_limits_ext( - p_power_handle, &count_power, - power_limits_descriptors); // get power limits for all descriptors - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - std::vector - power_limits_descriptors_initial; // preserve initial power limit - // descriptors for restoration - // later - for (int i = 0; i < power_limits_descriptors.size(); i++) { - power_limits_descriptors[i] = { - ZES_STRUCTURE_TYPE_POWER_LIMIT_EXT_DESC, nullptr}; - power_limits_descriptors_initial.push_back( - power_limits_descriptors[i]); - - if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_SUSTAINED) { - power_sustained_set = power_limits_descriptors[i]; - power_sustained_set.limit = - power_limits_descriptors[i].limit - 1000; - power_limits_descriptors[i].limit = power_sustained_set.limit; - } - } + auto p_power_handles = lzt::get_power_handles(device, count); + if (count == 0) { + FAIL() << "No handles found: " + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + } - if (power_sustained_set.level == ZES_POWER_LEVEL_SUSTAINED) { - if (power_sustained_set.limitValueLocked == false) { - status = lzt::set_power_limits_ext( - p_power_handle, &count_power, - power_limits_descriptors - .data()); // set power limits for all descriptors - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - zes_power_limit_ext_desc_t power_sustained_get = {}; + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); + uint32_t count_power = 0; - std::vector - power_limits_descriptors_get; - status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors_get); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - for (const auto &p_power_limits_descriptor_get : - power_limits_descriptors_get) { - if (p_power_limits_descriptor_get.level == - ZES_POWER_LEVEL_SUSTAINED) { - power_sustained_get = p_power_limits_descriptor_get; - } - } - - EXPECT_EQ(power_sustained_get.limitValueLocked, - power_sustained_set.limitValueLocked); - EXPECT_EQ(power_sustained_get.interval, - power_sustained_set.interval); - EXPECT_EQ(power_sustained_get.limit, power_sustained_set.limit); + zes_power_limit_ext_desc_t power_sustained_set = {}; - status = lzt::set_power_limits_ext( - p_power_handle, &count_power, - power_limits_descriptors_initial - .data()); // restore initial limits - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - } else { - LOG_INFO << "Set limit not supported due to sustained " - "limitValueLocked flag is true"; - } - } else { - LOG_INFO << "Sustained power limit not supported"; - } + std::vector power_limits_descriptors; + auto status = lzt::get_power_limits_ext( + p_power_handle, &count_power, + power_limits_descriptors); // get power limits for all descriptors + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; } - } else { - LOG_INFO << "No power handles found for this device! "; - } - } - if (!is_power_supported) { - FAIL() << "No power handles found on any of the devices! "; - } -} -LZT_TEST_F( - POWER_TEST, - GivenValidPowerHandleWhenSettingPowerValuesForPeakPowerThenExpectzesPowerSetLimitsExtFollowedByzesPowerGetLimitsExtToMatch) { - for (auto device : devices) { - uint32_t count = 0; - count = lzt::get_power_handle_count(device); - if (count > 0) { - is_power_supported = true; - LOG_INFO << "Power handles are available on this device! "; - auto p_power_handles = lzt::get_power_handles(device, count); - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); - uint32_t count_power = 0; + EXPECT_ZE_RESULT_SUCCESS(status); + std::vector + power_limits_descriptors_initial; // preserve initial power limit + // descriptors for restoration + // later - zes_power_limit_ext_desc_t power_peak_set = {}; + for (int i = 0; i < power_limits_descriptors.size(); i++) { + power_limits_descriptors[i] = {ZES_STRUCTURE_TYPE_POWER_LIMIT_EXT_DESC, + nullptr}; + power_limits_descriptors_initial.push_back(power_limits_descriptors[i]); - std::vector power_limits_descriptors; - auto status = lzt::get_power_limits_ext( - p_power_handle, &count_power, - power_limits_descriptors); // get power limits for all descriptors - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - std::vector - power_limits_descriptors_initial; // preserve initial power limit - // descriptors for restoration - // later - for (int i = 0; i < power_limits_descriptors.size(); i++) { - power_limits_descriptors_initial.push_back( - power_limits_descriptors[i]); - - if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_PEAK) { - power_peak_set = power_limits_descriptors[i]; - power_peak_set.limit = power_limits_descriptors[i].limit - 1000; - power_limits_descriptors[i].limit = power_peak_set.limit; - } + if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_SUSTAINED) { + power_sustained_set = power_limits_descriptors[i]; + power_sustained_set.limit = power_limits_descriptors[i].limit - 1000; + power_limits_descriptors[i].limit = power_sustained_set.limit; } + } - if (power_peak_set.limitValueLocked == false) { + if (power_sustained_set.level == ZES_POWER_LEVEL_SUSTAINED) { + if (power_sustained_set.limitValueLocked == false) { status = lzt::set_power_limits_ext( p_power_handle, &count_power, power_limits_descriptors .data()); // set power limits for all descriptors + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { continue; } EXPECT_ZE_RESULT_SUCCESS(status); - zes_power_limit_ext_desc_t power_peak_get = {}; + zes_power_limit_ext_desc_t power_sustained_get = {}; + std::vector power_limits_descriptors_get; status = lzt::get_power_limits_ext(p_power_handle, &count_power, power_limits_descriptors_get); @@ -746,14 +587,16 @@ LZT_TEST_F( EXPECT_ZE_RESULT_SUCCESS(status); for (const auto &p_power_limits_descriptor_get : power_limits_descriptors_get) { - if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_PEAK) { - power_peak_get = p_power_limits_descriptor_get; + if (p_power_limits_descriptor_get.level == + ZES_POWER_LEVEL_SUSTAINED) { + power_sustained_get = p_power_limits_descriptor_get; } } - EXPECT_EQ(power_peak_get.limitValueLocked, - power_peak_set.limitValueLocked); - EXPECT_EQ(power_peak_get.interval, power_peak_set.interval); - EXPECT_EQ(power_peak_get.limit, power_peak_set.limit); + + EXPECT_EQ(power_sustained_get.limitValueLocked, + power_sustained_set.limitValueLocked); + EXPECT_EQ(power_sustained_get.interval, power_sustained_set.interval); + EXPECT_EQ(power_sustained_get.limit, power_sustained_set.limit); status = lzt::set_power_limits_ext(p_power_handle, &count_power, @@ -764,198 +607,273 @@ LZT_TEST_F( } EXPECT_ZE_RESULT_SUCCESS(status); } else { - LOG_INFO << "Set limit not supported due to peak " + LOG_INFO << "Set limit not supported due to sustained " "limitValueLocked flag is true"; } + } else { + LOG_INFO << "Sustained power limit not supported"; } - } else { - LOG_INFO << "No power handles found for this device! "; } } - if (!is_power_supported) { - FAIL() << "No power handles found on any of the devices! "; - } } LZT_TEST_F( POWER_TEST, - GivenValidPowerHandleWhenSettingPowerValuesForBurstPowerThenExpectzesPowerSetLimitsExtFollowedByzesPowerGetLimitsExtToMatch) { + GivenValidPowerHandleWhenSettingPowerValuesForPeakPowerThenExpectzesPowerSetLimitsExtFollowedByzesPowerGetLimitsExtToMatch) { for (auto device : devices) { uint32_t count = 0; - count = lzt::get_power_handle_count(device); - if (count > 0) { - is_power_supported = true; - LOG_INFO << "Power handles are available on this device! "; - auto p_power_handles = lzt::get_power_handles(device, count); - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); - uint32_t count_power = 0; - zes_power_limit_ext_desc_t power_burst_set = {}; - - std::vector power_limits_descriptors; - auto status = lzt::get_power_limits_ext( + auto p_power_handles = lzt::get_power_handles(device, count); + if (count == 0) { + FAIL() << "No handles found: " + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + } + + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); + uint32_t count_power = 0; + + zes_power_limit_ext_desc_t power_peak_set = {}; + + std::vector power_limits_descriptors; + auto status = lzt::get_power_limits_ext( + p_power_handle, &count_power, + power_limits_descriptors); // get power limits for all descriptors + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + std::vector + power_limits_descriptors_initial; // preserve initial power limit + // descriptors for restoration + // later + + for (int i = 0; i < power_limits_descriptors.size(); i++) { + power_limits_descriptors_initial.push_back(power_limits_descriptors[i]); + + if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_PEAK) { + power_peak_set = power_limits_descriptors[i]; + power_peak_set.limit = power_limits_descriptors[i].limit - 1000; + power_limits_descriptors[i].limit = power_peak_set.limit; + } + } + + if (power_peak_set.limitValueLocked == false) { + status = lzt::set_power_limits_ext( p_power_handle, &count_power, - power_limits_descriptors); // get power limits for all descriptors + power_limits_descriptors + .data()); // set power limits for all descriptors + + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + zes_power_limit_ext_desc_t power_peak_get = {}; + + std::vector power_limits_descriptors_get; + status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_get); if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { continue; } EXPECT_ZE_RESULT_SUCCESS(status); - std::vector - power_limits_descriptors_initial; // preserve initial power limit - // descriptors for restoration - // later - - for (int i = 0; i < power_limits_descriptors.size(); i++) { - power_limits_descriptors_initial.push_back( - power_limits_descriptors[i]); - if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_BURST) { - power_burst_set = power_limits_descriptors[i]; - power_burst_set.limit = power_limits_descriptors[i].limit - 1000; - power_limits_descriptors[i].limit = power_burst_set.limit; + for (const auto &p_power_limits_descriptor_get : + power_limits_descriptors_get) { + if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_PEAK) { + power_peak_get = p_power_limits_descriptor_get; } } - if (power_burst_set.limitValueLocked == false) { - status = lzt::set_power_limits_ext( - p_power_handle, &count_power, - power_limits_descriptors - .data()); // set power limits for all descriptors - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - zes_power_limit_ext_desc_t power_burst_get = {}; + EXPECT_EQ(power_peak_get.limitValueLocked, + power_peak_set.limitValueLocked); + EXPECT_EQ(power_peak_get.interval, power_peak_set.interval); + EXPECT_EQ(power_peak_get.limit, power_peak_set.limit); - std::vector power_limits_descriptors_get; - status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors_get); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - for (const auto &p_power_limits_descriptor_get : - power_limits_descriptors_get) { - if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_BURST) { - power_burst_get = p_power_limits_descriptor_get; - } - } - EXPECT_EQ(power_burst_get.limitValueLocked, - power_burst_set.limitValueLocked); - EXPECT_EQ(power_burst_get.interval, power_burst_set.interval); - EXPECT_EQ(power_burst_get.limit, power_burst_set.limit); - status = - lzt::set_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors_initial - .data()); // restore initial limits - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - } else { - LOG_INFO << "Set limit not supported due to burst " - "limitValueLocked flag is true"; + status = lzt::set_power_limits_ext( + p_power_handle, &count_power, + power_limits_descriptors_initial.data()); // restore initial limits + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; } + EXPECT_ZE_RESULT_SUCCESS(status); + } else { + LOG_INFO << "Set limit not supported due to peak " + "limitValueLocked flag is true"; } - } else { - LOG_INFO << "No power handles found for this device! "; } } - if (!is_power_supported) { - FAIL() << "No power handles found on any of the devices! "; - } } LZT_TEST_F( POWER_TEST, - GivenValidPowerHandleWhenSettingPowerValuesForInstantaneousPowerThenExpectzesPowerSetLimitsExtFollowedByzesPowerGetLimitsExtToMatch) { + GivenValidPowerHandleWhenSettingPowerValuesForBurstPowerThenExpectzesPowerSetLimitsExtFollowedByzesPowerGetLimitsExtToMatch) { for (auto device : devices) { uint32_t count = 0; - count = lzt::get_power_handle_count(device); - if (count > 0) { - is_power_supported = true; - LOG_INFO << "Power handles are available on this device! "; - auto p_power_handles = lzt::get_power_handles(device, count); - for (auto p_power_handle : p_power_handles) { - EXPECT_NE(nullptr, p_power_handle); - uint32_t count_power = 0; - zes_power_limit_ext_desc_t power_instantaneous_set = {}; - std::vector power_limits_descriptors; - auto status = lzt::get_power_limits_ext( + auto p_power_handles = lzt::get_power_handles(device, count); + if (count == 0) { + FAIL() << "No handles found: " + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + } + + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); + uint32_t count_power = 0; + + zes_power_limit_ext_desc_t power_burst_set = {}; + + std::vector power_limits_descriptors; + auto status = lzt::get_power_limits_ext( + p_power_handle, &count_power, + power_limits_descriptors); // get power limits for all descriptors + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + std::vector + power_limits_descriptors_initial; // preserve initial power limit + // descriptors for restoration + // later + + for (int i = 0; i < power_limits_descriptors.size(); i++) { + power_limits_descriptors_initial.push_back(power_limits_descriptors[i]); + + if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_BURST) { + power_burst_set = power_limits_descriptors[i]; + power_burst_set.limit = power_limits_descriptors[i].limit - 1000; + power_limits_descriptors[i].limit = power_burst_set.limit; + } + } + + if (power_burst_set.limitValueLocked == false) { + status = lzt::set_power_limits_ext( p_power_handle, &count_power, - power_limits_descriptors); // get power limits for all descriptors + power_limits_descriptors + .data()); // set power limits for all descriptors + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { continue; } EXPECT_ZE_RESULT_SUCCESS(status); - std::vector - power_limits_descriptors_initial; // preserve initial power limit - // descriptors for restoration - // later - - for (int i = 0; i < power_limits_descriptors.size(); i++) { - power_limits_descriptors_initial.push_back( - power_limits_descriptors[i]); - if (power_limits_descriptors[i].level == - ZES_POWER_LEVEL_INSTANTANEOUS) { - power_instantaneous_set = power_limits_descriptors[i]; - power_instantaneous_set.limit = - power_limits_descriptors[i].limit - 1000; - power_limits_descriptors[i].limit = power_instantaneous_set.limit; + zes_power_limit_ext_desc_t power_burst_get = {}; + + std::vector power_limits_descriptors_get; + status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_get); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + for (const auto &p_power_limits_descriptor_get : + power_limits_descriptors_get) { + if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_BURST) { + power_burst_get = p_power_limits_descriptor_get; } } - if (power_instantaneous_set.limitValueLocked == false) { - status = lzt::set_power_limits_ext( - p_power_handle, &count_power, - power_limits_descriptors - .data()); // set power limits for all descriptors + EXPECT_EQ(power_burst_get.limitValueLocked, + power_burst_set.limitValueLocked); + EXPECT_EQ(power_burst_get.interval, power_burst_set.interval); + EXPECT_EQ(power_burst_get.limit, power_burst_set.limit); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - zes_power_limit_ext_desc_t power_instantaneous_get = {}; + status = lzt::set_power_limits_ext( + p_power_handle, &count_power, + power_limits_descriptors_initial.data()); // restore initial limits + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + } else { + LOG_INFO << "Set limit not supported due to burst " + "limitValueLocked flag is true"; + } + } + } +} +LZT_TEST_F( + POWER_TEST, + GivenValidPowerHandleWhenSettingPowerValuesForInstantaneousPowerThenExpectzesPowerSetLimitsExtFollowedByzesPowerGetLimitsExtToMatch) { + for (auto device : devices) { + uint32_t count = 0; + auto p_power_handles = lzt::get_power_handles(device, count); + if (count == 0) { + FAIL() << "No handles found: " + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + } - std::vector power_limits_descriptors_get; - status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors_get); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - for (const auto &p_power_limits_descriptor_get : - power_limits_descriptors_get) { - if (p_power_limits_descriptor_get.level == - ZES_POWER_LEVEL_INSTANTANEOUS) { - power_instantaneous_get = p_power_limits_descriptor_get; - } - } + for (auto p_power_handle : p_power_handles) { + EXPECT_NE(nullptr, p_power_handle); + uint32_t count_power = 0; - EXPECT_EQ(power_instantaneous_get.limitValueLocked, - power_instantaneous_set.limitValueLocked); - EXPECT_EQ(power_instantaneous_get.interval, - power_instantaneous_set.interval); - EXPECT_EQ(power_instantaneous_get.limit, - power_instantaneous_set.limit); + zes_power_limit_ext_desc_t power_instantaneous_set = {}; - status = - lzt::set_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors_initial - .data()); // restore initial limits - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; + std::vector power_limits_descriptors; + auto status = lzt::get_power_limits_ext( + p_power_handle, &count_power, + power_limits_descriptors); // get power limits for all descriptors + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + std::vector + power_limits_descriptors_initial; // preserve initial power limit + // descriptors for restoration + // later + + for (int i = 0; i < power_limits_descriptors.size(); i++) { + power_limits_descriptors_initial.push_back(power_limits_descriptors[i]); + + if (power_limits_descriptors[i].level == + ZES_POWER_LEVEL_INSTANTANEOUS) { + power_instantaneous_set = power_limits_descriptors[i]; + power_instantaneous_set.limit = + power_limits_descriptors[i].limit - 1000; + power_limits_descriptors[i].limit = power_instantaneous_set.limit; + } + } + + if (power_instantaneous_set.limitValueLocked == false) { + status = lzt::set_power_limits_ext( + p_power_handle, &count_power, + power_limits_descriptors + .data()); // set power limits for all descriptors + + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + zes_power_limit_ext_desc_t power_instantaneous_get = {}; + + std::vector power_limits_descriptors_get; + status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_get); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + for (const auto &p_power_limits_descriptor_get : + power_limits_descriptors_get) { + if (p_power_limits_descriptor_get.level == + ZES_POWER_LEVEL_INSTANTANEOUS) { + power_instantaneous_get = p_power_limits_descriptor_get; } - EXPECT_ZE_RESULT_SUCCESS(status); - } else { - LOG_INFO << "Set limit not supported due to instantaneous " - "limitValueLocked flag is true"; } + + EXPECT_EQ(power_instantaneous_get.limitValueLocked, + power_instantaneous_set.limitValueLocked); + EXPECT_EQ(power_instantaneous_get.interval, + power_instantaneous_set.interval); + EXPECT_EQ(power_instantaneous_get.limit, power_instantaneous_set.limit); + + status = lzt::set_power_limits_ext( + p_power_handle, &count_power, + power_limits_descriptors_initial.data()); // restore initial limits + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + } else { + LOG_INFO << "Set limit not supported due to instantaneous " + "limitValueLocked flag is true"; } - } else { - LOG_INFO << "No power handles found for this device! "; } } - if (!is_power_supported) { - FAIL() << "No power handles found on any of the devices! "; - } } LZT_TEST_F( @@ -963,30 +881,24 @@ LZT_TEST_F( GivenValidPowerHandleWhenRequestingEnergyCounterThenExpectEnergyConsumedByRootDeviceToBeGreaterThanOrEqualToEnergyConsumedBySubdevices) { for (auto device : devices) { uint32_t count = 0; - count = lzt::get_power_handle_count(device); - if (count > 0) { - is_power_supported = true; - LOG_INFO << "Power handles are available on this device! "; - auto p_power_handles = lzt::get_power_handles(device, count); - uint64_t total_rootdevice_energy = 0; - uint64_t total_subdevices_energy = 0; - for (auto p_power_handle : p_power_handles) { - auto p_properties = lzt::get_power_properties(p_power_handle); - zes_power_energy_counter_t p_energy_counter = {}; - lzt::get_power_energy_counter(p_power_handle, &p_energy_counter); - if (p_properties.onSubdevice == false) { - total_rootdevice_energy += p_energy_counter.energy; - } else { - total_subdevices_energy += p_energy_counter.energy; - } + auto p_power_handles = lzt::get_power_handles(device, count); + if (count == 0) { + FAIL() << "No handles found: " + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + } + uint64_t total_rootdevice_energy = 0; + uint64_t total_subdevices_energy = 0; + for (auto p_power_handle : p_power_handles) { + auto p_properties = lzt::get_power_properties(p_power_handle); + zes_power_energy_counter_t p_energy_counter = {}; + lzt::get_power_energy_counter(p_power_handle, &p_energy_counter); + if (p_properties.onSubdevice == false) { + total_rootdevice_energy += p_energy_counter.energy; + } else { + total_subdevices_energy += p_energy_counter.energy; } - EXPECT_GE(total_rootdevice_energy, total_subdevices_energy); - } else { - LOG_INFO << "No power handles found for this device! "; } - } - if (!is_power_supported) { - FAIL() << "No power handles found on any of the devices! "; + EXPECT_GE(total_rootdevice_energy, total_subdevices_energy); } } @@ -995,99 +907,92 @@ LZT_TEST_F( GivenValidPowerHandlesAfterGettingMaxPowerLimitsWhenSettingValuesForSustainedPowerThenExpectzesPowerGetLimitsExtToReturnPowerLimitsLessThanMaxPowerLimits) { for (auto device : devices) { uint32_t count = 0; - count = lzt::get_power_handle_count(device); - if (count > 0) { - is_power_supported = true; - LOG_INFO << "Power handles are available on this device! "; - auto p_power_handles = lzt::get_power_handles(device, count); - for (auto p_power_handle : p_power_handles) { - auto p_properties = lzt::get_power_properties(p_power_handle); - if (p_properties.onSubdevice == true) { - continue; - } - uint32_t count_power = 0; - bool sustained_limit_available = false; - zes_power_limit_ext_desc_t power_sustained_Max = {}; - zes_power_limit_ext_desc_t power_sustained_Initial = {}; - zes_power_limit_ext_desc_t power_sustained_getMax = {}; - zes_power_limit_ext_desc_t power_sustained_get = {}; - std::vector power_limits_descriptors; - auto status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - for (int i = 0; i < power_limits_descriptors.size(); i++) { - if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_SUSTAINED) { - sustained_limit_available = true; - power_sustained_Max = power_limits_descriptors[i]; - power_sustained_Initial = power_limits_descriptors[i]; - power_sustained_Max.limit = std::numeric_limits::max(); - power_sustained_Initial.limit *= 2; - if (power_sustained_Max.limitValueLocked == false) { - status = lzt::set_power_limits_ext(p_power_handle, &count_power, - &power_sustained_Max); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - std::vector - power_limits_descriptors_getMax; - status = - lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors_getMax); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - for (const auto &p_power_limits_descriptor_get : - power_limits_descriptors_getMax) { - if (p_power_limits_descriptor_get.level == - ZES_POWER_LEVEL_SUSTAINED) { - power_sustained_getMax = p_power_limits_descriptor_get; - } - } - status = lzt::set_power_limits_ext(p_power_handle, &count_power, - &power_sustained_Initial); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - std::vector - power_limits_descriptors_get; - status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors_get); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; + auto p_power_handles = lzt::get_power_handles(device, count); + if (count == 0) { + FAIL() << "No handles found: " + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + } + for (auto p_power_handle : p_power_handles) { + auto p_properties = lzt::get_power_properties(p_power_handle); + if (p_properties.onSubdevice == true) { + continue; + } + uint32_t count_power = 0; + bool sustained_limit_available = false; + zes_power_limit_ext_desc_t power_sustained_Max = {}; + zes_power_limit_ext_desc_t power_sustained_Initial = {}; + zes_power_limit_ext_desc_t power_sustained_getMax = {}; + zes_power_limit_ext_desc_t power_sustained_get = {}; + std::vector power_limits_descriptors; + auto status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + for (int i = 0; i < power_limits_descriptors.size(); i++) { + if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_SUSTAINED) { + sustained_limit_available = true; + power_sustained_Max = power_limits_descriptors[i]; + power_sustained_Initial = power_limits_descriptors[i]; + power_sustained_Max.limit = std::numeric_limits::max(); + power_sustained_Initial.limit *= 2; + + if (power_sustained_Max.limitValueLocked == false) { + status = lzt::set_power_limits_ext(p_power_handle, &count_power, + &power_sustained_Max); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + std::vector + power_limits_descriptors_getMax; + status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_getMax); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + for (const auto &p_power_limits_descriptor_get : + power_limits_descriptors_getMax) { + if (p_power_limits_descriptor_get.level == + ZES_POWER_LEVEL_SUSTAINED) { + power_sustained_getMax = p_power_limits_descriptor_get; } - EXPECT_ZE_RESULT_SUCCESS(status); - for (const auto &p_power_limits_descriptor_get : - power_limits_descriptors_get) { - if (p_power_limits_descriptor_get.level == - ZES_POWER_LEVEL_SUSTAINED) { - power_sustained_get = p_power_limits_descriptor_get; - } + } + status = lzt::set_power_limits_ext(p_power_handle, &count_power, + &power_sustained_Initial); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + std::vector + power_limits_descriptors_get; + status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_get); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + for (const auto &p_power_limits_descriptor_get : + power_limits_descriptors_get) { + if (p_power_limits_descriptor_get.level == + ZES_POWER_LEVEL_SUSTAINED) { + power_sustained_get = p_power_limits_descriptor_get; } - EXPECT_LE(power_sustained_get.limit, - power_sustained_getMax.limit); - } else { - LOG_INFO << "Set limit not supported due to sustained " - "limitValueLocked flag is true"; } + EXPECT_LE(power_sustained_get.limit, power_sustained_getMax.limit); + } else { + LOG_INFO << "Set limit not supported due to sustained " + "limitValueLocked flag is true"; } } - if (!sustained_limit_available) { - LOG_INFO << "Sustained power limit not supported"; - } } - } else { - LOG_INFO << "No power handles found for this device! "; + if (!sustained_limit_available) { + LOG_INFO << "Sustained power limit not supported"; + } } } - if (!is_power_supported) { - FAIL() << "No power handles found on any of the devices! "; - } } LZT_TEST_F( @@ -1095,106 +1000,101 @@ LZT_TEST_F( GivenValidPowerHandlesAfterGettingMaxPowerLimitWhenSettingValuesForPeakPowerThenExpectZesPowerGetLimitsExtToReturnPowerLimitsLessThanMaxPowerLimits) { for (auto device : devices) { uint32_t count = 0; - count = lzt::get_power_handle_count(device); - if (count > 0) { - is_power_supported = true; - LOG_INFO << "Power handles are available on this device! "; - auto p_power_handles = lzt::get_power_handles(device, count); - for (auto p_power_handle : p_power_handles) { - auto p_properties = lzt::get_power_properties(p_power_handle); - if (p_properties.onSubdevice == true) { - continue; - } - uint32_t count_power = 0; - uint32_t single_count = 1; - bool peak_limit_available = false; + auto p_power_handles = lzt::get_power_handles(device, count); + if (count == 0) { + FAIL() << "No handles found: " + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + } + for (auto p_power_handle : p_power_handles) { + auto p_properties = lzt::get_power_properties(p_power_handle); + if (p_properties.onSubdevice == true) { + continue; + } + uint32_t count_power = 0; + uint32_t single_count = 1; + bool peak_limit_available = false; - std::vector power_limits_descriptors; - auto status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - for (int i = 0; i < power_limits_descriptors.size(); i++) { - zes_power_limit_ext_desc_t power_peak_initial = {}; - zes_power_limit_ext_desc_t power_peak_Max = {}; - zes_power_limit_ext_desc_t power_peak_getMax = {}; - zes_power_limit_ext_desc_t power_peak_get = {}; - if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_PEAK) { - peak_limit_available = true; - zes_power_source_t power_source = - power_limits_descriptors[i].source; - power_peak_Max = power_limits_descriptors[i]; - power_peak_initial = power_limits_descriptors[i]; - power_peak_Max.limit = std::numeric_limits::max(); - power_peak_initial.limit *= 2; - - if (power_limits_descriptors[i].limitValueLocked == false) { - status = lzt::set_power_limits_ext(p_power_handle, &single_count, - &power_peak_Max); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - std::vector - power_limits_descriptors_getMax; - status = - lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors_getMax); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - for (const auto &p_power_limits_descriptor_get : - power_limits_descriptors_getMax) { - if (p_power_limits_descriptor_get.level == - ZES_POWER_LEVEL_PEAK && - p_power_limits_descriptor_get.source == power_source) { - power_peak_getMax = p_power_limits_descriptor_get; - } - } + std::vector power_limits_descriptors; + auto status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + int32_t max_power_limit_first = std::numeric_limits::max(); + for (int i = 0; i < power_limits_descriptors.size(); i++) { + zes_power_limit_ext_desc_t power_peak_initial = {}; + zes_power_limit_ext_desc_t power_peak_Max = {}; + zes_power_limit_ext_desc_t power_peak_getMax = {}; + zes_power_limit_ext_desc_t power_peak_get = {}; + if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_PEAK) { + peak_limit_available = true; + zes_power_source_t power_source = power_limits_descriptors[i].source; + power_peak_Max = power_limits_descriptors[i]; + power_peak_initial = power_limits_descriptors[i]; + power_peak_Max.limit = max_power_limit_first; - status = lzt::set_power_limits_ext(p_power_handle, &single_count, - &power_peak_initial); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; - } - EXPECT_ZE_RESULT_SUCCESS(status); - std::vector - power_limits_descriptors_get; - status = lzt::get_power_limits_ext(p_power_handle, &count_power, - power_limits_descriptors_get); - if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { - continue; + int32_t max_power_limit_second = + power_limits_descriptors[i].limit * 2; + power_peak_initial.limit = max_power_limit_second; + + if (power_limits_descriptors[i].limitValueLocked == false) { + status = lzt::set_power_limits_ext(p_power_handle, &single_count, + &power_peak_Max); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + std::vector + power_limits_descriptors_getMax; + status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_getMax); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + for (const auto &p_power_limits_descriptor_get : + power_limits_descriptors_getMax) { + if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_PEAK && + p_power_limits_descriptor_get.source == power_source) { + power_peak_getMax = p_power_limits_descriptor_get; + EXPECT_LT(power_peak_getMax.limit, max_power_limit_first); } - EXPECT_ZE_RESULT_SUCCESS(status); - for (const auto &p_power_limits_descriptor_get : - power_limits_descriptors_get) { - if (p_power_limits_descriptor_get.level == - ZES_POWER_LEVEL_PEAK && - p_power_limits_descriptor_get.source == power_source) { - power_peak_get = p_power_limits_descriptor_get; - } + } + + status = lzt::set_power_limits_ext(p_power_handle, &single_count, + &power_peak_initial); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + std::vector + power_limits_descriptors_get; + status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_get); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } + EXPECT_ZE_RESULT_SUCCESS(status); + for (const auto &p_power_limits_descriptor_get : + power_limits_descriptors_get) { + if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_PEAK && + p_power_limits_descriptor_get.source == power_source) { + power_peak_get = p_power_limits_descriptor_get; + EXPECT_LE(power_peak_get.limit, max_power_limit_second); } - EXPECT_LE(power_peak_get.limit, power_peak_getMax.limit); - } else { - LOG_INFO << "Set limit not supported due to peak " - "limitValueLocked flag is true"; } + } else { + LOG_INFO << "Set limit not supported due to peak " + "limitValueLocked flag is true"; } } - if (!peak_limit_available) { - LOG_INFO << "peak power limit not supported"; - } } - } else { - LOG_INFO << "No power handles found for this device! "; + if (!peak_limit_available) { + LOG_INFO << "peak power limit not supported"; + } } } - if (!is_power_supported) { - FAIL() << "No power handles found on any of the devices! "; - } } LZT_TEST_F( @@ -1202,30 +1102,24 @@ LZT_TEST_F( GivenPowerHandleWhenRequestingExtensionPowerPropertiesThenValidPowerDomainIsReturned) { for (auto device : devices) { uint32_t count = 0; - count = lzt::get_power_handle_count(device); - if (count > 0) { - is_power_supported = true; - LOG_INFO << "Power handles are available on this device! "; - auto p_power_handles = lzt::get_power_handles(device, count); - for (auto p_power_handle : p_power_handles) { - zes_power_properties_t pProperties = { - ZES_STRUCTURE_TYPE_POWER_PROPERTIES, nullptr}; - zes_power_ext_properties_t pExtProperties = { - ZES_STRUCTURE_TYPE_POWER_EXT_PROPERTIES, nullptr}; - pProperties.pNext = &pExtProperties; - - EXPECT_ZE_RESULT_SUCCESS( - zesPowerGetProperties(p_power_handle, &pProperties)); - - EXPECT_GT(pExtProperties.domain, ZES_POWER_DOMAIN_UNKNOWN); - EXPECT_LT(pExtProperties.domain, ZES_POWER_DOMAIN_FORCE_UINT32); - } - } else { - LOG_INFO << "No power handles found for this device! "; + auto p_power_handles = lzt::get_power_handles(device, count); + if (count == 0) { + FAIL() << "No handles found: " + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + } + for (auto p_power_handle : p_power_handles) { + zes_power_properties_t pProperties = {ZES_STRUCTURE_TYPE_POWER_PROPERTIES, + nullptr}; + zes_power_ext_properties_t pExtProperties = { + ZES_STRUCTURE_TYPE_POWER_EXT_PROPERTIES, nullptr}; + pProperties.pNext = &pExtProperties; + + EXPECT_ZE_RESULT_SUCCESS( + zesPowerGetProperties(p_power_handle, &pProperties)); + + EXPECT_GT(pExtProperties.domain, ZES_POWER_DOMAIN_UNKNOWN); + EXPECT_LT(pExtProperties.domain, ZES_POWER_DOMAIN_FORCE_UINT32); } - } - if (!is_power_supported) { - FAIL() << "No power handles found on any of the devices! "; } } @@ -1234,48 +1128,40 @@ LZT_TEST_F( GivenPowerHandleWhenRequestingExtensionPowerPropertiesThenValidDefaultLimitsAreReturned) { for (auto device : devices) { uint32_t count = 0; - count = lzt::get_power_handle_count(device); - if (count > 0) { - is_power_supported = true; - LOG_INFO << "Power handles are available on this device! "; - auto p_power_handles = lzt::get_power_handles(device, count); - for (auto p_power_handle : p_power_handles) { - zes_power_properties_t pProperties = { - ZES_STRUCTURE_TYPE_POWER_PROPERTIES, nullptr}; - zes_power_ext_properties_t pExtProperties = { - ZES_STRUCTURE_TYPE_POWER_EXT_PROPERTIES, nullptr}; - zes_power_limit_ext_desc_t default_limits = {}; - pExtProperties.defaultLimit = &default_limits; - pProperties.pNext = &pExtProperties; - // query extension properties - EXPECT_ZE_RESULT_SUCCESS( - zesPowerGetProperties(p_power_handle, &pProperties)); - // verify default limits - EXPECT_GE(pExtProperties.defaultLimit->level, ZES_POWER_LEVEL_UNKNOWN); - EXPECT_LE(pExtProperties.defaultLimit->level, - ZES_POWER_LEVEL_INSTANTANEOUS); - EXPECT_GE(pExtProperties.defaultLimit->source, ZES_POWER_SOURCE_ANY); - EXPECT_LE(pExtProperties.defaultLimit->source, - ZES_POWER_SOURCE_BATTERY); - EXPECT_GE(pExtProperties.defaultLimit->limitUnit, - ZES_LIMIT_UNIT_UNKNOWN); - EXPECT_LE(pExtProperties.defaultLimit->limitUnit, ZES_LIMIT_UNIT_POWER); - if (!pExtProperties.defaultLimit->intervalValueLocked) { - EXPECT_GE(pExtProperties.defaultLimit->interval, 0u); - EXPECT_LE(pExtProperties.defaultLimit->interval, INT32_MAX); - } - if (!pExtProperties.defaultLimit->limitValueLocked) { - EXPECT_GE(pExtProperties.defaultLimit->limit, 0u); - EXPECT_LE(pExtProperties.defaultLimit->limit, INT32_MAX); - } + auto p_power_handles = lzt::get_power_handles(device, count); + if (count == 0) { + FAIL() << "No handles found: " + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + } + for (auto p_power_handle : p_power_handles) { + zes_power_properties_t pProperties = {ZES_STRUCTURE_TYPE_POWER_PROPERTIES, + nullptr}; + zes_power_ext_properties_t pExtProperties = { + ZES_STRUCTURE_TYPE_POWER_EXT_PROPERTIES, nullptr}; + zes_power_limit_ext_desc_t default_limits = {}; + pExtProperties.defaultLimit = &default_limits; + pProperties.pNext = &pExtProperties; + // query extension properties + EXPECT_ZE_RESULT_SUCCESS( + zesPowerGetProperties(p_power_handle, &pProperties)); + // verify default limits + EXPECT_GE(pExtProperties.defaultLimit->level, ZES_POWER_LEVEL_UNKNOWN); + EXPECT_LE(pExtProperties.defaultLimit->level, + ZES_POWER_LEVEL_INSTANTANEOUS); + EXPECT_GE(pExtProperties.defaultLimit->source, ZES_POWER_SOURCE_ANY); + EXPECT_LE(pExtProperties.defaultLimit->source, ZES_POWER_SOURCE_BATTERY); + EXPECT_GE(pExtProperties.defaultLimit->limitUnit, ZES_LIMIT_UNIT_UNKNOWN); + EXPECT_LE(pExtProperties.defaultLimit->limitUnit, ZES_LIMIT_UNIT_POWER); + if (!pExtProperties.defaultLimit->intervalValueLocked) { + EXPECT_GE(pExtProperties.defaultLimit->interval, 0u); + EXPECT_LE(pExtProperties.defaultLimit->interval, INT32_MAX); + } + if (!pExtProperties.defaultLimit->limitValueLocked) { + EXPECT_GE(pExtProperties.defaultLimit->limit, 0u); + EXPECT_LE(pExtProperties.defaultLimit->limit, INT32_MAX); } - } else { - LOG_INFO << "No power handles found for this device! "; } } - if (!is_power_supported) { - FAIL() << "No power handles found on any of the devices! "; - } } LZT_TEST_F( @@ -1283,52 +1169,43 @@ LZT_TEST_F( GivenValidPowerAndPerformanceHandlesWhenIncreasingPerformanceFactorThenExpectTotalEnergyConsumedToBeIncreased) { for (auto device : devices) { uint32_t count = 0; - count = lzt::get_power_handle_count(device); - if (count > 0) { - is_power_supported = true; - LOG_INFO << "Power handles are available on this device! "; - auto p_power_handles = lzt::get_power_handles(device, count); - for (auto p_power_handle : p_power_handles) { - auto p_properties = lzt::get_power_properties(p_power_handle); - if (p_properties.onSubdevice == true) { - continue; - } - uint32_t perf_count = 0; - perf_count = lzt::get_performance_handle_count(device); - zes_power_energy_counter_t energy_counter_initial; - zes_power_energy_counter_t energy_counter_later; - auto p_performance_handles = - lzt::get_performance_handles(device, perf_count); - if (perf_count == 0) { - FAIL() << "No performance handles found for this device! "; - } - for (auto p_performance_handle : p_performance_handles) { - zes_perf_properties_t p_perf_properties = - lzt::get_performance_properties(p_performance_handle); - p_perf_properties.engines = - 1; // 1 is the equivalent value for ZES_ENGINE_TYPE_FLAG_OTHER - - if (p_perf_properties.engines == ZES_ENGINE_TYPE_FLAG_OTHER) { - lzt::set_performance_config(p_performance_handle, 25); - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - lzt::get_power_energy_counter(p_power_handle, - &energy_counter_initial); - lzt::set_performance_config(p_performance_handle, 100); - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - lzt::get_power_energy_counter(p_power_handle, - &energy_counter_later); - EXPECT_GE(energy_counter_later.energy, - energy_counter_initial.energy); - } + auto p_power_handles = lzt::get_power_handles(device, count); + if (count == 0) { + FAIL() << "No handles found: " + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + } + for (auto p_power_handle : p_power_handles) { + auto p_properties = lzt::get_power_properties(p_power_handle); + if (p_properties.onSubdevice == true) { + continue; + } + uint32_t perf_count = 0; + zes_power_energy_counter_t energy_counter_initial; + zes_power_energy_counter_t energy_counter_later; + auto p_performance_handles = + lzt::get_performance_handles(device, perf_count); + if (perf_count == 0) { + FAIL() << "No handles found: " + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + } + for (auto p_performance_handle : p_performance_handles) { + zes_perf_properties_t p_perf_properties = + lzt::get_performance_properties(p_performance_handle); + p_perf_properties.engines = + 1; // 1 is the equivalent value for ZES_ENGINE_TYPE_FLAG_OTHER + if (p_perf_properties.engines == ZES_ENGINE_TYPE_FLAG_OTHER) { + lzt::set_performance_config(p_performance_handle, 25); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + lzt::get_power_energy_counter(p_power_handle, + &energy_counter_initial); + lzt::set_performance_config(p_performance_handle, 100); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + lzt::get_power_energy_counter(p_power_handle, &energy_counter_later); + EXPECT_GE(energy_counter_later.energy, energy_counter_initial.energy); } } - } else { - LOG_INFO << "No power handles found for this device! "; } } - if (!is_power_supported) { - FAIL() << "No power handles found on any of the devices! "; - } } #ifdef __linux__ @@ -1337,11 +1214,10 @@ LZT_TEST_F( GivenValidDeviceWhenCallingPowerGetEnergyCountersMultipleTimesThenExpectFirstCallIsSlowerThanSubsequentCalls) { for (auto device : devices) { uint32_t count = 0; - count = lzt::get_power_handle_count(device); auto power_handles = lzt::get_power_handles(device, count); + if (count > 0) { - is_power_supported = true; - LOG_INFO << "Power handles are available on this device! "; + power_handles_available = true; auto start = std::chrono::steady_clock::now(); auto energy_counters = lzt::get_power_energy_counter(power_handles); auto end = std::chrono::steady_clock::now(); @@ -1368,11 +1244,12 @@ LZT_TEST_F( EXPECT_GT(avg_time.count(), 0); EXPECT_GT(elapsed_initial.count(), avg_time.count()); } else { - LOG_INFO << "No power handles found for this device! "; + LOG_WARNING << "No handles found on this device!"; } } - if (!is_power_supported) { - FAIL() << "No power handles found on any of the devices!"; + + if (!power_handles_available) { + FAIL() << "No handles found in any of the devices!"; } } #endif