diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index a72b9f293d..9d05736da8 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -313,8 +313,9 @@ DECLARE_DEBUG_VARIABLE(int32_t, EnableRingSwitchTagUpdateWa, -1, "-1: default, 0 DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionReadBackCommandBuffer, -1, "-1: default - disabled, 0 - disable, 1 - enable. If enabled, read first dword of cmd buffer after handling residency.") DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionReadBackRingBuffer, -1, "-1: default - disabled, 0 - disable, 1 - enable. If enabled, read first dword of ring buffer after handling residency.") DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionInsertExtraMiMemFenceCommands, -1, "-1: default, 0 - disable, 1 - enable. If enabled, add extra MI_MEM_FENCE instructions with acquire bit set") -DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionInsertSfenceInstructionPriorToSubmission, -1, "-1: default, 0 - disable, 1 - Instert _mm_sfence before unlocking semaphore only, 2 - insert before and after semaphore") +DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionInsertSfenceInstructionPriorToSubmission, -1, "-1: default, 0 - disable, 1 - Insert _mm_sfence before unlocking semaphore only, 2 - insert before and after semaphore") DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionMaxRingBuffers, -1, "-1: default, >0: max ring buffer count, During switch ring buffer, if there is no available ring, wait for completion instead of allocating new one if DirectSubmissionMaxRingBuffers is reached") +DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionDisablePrefetcher, -1, "-1: default, 0 - disable, 1 - enable. If enabled, disable prefetcher is being dispatched") DECLARE_DEBUG_VARIABLE(bool, DirectSubmissionPrintBuffers, false, "Print address of submitted command buffers") /*FEATURE FLAGS*/ diff --git a/shared/source/direct_submission/direct_submission_hw.h b/shared/source/direct_submission/direct_submission_hw.h index 848fb603b7..43f1128b06 100644 --- a/shared/source/direct_submission/direct_submission_hw.h +++ b/shared/source/direct_submission/direct_submission_hw.h @@ -202,5 +202,6 @@ class DirectSubmissionHw { bool miMemFenceRequired = false; bool systemMemoryFenceAddressSet = false; bool completionFenceSupported = false; + bool isDisablePrefetcherRequired = false; }; } // namespace NEO diff --git a/shared/source/direct_submission/direct_submission_hw.inl b/shared/source/direct_submission/direct_submission_hw.inl index b0f9da4dd5..168017b332 100644 --- a/shared/source/direct_submission/direct_submission_hw.inl +++ b/shared/source/direct_submission/direct_submission_hw.inl @@ -65,6 +65,11 @@ DirectSubmissionHw::DirectSubmissionHw(const DirectSubmis disableCpuCacheFlush = disableCacheFlushKey == 1 ? true : false; } + isDisablePrefetcherRequired = hwInfoConfig->isPrefetcherDisablingInDirectSubmissionRequired(); + if (DebugManager.flags.DirectSubmissionDisablePrefetcher.get() != -1) { + isDisablePrefetcherRequired = !!DebugManager.flags.DirectSubmissionDisablePrefetcher.get(); + } + UNRECOVERABLE_IF(!CpuInfo::getInstance().isFeatureSupported(CpuInfo::featureClflush) && !disableCpuCacheFlush); createDiagnostic(); @@ -298,7 +303,10 @@ template inline size_t DirectSubmissionHw::getSizeSemaphoreSection() { size_t semaphoreSize = EncodeSempahore::getSizeMiSemaphoreWait(); semaphoreSize += getSizePrefetchMitigation(); - semaphoreSize += 2 * getSizeDisablePrefetcher(); + + if (isDisablePrefetcherRequired) { + semaphoreSize += 2 * getSizeDisablePrefetcher(); + } if (miMemFenceRequired) { semaphoreSize += MemorySynchronizationCommands::getSizeForSingleAdditionalSynchronizationForDirectSubmission(*hwInfo); diff --git a/shared/source/direct_submission/direct_submission_prefetcher_pvc_and_later.inl b/shared/source/direct_submission/direct_submission_prefetcher_pvc_and_later.inl index 17fe69d3d1..7baa553c97 100644 --- a/shared/source/direct_submission/direct_submission_prefetcher_pvc_and_later.inl +++ b/shared/source/direct_submission/direct_submission_prefetcher_pvc_and_later.inl @@ -13,13 +13,15 @@ template inline void DirectSubmissionHw::dispatchDisablePrefetcher(bool disable) { using MI_ARB_CHECK = typename GfxFamily::MI_ARB_CHECK; - MI_ARB_CHECK arbCheck = GfxFamily::cmdInitArbCheck; - arbCheck.setPreParserDisable(disable); + if (isDisablePrefetcherRequired) { + MI_ARB_CHECK arbCheck = GfxFamily::cmdInitArbCheck; + arbCheck.setPreParserDisable(disable); - EncodeMiArbCheck::adjust(arbCheck); + EncodeMiArbCheck::adjust(arbCheck); - MI_ARB_CHECK *arbCheckSpace = ringCommandStream.getSpaceForCmd(); - *arbCheckSpace = arbCheck; + MI_ARB_CHECK *arbCheckSpace = ringCommandStream.getSpaceForCmd(); + *arbCheckSpace = arbCheck; + } } -} // namespace NEO \ No newline at end of file +} // namespace NEO diff --git a/shared/source/direct_submission/direct_submission_prefetcher_xe_hp_core_and_later.inl b/shared/source/direct_submission/direct_submission_prefetcher_xe_hp_core_and_later.inl index 46481debfb..686761b204 100644 --- a/shared/source/direct_submission/direct_submission_prefetcher_xe_hp_core_and_later.inl +++ b/shared/source/direct_submission/direct_submission_prefetcher_xe_hp_core_and_later.inl @@ -13,13 +13,15 @@ template inline void DirectSubmissionHw::dispatchDisablePrefetcher(bool disable) { using MI_ARB_CHECK = typename GfxFamily::MI_ARB_CHECK; - MI_ARB_CHECK arbCheck = GfxFamily::cmdInitArbCheck; - arbCheck.setPreFetchDisable(disable); + if (isDisablePrefetcherRequired) { + MI_ARB_CHECK arbCheck = GfxFamily::cmdInitArbCheck; + arbCheck.setPreFetchDisable(disable); - EncodeMiArbCheck::adjust(arbCheck); + EncodeMiArbCheck::adjust(arbCheck); - MI_ARB_CHECK *arbCheckSpace = ringCommandStream.getSpaceForCmd(); - *arbCheckSpace = arbCheck; + MI_ARB_CHECK *arbCheckSpace = ringCommandStream.getSpaceForCmd(); + *arbCheckSpace = arbCheck; + } } -} // namespace NEO \ No newline at end of file +} // namespace NEO diff --git a/shared/source/os_interface/hw_info_config.h b/shared/source/os_interface/hw_info_config.h index a9bea81957..2a8f90db1d 100644 --- a/shared/source/os_interface/hw_info_config.h +++ b/shared/source/os_interface/hw_info_config.h @@ -133,6 +133,7 @@ class HwInfoConfig { virtual uint32_t getL1CachePolicy() const = 0; virtual bool isEvictionWhenNecessaryFlagSupported() const = 0; virtual void adjustNumberOfCcs(HardwareInfo &hwInfo) const = 0; + virtual bool isPrefetcherDisablingInDirectSubmissionRequired() const = 0; MOCKABLE_VIRTUAL ~HwInfoConfig() = default; @@ -236,6 +237,7 @@ class HwInfoConfigHw : public HwInfoConfig { uint32_t getL1CachePolicy() const override; bool isEvictionWhenNecessaryFlagSupported() const override; void adjustNumberOfCcs(HardwareInfo &hwInfo) const override; + bool isPrefetcherDisablingInDirectSubmissionRequired() const override; protected: HwInfoConfigHw() = default; diff --git a/shared/source/os_interface/hw_info_config.inl b/shared/source/os_interface/hw_info_config.inl index a7f797d317..ab10d12056 100644 --- a/shared/source/os_interface/hw_info_config.inl +++ b/shared/source/os_interface/hw_info_config.inl @@ -482,4 +482,9 @@ uint32_t HwInfoConfigHw::getL1CachePolicy() const { template void HwInfoConfigHw::adjustNumberOfCcs(HardwareInfo &hwInfo) const {} + +template +bool HwInfoConfigHw::isPrefetcherDisablingInDirectSubmissionRequired() const { + return true; +} } // namespace NEO diff --git a/shared/source/xe_hpc_core/os_agnostic_hw_info_config_xe_hpc_core.inl b/shared/source/xe_hpc_core/os_agnostic_hw_info_config_xe_hpc_core.inl index 1cb3aeb6ea..6d7849e04f 100644 --- a/shared/source/xe_hpc_core/os_agnostic_hw_info_config_xe_hpc_core.inl +++ b/shared/source/xe_hpc_core/os_agnostic_hw_info_config_xe_hpc_core.inl @@ -53,3 +53,8 @@ void HwInfoConfigHw::getKernelExtendedProperties(uint32_t *fp16, uin *fp32 = (FP_ATOMIC_EXT_FLAG_GLOBAL_LOAD_STORE | FP_ATOMIC_EXT_FLAG_GLOBAL_ADD | FP_ATOMIC_EXT_FLAG_GLOBAL_MIN_MAX); *fp64 = (FP_ATOMIC_EXT_FLAG_GLOBAL_LOAD_STORE | FP_ATOMIC_EXT_FLAG_GLOBAL_ADD | FP_ATOMIC_EXT_FLAG_GLOBAL_MIN_MAX); } + +template <> +bool HwInfoConfigHw::isPrefetcherDisablingInDirectSubmissionRequired() const { + return false; +} diff --git a/shared/test/common/mocks/mock_hw_info_config.cpp b/shared/test/common/mocks/mock_hw_info_config.cpp index 5406637509..56a445ab07 100644 --- a/shared/test/common/mocks/mock_hw_info_config.cpp +++ b/shared/test/common/mocks/mock_hw_info_config.cpp @@ -406,6 +406,11 @@ uint32_t L1CachePolicyHelper::getDefaultL1CachePolicy() { return 0u; } +template <> +bool HwInfoConfigHw::isPrefetcherDisablingInDirectSubmissionRequired() const { + return true; +} + } // namespace NEO #include "shared/source/os_interface/hw_info_config.inl" diff --git a/shared/test/common/test_files/igdrcl.config b/shared/test/common/test_files/igdrcl.config index f8268f7872..9472c7b69c 100644 --- a/shared/test/common/test_files/igdrcl.config +++ b/shared/test/common/test_files/igdrcl.config @@ -446,4 +446,5 @@ ExperimentalEnableL0DebuggerForOpenCL = 0 DebuggerDisableSingleAddressSbaTracking = 0 ForceImagesSupport = -1 ForceCsrLockInBcsEnqueueOnlyForGpgpuSubmission = -1 -ExperimentalEnableTileAttach = 0 \ No newline at end of file +ExperimentalEnableTileAttach = 0 +DirectSubmissionDisablePrefetcher = -1 diff --git a/shared/test/unit_test/direct_submission/CMakeLists.txt b/shared/test/unit_test/direct_submission/CMakeLists.txt index 7a7d73d728..bd632258b7 100644 --- a/shared/test/unit_test/direct_submission/CMakeLists.txt +++ b/shared/test/unit_test/direct_submission/CMakeLists.txt @@ -16,4 +16,8 @@ if(TESTS_XE_HP_CORE) target_sources(neo_shared_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/direct_submission_tests_xe_hp_core.cpp) endif() +if(TESTS_XE_HPC_CORE) + target_sources(neo_shared_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/direct_submission_tests_xe_hpc_core.cpp) +endif() + add_subdirectories() diff --git a/shared/test/unit_test/direct_submission/direct_submission_tests_1.cpp b/shared/test/unit_test/direct_submission/direct_submission_tests_1.cpp index 0f45b0c366..89458f8602 100644 --- a/shared/test/unit_test/direct_submission/direct_submission_tests_1.cpp +++ b/shared/test/unit_test/direct_submission/direct_submission_tests_1.cpp @@ -926,7 +926,9 @@ HWTEST_F(DirectSubmissionTest, EXPECT_EQ(expectedStoreAddress, storeDataCmdAtPosition->getAddress()); cmdBufferPosition += sizeof(MI_STORE_DATA_IMM); - cmdBufferPosition += directSubmission.getSizeDisablePrefetcher(); + if (HwInfoConfig::get(defaultHwInfo->platform.eProductFamily)->isPrefetcherDisablingInDirectSubmissionRequired()) { + cmdBufferPosition += directSubmission.getSizeDisablePrefetcher(); + } MI_SEMAPHORE_WAIT *semaphoreWaitCmdAtPosition = genCmdCast(cmdBufferPosition); ASSERT_NE(nullptr, semaphoreWaitCmdAtPosition); EXPECT_EQ(COMPARE_OPERATION::COMPARE_OPERATION_SAD_GREATER_THAN_OR_EQUAL_SDD, @@ -1103,3 +1105,24 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, DirectSubmissionTest, givenDebugFlagSetWhenDispatch EXPECT_EQ(0u, arbCheck->getPreParserDisable()); } + +HWCMDTEST_F(IGFX_XE_HP_CORE, DirectSubmissionTest, givenDisablePrefetcherDebugFlagDisabledWhenDispatchingPrefetcherThenSetCorrectValue) { + DebugManagerStateRestore restore; + DebugManager.flags.DirectSubmissionDisablePrefetcher.set(0); + + using MI_ARB_CHECK = typename FamilyType::MI_ARB_CHECK; + using Dispatcher = BlitterDispatcher; + + MockDirectSubmissionHw directSubmission(*pDevice->getDefaultEngine().commandStreamReceiver); + + bool ret = directSubmission.allocateResources(); + EXPECT_TRUE(ret); + + directSubmission.dispatchDisablePrefetcher(true); + + HardwareParse hwParse; + hwParse.parseCommands(directSubmission.ringCommandStream, 0); + hwParse.findHardwareCommands(); + MI_ARB_CHECK *arbCheck = hwParse.getCommand(); + EXPECT_EQ(nullptr, arbCheck); +} diff --git a/shared/test/unit_test/direct_submission/direct_submission_tests_xe_hpc_core.cpp b/shared/test/unit_test/direct_submission/direct_submission_tests_xe_hpc_core.cpp new file mode 100644 index 0000000000..5c3e2133aa --- /dev/null +++ b/shared/test/unit_test/direct_submission/direct_submission_tests_xe_hpc_core.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/direct_submission/dispatchers/blitter_dispatcher.h" +#include "shared/source/xe_hp_core/hw_cmds.h" +#include "shared/test/common/cmd_parse/hw_parse.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/mocks/mock_direct_submission_hw.h" +#include "shared/test/common/test_macros/hw_test.h" +#include "shared/test/unit_test/fixtures/direct_submission_fixture.h" + +using DirectSubmissionTestXeHpcCore = Test; + +XE_HPC_CORETEST_F(DirectSubmissionTestXeHpcCore, givenXeHpcCoreWhenDispatchDisablePrefetcherIsCalledThenPrefetcherIsNotDisabled) { + using MI_ARB_CHECK = typename FamilyType::MI_ARB_CHECK; + using Dispatcher = BlitterDispatcher; + + MockDirectSubmissionHw directSubmission(*pDevice->getDefaultEngine().commandStreamReceiver); + + EXPECT_EQ(sizeof(MI_ARB_CHECK), directSubmission.getSizeDisablePrefetcher()); + + bool ret = directSubmission.allocateResources(); + EXPECT_TRUE(ret); + + directSubmission.dispatchDisablePrefetcher(true); + + HardwareParse hwParse; + hwParse.parseCommands(directSubmission.ringCommandStream, 0); + hwParse.findHardwareCommands(); + MI_ARB_CHECK *arbCheck = hwParse.getCommand(); + EXPECT_EQ(nullptr, arbCheck); +} + +XE_HPC_CORETEST_F(DirectSubmissionTestXeHpcCore, givenXeHpcCoreAndDisablePrefetcherDebugFlagEnabledWhenDispatchDisablePrefetcherIsCalledThenPrefetcherIsDisabled) { + DebugManagerStateRestore restore; + DebugManager.flags.DirectSubmissionDisablePrefetcher.set(1); + + using MI_ARB_CHECK = typename FamilyType::MI_ARB_CHECK; + using Dispatcher = BlitterDispatcher; + + MockDirectSubmissionHw directSubmission(*pDevice->getDefaultEngine().commandStreamReceiver); + + bool ret = directSubmission.allocateResources(); + EXPECT_TRUE(ret); + + directSubmission.dispatchDisablePrefetcher(true); + + HardwareParse hwParse; + hwParse.parseCommands(directSubmission.ringCommandStream, 0); + hwParse.findHardwareCommands(); + MI_ARB_CHECK *arbCheck = hwParse.getCommand(); + ASSERT_NE(nullptr, arbCheck); +} diff --git a/shared/test/unit_test/helpers/test_hw_info_config.cpp b/shared/test/unit_test/helpers/test_hw_info_config.cpp index bd8a94b9bc..eb586f7c92 100644 --- a/shared/test/unit_test/helpers/test_hw_info_config.cpp +++ b/shared/test/unit_test/helpers/test_hw_info_config.cpp @@ -161,3 +161,8 @@ HWTEST2_F(HwInfoConfigTest, givenPlatformWithUnsupportedL1CachePoliciesWhenGetL1 EXPECT_EQ(0u, hwInfoConfig->getL1CachePolicy()); } + +HWTEST_F(HwInfoConfigTest, givenHwInfoConfigWhenIsPrefetcherDisablingInDirectSubmissionRequiredThenTrueIsReturned) { + const auto &hwInfoConfig = *HwInfoConfig::get(defaultHwInfo->platform.eProductFamily); + EXPECT_TRUE(hwInfoConfig.isPrefetcherDisablingInDirectSubmissionRequired()); +} diff --git a/shared/test/unit_test/xe_hpc_core/excludes_xe_hpc_core.cpp b/shared/test/unit_test/xe_hpc_core/excludes_xe_hpc_core.cpp index 05caea1cc5..9359b5080f 100644 --- a/shared/test/unit_test/xe_hpc_core/excludes_xe_hpc_core.cpp +++ b/shared/test/unit_test/xe_hpc_core/excludes_xe_hpc_core.cpp @@ -37,3 +37,5 @@ HWTEST_EXCLUDE_PRODUCT(HwInfoConfigTest, whenCallingGetDeviceMemoryNameThenDdrIs HWTEST_EXCLUDE_PRODUCT(HwInfoConfigTest, givenHardwareInfoWhenCallingIsMaxThreadsForWorkgroupWARequiredThenFalseIsReturned, IGFX_XE_HPC_CORE); HWTEST_EXCLUDE_PRODUCT(HwInfoConfigTest, givenHwInfoConfigWhenAskedIfPipeControlPriorToNonPipelinedStateCommandsWARequiredThenFalseIsReturned, IGFX_XE_HPC_CORE); HWTEST_EXCLUDE_PRODUCT(HwInfoConfigTest, givenHwInfoConfigWhenAskedIfTile64With3DSurfaceOnBCSIsSupportedThenTrueIsReturned, IGFX_XE_HPC_CORE); +HWTEST_EXCLUDE_PRODUCT(HwInfoConfigTest, givenHwInfoConfigWhenIsPrefetcherDisablingInDirectSubmissionRequiredThenTrueIsReturned, IGFX_XE_HPC_CORE); +HWTEST_EXCLUDE_PRODUCT(DirectSubmissionTest, givenDebugFlagSetWhenDispatchingPrefetcherThenSetCorrectValue, IGFX_XE_HPC_CORE); diff --git a/shared/test/unit_test/xe_hpc_core/pvc/test_hw_info_config_pvc.cpp b/shared/test/unit_test/xe_hpc_core/pvc/test_hw_info_config_pvc.cpp index 2c2e309cf6..0ebe24ecbe 100644 --- a/shared/test/unit_test/xe_hpc_core/pvc/test_hw_info_config_pvc.cpp +++ b/shared/test/unit_test/xe_hpc_core/pvc/test_hw_info_config_pvc.cpp @@ -69,3 +69,8 @@ PVCTEST_F(PVCHwInfoConfig, givenHwInfoConfigWhenGettingEvictWhenNecessaryFlagSup const auto &hwInfoConfig = *HwInfoConfig::get(hwInfo.platform.eProductFamily); EXPECT_TRUE(hwInfoConfig.isEvictionWhenNecessaryFlagSupported()); } + +PVCTEST_F(PVCHwInfoConfig, givenPVCHwInfoConfigWhenIsPrefetcherDisablingInDirectSubmissionRequiredThenFalseIsReturned) { + const auto &hwInfoConfig = *HwInfoConfig::get(productFamily); + EXPECT_FALSE(hwInfoConfig.isPrefetcherDisablingInDirectSubmissionRequired()); +}