diff --git a/opencl/test/unit_test/test_files/igdrcl.config b/opencl/test/unit_test/test_files/igdrcl.config index a8d470958c..8ba78ef90f 100644 --- a/opencl/test/unit_test/test_files/igdrcl.config +++ b/opencl/test/unit_test/test_files/igdrcl.config @@ -398,3 +398,4 @@ OverridePatIndex = -1 UseTileMemoryBankInVirtualMemoryCreation = -1 DisableScratchPages = 0 ForceAllResourcesUncached = 0 +ForcePreParserEnabledForMiArbCheck = -1 diff --git a/shared/source/command_container/command_encoder.h b/shared/source/command_container/command_encoder.h index e6d1c6d4d4..92770bf364 100644 --- a/shared/source/command_container/command_encoder.h +++ b/shared/source/command_container/command_encoder.h @@ -378,6 +378,7 @@ struct EncodeMiArbCheck { using MI_ARB_CHECK = typename GfxFamily::MI_ARB_CHECK; static void program(LinearStream &commandStream); + static void adjust(MI_ARB_CHECK &miArbCheck); static size_t getCommandSize(); }; diff --git a/shared/source/command_container/command_encoder.inl b/shared/source/command_container/command_encoder.inl index 12f5e0548c..c45db4731e 100644 --- a/shared/source/command_container/command_encoder.inl +++ b/shared/source/command_container/command_encoder.inl @@ -798,8 +798,12 @@ inline size_t EncodeMemoryPrefetch::getSizeForMemoryPrefetch(size_t size template void EncodeMiArbCheck::program(LinearStream &commandStream) { + MI_ARB_CHECK cmd = Family::cmdInitArbCheck; + + EncodeMiArbCheck::adjust(cmd); + auto miArbCheckStream = commandStream.getSpaceForCmd(); - *miArbCheckStream = Family::cmdInitArbCheck; + *miArbCheckStream = cmd; } template diff --git a/shared/source/command_container/command_encoder_bdw_and_later.inl b/shared/source/command_container/command_encoder_bdw_and_later.inl index cad7d96953..6268637244 100644 --- a/shared/source/command_container/command_encoder_bdw_and_later.inl +++ b/shared/source/command_container/command_encoder_bdw_and_later.inl @@ -472,4 +472,8 @@ inline void EncodeStoreMemory::programStoreDataImm(MI_STORE_DATA_IMM *cm *cmdBuffer = storeDataImmediate; } +template +inline void EncodeMiArbCheck::adjust(MI_ARB_CHECK &miArbCheck) { +} + } // namespace NEO diff --git a/shared/source/command_container/command_encoder_xehp_and_later.inl b/shared/source/command_container/command_encoder_xehp_and_later.inl index f4b2db6169..362372f630 100644 --- a/shared/source/command_container/command_encoder_xehp_and_later.inl +++ b/shared/source/command_container/command_encoder_xehp_and_later.inl @@ -672,4 +672,11 @@ inline void EncodeStoreMemory::programStoreDataImm(MI_STORE_DATA_IMM *cm *cmdBuffer = storeDataImmediate; } +template +inline void EncodeMiArbCheck::adjust(MI_ARB_CHECK &miArbCheck) { + if (DebugManager.flags.ForcePreParserEnabledForMiArbCheck.get() != -1) { + miArbCheck.setPreParserDisable(!DebugManager.flags.ForcePreParserEnabledForMiArbCheck.get()); + } +} + } // namespace NEO diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index af006faaa7..b38a7c0646 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -194,6 +194,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, AccessCountersGranularity, -1, "-1: default - AC DECLARE_DEBUG_VARIABLE(int32_t, OverridePatIndex, -1, "-1: default, >=0: PatIndex to override") DECLARE_DEBUG_VARIABLE(int32_t, UseTileMemoryBankInVirtualMemoryCreation, -1, "-1: default - on, 0: do not assign tile memory bank to virtual memory space, 1: assign tile memory bank to virtual memory space") DECLARE_DEBUG_VARIABLE(int32_t, OverrideTimestampEvents, -1, "-1: default (based on user settings), 0: Force disable timestamp events (no timestamps will be reported), 1: Force enable timestamp events") +DECLARE_DEBUG_VARIABLE(int32_t, ForcePreParserEnabledForMiArbCheck, -1, "-1: default , 0: PreParser disabled, 1: PreParser enabled") DECLARE_DEBUG_VARIABLE(bool, DisableScratchPages, false, "Disable scratch pages during VM creations") /*LOGGING FLAGS*/ DECLARE_DEBUG_VARIABLE(int32_t, PrintDriverDiagnostics, -1, "prints driver diagnostics messages to standard output, value corresponds to hint level") 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 c0716e5c07..17fe69d3d1 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 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Intel Corporation + * Copyright (C) 2021-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -15,6 +15,9 @@ inline void DirectSubmissionHw::dispatchDisablePrefetcher MI_ARB_CHECK arbCheck = GfxFamily::cmdInitArbCheck; arbCheck.setPreParserDisable(disable); + + EncodeMiArbCheck::adjust(arbCheck); + MI_ARB_CHECK *arbCheckSpace = ringCommandStream.getSpaceForCmd(); *arbCheckSpace = arbCheck; } 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 158f702477..46481debfb 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 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Intel Corporation + * Copyright (C) 2021-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -15,6 +15,9 @@ inline void DirectSubmissionHw::dispatchDisablePrefetcher MI_ARB_CHECK arbCheck = GfxFamily::cmdInitArbCheck; arbCheck.setPreFetchDisable(disable); + + EncodeMiArbCheck::adjust(arbCheck); + MI_ARB_CHECK *arbCheckSpace = ringCommandStream.getSpaceForCmd(); *arbCheckSpace = arbCheck; } diff --git a/shared/source/generated/xe_hp_core/hw_cmds_generated_xe_hp_core.inl b/shared/source/generated/xe_hp_core/hw_cmds_generated_xe_hp_core.inl index 279d660233..9ab5bdf1b5 100644 --- a/shared/source/generated/xe_hp_core/hw_cmds_generated_xe_hp_core.inl +++ b/shared/source/generated/xe_hp_core/hw_cmds_generated_xe_hp_core.inl @@ -5690,6 +5690,17 @@ typedef struct tagMI_ARB_CHECK { inline uint32_t getPreFetchDisable() const { return TheStructure.Common.Pre_FetchDisable; } + + // patched for easier templates usage + inline void setPreParserDisable(const uint32_t value) { + setPreFetchDisable(value); + } + + // patched for easier templates usage + inline uint32_t getPreParserDisable() const { + return getPreFetchDisable(); + } + inline void setMaskBits(const uint32_t value) { DEBUG_BREAK_IF(value > 0xff00); TheStructure.Common.MaskBits = value; diff --git a/shared/source/generated/xe_hpg_core/hw_cmds_generated_xe_hpg_core.inl b/shared/source/generated/xe_hpg_core/hw_cmds_generated_xe_hpg_core.inl index 6edaf910fc..8fa23efff5 100644 --- a/shared/source/generated/xe_hpg_core/hw_cmds_generated_xe_hpg_core.inl +++ b/shared/source/generated/xe_hpg_core/hw_cmds_generated_xe_hpg_core.inl @@ -5761,6 +5761,17 @@ typedef struct tagMI_ARB_CHECK { inline uint32_t getPreFetchDisable() const { return TheStructure.Common.Pre_FetchDisable; } + + // patched for easier templates usage + inline void setPreParserDisable(const uint32_t value) { + setPreFetchDisable(value); + } + + // patched for easier templates usage + inline uint32_t getPreParserDisable() const { + return getPreFetchDisable(); + } + inline void setMaskBits(const uint32_t value) { DEBUG_BREAK_IF(value > 0xff00); TheStructure.Common.MaskBits = value; diff --git a/shared/test/unit_test/command_container/command_encoder_tests.cpp b/shared/test/unit_test/command_container/command_encoder_tests.cpp index 7bfa8babfa..c1a9aeeab2 100644 --- a/shared/test/unit_test/command_container/command_encoder_tests.cpp +++ b/shared/test/unit_test/command_container/command_encoder_tests.cpp @@ -8,6 +8,7 @@ #include "shared/source/command_container/command_encoder.h" #include "shared/source/command_stream/linear_stream.h" #include "shared/source/memory_manager/graphics_allocation.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/unit_test_helper.h" #include "shared/test/common/test_macros/test.h" @@ -111,4 +112,25 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandEncoderTests, whenAppendParamsForImageFromBuf EncodeSurfaceState::appendParamsForImageFromBuffer(&surfaceState); EXPECT_EQ(0, memcmp(&expectedState, &surfaceState, sizeof(surfaceState))); +} + +HWCMDTEST_F(IGFX_XE_HP_CORE, CommandEncoderTests, givenDebugFlagSetWhenProgrammingMiArbThenSetPreparserDisabledValue) { + DebugManagerStateRestore restore; + + using MI_ARB_CHECK = typename FamilyType::MI_ARB_CHECK; + + for (int32_t value : {-1, 0, 1}) { + DebugManager.flags.ForcePreParserEnabledForMiArbCheck.set(value); + + MI_ARB_CHECK buffer[2] = {}; + LinearStream linearStream(buffer, sizeof(buffer)); + + EncodeMiArbCheck::program(linearStream); + + if (value == 0) { + EXPECT_TRUE(buffer[0].getPreParserDisable()); + } else { + EXPECT_FALSE(buffer[0].getPreParserDisable()); + } + } } \ No newline at end of file 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 0ebfaecb13..37ad85918c 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 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 Intel Corporation + * Copyright (C) 2020-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -956,3 +956,26 @@ HWCMDTEST_F(IGFX_GEN8_CORE, DirectSubmissionTest, size_t usedSizeAfter = directSubmission.ringCommandStream.getUsed(); EXPECT_EQ(expectedSize, usedSizeAfter - usedSize); } + +HWCMDTEST_F(IGFX_XE_HP_CORE, DirectSubmissionTest, givenDebugFlagSetWhenDispatchingPrefetcherThenSetCorrectValue) { + DebugManagerStateRestore restore; + DebugManager.flags.ForcePreParserEnabledForMiArbCheck.set(1); + + using MI_ARB_CHECK = typename FamilyType::MI_ARB_CHECK; + using Dispatcher = BlitterDispatcher; + + MockDirectSubmissionHw directSubmission(*pDevice, *osContext.get()); + + 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); + + EXPECT_EQ(0u, arbCheck->getPreParserDisable()); +}