performance: Adjust waitpkg threshold for discrete devices

Related-To: NEO-14336

Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
Lukasz Jobczyk
2025-03-26 12:53:38 +00:00
committed by Compute-Runtime-Automation
parent a89113fa1a
commit 60b551758c
7 changed files with 45 additions and 34 deletions

View File

@@ -1442,7 +1442,7 @@ inline bool CommandStreamReceiverHw<GfxFamily>::initDirectSubmission() {
this->osContext->setDirectSubmissionActive();
if (this->osContext->isDirectSubmissionLightActive()) {
this->pushAllocationsForMakeResident = false;
WaitUtils::init(WaitUtils::WaitpkgUse::tpause);
WaitUtils::init(WaitUtils::WaitpkgUse::tpause, *this->peekExecutionEnvironment().rootDeviceEnvironments[this->getRootDeviceIndex()]->getHardwareInfo());
}
}
}

View File

@@ -26,11 +26,9 @@
#include "shared/source/os_interface/os_environment.h"
#include "shared/source/os_interface/os_interface.h"
#include "shared/source/os_interface/product_helper.h"
#include "shared/source/utilities/wait_util.h"
namespace NEO {
ExecutionEnvironment::ExecutionEnvironment() {
WaitUtils::init(WaitUtils::WaitpkgUse::tpause);
this->configureNeoEnvironment();
}

View File

@@ -36,6 +36,7 @@
#include "shared/source/release_helper/release_helper.h"
#include "shared/source/sip_external_lib/sip_external_lib.h"
#include "shared/source/utilities/software_tags_manager.h"
#include "shared/source/utilities/wait_util.h"
namespace NEO {
@@ -85,6 +86,8 @@ void RootDeviceEnvironment::setHwInfo(const HardwareInfo *hwInfo) {
if (debugManager.flags.DisableSupportForL0Debugger.get() == 1) {
this->hwInfo->capabilityTable.l0DebuggerSupported = false;
}
WaitUtils::init(WaitUtils::WaitpkgUse::tpause, *hwInfo);
}
bool RootDeviceEnvironment::isFullRangeSvm() const {

View File

@@ -8,6 +8,7 @@
#include "shared/source/utilities/wait_util.h"
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/helpers/hw_info.h"
#include "shared/source/utilities/cpu_info.h"
namespace NEO {
@@ -27,7 +28,7 @@ bool waitpkgSupport = SUPPORTS_WAITPKG;
bool waitpkgSupport = false;
#endif
void init(WaitpkgUse inputWaitpkgUse) {
void init(WaitpkgUse inputWaitpkgUse, const HardwareInfo &hwInfo) {
if (debugManager.flags.WaitLoopCount.get() != -1) {
waitCount = debugManager.flags.WaitLoopCount.get();
}
@@ -47,6 +48,10 @@ void init(WaitpkgUse inputWaitpkgUse) {
waitpkgUse = inputWaitpkgUse;
if (!hwInfo.capabilityTable.isIntegratedDevice) {
waitPkgThresholdInMicroSeconds = WaitUtils::defaultWaitPkgThresholdForDiscreteInMicroSeconds;
}
if (waitpkgUse == WaitpkgUse::umonitorAndUmwait) {
waitCount = 0u;
}

View File

@@ -15,6 +15,8 @@
namespace NEO {
struct HardwareInfo;
namespace WaitUtils {
enum class WaitpkgUse : int32_t {
@@ -25,6 +27,7 @@ enum class WaitpkgUse : int32_t {
};
constexpr int64_t defaultWaitPkgThresholdInMicroSeconds = 12;
constexpr int64_t defaultWaitPkgThresholdForDiscreteInMicroSeconds = 28;
constexpr uint64_t defaultCounterValue = 16000;
constexpr uint32_t defaultControlValue = 0;
constexpr uint32_t defaultWaitCount = 1u;
@@ -77,7 +80,7 @@ inline bool waitFunction(volatile TagAddressType *pollAddress, TaskCountType exp
return waitFunctionWithPredicate<TaskCountType>(pollAddress, expectedValue, std::greater_equal<TaskCountType>(), timeElapsedSinceWaitStarted);
}
void init(WaitpkgUse inputWaitpkgUse);
void init(WaitpkgUse inputWaitpkgUse, const HardwareInfo &hwInfo);
} // namespace WaitUtils
} // namespace NEO

View File

@@ -7,6 +7,7 @@
#include "shared/source/utilities/wait_util.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/default_hw_info.h"
#include "shared/test/common/helpers/variable_backup.h"
#include "shared/test/common/test_macros/hw_test.h"
@@ -35,7 +36,7 @@ using WaitPredicateOnlyTest = Test<WaitPredicateOnlyFixture>;
TEST_F(WaitPredicateOnlyTest, givenDefaultSettingsWhenNoPollAddressProvidedThenPauseDefaultTimeAndReturnFalse) {
EXPECT_EQ(1u, WaitUtils::defaultWaitCount);
WaitUtils::init(WaitUtils::WaitpkgUse::noUse);
WaitUtils::init(WaitUtils::WaitpkgUse::noUse, *defaultHwInfo);
EXPECT_EQ(WaitUtils::defaultWaitCount, WaitUtils::waitCount);
uint32_t oldCount = CpuIntrinsicsTests::pauseCounter.load();
@@ -48,7 +49,7 @@ TEST_F(WaitPredicateOnlyTest, givenDebugFlagOverridesWhenNoPollAddressProvidedTh
uint32_t count = 10u;
debugManager.flags.WaitLoopCount.set(count);
WaitUtils::init(WaitUtils::WaitpkgUse::noUse);
WaitUtils::init(WaitUtils::WaitpkgUse::noUse, *defaultHwInfo);
EXPECT_EQ(count, WaitUtils::waitCount);
uint32_t oldCount = CpuIntrinsicsTests::pauseCounter.load();
@@ -58,7 +59,7 @@ TEST_F(WaitPredicateOnlyTest, givenDebugFlagOverridesWhenNoPollAddressProvidedTh
}
TEST_F(WaitPredicateOnlyTest, givenDefaultSettingsWhenPollAddressProvidedDoesNotMeetCriteriaThenPauseDefaultTimeAndReturnFalse) {
WaitUtils::init(WaitUtils::WaitpkgUse::noUse);
WaitUtils::init(WaitUtils::WaitpkgUse::noUse, *defaultHwInfo);
EXPECT_EQ(WaitUtils::defaultWaitCount, WaitUtils::waitCount);
volatile TagAddressType pollValue = 1u;
@@ -71,7 +72,7 @@ TEST_F(WaitPredicateOnlyTest, givenDefaultSettingsWhenPollAddressProvidedDoesNot
}
TEST_F(WaitPredicateOnlyTest, givenDefaultSettingsWhenPollAddressProvidedMeetsCriteriaThenPauseDefaultTimeAndReturnTrue) {
WaitUtils::init(WaitUtils::WaitpkgUse::noUse);
WaitUtils::init(WaitUtils::WaitpkgUse::noUse, *defaultHwInfo);
EXPECT_EQ(WaitUtils::defaultWaitCount, WaitUtils::waitCount);
volatile TagAddressType pollValue = 3u;
@@ -87,7 +88,7 @@ TEST_F(WaitPredicateOnlyTest, givenDebugFlagSetZeroWhenPollAddressProvidedMeetsC
uint32_t count = 0u;
debugManager.flags.WaitLoopCount.set(count);
WaitUtils::init(WaitUtils::WaitpkgUse::noUse);
WaitUtils::init(WaitUtils::WaitpkgUse::noUse, *defaultHwInfo);
EXPECT_EQ(count, WaitUtils::waitCount);
volatile TagAddressType pollValue = 3u;

View File

@@ -7,6 +7,7 @@
#include "shared/source/utilities/wait_util.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/default_hw_info.h"
#include "shared/test/common/helpers/variable_backup.h"
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "shared/test/common/test_macros/hw_test.h"
@@ -83,7 +84,7 @@ struct WaitPkgEnabledFixture : public WaitPkgFixture {
CpuInfo::cpuidFunc = mockCpuidEnableAll;
WaitUtils::waitpkgSupport = true;
WaitUtils::init(WaitUtils::WaitpkgUse::noUse);
WaitUtils::init(WaitUtils::WaitpkgUse::noUse, *defaultHwInfo);
CpuIntrinsicsTests::lastUmwaitCounter = 0;
CpuIntrinsicsTests::lastUmwaitControl = 0;
@@ -120,7 +121,7 @@ TEST_F(WaitPkgTest, givenDefaultSettingsAndWaitpkgSupportTrueWhenWaitInitialized
WaitUtils::waitpkgSupport = true;
WaitUtils::init(WaitUtils::WaitpkgUse::noUse);
WaitUtils::init(WaitUtils::WaitpkgUse::noUse, *defaultHwInfo);
EXPECT_EQ(WaitUtils::defaultWaitCount, WaitUtils::waitCount);
EXPECT_EQ(16000u, WaitUtils::waitpkgCounterValue);
EXPECT_EQ(0u, WaitUtils::waitpkgControlValue);
@@ -132,7 +133,7 @@ TEST_F(WaitPkgTest, givenEnabledWaitPkgSettingsAndWaitpkgSupportFalseWhenWaitIni
debugManager.flags.EnableWaitpkg.set(1);
WaitUtils::init(WaitUtils::WaitpkgUse::noUse);
WaitUtils::init(WaitUtils::WaitpkgUse::noUse, *defaultHwInfo);
EXPECT_EQ(WaitUtils::defaultWaitCount, WaitUtils::waitCount);
EXPECT_EQ(16000u, WaitUtils::waitpkgCounterValue);
EXPECT_EQ(0u, WaitUtils::waitpkgControlValue);
@@ -145,7 +146,7 @@ TEST_F(WaitPkgTest, givenDisabledWaitPkgSettingsAndWaitpkgSupportTrueWhenWaitIni
debugManager.flags.EnableWaitpkg.set(0);
WaitUtils::init(WaitUtils::WaitpkgUse::noUse);
WaitUtils::init(WaitUtils::WaitpkgUse::noUse, *defaultHwInfo);
EXPECT_EQ(WaitUtils::defaultWaitCount, WaitUtils::waitCount);
EXPECT_EQ(16000u, WaitUtils::waitpkgCounterValue);
EXPECT_EQ(0u, WaitUtils::waitpkgControlValue);
@@ -160,7 +161,7 @@ TEST_F(WaitPkgTest, givenEnabledWaitPkgSettingsAndWaitpkgSupportTrueWhenWaitInit
debugManager.flags.EnableWaitpkg.set(1);
WaitUtils::init(WaitUtils::WaitpkgUse::noUse);
WaitUtils::init(WaitUtils::WaitpkgUse::noUse, *defaultHwInfo);
EXPECT_EQ(WaitUtils::defaultWaitCount, WaitUtils::waitCount);
EXPECT_EQ(16000u, WaitUtils::waitpkgCounterValue);
EXPECT_EQ(0u, WaitUtils::waitpkgControlValue);
@@ -175,13 +176,13 @@ TEST_F(WaitPkgTest, givenEnabledWaitPkgSettingsAndWaitpkgSupportTrueWhenWaitInit
debugManager.flags.EnableWaitpkg.set(1);
WaitUtils::init(WaitUtils::WaitpkgUse::noUse);
WaitUtils::init(WaitUtils::WaitpkgUse::noUse, *defaultHwInfo);
EXPECT_EQ(0u, WaitUtils::waitCount);
EXPECT_EQ(16000u, WaitUtils::waitpkgCounterValue);
EXPECT_EQ(0u, WaitUtils::waitpkgControlValue);
EXPECT_EQ(WaitUtils::waitpkgUse, WaitUtils::WaitpkgUse::umonitorAndUmwait);
EXPECT_EQ(12, WaitUtils::waitPkgThresholdInMicroSeconds);
EXPECT_EQ(defaultHwInfo->capabilityTable.isIntegratedDevice ? 12 : 28, WaitUtils::waitPkgThresholdInMicroSeconds);
}
TEST_F(WaitPkgTest, givenEnabledWaitPkgSetToTpauseAndWaitpkgSupportTrueWhenWaitInitializedAndCpuSupportsOperandThenWaitPkgEnabled) {
@@ -191,16 +192,16 @@ TEST_F(WaitPkgTest, givenEnabledWaitPkgSetToTpauseAndWaitpkgSupportTrueWhenWaitI
debugManager.flags.EnableWaitpkg.set(2);
WaitUtils::init(WaitUtils::WaitpkgUse::noUse);
WaitUtils::init(WaitUtils::WaitpkgUse::noUse, *defaultHwInfo);
EXPECT_EQ(1u, WaitUtils::waitCount);
EXPECT_EQ(16000u, WaitUtils::waitpkgCounterValue);
EXPECT_EQ(0u, WaitUtils::waitpkgControlValue);
EXPECT_EQ(WaitUtils::waitpkgUse, WaitUtils::WaitpkgUse::tpause);
EXPECT_EQ(12, WaitUtils::waitPkgThresholdInMicroSeconds);
EXPECT_EQ(defaultHwInfo->capabilityTable.isIntegratedDevice ? 12 : 28, WaitUtils::waitPkgThresholdInMicroSeconds);
}
TEST_F(WaitPkgTest, givenWaitpkgSupportTrueWhenCreateExecutionEnvironmentThenWaitPkgEnabled) {
TEST_F(WaitPkgTest, givenWaitpkgSupportTrueWhenSetHwInfoThenWaitPkgEnabled) {
CpuInfo::cpuidFunc = mockCpuidEnableAll;
WaitUtils::waitpkgSupport = true;
@@ -211,7 +212,7 @@ TEST_F(WaitPkgTest, givenWaitpkgSupportTrueWhenCreateExecutionEnvironmentThenWai
EXPECT_EQ(16000u, WaitUtils::waitpkgCounterValue);
EXPECT_EQ(0u, WaitUtils::waitpkgControlValue);
EXPECT_EQ(WaitUtils::waitpkgUse, WaitUtils::WaitpkgUse::tpause);
EXPECT_EQ(12, WaitUtils::waitPkgThresholdInMicroSeconds);
EXPECT_EQ(defaultHwInfo->capabilityTable.isIntegratedDevice ? 12 : 28, WaitUtils::waitPkgThresholdInMicroSeconds);
}
TEST_F(WaitPkgTest, givenEnabledWaitPkgSetToTpauseAndWaitpkgThresholdAndWaitpkgSupportTrueWhenWaitInitializedAndCpuSupportsOperandThenWaitPkgEnabled) {
@@ -222,7 +223,7 @@ TEST_F(WaitPkgTest, givenEnabledWaitPkgSetToTpauseAndWaitpkgThresholdAndWaitpkgS
debugManager.flags.EnableWaitpkg.set(2);
debugManager.flags.WaitpkgThreshold.set(56789);
WaitUtils::init(WaitUtils::WaitpkgUse::noUse);
WaitUtils::init(WaitUtils::WaitpkgUse::noUse, *defaultHwInfo);
EXPECT_EQ(1u, WaitUtils::waitCount);
EXPECT_EQ(16000u, WaitUtils::waitpkgCounterValue);
@@ -236,13 +237,13 @@ TEST_F(WaitPkgTest, givenEnabledSetToTrueAndWaitpkgSupportTrueWhenWaitInitialize
WaitUtils::waitpkgSupport = true;
WaitUtils::init(WaitUtils::WaitpkgUse::umonitorAndUmwait);
WaitUtils::init(WaitUtils::WaitpkgUse::umonitorAndUmwait, *defaultHwInfo);
EXPECT_EQ(0u, WaitUtils::waitCount);
EXPECT_EQ(16000u, WaitUtils::waitpkgCounterValue);
EXPECT_EQ(0u, WaitUtils::waitpkgControlValue);
EXPECT_EQ(WaitUtils::waitpkgUse, WaitUtils::WaitpkgUse::umonitorAndUmwait);
EXPECT_EQ(12, WaitUtils::waitPkgThresholdInMicroSeconds);
EXPECT_EQ(defaultHwInfo->capabilityTable.isIntegratedDevice ? 12 : 28, WaitUtils::waitPkgThresholdInMicroSeconds);
}
TEST_F(WaitPkgTest, givenEnabledSetToTpauseAndWaitpkgSupportTrueWhenWaitInitializedAndCpuSupportsOperandThenWaitPkgEnabled) {
@@ -250,13 +251,13 @@ TEST_F(WaitPkgTest, givenEnabledSetToTpauseAndWaitpkgSupportTrueWhenWaitInitiali
WaitUtils::waitpkgSupport = true;
WaitUtils::init(WaitUtils::WaitpkgUse::tpause);
WaitUtils::init(WaitUtils::WaitpkgUse::tpause, *defaultHwInfo);
EXPECT_EQ(1u, WaitUtils::waitCount);
EXPECT_EQ(16000u, WaitUtils::waitpkgCounterValue);
EXPECT_EQ(0u, WaitUtils::waitpkgControlValue);
EXPECT_EQ(WaitUtils::waitpkgUse, WaitUtils::WaitpkgUse::tpause);
EXPECT_EQ(12, WaitUtils::waitPkgThresholdInMicroSeconds);
EXPECT_EQ(defaultHwInfo->capabilityTable.isIntegratedDevice ? 12 : 28, WaitUtils::waitPkgThresholdInMicroSeconds);
}
TEST_F(WaitPkgTest, givenFullyEnabledWaitPkgAndOverrideCounterValueWhenWaitInitializedThenNewCounterValueSet) {
@@ -267,12 +268,12 @@ TEST_F(WaitPkgTest, givenFullyEnabledWaitPkgAndOverrideCounterValueWhenWaitIniti
debugManager.flags.EnableWaitpkg.set(1);
debugManager.flags.WaitpkgCounterValue.set(1234);
WaitUtils::init(WaitUtils::WaitpkgUse::noUse);
WaitUtils::init(WaitUtils::WaitpkgUse::noUse, *defaultHwInfo);
EXPECT_EQ(0u, WaitUtils::waitCount);
EXPECT_EQ(1234u, WaitUtils::waitpkgCounterValue);
EXPECT_EQ(0u, WaitUtils::waitpkgControlValue);
EXPECT_EQ(WaitUtils::waitpkgUse, WaitUtils::WaitpkgUse::umonitorAndUmwait);
EXPECT_EQ(12, WaitUtils::waitPkgThresholdInMicroSeconds);
EXPECT_EQ(defaultHwInfo->capabilityTable.isIntegratedDevice ? 12 : 28, WaitUtils::waitPkgThresholdInMicroSeconds);
}
TEST_F(WaitPkgTest, givenFullyEnabledWaitPkgAndOverrideControlValueWhenWaitInitializedThenNewControlValueSet) {
@@ -283,12 +284,12 @@ TEST_F(WaitPkgTest, givenFullyEnabledWaitPkgAndOverrideControlValueWhenWaitIniti
debugManager.flags.EnableWaitpkg.set(1);
debugManager.flags.WaitpkgControlValue.set(1);
WaitUtils::init(WaitUtils::WaitpkgUse::noUse);
WaitUtils::init(WaitUtils::WaitpkgUse::noUse, *defaultHwInfo);
EXPECT_EQ(0u, WaitUtils::waitCount);
EXPECT_EQ(16000u, WaitUtils::waitpkgCounterValue);
EXPECT_EQ(1u, WaitUtils::waitpkgControlValue);
EXPECT_EQ(WaitUtils::waitpkgUse, WaitUtils::WaitpkgUse::umonitorAndUmwait);
EXPECT_EQ(12, WaitUtils::waitPkgThresholdInMicroSeconds);
EXPECT_EQ(defaultHwInfo->capabilityTable.isIntegratedDevice ? 12 : 28, WaitUtils::waitPkgThresholdInMicroSeconds);
}
TEST_F(WaitPkgTest, givenEnabledWaitPkgSettingsAndWaitpkgSupportTrueWhenWaitInitializedTwiceThenInitOnce) {
@@ -296,23 +297,23 @@ TEST_F(WaitPkgTest, givenEnabledWaitPkgSettingsAndWaitpkgSupportTrueWhenWaitInit
WaitUtils::waitpkgSupport = true;
WaitUtils::init(WaitUtils::WaitpkgUse::umonitorAndUmwait);
WaitUtils::init(WaitUtils::WaitpkgUse::umonitorAndUmwait, *defaultHwInfo);
EXPECT_EQ(0u, WaitUtils::waitCount);
EXPECT_EQ(16000u, WaitUtils::waitpkgCounterValue);
EXPECT_EQ(0u, WaitUtils::waitpkgControlValue);
EXPECT_EQ(WaitUtils::waitpkgUse, WaitUtils::WaitpkgUse::umonitorAndUmwait);
EXPECT_EQ(12, WaitUtils::waitPkgThresholdInMicroSeconds);
EXPECT_EQ(defaultHwInfo->capabilityTable.isIntegratedDevice ? 12 : 28, WaitUtils::waitPkgThresholdInMicroSeconds);
debugManager.flags.WaitpkgControlValue.set(1);
WaitUtils::init(WaitUtils::WaitpkgUse::umonitorAndUmwait);
WaitUtils::init(WaitUtils::WaitpkgUse::umonitorAndUmwait, *defaultHwInfo);
EXPECT_EQ(0u, WaitUtils::waitCount);
EXPECT_EQ(16000u, WaitUtils::waitpkgCounterValue);
EXPECT_EQ(0u, WaitUtils::waitpkgControlValue);
EXPECT_EQ(WaitUtils::waitpkgUse, WaitUtils::WaitpkgUse::umonitorAndUmwait);
EXPECT_EQ(12, WaitUtils::waitPkgThresholdInMicroSeconds);
EXPECT_EQ(defaultHwInfo->capabilityTable.isIntegratedDevice ? 12 : 28, WaitUtils::waitPkgThresholdInMicroSeconds);
}
TEST_F(WaitPkgEnabledTest, givenMonitoredAddressChangedWhenAddressMatchesPredicateValueThenWaitReturnsTrue) {