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 0eab48273..4b6c95233 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,31 +279,42 @@ 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 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 @@ -268,25 +324,31 @@ LZT_TEST_P( GivenValidPerformanceHandleWhenSettingMultiplePerformanceFactorForComputeThenValidPerformanceFactorIsReturned) { 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_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_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_performance_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 711e8636a..c7c3829bf 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 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 +36,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 +58,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 +79,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 +142,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 +180,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 +746,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 +764,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 +781,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 +963,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 +995,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,96 +1095,106 @@ 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); - 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; + 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; + 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; + 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! "; } } + if (!is_power_supported) { + FAIL() << "No power handles found on any of the devices! "; + } } LZT_TEST_F( @@ -1097,25 +1202,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 found on any of the devices! "; + } } LZT_TEST_F( @@ -1123,40 +1234,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 found on any of the devices! "; + } } LZT_TEST_F( @@ -1164,43 +1283,52 @@ 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__ @@ -1209,10 +1337,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 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(); @@ -1239,12 +1368,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!"; + if (!is_power_supported) { + FAIL() << "No power handles found on 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 936103c00..c04161895 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 devices! "; + } } 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 devices! "; + } } 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 devices! "; } } @@ -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 devices! "; } } @@ -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 devices! "; + } } 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 devices! "; + } } 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 devices! "; + } } 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 devices! "; + } } 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 devices! "; + } } 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 devices! "; + } } 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 devices! "; + } } 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 devices! "; + } } 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 devices! "; + } } 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 devices! "; + } } 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 devices! "; + } } } // namespace