diff --git a/shared/source/command_stream/command_stream_receiver_hw_base.inl b/shared/source/command_stream/command_stream_receiver_hw_base.inl index be7d871f50..4b8016b08d 100644 --- a/shared/source/command_stream/command_stream_receiver_hw_base.inl +++ b/shared/source/command_stream/command_stream_receiver_hw_base.inl @@ -1442,7 +1442,7 @@ inline bool CommandStreamReceiverHw::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()); } } } diff --git a/shared/source/execution_environment/execution_environment.cpp b/shared/source/execution_environment/execution_environment.cpp index 1bfd2be044..08d97f14d5 100644 --- a/shared/source/execution_environment/execution_environment.cpp +++ b/shared/source/execution_environment/execution_environment.cpp @@ -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(); } diff --git a/shared/source/execution_environment/root_device_environment.cpp b/shared/source/execution_environment/root_device_environment.cpp index f38b560d99..0c9d306808 100644 --- a/shared/source/execution_environment/root_device_environment.cpp +++ b/shared/source/execution_environment/root_device_environment.cpp @@ -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 { diff --git a/shared/source/utilities/wait_util.cpp b/shared/source/utilities/wait_util.cpp index 65331f4b59..179d521eb5 100644 --- a/shared/source/utilities/wait_util.cpp +++ b/shared/source/utilities/wait_util.cpp @@ -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; } diff --git a/shared/source/utilities/wait_util.h b/shared/source/utilities/wait_util.h index 2c02a4ddb9..7b0e361288 100644 --- a/shared/source/utilities/wait_util.h +++ b/shared/source/utilities/wait_util.h @@ -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(pollAddress, expectedValue, std::greater_equal(), timeElapsedSinceWaitStarted); } -void init(WaitpkgUse inputWaitpkgUse); +void init(WaitpkgUse inputWaitpkgUse, const HardwareInfo &hwInfo); } // namespace WaitUtils } // namespace NEO diff --git a/shared/test/unit_test/utilities/wait_util_tests.cpp b/shared/test/unit_test/utilities/wait_util_tests.cpp index 111ce0d006..ed7bf4b76a 100644 --- a/shared/test/unit_test/utilities/wait_util_tests.cpp +++ b/shared/test/unit_test/utilities/wait_util_tests.cpp @@ -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; 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; diff --git a/shared/test/unit_test/utilities/x86_64/wait_util_tests_x86_64.cpp b/shared/test/unit_test/utilities/x86_64/wait_util_tests_x86_64.cpp index 991ff46dfa..dafdde01f9 100644 --- a/shared/test/unit_test/utilities/x86_64/wait_util_tests_x86_64.cpp +++ b/shared/test/unit_test/utilities/x86_64/wait_util_tests_x86_64.cpp @@ -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) {