From e7e8f4ce366495a3bda5d881d7c0a7a35c3bc149 Mon Sep 17 00:00:00 2001 From: shubham kumar Date: Thu, 7 Nov 2024 19:55:41 +0530 Subject: [PATCH] fix: Update power CTS to handle new GPU/Memory domains Related-To: NEO-13195 Signed-off-by: shubham kumar --- .../src/test_sysman_events.cpp | 14 +- .../src/test_sysman_frequency.cpp | 15 +- .../src/test_sysman_power.cpp | 204 ++++++++++++------ .../include/test_harness_sysman_power.hpp | 16 +- .../sysman/src/test_harness_sysman_power.cpp | 83 ++++--- 5 files changed, 223 insertions(+), 109 deletions(-) diff --git a/conformance_tests/sysman/test_sysman_events/src/test_sysman_events.cpp b/conformance_tests/sysman/test_sysman_events/src/test_sysman_events.cpp index d98f28c3..4d625a54 100644 --- a/conformance_tests/sysman/test_sysman_events/src/test_sysman_events.cpp +++ b/conformance_tests/sysman/test_sysman_events/src/test_sysman_events.cpp @@ -453,7 +453,12 @@ TEST_F( << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); } for (auto power_handle : power_handles) { - auto energy_threshold = lzt::get_power_energy_threshold(power_handle); + zes_energy_threshold_t energy_threshold = {}; + auto status = + lzt::get_power_energy_threshold(power_handle, &energy_threshold); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } // Aim to receive event for energy threshold after setting energy // threshold 25% more than current threshold double threshold = @@ -490,7 +495,12 @@ TEST_F( << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); } for (auto power_handle : power_handles) { - auto energy_threshold = lzt::get_power_energy_threshold(power_handle); + zes_energy_threshold_t energy_threshold = {}; + auto status = + lzt::get_power_energy_threshold(power_handle, &energy_threshold); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } // Aim to receive event for energy threshold after setting energy // threshold 25% more than current threshold double threshold = diff --git a/conformance_tests/sysman/test_sysman_frequency/src/test_sysman_frequency.cpp b/conformance_tests/sysman/test_sysman_frequency/src/test_sysman_frequency.cpp index 18e098a1..8202f632 100644 --- a/conformance_tests/sysman/test_sysman_frequency/src/test_sysman_frequency.cpp +++ b/conformance_tests/sysman/test_sysman_frequency/src/test_sysman_frequency.cpp @@ -569,12 +569,18 @@ TEST_F(FREQUENCY_TEST, GivenValidFrequencyHandleThenCheckForThrottling) { for (auto p_power_handle : p_power_handles) { EXPECT_NE(nullptr, p_power_handle); zes_power_sustained_limit_t power_sustained_limit_Initial; - lzt::get_power_limits(p_power_handle, &power_sustained_limit_Initial, + auto status = lzt::get_power_limits(p_power_handle, &power_sustained_limit_Initial, nullptr, nullptr); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } zes_power_sustained_limit_t power_sustained_limit_set; power_sustained_limit_set.power = 0; - lzt::set_power_limits(p_power_handle, &power_sustained_limit_set, + status = lzt::set_power_limits(p_power_handle, &power_sustained_limit_set, nullptr, nullptr); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } auto before_throttletime = lzt::get_throttle_time(pfreq_handle); zes_freq_throttle_time_t throttletime; #ifdef USE_ZESINIT @@ -596,8 +602,11 @@ TEST_F(FREQUENCY_TEST, GivenValidFrequencyHandleThenCheckForThrottling) { after_throttletime.throttleTime); EXPECT_NE(before_throttletime.timestamp, after_throttletime.timestamp); - lzt::set_power_limits(p_power_handle, &power_sustained_limit_Initial, + status = lzt::set_power_limits(p_power_handle, &power_sustained_limit_Initial, nullptr, nullptr); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } } } } 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 e6d3fe63..964832dd 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 @@ -147,7 +147,7 @@ TEST_F( TEST_F( POWER_TEST, - GivenValidPowerHandleWhenRequestingPowerLimitsThenExpectzesSysmanPowerGetLimitsToReturnValidPowerLimits) { + GivenValidPowerHandleWhenRequestingPowerLimitsThenExpectZesSysmanPowerGetLimitsToReturnValidPowerLimits) { for (auto device : devices) { uint32_t count = 0; auto p_power_handles = lzt::get_power_handles(device, count); @@ -161,7 +161,10 @@ TEST_F( zes_power_sustained_limit_t pSustained = {}; zes_power_burst_limit_t pBurst = {}; zes_power_peak_limit_t pPeak = {}; - lzt::get_power_limits(p_power_handle, &pSustained, &pBurst, &pPeak); + auto status = lzt::get_power_limits(p_power_handle, &pSustained, &pBurst, &pPeak); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } auto pProperties = lzt::get_power_properties(p_power_handle); if (pProperties.maxLimit == -1) { LOG_INFO << "maxlimit unsupported: "; @@ -194,12 +197,15 @@ TEST_F( zes_power_sustained_limit_t pSustainedInitial = {}; zes_power_burst_limit_t pBurstInitial = {}; zes_power_peak_limit_t pPeakInitial = {}; - lzt::get_power_limits(p_power_handle, &pSustainedInitial, &pBurstInitial, + auto status = lzt::get_power_limits(p_power_handle, &pSustainedInitial, &pBurstInitial, &pPeakInitial); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } zes_power_sustained_limit_t pSustainedLater = {}; zes_power_burst_limit_t pBurstLater = {}; zes_power_peak_limit_t pPeakLater = {}; - lzt::get_power_limits(p_power_handle, &pSustainedLater, &pBurstLater, + status = lzt::get_power_limits(p_power_handle, &pSustainedLater, &pBurstLater, &pPeakLater); EXPECT_EQ(pSustainedInitial.enabled, pSustainedLater.enabled); @@ -228,8 +234,11 @@ TEST_F( zes_power_sustained_limit_t pSustainedInitial = {}; zes_power_burst_limit_t pBurstInitial = {}; zes_power_peak_limit_t pPeakInitial = {}; - lzt::get_power_limits(p_power_handle, &pSustainedInitial, &pBurstInitial, + auto status = lzt::get_power_limits(p_power_handle, &pSustainedInitial, &pBurstInitial, &pPeakInitial); // get default power values + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } auto pProperties = lzt::get_power_properties(p_power_handle); if (pProperties.maxLimit == -1) { LOG_INFO << "maxlimit unsupported:"; @@ -253,12 +262,12 @@ TEST_F( } pPeakSet.powerDC = pPeakInitial.powerDC; if (pBurstSet.enabled && pSustainedSet.enabled) { - lzt::set_power_limits(p_power_handle, &pSustainedSet, &pBurstSet, + status = lzt::set_power_limits(p_power_handle, &pSustainedSet, &pBurstSet, &pPeakSet); // Set power values zes_power_sustained_limit_t pSustainedGet = {}; zes_power_burst_limit_t pBurstGet = {}; zes_power_peak_limit_t pPeakGet = {}; - lzt::get_power_limits(p_power_handle, &pSustainedGet, &pBurstGet, + status = lzt::get_power_limits(p_power_handle, &pSustainedGet, &pBurstGet, &pPeakGet); // Get power values EXPECT_EQ(pSustainedGet.enabled, pSustainedSet.enabled); EXPECT_EQ(pSustainedGet.power, pSustainedSet.power); @@ -272,7 +281,7 @@ TEST_F( EXPECT_EQ(pPeakGet.powerDC, pPeakSet.powerDC); // Verify whether values match or not } - lzt::set_power_limits(p_power_handle, &pSustainedInitial, + status = lzt::set_power_limits(p_power_handle, &pSustainedInitial, &pBurstInitial, &pPeakInitial); // Set values to default } else { @@ -321,7 +330,12 @@ TEST_F( for (auto p_power_handle : p_power_handles) { EXPECT_NE(nullptr, p_power_handle); - auto pThreshold = lzt::get_power_energy_threshold(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; + } ASSERT_GE(pThreshold.threshold, 0); if (pThreshold.threshold > 0) EXPECT_LT(pThreshold.processId, UINT32_MAX); @@ -343,8 +357,15 @@ TEST_F( for (auto p_power_handle : p_power_handles) { EXPECT_NE(nullptr, p_power_handle); - auto pThresholdInitial = lzt::get_power_energy_threshold(p_power_handle); - auto pThresholdLater = lzt::get_power_energy_threshold(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; + } + zes_energy_threshold_t pThresholdLater = {}; + status = + lzt::get_power_energy_threshold(p_power_handle, &pThresholdLater); EXPECT_EQ(pThresholdInitial.enable, pThresholdLater.enable); EXPECT_EQ(pThresholdInitial.threshold, pThresholdLater.threshold); EXPECT_EQ(pThresholdInitial.processId, pThresholdLater.processId); @@ -353,7 +374,7 @@ TEST_F( } TEST_F( POWER_TEST, - GivenValidPowerHandleWhenSettingEnergyValuesThenExpectzesSysmanPowerSetEnergyThresholdFollowedByzesSysmanPowerGetEnergyThresholdToMatch) { + GivenValidPowerHandleWhenSettingEnergyValuesThenExpectZesSysmanPowerSetEnergyThresholdFollowedByZesSysmanPowerGetEnergyThresholdToMatch) { for (auto device : devices) { uint32_t count = 0; auto p_power_handles = lzt::get_power_handles(device, count); @@ -364,13 +385,18 @@ TEST_F( for (auto p_power_handle : p_power_handles) { EXPECT_NE(nullptr, p_power_handle); - auto pThresholdInitial = - lzt::get_power_energy_threshold(p_power_handle); // get initial value + 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; + } double threshold = 0; lzt::set_power_energy_threshold(p_power_handle, threshold); // set test // value - auto pThresholdGet = - lzt::get_power_energy_threshold(p_power_handle); // get test value + zes_energy_threshold_t pThresholdGet = {}; + status = lzt::get_power_energy_threshold(p_power_handle, + &pThresholdGet); // get test value EXPECT_EQ(pThresholdGet.threshold, threshold); // match both the values EXPECT_EQ(pThresholdGet.processId, UINT32_MAX); lzt::set_power_energy_threshold( @@ -381,7 +407,7 @@ TEST_F( } TEST_F( POWER_TEST, - GivenValidPowerHandleWhenRequestingPowerLimitsThenExpectzesPowerGetLimitsExtToReturnSameValuesTwice) { + GivenValidPowerHandleWhenRequestingPowerLimitsThenExpectZesPowerGetLimitsExtToReturnSameValuesTwice) { for (auto device : devices) { uint32_t count = 0; auto p_power_handles = lzt::get_power_handles(device, count); @@ -404,8 +430,12 @@ TEST_F( zes_power_limit_ext_desc_t power_sustained_descriptor_second = {}; zes_power_limit_ext_desc_t power_instantaneous_descriptor_second = {}; - auto power_limits_descriptors_initial = - lzt::get_power_limits_ext(p_power_handle, &count_power); + 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; + } for (auto power_limits_descriptor_initial : power_limits_descriptors_initial) { if (power_limits_descriptor_initial.level == @@ -424,8 +454,9 @@ TEST_F( } } - auto power_limits_descriptors_final = - lzt::get_power_limits_ext(p_power_handle, &count_power); + std::vector power_limits_descriptors_final; + status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_final); for (auto power_limits_descriptor_final : power_limits_descriptors_final) { if (power_limits_descriptor_final.level == ZES_POWER_LEVEL_SUSTAINED) { @@ -471,8 +502,13 @@ TEST_F( zes_power_limit_ext_desc_t power_sustained_set = {}; - auto power_limits_descriptors = lzt::get_power_limits_ext( - p_power_handle, &count_power); // get power limits for all descriptors + 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; + } std::vector power_limits_descriptors_initial; // preserve initial power limit // descriptors for restoration @@ -492,15 +528,16 @@ TEST_F( if (power_sustained_set.level == ZES_POWER_LEVEL_SUSTAINED) { if (power_sustained_set.limitValueLocked == false) { - lzt::set_power_limits_ext( + status = lzt::set_power_limits_ext( p_power_handle, &count_power, power_limits_descriptors.data()); // set power limits for all // descriptors zes_power_limit_ext_desc_t power_sustained_get = {}; - auto power_limits_descriptors_get = - lzt::get_power_limits_ext(p_power_handle, &count_power); + std::vector power_limits_descriptors_get; + status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_get); for (const auto& p_power_limits_descriptor_get : power_limits_descriptors_get) { if (p_power_limits_descriptor_get.level == @@ -514,7 +551,7 @@ TEST_F( EXPECT_EQ(power_sustained_get.interval, power_sustained_set.interval); EXPECT_EQ(power_sustained_get.limit, power_sustained_set.limit); - lzt::set_power_limits_ext(p_power_handle, &count_power, + status = lzt::set_power_limits_ext(p_power_handle, &count_power, power_limits_descriptors_initial .data()); // restore initial limits } else { @@ -544,8 +581,13 @@ TEST_F( zes_power_limit_ext_desc_t power_peak_set = {}; - auto power_limits_descriptors = lzt::get_power_limits_ext( - p_power_handle, &count_power); // get power limits for all descriptors + 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; + } std::vector power_limits_descriptors_initial; // preserve initial power limit // descriptors for restoration @@ -562,15 +604,16 @@ TEST_F( } if (power_peak_set.limitValueLocked == false) { - lzt::set_power_limits_ext( + status = lzt::set_power_limits_ext( p_power_handle, &count_power, power_limits_descriptors.data()); // set power limits for all // descriptors zes_power_limit_ext_desc_t power_peak_get = {}; - auto power_limits_descriptors_get = - lzt::get_power_limits_ext(p_power_handle, &count_power); + std::vector power_limits_descriptors_get; + status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_get); for (const auto& p_power_limits_descriptor_get : power_limits_descriptors_get) { if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_PEAK) { @@ -583,7 +626,7 @@ TEST_F( EXPECT_EQ(power_peak_get.interval, power_peak_set.interval); EXPECT_EQ(power_peak_get.limit, power_peak_set.limit); - lzt::set_power_limits_ext( + status = lzt::set_power_limits_ext( p_power_handle, &count_power, power_limits_descriptors_initial.data()); // restore initial limits } else { @@ -610,8 +653,13 @@ TEST_F( zes_power_limit_ext_desc_t power_burst_set = {}; - auto power_limits_descriptors = lzt::get_power_limits_ext( - p_power_handle, &count_power); // get power limits for all descriptors + 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; + } std::vector power_limits_descriptors_initial; // preserve initial power limit // descriptors for restoration @@ -628,15 +676,16 @@ TEST_F( } if (power_burst_set.limitValueLocked == false) { - lzt::set_power_limits_ext( + status = lzt::set_power_limits_ext( p_power_handle, &count_power, power_limits_descriptors.data()); // set power limits for all // descriptors zes_power_limit_ext_desc_t power_burst_get = {}; - auto power_limits_descriptors_get = - lzt::get_power_limits_ext(p_power_handle, &count_power); + std::vector power_limits_descriptors_get; + status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_get); for (const auto& p_power_limits_descriptor_get : power_limits_descriptors_get) { if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_BURST) { @@ -649,7 +698,7 @@ TEST_F( EXPECT_EQ(power_burst_get.interval, power_burst_set.interval); EXPECT_EQ(power_burst_get.limit, power_burst_set.limit); - lzt::set_power_limits_ext( + status = lzt::set_power_limits_ext( p_power_handle, &count_power, power_limits_descriptors_initial.data()); // restore initial limits } else { @@ -676,8 +725,13 @@ TEST_F( zes_power_limit_ext_desc_t power_instantaneous_set = {}; - auto power_limits_descriptors = lzt::get_power_limits_ext( - p_power_handle, &count_power); // get power limits for all descriptors + 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; + } std::vector power_limits_descriptors_initial; // preserve initial power limit // descriptors for restoration @@ -696,15 +750,15 @@ TEST_F( } if (power_instantaneous_set.limitValueLocked == false) { - lzt::set_power_limits_ext( + status = lzt::set_power_limits_ext( p_power_handle, &count_power, power_limits_descriptors.data()); // set power limits for all // descriptors zes_power_limit_ext_desc_t power_instantaneous_get = {}; - auto power_limits_descriptors_get = - lzt::get_power_limits_ext(p_power_handle, &count_power); + std::vector power_limits_descriptors_get; + status = lzt::get_power_limits_ext(p_power_handle, &count_power, power_limits_descriptors_get); for (const auto& p_power_limits_descriptor_get : power_limits_descriptors_get) { if (p_power_limits_descriptor_get.level == @@ -719,7 +773,7 @@ TEST_F( power_instantaneous_set.interval); EXPECT_EQ(power_instantaneous_get.limit, power_instantaneous_set.limit); - lzt::set_power_limits_ext( + status = lzt::set_power_limits_ext( p_power_handle, &count_power, power_limits_descriptors_initial.data()); // restore initial limits } else { @@ -761,8 +815,12 @@ TEST_F( zes_power_limit_ext_desc_t power_burst_descriptor_later = {}; zes_power_limit_ext_desc_t power_sustained_descriptor_later = {}; zes_power_limit_ext_desc_t power_instantaneous_descriptor_later = {}; - auto power_limits_descriptors_initial = - lzt::get_power_limits_ext(p_power_handle, &count_power); + 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; + } for (auto power_limits_descriptor_initial : power_limits_descriptors_initial) { if (power_limits_descriptor_initial.level == ZES_POWER_LEVEL_SUSTAINED) { @@ -779,8 +837,9 @@ TEST_F( power_limits_descriptor_initial; } } - auto power_limits_descriptors_later = - lzt::get_power_limits_ext(p_power_handle, &count_power); + std::vector power_limits_descriptors_later; + status = lzt::get_power_limits_ext(p_power_handle, &count_power, + power_limits_descriptors_later); for (auto power_limits_descriptor_later : power_limits_descriptors_later) { if (power_limits_descriptor_later.level == ZES_POWER_LEVEL_SUSTAINED) { power_sustained_descriptor_later = power_limits_descriptor_later; @@ -849,8 +908,12 @@ TEST_F( 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 = {}; - auto power_limits_descriptors = - lzt::get_power_limits_ext(power_card_handle, &count_power); + std::vector power_limits_descriptors; + auto status = lzt::get_power_limits_ext(power_card_handle, &count_power, + power_limits_descriptors); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } for (int i = 0; i < power_limits_descriptors.size(); i++) { if (power_limits_descriptors[i].level == ZES_POWER_LEVEL_SUSTAINED) { sustained_limit_available = true; @@ -860,10 +923,11 @@ TEST_F( power_sustained_Initial.limit *= 2; if (power_sustained_Max.limitValueLocked == false) { - lzt::set_power_limits_ext(power_card_handle, &count_power, + status = lzt::set_power_limits_ext(power_card_handle, &count_power, &power_sustained_Max); - auto power_limits_descriptors_getMax = - lzt::get_power_limits_ext(power_card_handle, &count_power); + std::vector power_limits_descriptors_getMax; + status = lzt::get_power_limits_ext(power_card_handle, &count_power, + power_limits_descriptors_getMax); for (const auto& p_power_limits_descriptor_get : power_limits_descriptors_getMax) { if (p_power_limits_descriptor_get.level == @@ -871,10 +935,11 @@ TEST_F( power_sustained_getMax = p_power_limits_descriptor_get; } } - lzt::set_power_limits_ext(power_card_handle, &count_power, + status = lzt::set_power_limits_ext(power_card_handle, &count_power, &power_sustained_Initial); - auto power_limits_descriptors_get = - lzt::get_power_limits_ext(power_card_handle, &count_power); + std::vector power_limits_descriptors_get; + status = lzt::get_power_limits_ext(power_card_handle, &count_power, + power_limits_descriptors_get); for (const auto& p_power_limits_descriptor_get : power_limits_descriptors_get) { if (p_power_limits_descriptor_get.level == @@ -907,8 +972,12 @@ TEST_F( uint32_t single_count = 1; bool peak_limit_available = false; - auto power_limits_descriptors = - lzt::get_power_limits_ext(power_card_handle, &count_power); + std::vector power_limits_descriptors; + auto status = lzt::get_power_limits_ext(power_card_handle, &count_power, + power_limits_descriptors); + if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + continue; + } 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 = {}; @@ -923,10 +992,12 @@ TEST_F( power_peak_initial.limit *= 2; if (power_limits_descriptors[i].limitValueLocked == false) { - lzt::set_power_limits_ext(power_card_handle, &single_count, + status = lzt::set_power_limits_ext(power_card_handle, &single_count, &power_peak_Max); - auto power_limits_descriptors_getMax = - lzt::get_power_limits_ext(power_card_handle, &count_power); + std::vector + power_limits_descriptors_getMax; + status = lzt::get_power_limits_ext(power_card_handle, &count_power, + power_limits_descriptors_getMax); for (const auto& p_power_limits_descriptor_get : power_limits_descriptors_getMax) { if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_PEAK && @@ -934,10 +1005,11 @@ TEST_F( power_peak_getMax = p_power_limits_descriptor_get; } } - lzt::set_power_limits_ext(power_card_handle, &single_count, + status = lzt::set_power_limits_ext(power_card_handle, &single_count, &power_peak_initial); - auto power_limits_descriptors_get = - lzt::get_power_limits_ext(power_card_handle, &count_power); + std::vector power_limits_descriptors_get; + status = lzt::get_power_limits_ext(power_card_handle, &count_power, + power_limits_descriptors_get); for (const auto& p_power_limits_descriptor_get : power_limits_descriptors_get) { if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_PEAK && @@ -979,7 +1051,7 @@ TEST_F( zesPowerGetProperties(p_power_handle, &pProperties)); EXPECT_GT(pExtProperties.domain, ZES_POWER_DOMAIN_UNKNOWN); - EXPECT_LE(pExtProperties.domain, ZES_POWER_DOMAIN_STACK); + EXPECT_LE(pExtProperties.domain, ZES_POWER_DOMAIN_GPU); } } } diff --git a/utils/test_harness/sysman/include/test_harness_sysman_power.hpp b/utils/test_harness/sysman/include/test_harness_sysman_power.hpp index 0d1d1017..d82c3dbf 100644 --- a/utils/test_harness/sysman/include/test_harness_sysman_power.hpp +++ b/utils/test_harness/sysman/include/test_harness_sysman_power.hpp @@ -17,28 +17,28 @@ std::vector get_power_handles(zes_device_handle_t device, uint32_t &count); zes_pwr_handle_t get_card_power_handle(zes_device_handle_t device); zes_power_properties_t get_power_properties(zes_pwr_handle_t pPowerhandle); -void get_power_limits(zes_pwr_handle_t pPowerHandle, +ze_result_t get_power_limits(zes_pwr_handle_t pPowerHandle, zes_power_sustained_limit_t *pSustained, zes_power_burst_limit_t *pBurst, zes_power_peak_limit_t *pPeak); -void set_power_limits(zes_pwr_handle_t pPowerHandle, +ze_result_t set_power_limits(zes_pwr_handle_t pPowerHandle, zes_power_sustained_limit_t *pSustained, zes_power_burst_limit_t *pBurst, zes_power_peak_limit_t *pPeak); void get_power_energy_counter(zes_pwr_handle_t pPowerHandle, zes_power_energy_counter_t *pEnergy); -zes_energy_threshold_t -get_power_energy_threshold(zes_pwr_handle_t pPowerHandle); +ze_result_t get_power_energy_threshold(zes_pwr_handle_t pPowerHandle, + zes_energy_threshold_t *pThreshold); void set_power_energy_threshold(zes_pwr_handle_t pPowerHandle, double threshold); -std::vector -get_power_limits_ext(zes_pwr_handle_t hPower, uint32_t *pCount); -void set_power_limits_ext(zes_pwr_handle_t hPower, uint32_t *pCount, +ze_result_t get_power_limits_ext(zes_pwr_handle_t hPower, uint32_t *pCount, + std::vector &pPowerLimitsDescriptors); +ze_result_t set_power_limits_ext(zes_pwr_handle_t hPower, uint32_t *pCount, zes_power_limit_ext_desc_t *pSustained); void compare_power_descriptor_structures( zes_power_limit_ext_desc_t firstDescriptor, zes_power_limit_ext_desc_t secondDescriptor); -uint32_t get_power_limit_count(zes_pwr_handle_t hPower); +ze_result_t get_power_limit_count(zes_pwr_handle_t hPower, uint32_t *pCount); } // namespace level_zero_tests #endif diff --git a/utils/test_harness/sysman/src/test_harness_sysman_power.cpp b/utils/test_harness/sysman/src/test_harness_sysman_power.cpp index 2fb9ac28..f21432aa 100644 --- a/utils/test_harness/sysman/src/test_harness_sysman_power.cpp +++ b/utils/test_harness/sysman/src/test_harness_sysman_power.cpp @@ -44,29 +44,43 @@ zes_power_properties_t get_power_properties(zes_pwr_handle_t pPowerHandle) { zesPowerGetProperties(pPowerHandle, &pProperties)); return pProperties; } -uint32_t get_power_limit_count(zes_pwr_handle_t hPower) { - uint32_t pCount = 0; - EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerGetLimitsExt(hPower, &pCount, nullptr)); - EXPECT_GE(pCount, 0); - return pCount; +ze_result_t get_power_limit_count(zes_pwr_handle_t hPower, uint32_t *pCount) { + *pCount = 0; + ze_result_t status = zesPowerGetLimitsExt(hPower, pCount, nullptr); + if (status != ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + EXPECT_EQ(ZE_RESULT_SUCCESS, status); + EXPECT_GE(*pCount, 0); + } + return status; } -std::vector -get_power_limits_ext(zes_pwr_handle_t hPower, uint32_t *pCount) { - if (*pCount == 0) - *pCount = get_power_limit_count(hPower); - std::vector p_power_limits_descriptors(*pCount); - for (auto desc : p_power_limits_descriptors) { +ze_result_t +get_power_limits_ext(zes_pwr_handle_t hPower, uint32_t *pCount, + std::vector &pPowerLimitsDescriptors) { + if (*pCount == 0) { + ze_result_t status = get_power_limit_count(hPower, pCount); + if (status != ZE_RESULT_SUCCESS) { + return status; + } + } + pPowerLimitsDescriptors.resize(*pCount); + for (auto desc : pPowerLimitsDescriptors) { desc = {ZES_STRUCTURE_TYPE_POWER_LIMIT_EXT_DESC, nullptr}; } - EXPECT_EQ( - ZE_RESULT_SUCCESS, - zesPowerGetLimitsExt(hPower, pCount, p_power_limits_descriptors.data())); - return p_power_limits_descriptors; + ze_result_t status = + zesPowerGetLimitsExt(hPower, pCount, pPowerLimitsDescriptors.data()); + if (status != ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + EXPECT_EQ(ZE_RESULT_SUCCESS, status); + } + return status; } -void set_power_limits_ext(zes_pwr_handle_t hPower, uint32_t *pCount, +ze_result_t set_power_limits_ext(zes_pwr_handle_t hPower, uint32_t *pCount, zes_power_limit_ext_desc_t *pSustained) { - EXPECT_EQ(ZE_RESULT_SUCCESS, - zesPowerSetLimitsExt(hPower, pCount, pSustained)); + ze_result_t status = + zesPowerSetLimitsExt(hPower, pCount, pSustained); + if (status != ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + EXPECT_EQ(ZE_RESULT_SUCCESS, status); + } + return status; } void compare_power_descriptor_structures( zes_power_limit_ext_desc_t firstDescriptor, @@ -85,30 +99,39 @@ void compare_power_descriptor_structures( secondDescriptor.limitValueLocked); EXPECT_EQ(firstDescriptor.limit, secondDescriptor.limit); } -void get_power_limits(zes_pwr_handle_t pPowerHandle, +ze_result_t get_power_limits(zes_pwr_handle_t pPowerHandle, zes_power_sustained_limit_t *pSustained, zes_power_burst_limit_t *pBurst, zes_power_peak_limit_t *pPeak) { - EXPECT_EQ(ZE_RESULT_SUCCESS, - zesPowerGetLimits(pPowerHandle, pSustained, pBurst, pPeak)); + ze_result_t status = + zesPowerGetLimits(pPowerHandle, pSustained, pBurst, pPeak); + if (status != ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + EXPECT_EQ(ZE_RESULT_SUCCESS, status); + } + return status; } -void set_power_limits(zes_pwr_handle_t pPowerHandle, +ze_result_t set_power_limits(zes_pwr_handle_t pPowerHandle, zes_power_sustained_limit_t *pSustained, zes_power_burst_limit_t *pBurst, zes_power_peak_limit_t *pPeak) { - EXPECT_EQ(ZE_RESULT_SUCCESS, - zesPowerSetLimits(pPowerHandle, pSustained, pBurst, pPeak)); + ze_result_t status = + zesPowerSetLimits(pPowerHandle, pSustained, pBurst, pPeak); + if (status != ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + EXPECT_EQ(ZE_RESULT_SUCCESS, status); + } + return status; } void get_power_energy_counter(zes_pwr_handle_t pPowerHandle, zes_power_energy_counter_t *pEnergy) { EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerGetEnergyCounter(pPowerHandle, pEnergy)); } -zes_energy_threshold_t -get_power_energy_threshold(zes_pwr_handle_t pPowerHandle) { - zes_energy_threshold_t pThreshold = {}; - EXPECT_EQ(ZE_RESULT_SUCCESS, - zesPowerGetEnergyThreshold(pPowerHandle, &pThreshold)); - return pThreshold; +ze_result_t get_power_energy_threshold(zes_pwr_handle_t pPowerHandle, + zes_energy_threshold_t *pThreshold) { + ze_result_t status = zesPowerGetEnergyThreshold(pPowerHandle, pThreshold); + if (status != ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) { + EXPECT_EQ(ZE_RESULT_SUCCESS, status); + } + return status; } void set_power_energy_threshold(zes_pwr_handle_t pPowerHandle, double threshold) {