From 8cc0177f1c7d898a912b1cb1bbb94ef96fb66856 Mon Sep 17 00:00:00 2001 From: Dominik Dabek Date: Tue, 23 Aug 2022 11:48:18 +0000 Subject: [PATCH] Change DG2 l1 cache policy to WB With compiler LSC WAs this gives better performance. If debugger is active, policy will not be changed ie. will be WBP. Related-To: NEO-7003 Signed-off-by: Dominik Dabek --- .../core/source/cmdlist/cmdlist_hw_base.inl | 1 + .../core/source/cmdqueue/cmdqueue_hw_base.inl | 4 +- .../cmdqueue_xe_hp_core_and_later.inl | 4 +- level_zero/core/source/kernel/kernel_hw.h | 3 +- level_zero/core/source/kernel/kernel_imp.cpp | 3 +- level_zero/core/source/module/module_imp.cpp | 6 +- .../unit_tests/sources/module/test_module.cpp | 2 +- .../unit_tests/xe_hpg_core/dg2/CMakeLists.txt | 6 +- .../xe_hpg_core/dg2/test_cache_flush_dg2.cpp | 60 +++++++ .../xe_hpg_core/dg2/test_cmdqueue_dg2.cpp | 76 +++++++++ .../xe_hpg_core/dg2/test_excludes_dg2.cpp | 10 ++ .../xe_hpg_core/dg2/test_kernel_dg2.cpp | 73 +++++++++ .../xe_hpg_core/dg2/test_module_dg2.cpp | 76 +++++++++ .../xe_hpg_core/test_module_xe_hpg_core.cpp | 4 +- opencl/source/mem_obj/buffer_base.inl | 2 + opencl/source/program/program.cpp | 3 +- .../cache_flush_tests_dg2_and_later.cpp | 2 +- .../test/unit_test/program/program_tests.cpp | 2 +- .../xe_hpg_core/dg2/excludes_ocl_dg2.cpp | 4 + .../dg2/test_cmds_programming_dg2.cpp | 57 ++++++- .../source/offline_compiler.cpp | 2 +- .../command_container/command_encoder.h | 2 +- .../command_container/command_encoder.inl | 2 +- .../command_encoder_bdw_and_later.inl | 6 +- .../command_encoder_xe_hpg_core_and_later.inl | 10 +- .../command_encoder_xehp_and_later.inl | 11 +- .../encode_surface_state_args_base.h | 1 + .../command_stream_receiver_hw_base.inl | 3 +- .../helpers/cache_flush_xehp_and_later.inl | 4 + shared/source/helpers/cache_policy.h | 6 +- shared/source/helpers/cache_policy_base.inl | 4 +- .../helpers/cache_policy_bdw_and_later.inl | 4 +- .../helpers/cache_policy_dg2_and_later.inl | 6 +- .../source/helpers/compiler_hw_info_config.h | 4 +- .../helpers/compiler_hw_info_config_base.inl | 4 +- shared/source/helpers/state_base_address.h | 3 +- .../state_base_address_bdw_and_later.inl | 2 +- ...ate_base_address_xe_hpg_core_and_later.inl | 10 +- .../state_base_address_xehp_and_later.inl | 2 +- shared/source/os_interface/hw_info_config.h | 4 +- shared/source/os_interface/hw_info_config.inl | 4 +- .../xe_hp_core/command_encoder_xe_hp_core.cpp | 9 +- .../state_base_address_xe_hp_core.cpp | 2 +- .../command_encoder_xe_hpg_core.cpp | 10 ++ .../source/xe_hpg_core/enable_xe_hpg_core.cpp | 7 +- .../test/common/mocks/mock_hw_info_config.cpp | 8 +- shared/test/unit_test/encoders/CMakeLists.txt | 5 +- .../encoders/test_encode_states_dg2.cpp | 66 ++++++++ .../unit_test/helpers/cache_policy_tests.cpp | 24 ++- .../helpers/state_base_address_tests.cpp | 150 ++++++++++++++---- .../unit_test/helpers/test_hw_info_config.cpp | 36 +++-- .../test/unit_test/xe_hp_core/CMakeLists.txt | 1 + .../command_encoder_tests_xe_hp_core.cpp | 22 +++ .../test/unit_test/xe_hpg_core/CMakeLists.txt | 1 + .../command_encoder_tests_xe_hpg_core.cpp | 25 +++ .../dg2/cache_policy_tests_dg2.cpp | 12 +- .../dg2/excludes_xe_hpg_core_dg2.cpp | 7 +- .../xe_hpg_core/dg2/test_encode_dg2.cpp | 8 +- 58 files changed, 754 insertions(+), 131 deletions(-) create mode 100644 level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_cache_flush_dg2.cpp create mode 100644 level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_excludes_dg2.cpp create mode 100644 level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_kernel_dg2.cpp create mode 100644 level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_module_dg2.cpp create mode 100644 shared/test/unit_test/encoders/test_encode_states_dg2.cpp create mode 100644 shared/test/unit_test/xe_hp_core/command_encoder_tests_xe_hp_core.cpp create mode 100644 shared/test/unit_test/xe_hpg_core/command_encoder_tests_xe_hpg_core.cpp diff --git a/level_zero/core/source/cmdlist/cmdlist_hw_base.inl b/level_zero/core/source/cmdlist/cmdlist_hw_base.inl index bba220bbea..ef57256219 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw_base.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw_base.inl @@ -159,6 +159,7 @@ ze_result_t CommandListCoreFamily::appendLaunchKernelWithParams(K args.gmmHelper = neoDevice->getGmmHelper(); args.useGlobalAtomics = kernelImp->getKernelDescriptor().kernelAttributes.flags.useGlobalAtomics; args.areMultipleSubDevicesInContext = false; + args.isDebuggerActive = true; NEO::EncodeSurfaceState::encodeBuffer(args); *reinterpret_cast(surfaceStateSpace) = surfaceState; } diff --git a/level_zero/core/source/cmdqueue/cmdqueue_hw_base.inl b/level_zero/core/source/cmdqueue/cmdqueue_hw_base.inl index f5a14b4392..a43cfb8e9b 100644 --- a/level_zero/core/source/cmdqueue/cmdqueue_hw_base.inl +++ b/level_zero/core/source/cmdqueue/cmdqueue_hw_base.inl @@ -52,6 +52,7 @@ void CommandQueueHw::programStateBaseAddress(uint64_t gsba, bool auto indirectObjectHeapBaseAddress = neoDevice->getMemoryManager()->getInternalHeapBaseAddress(device->getRootDeviceIndex(), useLocalMemoryForIndirectHeap); auto instructionHeapBaseAddress = neoDevice->getMemoryManager()->getInternalHeapBaseAddress(device->getRootDeviceIndex(), neoDevice->getMemoryManager()->isLocalMemoryUsedForIsa(neoDevice->getRootDeviceIndex())); + auto isDebuggerActive = neoDevice->isDebuggerActive() || neoDevice->getDebugger() != nullptr; NEO::StateBaseAddressHelperArgs stateBaseAddressHelperArgs = { gsba, // generalStateBase @@ -72,7 +73,8 @@ void CommandQueueHw::programStateBaseAddress(uint64_t gsba, bool false, // isMultiOsContextCapable false, // useGlobalAtomics false, // areMultipleSubDevicesInContext - false // overrideSurfaceStateBaseAddress + false, // overrideSurfaceStateBaseAddress + isDebuggerActive // isDebuggerActive }; NEO::StateBaseAddressHelper::programStateBaseAddress(stateBaseAddressHelperArgs); diff --git a/level_zero/core/source/cmdqueue/cmdqueue_xe_hp_core_and_later.inl b/level_zero/core/source/cmdqueue/cmdqueue_xe_hp_core_and_later.inl index 3fb234991c..aea21e771d 100644 --- a/level_zero/core/source/cmdqueue/cmdqueue_xe_hp_core_and_later.inl +++ b/level_zero/core/source/cmdqueue/cmdqueue_xe_hp_core_and_later.inl @@ -41,6 +41,7 @@ void CommandQueueHw::programStateBaseAddress(uint64_t gsba, bool NEO::EncodeWA::addPipeControlBeforeStateBaseAddress(commandStream, hwInfo, isRcs); auto sbaCmdBuf = NEO::StateBaseAddressHelper::getSpaceForSbaCmd(commandStream); + auto isDebuggerActive = neoDevice->isDebuggerActive() || neoDevice->getDebugger() != nullptr; STATE_BASE_ADDRESS sbaCmd; NEO::StateBaseAddressHelperArgs stateBaseAddressHelperArgs = { @@ -62,7 +63,8 @@ void CommandQueueHw::programStateBaseAddress(uint64_t gsba, bool multiOsContextCapable, // isMultiOsContextCapable false, // useGlobalAtomics false, // areMultipleSubDevicesInContext - false // overrideSurfaceStateBaseAddress + false, // overrideSurfaceStateBaseAddress + isDebuggerActive // isDebuggerActive }; NEO::StateBaseAddressHelper::programStateBaseAddress(stateBaseAddressHelperArgs); diff --git a/level_zero/core/source/kernel/kernel_hw.h b/level_zero/core/source/kernel/kernel_hw.h index dd9ed333db..7ee42e7e64 100644 --- a/level_zero/core/source/kernel/kernel_hw.h +++ b/level_zero/core/source/kernel/kernel_hw.h @@ -75,7 +75,7 @@ struct KernelHw : public KernelImp { if (l3Enabled == false) { this->kernelRequiresQueueUncachedMocsCount++; } - + auto isDebuggerActive = neoDevice->isDebuggerActive() || neoDevice->getDebugger() != nullptr; NEO::EncodeSurfaceStateArgs args; args.outMemory = &surfaceState; args.graphicsAddress = bufferAddressForSsh; @@ -87,6 +87,7 @@ struct KernelHw : public KernelImp { args.useGlobalAtomics = kernelImmData->getDescriptor().kernelAttributes.flags.useGlobalAtomics; args.areMultipleSubDevicesInContext = args.numAvailableDevices > 1; args.implicitScaling = device->isImplicitScalingCapable(); + args.isDebuggerActive = isDebuggerActive; NEO::EncodeSurfaceState::encodeBuffer(args); *reinterpret_cast(surfaceStateAddress) = surfaceState; diff --git a/level_zero/core/source/kernel/kernel_imp.cpp b/level_zero/core/source/kernel/kernel_imp.cpp index 60519e61f9..2bbab418dd 100644 --- a/level_zero/core/source/kernel/kernel_imp.cpp +++ b/level_zero/core/source/kernel/kernel_imp.cpp @@ -72,7 +72,7 @@ inline void patchWithImplicitSurface(ArrayRef crossThreadData, ArrayRef auto &hwInfo = device.getHardwareInfo(); auto &hwHelper = NEO::HwHelper::get(hwInfo.platform.eRenderCoreFamily); - + auto isDebuggerActive = device.isDebuggerActive() || device.getDebugger() != nullptr; NEO::EncodeSurfaceStateArgs args; args.outMemory = surfaceState; args.size = sizeToPatch; @@ -84,6 +84,7 @@ inline void patchWithImplicitSurface(ArrayRef crossThreadData, ArrayRef args.areMultipleSubDevicesInContext = args.numAvailableDevices > 1; args.mocs = hwHelper.getMocsIndex(*args.gmmHelper, true, false) << 1; args.implicitScaling = implicitScaling; + args.isDebuggerActive = isDebuggerActive; hwHelper.encodeBufferSurfaceState(args); } diff --git a/level_zero/core/source/module/module_imp.cpp b/level_zero/core/source/module/module_imp.cpp index 261f06d555..fbd08b1f39 100644 --- a/level_zero/core/source/module/module_imp.cpp +++ b/level_zero/core/source/module/module_imp.cpp @@ -121,8 +121,8 @@ std::string ModuleTranslationUnit::generateCompilerOptions(const char *buildOpti } std::string internalOptions = NEO::CompilerOptions::concatenate(internalBuildOptions, BuildOptions::hasBufferOffsetArg); auto &neoDevice = *device->getNEODevice(); - - if (neoDevice.getDeviceInfo().debuggerActive) { + auto isDebuggerActive = neoDevice.getDeviceInfo().debuggerActive; + if (isDebuggerActive) { if (NEO::SourceLevelDebugger::shouldAppendOptDisable(*device->getSourceLevelDebugger())) { NEO::CompilerOptions::concatenateAppend(options, BuildOptions::optDisable); } @@ -139,7 +139,7 @@ std::string ModuleTranslationUnit::generateCompilerOptions(const char *buildOpti internalOptions = NEO::CompilerOptions::concatenate(internalOptions, NEO::CompilerOptions::greaterThan4gbBuffersRequired); } - NEO::CompilerOptions::concatenateAppend(internalOptions, compilerHwInfoConfig.getCachingPolicyOptions()); + NEO::CompilerOptions::concatenateAppend(internalOptions, compilerHwInfoConfig.getCachingPolicyOptions(isDebuggerActive)); return internalOptions; } diff --git a/level_zero/core/test/unit_tests/sources/module/test_module.cpp b/level_zero/core/test/unit_tests/sources/module/test_module.cpp index 0cc33543c0..0e8e9dc606 100644 --- a/level_zero/core/test/unit_tests/sources/module/test_module.cpp +++ b/level_zero/core/test/unit_tests/sources/module/test_module.cpp @@ -2259,7 +2259,7 @@ HWTEST_F(ModuleTranslationUnitTest, givenInternalOptionsThenLSCCachePolicyIsSet) auto ret = moduleTu.buildFromSpirV("", 0U, nullptr, "", nullptr); const auto &compilerHwInfoConfig = *CompilerHwInfoConfig::get(defaultHwInfo->platform.eProductFamily); EXPECT_TRUE(ret); - auto expectedPolicy = compilerHwInfoConfig.getCachingPolicyOptions(); + auto expectedPolicy = compilerHwInfoConfig.getCachingPolicyOptions(false); if (expectedPolicy != nullptr) { EXPECT_NE(pMockCompilerInterface->inputInternalOptions.find(expectedPolicy), std::string::npos); } else { diff --git a/level_zero/core/test/unit_tests/xe_hpg_core/dg2/CMakeLists.txt b/level_zero/core/test/unit_tests/xe_hpg_core/dg2/CMakeLists.txt index 95cc240a8c..0b74c60313 100644 --- a/level_zero/core/test/unit_tests/xe_hpg_core/dg2/CMakeLists.txt +++ b/level_zero/core/test/unit_tests/xe_hpg_core/dg2/CMakeLists.txt @@ -7,9 +7,13 @@ if(TESTS_DG2) target_sources(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt - ${CMAKE_CURRENT_SOURCE_DIR}/test_sampler_dg2.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_cache_flush_dg2.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_dg2.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_cmdqueue_dg2.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_excludes_dg2.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_kernel_dg2.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_module_dg2.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_sampler_dg2.cpp ) add_subdirectories() endif() diff --git a/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_cache_flush_dg2.cpp b/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_cache_flush_dg2.cpp new file mode 100644 index 0000000000..13505eda17 --- /dev/null +++ b/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_cache_flush_dg2.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2021-2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/cache_flush_xehp_and_later.inl" +#include "shared/source/helpers/l3_range.h" +#include "shared/source/xe_hpg_core/hw_cmds.h" +#include "shared/test/common/cmd_parse/gen_cmd_parse.h" +#include "shared/test/common/mocks/mock_graphics_allocation.h" +#include "shared/test/common/test_macros/hw_test.h" + +#include "level_zero/core/source/xe_hpg_core/cmdlist_xe_hpg_core.h" +#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h" +#include "level_zero/core/test/unit_tests/mocks/mock_cmdlist.h" + +namespace L0 { +namespace ult { + +using CacheFlushDG2Tests = Test; + +HWTEST2_F(CacheFlushDG2Tests, givenCommandStreamWithSingleL3RangeAndNonZeroPostSyncAddressWhenFlushGpuCacheIsCalledThenPostSyncOperationIsSetForL3ControlAndUnTypedDataPortCacheFlushIsSet, IsDG2) { + using GfxFamily = typename NEO::GfxFamilyMapper::GfxFamily; + using L3_CONTROL = typename GfxFamily::L3_CONTROL; + auto &hardwareInfo = this->neoDevice->getHardwareInfo(); + auto commandList = std::make_unique>>(); + commandList->initialize(device, NEO::EngineGroupType::Copy, 0u); + LinearStream *cmdStream = commandList->commandContainer.getCommandStream(); + uint64_t gpuAddress = 0x1200; + void *buffer = reinterpret_cast(gpuAddress); + size_t size = 0x1000; + uint64_t postSyncAddress = 0x1200; + + NEO::MockGraphicsAllocation mockAllocation(buffer, gpuAddress, size); + NEO::SvmAllocationData allocData(0); + allocData.size = size; + allocData.gpuAllocations.addAllocation(&mockAllocation); + device->getDriverHandle()->getSvmAllocsManager()->insertSVMAlloc(allocData); + + L3RangesVec ranges; + ranges.push_back(L3Range::fromAddressSizeWithPolicy( + gpuAddress, size, + GfxFamily::L3_FLUSH_ADDRESS_RANGE:: + L3_FLUSH_EVICTION_POLICY_FLUSH_L3_WITH_EVICTION)); + NEO::flushGpuCache(cmdStream, ranges, postSyncAddress, + hardwareInfo); + + GenCmdList cmdList; + EXPECT_TRUE(FamilyType::PARSE::parseCommandBuffer( + cmdList, ptrOffset(cmdStream->getCpuBase(), 0), cmdStream->getUsed())); + auto itor = find(cmdList.begin(), cmdList.end()); + ASSERT_NE(cmdList.end(), itor); + auto l3Control = genCmdCast(*itor); + EXPECT_TRUE(l3Control->getUnTypedDataPortCacheFlush()); +} + +} // namespace ult +} // namespace L0 diff --git a/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_cmdqueue_dg2.cpp b/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_cmdqueue_dg2.cpp index 701c4f146d..1f90c3695f 100644 --- a/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_cmdqueue_dg2.cpp +++ b/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_cmdqueue_dg2.cpp @@ -5,7 +5,9 @@ * */ +#include "shared/test/common/cmd_parse/gen_cmd_parse.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/mocks/mock_l0_debugger.h" #include "shared/test/common/test_macros/hw_test.h" #include "level_zero/core/test/unit_tests/fixtures/device_fixture.h" @@ -30,5 +32,79 @@ HWTEST2_F(CommandQueueTestDG2, givenBindlessEnabledWhenEstimateStateBaseAddressC EXPECT_EQ(size, expectedSize); } +HWTEST2_F(CommandQueueTestDG2, givenBindlessEnabledWhenProgramStateBaseAddressCalledOnDG2ThenProgramCorrectL1CachePolicy, IsDG2) { + DebugManagerStateRestore restorer; + DebugManager.flags.UseBindlessMode.set(1); + + neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(neoDevice->getMemoryManager(), + neoDevice->getNumGenericSubDevices() > 1, + neoDevice->getRootDeviceIndex(), + neoDevice->getDeviceBitfield()); + + using GfxFamily = typename NEO::GfxFamilyMapper::GfxFamily; + using STATE_BASE_ADDRESS = typename GfxFamily::STATE_BASE_ADDRESS; + ze_command_queue_desc_t desc = {}; + auto &csr = neoDevice->getGpgpuCommandStreamReceiver(); + auto commandQueue = std::make_unique>(device, &csr, &desc); + void *linearStreamBuffer = alignedMalloc(4096, 0x1000); + { + NEO::LinearStream cmdStream(linearStreamBuffer, 4096); + auto usedSpaceBefore = cmdStream.getUsed(); + commandQueue->programStateBaseAddress(0, false, cmdStream, false); + auto usedSpaceAfter = cmdStream.getUsed(); + ASSERT_GT(usedSpaceAfter, usedSpaceBefore); + + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer( + cmdList, ptrOffset(cmdStream.getCpuBase(), 0), usedSpaceAfter)); + + auto sbaItor = find(cmdList.begin(), cmdList.end()); + ASSERT_NE(cmdList.end(), sbaItor); + auto cmdSba = genCmdCast(*sbaItor); + + EXPECT_EQ(STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB, cmdSba->getL1CachePolicyL1CacheControl()); + } + { + const_cast(device->getDeviceInfo()).debuggerActive = true; + NEO::LinearStream cmdStream(linearStreamBuffer, 4096); + auto usedSpaceBefore = cmdStream.getUsed(); + commandQueue->programStateBaseAddress(0, false, cmdStream, false); + auto usedSpaceAfter = cmdStream.getUsed(); + ASSERT_GT(usedSpaceAfter, usedSpaceBefore); + + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer( + cmdList, ptrOffset(cmdStream.getCpuBase(), 0), usedSpaceAfter)); + + auto sbaItor = find(cmdList.begin(), cmdList.end()); + ASSERT_NE(cmdList.end(), sbaItor); + auto cmdSba = genCmdCast(*sbaItor); + + EXPECT_EQ(STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP, cmdSba->getL1CachePolicyL1CacheControl()); + } + { + auto debugger = MockDebuggerL0Hw::allocate(neoDevice); + neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->debugger.reset(debugger); + const_cast(device->getDeviceInfo()).debuggerActive = false; + NEO::LinearStream cmdStream(linearStreamBuffer, 4096); + auto usedSpaceBefore = cmdStream.getUsed(); + commandQueue->programStateBaseAddress(0, false, cmdStream, false); + auto usedSpaceAfter = cmdStream.getUsed(); + ASSERT_GT(usedSpaceAfter, usedSpaceBefore); + + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer( + cmdList, ptrOffset(cmdStream.getCpuBase(), 0), usedSpaceAfter)); + + auto sbaItor = find(cmdList.begin(), cmdList.end()); + ASSERT_NE(cmdList.end(), sbaItor); + auto cmdSba = genCmdCast(*sbaItor); + + EXPECT_EQ(STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP, cmdSba->getL1CachePolicyL1CacheControl()); + } + + alignedFree(linearStreamBuffer); +} + } // namespace ult } // namespace L0 diff --git a/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_excludes_dg2.cpp b/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_excludes_dg2.cpp new file mode 100644 index 0000000000..947de841b1 --- /dev/null +++ b/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_excludes_dg2.cpp @@ -0,0 +1,10 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/test_macros/hw_test_base.h" + +HWTEST_EXCLUDE_PRODUCT(ModuleTranslationUnitTest, givenAtLeastXeHpgCoreWhenGetInternalOptionsThenCorrectBuildOptionIsSet_IsAtLeastXeHpgCore, IGFX_DG2); \ No newline at end of file diff --git a/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_kernel_dg2.cpp b/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_kernel_dg2.cpp new file mode 100644 index 0000000000..89a1f7e2a5 --- /dev/null +++ b/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_kernel_dg2.cpp @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/cmd_parse/gen_cmd_parse.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/mocks/mock_l0_debugger.h" +#include "shared/test/common/test_macros/hw_test.h" + +#include "level_zero/core/test/unit_tests/fixtures/module_fixture.h" +#include "level_zero/core/test/unit_tests/mocks/mock_cmdqueue.h" + +namespace L0 { +namespace ult { +using KernelTestDG2 = Test; + +HWTEST2_F(KernelTestDG2, givenKernelImpWhenSetBufferSurfaceStateCalledThenProgramCorrectL1CachePolicy, IsDG2) { + using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; + ze_kernel_handle_t kernelHandle; + + ze_kernel_desc_t kernelDesc = {}; + kernelDesc.pKernelName = kernelName.c_str(); + + ze_result_t res = module->createKernel(&kernelDesc, &kernelHandle); + + ASSERT_EQ(ZE_RESULT_SUCCESS, res); + + auto kernelImp = reinterpret_cast(L0::Kernel::fromHandle(kernelHandle)); + + void *devicePtr = nullptr; + ze_device_mem_alloc_desc_t deviceDesc = {}; + res = context->allocDeviceMem(device->toHandle(), + &deviceDesc, + 16384u, + 0u, + &devicePtr); + ASSERT_EQ(ZE_RESULT_SUCCESS, res); + + auto gpuAlloc = device->getDriverHandle()->getSvmAllocsManager()->getSVMAllocs()->get(devicePtr)->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex()); + ASSERT_NE(nullptr, gpuAlloc); + + uint32_t argIndex = 0u; + kernelImp->setBufferSurfaceState(argIndex, devicePtr, gpuAlloc); + + auto argInfo = kernelImp->getImmutableData()->getDescriptor().payloadMappings.explicitArgs[argIndex].as(); + auto surfaceStateAddressRaw = ptrOffset(kernelImp->getSurfaceStateHeapData(), argInfo.bindful); + auto surfaceStateAddress = reinterpret_cast(const_cast(surfaceStateAddressRaw)); + EXPECT_EQ(RENDER_SURFACE_STATE::L1_CACHE_POLICY_WB, surfaceStateAddress->getL1CachePolicyL1CacheControl()); + + const_cast(device->getDeviceInfo()).debuggerActive = true; + kernelImp->setBufferSurfaceState(argIndex, devicePtr, gpuAlloc); + surfaceStateAddressRaw = ptrOffset(kernelImp->getSurfaceStateHeapData(), argInfo.bindful); + surfaceStateAddress = reinterpret_cast(const_cast(surfaceStateAddressRaw)); + EXPECT_EQ(RENDER_SURFACE_STATE::L1_CACHE_POLICY_WBP, surfaceStateAddress->getL1CachePolicyL1CacheControl()); + + auto debugger = MockDebuggerL0Hw::allocate(neoDevice); + neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->debugger.reset(debugger); + const_cast(device->getDeviceInfo()).debuggerActive = false; + kernelImp->setBufferSurfaceState(argIndex, devicePtr, gpuAlloc); + surfaceStateAddressRaw = ptrOffset(kernelImp->getSurfaceStateHeapData(), argInfo.bindful); + surfaceStateAddress = reinterpret_cast(const_cast(surfaceStateAddressRaw)); + EXPECT_EQ(RENDER_SURFACE_STATE::L1_CACHE_POLICY_WBP, surfaceStateAddress->getL1CachePolicyL1CacheControl()); + + Kernel::fromHandle(kernelHandle)->destroy(); + + context->freeMem(devicePtr); +} + +} // namespace ult +} // namespace L0 diff --git a/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_module_dg2.cpp b/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_module_dg2.cpp new file mode 100644 index 0000000000..354b079f63 --- /dev/null +++ b/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_module_dg2.cpp @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/mocks/mock_compilers.h" +#include "shared/test/common/mocks/mock_l0_debugger.h" +#include "shared/test/common/test_macros/hw_test.h" + +#include "level_zero/core/test/unit_tests/fixtures/module_fixture.h" +#include "level_zero/core/test/unit_tests/mocks/mock_module.h" + +namespace L0 { +namespace ult { +using KernelDebugSurfaceDG2Test = Test; + +HWTEST2_F(KernelDebugSurfaceDG2Test, givenDebuggerAndBindfulKernelWhenAppendingKernelToCommandListThenCachePolicyIsWBP, IsDG2) { + NEO::MockCompilerEnableGuard mock(true); + using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; + + const_cast(neoDevice->getDeviceInfo()).debuggerActive = true; + auto debugger = MockDebuggerL0Hw::allocate(neoDevice); + + neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->debugger.reset(debugger); + auto &hwInfo = *NEO::defaultHwInfo.get(); + auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily); + auto maxDbgSurfaceSize = hwHelper.getSipKernelMaxDbgSurfaceSize(hwInfo); + auto debugSurface = neoDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties( + {device->getRootDeviceIndex(), true, + maxDbgSurfaceSize, + NEO::AllocationType::DEBUG_CONTEXT_SAVE_AREA, + false, + false, + device->getNEODevice()->getDeviceBitfield()}); + static_cast(device)->setDebugSurface(debugSurface); + + uint8_t binary[10]; + ze_module_desc_t moduleDesc = {}; + moduleDesc.format = ZE_MODULE_FORMAT_NATIVE; + moduleDesc.pInputModule = binary; + moduleDesc.inputSize = 10; + ModuleBuildLog *moduleBuildLog = nullptr; + + std::unique_ptr module = std::make_unique(device, + moduleBuildLog, + ModuleType::User); + + module->debugEnabled = true; + + uint32_t kernelHeap = 0; + KernelInfo kernelInfo; + kernelInfo.heapInfo.KernelHeapSize = 1; + kernelInfo.heapInfo.pKernelHeap = &kernelHeap; + + Mock<::L0::Kernel> kernel; + kernel.module = module.get(); + kernel.immutableData.kernelInfo = &kernelInfo; + + ze_kernel_desc_t desc = {}; + + kernel.immutableData.kernelDescriptor->payloadMappings.implicitArgs.systemThreadSurfaceAddress.bindful = sizeof(RENDER_SURFACE_STATE); + kernel.immutableData.surfaceStateHeapSize = 2 * sizeof(RENDER_SURFACE_STATE); + kernel.immutableData.surfaceStateHeapTemplate.reset(new uint8_t[2 * sizeof(RENDER_SURFACE_STATE)]); + module->kernelImmData = &kernel.immutableData; + + kernel.initialize(&desc); + + auto debugSurfaceState = reinterpret_cast(kernel.surfaceStateHeapData.get()); + debugSurfaceState = ptrOffset(debugSurfaceState, sizeof(RENDER_SURFACE_STATE)); + + EXPECT_EQ(RENDER_SURFACE_STATE::L1_CACHE_POLICY_WBP, debugSurfaceState->getL1CachePolicyL1CacheControl()); +} +} // namespace ult +} // namespace L0 \ No newline at end of file diff --git a/level_zero/core/test/unit_tests/xe_hpg_core/test_module_xe_hpg_core.cpp b/level_zero/core/test/unit_tests/xe_hpg_core/test_module_xe_hpg_core.cpp index 57417fa9fa..d7ac7228c3 100644 --- a/level_zero/core/test/unit_tests/xe_hpg_core/test_module_xe_hpg_core.cpp +++ b/level_zero/core/test/unit_tests/xe_hpg_core/test_module_xe_hpg_core.cpp @@ -46,14 +46,14 @@ HWTEST2_F(KernelPropertyTest, givenKernelExtendedPropertiesStructureWhenKernelPr EXPECT_FALSE(kernelExtendedProperties.fp64Flags & FP_ATOMIC_EXT_FLAG_LOCAL_MIN_MAX); } -HWTEST2_F(KernelPropertyTest, givenDG2WhenGetInternalOptionsThenWriteByPassBuildOptionIsSet, IsDG2) { +HWTEST2_F(KernelPropertyTest, givenDG2WhenGetInternalOptionsThenWriteBackBuildOptionIsSet, IsDG2) { auto pMockCompilerInterface = new MockCompilerInterface; auto &rootDeviceEnvironment = this->neoDevice->executionEnvironment->rootDeviceEnvironments[this->neoDevice->getRootDeviceIndex()]; rootDeviceEnvironment->compilerInterface.reset(pMockCompilerInterface); MockModuleTranslationUnit moduleTu(this->device); auto ret = moduleTu.buildFromSpirV("", 0U, nullptr, "", nullptr); EXPECT_TRUE(ret); - EXPECT_NE(pMockCompilerInterface->inputInternalOptions.find("-cl-store-cache-default=2 -cl-load-cache-default=4"), std::string::npos); + EXPECT_NE(pMockCompilerInterface->inputInternalOptions.find("-cl-store-cache-default=7 -cl-load-cache-default=4"), std::string::npos); } } // namespace ult diff --git a/opencl/source/mem_obj/buffer_base.inl b/opencl/source/mem_obj/buffer_base.inl index a448dc28f1..b166fc42de 100644 --- a/opencl/source/mem_obj/buffer_base.inl +++ b/opencl/source/mem_obj/buffer_base.inl @@ -30,6 +30,7 @@ void BufferHw::setArgStateful(void *memory, bool forceNonAuxMode, boo auto rootDeviceIndex = device.getRootDeviceIndex(); auto graphicsAllocation = multiGraphicsAllocation.getGraphicsAllocation(rootDeviceIndex); const auto isReadOnly = isValueSet(getFlags(), CL_MEM_READ_ONLY) || isReadOnlyArgument; + auto isDebuggerActive = device.isDebuggerActive() || device.getDebugger() != nullptr; NEO::EncodeSurfaceStateArgs args; args.outMemory = memory; @@ -45,6 +46,7 @@ void BufferHw::setArgStateful(void *memory, bool forceNonAuxMode, boo args.useGlobalAtomics = useGlobalAtomics; args.areMultipleSubDevicesInContext = areMultipleSubDevicesInContext; args.implicitScaling = ImplicitScalingHelper::isImplicitScalingEnabled(device.getDeviceBitfield(), true); + args.isDebuggerActive = isDebuggerActive; appendSurfaceStateArgs(args); EncodeSurfaceState::encodeBuffer(args); } diff --git a/opencl/source/program/program.cpp b/opencl/source/program/program.cpp index d94b47c2a0..6f087c80ec 100644 --- a/opencl/source/program/program.cpp +++ b/opencl/source/program/program.cpp @@ -105,7 +105,8 @@ std::string Program::getInternalOptions() const { } CompilerOptions::concatenateAppend(internalOptions, CompilerOptions::preserveVec3Type); - CompilerOptions::concatenateAppend(internalOptions, compilerHwInfoConfig.getCachingPolicyOptions()); + auto isDebuggerActive = pClDevice->getDevice().isDebuggerActive() || pClDevice->getDevice().getDebugger() != nullptr; + CompilerOptions::concatenateAppend(internalOptions, compilerHwInfoConfig.getCachingPolicyOptions(isDebuggerActive)); return internalOptions; } diff --git a/opencl/test/unit_test/command_stream/cache_flush_tests_dg2_and_later.cpp b/opencl/test/unit_test/command_stream/cache_flush_tests_dg2_and_later.cpp index 6a26ccf20e..3e618985d8 100644 --- a/opencl/test/unit_test/command_stream/cache_flush_tests_dg2_and_later.cpp +++ b/opencl/test/unit_test/command_stream/cache_flush_tests_dg2_and_later.cpp @@ -46,7 +46,7 @@ HWTEST2_F(CacheFlushTestsDg2AndLater, WhenProgrammingCacheFlushAfterWalkerThenEx if constexpr (FamilyType::isUsingL3Control) { using L3_CONTROL = typename FamilyType::L3_CONTROL; expectedCommands.push_back(new MatchHwCmd( - 1, Expects{EXPECT_MEMBER(L3_CONTROL, getUnTypedDataPortCacheFlush, false)})); + 1, Expects{EXPECT_MEMBER(L3_CONTROL, getUnTypedDataPortCacheFlush, true)})); } bool cmdBuffOk = expectCmdBuff(cmdQ.getCS(0), 0, std::move(expectedCommands), &err); diff --git a/opencl/test/unit_test/program/program_tests.cpp b/opencl/test/unit_test/program/program_tests.cpp index dfb0d1cb3b..ec1b9c0676 100644 --- a/opencl/test/unit_test/program/program_tests.cpp +++ b/opencl/test/unit_test/program/program_tests.cpp @@ -1743,7 +1743,7 @@ TEST_F(ProgramTests, whenGetInternalOptionsThenLSCPolicyIsSet) { MockProgram program(pContext, false, toClDeviceVector(*pClDevice)); auto internalOptions = program.getInternalOptions(); const auto &compilerHwInfoConfig = *CompilerHwInfoConfig::get(defaultHwInfo->platform.eProductFamily); - auto expectedPolicy = compilerHwInfoConfig.getCachingPolicyOptions(); + auto expectedPolicy = compilerHwInfoConfig.getCachingPolicyOptions(false); if (expectedPolicy != nullptr) { EXPECT_TRUE(CompilerOptions::contains(internalOptions, expectedPolicy)); } else { diff --git a/opencl/test/unit_test/xe_hpg_core/dg2/excludes_ocl_dg2.cpp b/opencl/test/unit_test/xe_hpg_core/dg2/excludes_ocl_dg2.cpp index d3fe7eaf6f..2d563324da 100644 --- a/opencl/test/unit_test/xe_hpg_core/dg2/excludes_ocl_dg2.cpp +++ b/opencl/test/unit_test/xe_hpg_core/dg2/excludes_ocl_dg2.cpp @@ -12,3 +12,7 @@ HWTEST_EXCLUDE_PRODUCT(HwInfoConfigTestXeHpAndLater, givenXeHPAndLaterPlatformWh HWTEST_EXCLUDE_PRODUCT(WddmMemoryManagerSimpleTest, givenLinearStreamWhenItIsAllocatedThenItIsInLocalMemoryHasCpuPointerAndHasStandardHeap64kbAsGpuAddress, IGFX_DG2); HWTEST_EXCLUDE_PRODUCT(HwHelperTestXeHPAndLater, GiveCcsNodeThenDefaultEngineTypeIsCcs, IGFX_DG2); HWTEST_EXCLUDE_PRODUCT(XeHPAndLaterDeviceCapsTests, givenHwInfoWhenRequestedComputeUnitsUsedForScratchThenReturnValidValue, IGFX_DG2); +HWTEST_EXCLUDE_PRODUCT(ProgramTests, givenAtLeastXeHpgCoreWhenGetInternalOptionsThenCorrectBuildOptionIsSet_IsAtLeastXeHpgCore, IGFX_DG2); +HWTEST_EXCLUDE_PRODUCT(CmdsProgrammingTestsXeHpgCore, givenL3ToL1DebugFlagWhenStatelessMocsIsProgrammedThenItHasL1CachingOn, IGFX_DG2); +HWTEST_EXCLUDE_PRODUCT(CmdsProgrammingTestsXeHpgCore, givenAlignedCacheableReadOnlyBufferThenChoseOclBufferConstPolicy, IGFX_DG2); +HWTEST_EXCLUDE_PRODUCT(CmdsProgrammingTestsXeHpgCore, whenAppendingRssThenProgramWBPL1CachePolicy, IGFX_DG2); diff --git a/opencl/test/unit_test/xe_hpg_core/dg2/test_cmds_programming_dg2.cpp b/opencl/test/unit_test/xe_hpg_core/dg2/test_cmds_programming_dg2.cpp index 036e62ea42..8fc59909cb 100644 --- a/opencl/test/unit_test/xe_hpg_core/dg2/test_cmds_programming_dg2.cpp +++ b/opencl/test/unit_test/xe_hpg_core/dg2/test_cmds_programming_dg2.cpp @@ -37,10 +37,27 @@ DG2TEST_F(CmdsProgrammingTestsDg2, givenL3ToL1DebugFlagWhenStatelessMocsIsProgra auto stateBaseAddress = static_cast(hwParserCsr.cmdStateBaseAddress); - auto actualL1CachePolocy = static_cast(stateBaseAddress->getL1CachePolicyL1CacheControl()); + EXPECT_EQ(stateBaseAddress->getL1CachePolicyL1CacheControl(), STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB); +} - const uint8_t expectedL1CachePolicy = FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP; - EXPECT_EQ(expectedL1CachePolicy, actualL1CachePolocy); +DG2TEST_F(CmdsProgrammingTestsDg2, givenL3ToL1DebugFlagAndDebuggerActiveWhenStatelessMocsIsProgrammedThenItHasCorrectL1CachingOn) { + using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; + + DebugManagerStateRestore restore; + DebugManager.flags.ForceL1Caching.set(1u); + pDevice->setDebuggerActive(true); + + auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); + flushTask(commandStreamReceiver); + + HardwareParse hwParserCsr; + hwParserCsr.parseCommands(commandStreamReceiver.commandStream, 0); + hwParserCsr.findHardwareCommands(); + ASSERT_NE(nullptr, hwParserCsr.cmdStateBaseAddress); + + auto stateBaseAddress = static_cast(hwParserCsr.cmdStateBaseAddress); + + EXPECT_EQ(stateBaseAddress->getL1CachePolicyL1CacheControl(), STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP); } DG2TEST_F(CmdsProgrammingTestsDg2, whenAppendingRssThenProgramWBPL1CachePolicy) { @@ -69,7 +86,10 @@ DG2TEST_F(CmdsProgrammingTestsDg2, whenAppendingRssThenProgramWBPL1CachePolicy) args.areMultipleSubDevicesInContext = true; EncodeSurfaceState::encodeBuffer(args); + EXPECT_EQ(FamilyType::RENDER_SURFACE_STATE::L1_CACHE_POLICY_WB, rssCmd.getL1CachePolicyL1CacheControl()); + args.isDebuggerActive = true; + EncodeSurfaceState::encodeBuffer(args); EXPECT_EQ(FamilyType::RENDER_SURFACE_STATE::L1_CACHE_POLICY_WBP, rssCmd.getL1CachePolicyL1CacheControl()); } @@ -95,10 +115,35 @@ DG2TEST_F(CmdsProgrammingTestsDg2, givenAlignedCacheableReadOnlyBufferThenChoseO const auto actualMocs = surfaceState.getMemoryObjectControlState(); EXPECT_EQ(expectedMocs, actualMocs); - auto actualL1CachePolocy = static_cast(surfaceState.getL1CachePolicyL1CacheControl()); + EXPECT_EQ(surfaceState.getL1CachePolicyL1CacheControl(), FamilyType::RENDER_SURFACE_STATE::L1_CACHE_POLICY_WB); - const uint8_t expectedL1CachePolicy = FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP; - EXPECT_EQ(expectedL1CachePolicy, actualL1CachePolocy); + alignedFree(ptr); +} + +DG2TEST_F(CmdsProgrammingTestsDg2, givenAlignedCacheableReadOnlyBufferAndDebuggerActiveWhenBufferCreateThenChoseOclBufferConstPolicy) { + MockContext context; + const_cast(context.getDevice(0)->getDevice().getDeviceInfo()).debuggerActive = true; + const auto size = MemoryConstants::pageSize; + const auto ptr = (void *)alignedMalloc(size * 2, MemoryConstants::pageSize); + const auto flags = CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY; + + auto retVal = CL_SUCCESS; + auto buffer = std::unique_ptr(Buffer::create( + &context, + flags, + size, + ptr, + retVal)); + EXPECT_EQ(CL_SUCCESS, retVal); + + typename FamilyType::RENDER_SURFACE_STATE surfaceState = {}; + buffer->setArgStateful(&surfaceState, false, false, false, false, context.getDevice(0)->getDevice(), false, false); + + const auto expectedMocs = context.getDevice(0)->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CONST); + const auto actualMocs = surfaceState.getMemoryObjectControlState(); + EXPECT_EQ(expectedMocs, actualMocs); + + EXPECT_EQ(surfaceState.getL1CachePolicyL1CacheControl(), FamilyType::RENDER_SURFACE_STATE::L1_CACHE_POLICY_WBP); alignedFree(ptr); } diff --git a/shared/offline_compiler/source/offline_compiler.cpp b/shared/offline_compiler/source/offline_compiler.cpp index 5dff56f8ca..6095a0bc0f 100644 --- a/shared/offline_compiler/source/offline_compiler.cpp +++ b/shared/offline_compiler/source/offline_compiler.cpp @@ -779,7 +779,7 @@ void OfflineCompiler::appendExtraInternalOptions(std::string &internalOptions) { if (compilerHwInfoConfig.isForceEmuInt32DivRemSPRequired()) { CompilerOptions::concatenateAppend(internalOptions, CompilerOptions::forceEmuInt32DivRemSP); } - CompilerOptions::concatenateAppend(internalOptions, compilerHwInfoConfig.getCachingPolicyOptions()); + CompilerOptions::concatenateAppend(internalOptions, compilerHwInfoConfig.getCachingPolicyOptions(false)); } void OfflineCompiler::parseDebugSettings() { diff --git a/shared/source/command_container/command_encoder.h b/shared/source/command_container/command_encoder.h index d560bfff73..2f8b2e02c9 100644 --- a/shared/source/command_container/command_encoder.h +++ b/shared/source/command_container/command_encoder.h @@ -286,7 +286,7 @@ struct EncodeSurfaceState { static void encodeBuffer(EncodeSurfaceStateArgs &args); static void encodeExtraBufferParams(EncodeSurfaceStateArgs &args); static void encodeImplicitScalingParams(const EncodeSurfaceStateArgs &args); - static void encodeExtraCacheSettings(R_SURFACE_STATE *surfaceState, const HardwareInfo &hwInfo); + static void encodeExtraCacheSettings(R_SURFACE_STATE *surfaceState, const EncodeSurfaceStateArgs &args); static void appendBufferSurfaceState(EncodeSurfaceStateArgs &args); static constexpr uintptr_t getSurfaceBaseAddressAlignmentMask() { diff --git a/shared/source/command_container/command_encoder.inl b/shared/source/command_container/command_encoder.inl index 8d83780baf..e1f4f5688d 100644 --- a/shared/source/command_container/command_encoder.inl +++ b/shared/source/command_container/command_encoder.inl @@ -467,7 +467,7 @@ size_t EncodeSurfaceState::pushBindingTableAndSurfaceStates(IndirectHeap } template -inline void EncodeSurfaceState::encodeExtraCacheSettings(R_SURFACE_STATE *surfaceState, const HardwareInfo &hwInfo) {} +inline void EncodeSurfaceState::encodeExtraCacheSettings(R_SURFACE_STATE *surfaceState, const EncodeSurfaceStateArgs &args) {} template void EncodeSurfaceState::setImageAuxParamsForCCS(R_SURFACE_STATE *surfaceState, Gmm *gmm) { 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 b701ec474d..2fa31bbe76 100644 --- a/shared/source/command_container/command_encoder_bdw_and_later.inl +++ b/shared/source/command_container/command_encoder_bdw_and_later.inl @@ -390,6 +390,7 @@ void EncodeStateBaseAddress::encode(EncodeStateBaseAddressArgs & auto dsh = args.container->isHeapDirty(HeapType::DYNAMIC_STATE) ? args.container->getIndirectHeap(HeapType::DYNAMIC_STATE) : nullptr; auto ioh = args.container->isHeapDirty(HeapType::INDIRECT_OBJECT) ? args.container->getIndirectHeap(HeapType::INDIRECT_OBJECT) : nullptr; auto ssh = args.container->isHeapDirty(HeapType::SURFACE_STATE) ? args.container->getIndirectHeap(HeapType::SURFACE_STATE) : nullptr; + auto isDebuggerActive = device.isDebuggerActive() || device.getDebugger() != nullptr; StateBaseAddressHelperArgs stateBaseAddressHelperArgs = { 0, // generalStateBase @@ -410,7 +411,8 @@ void EncodeStateBaseAddress::encode(EncodeStateBaseAddressArgs & false, // isMultiOsContextCapable args.useGlobalAtomics, // useGlobalAtomics false, // areMultipleSubDevicesInContext - false // overrideSurfaceStateBaseAddress + false, // overrideSurfaceStateBaseAddress + isDebuggerActive // isDebuggerActive }; StateBaseAddressHelper::programStateBaseAddress(stateBaseAddressHelperArgs); @@ -476,7 +478,7 @@ inline void EncodeWA::adjustCompressionFormatForPlanarImage(uint32_t template inline void EncodeSurfaceState::encodeExtraBufferParams(EncodeSurfaceStateArgs &args) { auto surfaceState = reinterpret_cast(args.outMemory); - encodeExtraCacheSettings(surfaceState, *args.gmmHelper->getHardwareInfo()); + encodeExtraCacheSettings(surfaceState, args); } template diff --git a/shared/source/command_container/command_encoder_xe_hpg_core_and_later.inl b/shared/source/command_container/command_encoder_xe_hpg_core_and_later.inl index 6642e2dd86..5fab081c11 100644 --- a/shared/source/command_container/command_encoder_xe_hpg_core_and_later.inl +++ b/shared/source/command_container/command_encoder_xe_hpg_core_and_later.inl @@ -13,16 +13,16 @@ namespace NEO { template <> -void EncodeSurfaceState::encodeExtraCacheSettings(R_SURFACE_STATE *surfaceState, const HardwareInfo &hwInfo) { +void EncodeSurfaceState::encodeExtraCacheSettings(R_SURFACE_STATE *surfaceState, const EncodeSurfaceStateArgs &args) { using L1_CACHE_POLICY = typename R_SURFACE_STATE::L1_CACHE_POLICY; + const auto &hwInfo = *args.gmmHelper->getHardwareInfo(); auto hwInfoConfig = HwInfoConfig::get(hwInfo.platform.eProductFamily); - auto cachePolicy = static_cast(hwInfoConfig->getL1CachePolicy()); - surfaceState->setL1CachePolicyL1CacheControl(cachePolicy); - + auto cachePolicy = static_cast(hwInfoConfig->getL1CachePolicy(args.isDebuggerActive)); if (DebugManager.flags.OverrideL1CacheControlInSurfaceState.get() != -1 && DebugManager.flags.ForceAllResourcesUncached.get() == false) { - surfaceState->setL1CachePolicyL1CacheControl(static_cast(DebugManager.flags.OverrideL1CacheControlInSurfaceState.get())); + cachePolicy = static_cast(DebugManager.flags.OverrideL1CacheControlInSurfaceState.get()); } + surfaceState->setL1CachePolicyL1CacheControl(cachePolicy); } template 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 224a2534e5..0f6a4667a6 100644 --- a/shared/source/command_container/command_encoder_xehp_and_later.inl +++ b/shared/source/command_container/command_encoder_xehp_and_later.inl @@ -492,11 +492,13 @@ void EncodeStateBaseAddress::setSbaAddressesForDebugger(NEO::Debugger::S template void EncodeStateBaseAddress::encode(EncodeStateBaseAddressArgs &args) { - auto gmmHelper = args.container->getDevice()->getRootDeviceEnvironment().getGmmHelper(); + auto &device = *args.container->getDevice(); + auto gmmHelper = device.getRootDeviceEnvironment().getGmmHelper(); auto dsh = args.container->isHeapDirty(HeapType::DYNAMIC_STATE) ? args.container->getIndirectHeap(HeapType::DYNAMIC_STATE) : nullptr; auto ioh = args.container->isHeapDirty(HeapType::INDIRECT_OBJECT) ? args.container->getIndirectHeap(HeapType::INDIRECT_OBJECT) : nullptr; auto ssh = args.container->isHeapDirty(HeapType::SURFACE_STATE) ? args.container->getIndirectHeap(HeapType::SURFACE_STATE) : nullptr; + auto isDebuggerActive = device.isDebuggerActive() || device.getDebugger() != nullptr; StateBaseAddressHelperArgs stateBaseAddressHelperArgs = { 0, // generalStateBase @@ -517,7 +519,8 @@ void EncodeStateBaseAddress::encode(EncodeStateBaseAddressArgs & args.multiOsContextCapable, // isMultiOsContextCapable args.useGlobalAtomics, // useGlobalAtomics false, // areMultipleSubDevicesInContext - false // overrideSurfaceStateBaseAddress + false, // overrideSurfaceStateBaseAddress + isDebuggerActive // isDebuggerActive }; StateBaseAddressHelper::programStateBaseAddress(stateBaseAddressHelperArgs); @@ -525,7 +528,7 @@ void EncodeStateBaseAddress::encode(EncodeStateBaseAddressArgs & auto cmdSpace = StateBaseAddressHelper::getSpaceForSbaCmd(*args.container->getCommandStream()); *cmdSpace = args.sbaCmd; - auto &hwInfo = args.container->getDevice()->getHardwareInfo(); + auto &hwInfo = device.getHardwareInfo(); auto &hwInfoConfig = *HwInfoConfig::get(hwInfo.platform.eProductFamily); if (hwInfoConfig.isAdditionalStateBaseAddressWARequired(hwInfo)) { cmdSpace = StateBaseAddressHelper::getSpaceForSbaCmd(*args.container->getCommandStream()); @@ -649,7 +652,7 @@ void EncodeSurfaceState::encodeExtraBufferParams(EncodeSurfaceStateArgs surfaceState->setMemoryObjectControlState(args.gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CONST)); } - encodeExtraCacheSettings(surfaceState, *args.gmmHelper->getHardwareInfo()); + encodeExtraCacheSettings(surfaceState, args); encodeImplicitScalingParams(args); diff --git a/shared/source/command_container/definitions/encode_surface_state_args_base.h b/shared/source/command_container/definitions/encode_surface_state_args_base.h index b6e0d635d8..00133857e1 100644 --- a/shared/source/command_container/definitions/encode_surface_state_args_base.h +++ b/shared/source/command_container/definitions/encode_surface_state_args_base.h @@ -31,6 +31,7 @@ struct EncodeSurfaceStateArgsBase { bool useGlobalAtomics = false; bool areMultipleSubDevicesInContext = false; bool implicitScaling = false; + bool isDebuggerActive = false; protected: EncodeSurfaceStateArgsBase() = default; 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 bdd2d5c2a3..4a1c10f2da 100644 --- a/shared/source/command_stream/command_stream_receiver_hw_base.inl +++ b/shared/source/command_stream/command_stream_receiver_hw_base.inl @@ -428,7 +428,8 @@ CompletionStamp CommandStreamReceiverHw::flushTask( isMultiOsContextCapable(), // isMultiOsContextCapable dispatchFlags.useGlobalAtomics, // useGlobalAtomics dispatchFlags.areMultipleSubDevicesInContext, // areMultipleSubDevicesInContext - false // overrideSurfaceStateBaseAddress + false, // overrideSurfaceStateBaseAddress + debuggingEnabled || device.isDebuggerActive() // isDebuggerActive }; StateBaseAddressHelper::programStateBaseAddress(args); diff --git a/shared/source/helpers/cache_flush_xehp_and_later.inl b/shared/source/helpers/cache_flush_xehp_and_later.inl index d9e0517d79..ded3a3c986 100644 --- a/shared/source/helpers/cache_flush_xehp_and_later.inl +++ b/shared/source/helpers/cache_flush_xehp_and_later.inl @@ -26,6 +26,9 @@ inline size_t getSizeNeededForL3Control(const Range &ranges) { return size; } +template +void adjustL3ControlField(void *l3ControlBuffer); + template inline void flushGpuCache(LinearStream *commandStream, const Range &ranges, uint64_t postSyncAddress, const HardwareInfo &hwInfo) { using L3_FLUSH_ADDRESS_RANGE = typename GfxFamily::L3_FLUSH_ADDRESS_RANGE; @@ -45,6 +48,7 @@ inline void flushGpuCache(LinearStream *commandStream, const Range &ran cmdL3Control.getPostSyncData().setAddress(postSyncAddress); cmdL3Control.getPostSyncData().setImmediateData(0); } + adjustL3ControlField(&cmdL3Control); *l3Control = cmdL3Control; l3Control++; diff --git a/shared/source/helpers/cache_policy.h b/shared/source/helpers/cache_policy.h index 0279b57dc8..fea12fbdea 100644 --- a/shared/source/helpers/cache_policy.h +++ b/shared/source/helpers/cache_policy.h @@ -21,13 +21,13 @@ bool isL3Capable(const GraphicsAllocation &graphicsAllocation); template struct L1CachePolicyHelper { - static const char *getCachingPolicyOptions(); + static const char *getCachingPolicyOptions(bool isDebuggerActive); - static uint32_t getDefaultL1CachePolicy(); + static uint32_t getDefaultL1CachePolicy(bool isDebuggerActive); static uint32_t getUncachedL1CachePolicy(); - static uint32_t getL1CachePolicy(); + static uint32_t getL1CachePolicy(bool isDebuggerActive); }; } // namespace NEO diff --git a/shared/source/helpers/cache_policy_base.inl b/shared/source/helpers/cache_policy_base.inl index ff731940bb..61b1b028f0 100644 --- a/shared/source/helpers/cache_policy_base.inl +++ b/shared/source/helpers/cache_policy_base.inl @@ -12,14 +12,14 @@ namespace NEO { template -uint32_t L1CachePolicyHelper::getL1CachePolicy() { +uint32_t L1CachePolicyHelper::getL1CachePolicy(bool isDebuggerActive) { if (DebugManager.flags.ForceAllResourcesUncached.get()) { return L1CachePolicyHelper::getUncachedL1CachePolicy(); } if (DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.get() != -1) { return DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.get(); } - return L1CachePolicyHelper::getDefaultL1CachePolicy(); + return L1CachePolicyHelper::getDefaultL1CachePolicy(isDebuggerActive); } } // namespace NEO \ No newline at end of file diff --git a/shared/source/helpers/cache_policy_bdw_and_later.inl b/shared/source/helpers/cache_policy_bdw_and_later.inl index ce3542db6e..a5c75969d5 100644 --- a/shared/source/helpers/cache_policy_bdw_and_later.inl +++ b/shared/source/helpers/cache_policy_bdw_and_later.inl @@ -11,12 +11,12 @@ namespace NEO { template -const char *L1CachePolicyHelper::getCachingPolicyOptions() { +const char *L1CachePolicyHelper::getCachingPolicyOptions(bool isDebuggerActive) { return nullptr; } template -uint32_t L1CachePolicyHelper::getDefaultL1CachePolicy() { +uint32_t L1CachePolicyHelper::getDefaultL1CachePolicy(bool isDebuggerActive) { return 0u; } diff --git a/shared/source/helpers/cache_policy_dg2_and_later.inl b/shared/source/helpers/cache_policy_dg2_and_later.inl index 502c935cc2..9d1278f595 100644 --- a/shared/source/helpers/cache_policy_dg2_and_later.inl +++ b/shared/source/helpers/cache_policy_dg2_and_later.inl @@ -12,14 +12,14 @@ namespace NEO { template -const char *L1CachePolicyHelper::getCachingPolicyOptions() { +const char *L1CachePolicyHelper::getCachingPolicyOptions(bool isDebuggerActive) { using GfxFamily = typename HwMapper::GfxFamily; static constexpr const char *writeBackCachingPolicy = "-cl-store-cache-default=7 -cl-load-cache-default=4"; static constexpr const char *writeByPassCachingPolicy = "-cl-store-cache-default=2 -cl-load-cache-default=4"; static constexpr const char *uncachedCachingPolicy = "-cl-store-cache-default=1 -cl-load-cache-default=1"; - switch (L1CachePolicyHelper::getL1CachePolicy()) { + switch (L1CachePolicyHelper::getL1CachePolicy(isDebuggerActive)) { case GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP: return writeByPassCachingPolicy; case GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB: @@ -32,7 +32,7 @@ const char *L1CachePolicyHelper::getCachingPolicyOptions() { } template -uint32_t L1CachePolicyHelper::getDefaultL1CachePolicy() { +uint32_t L1CachePolicyHelper::getDefaultL1CachePolicy(bool isDebuggerActive) { using GfxFamily = typename HwMapper::GfxFamily; return GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP; } diff --git a/shared/source/helpers/compiler_hw_info_config.h b/shared/source/helpers/compiler_hw_info_config.h index bfbb5858f3..70ca45f181 100644 --- a/shared/source/helpers/compiler_hw_info_config.h +++ b/shared/source/helpers/compiler_hw_info_config.h @@ -30,7 +30,7 @@ class CompilerHwInfoConfig { virtual bool isForceToStatelessRequired() const = 0; virtual void adjustHwInfoForIgc(HardwareInfo &hwInfo) const = 0; virtual void setProductConfigForHwInfo(HardwareInfo &hwInfo, AheadOfTimeConfig config) const = 0; - virtual const char *getCachingPolicyOptions() const = 0; + virtual const char *getCachingPolicyOptions(bool isDebuggerActive) const = 0; }; template @@ -47,7 +47,7 @@ class CompilerHwInfoConfigHw : public CompilerHwInfoConfig { bool isForceToStatelessRequired() const override; void adjustHwInfoForIgc(HardwareInfo &hwInfo) const override; void setProductConfigForHwInfo(HardwareInfo &hwInfo, AheadOfTimeConfig config) const override; - const char *getCachingPolicyOptions() const override; + const char *getCachingPolicyOptions(bool isDebuggerActive) const override; protected: CompilerHwInfoConfigHw() = default; diff --git a/shared/source/helpers/compiler_hw_info_config_base.inl b/shared/source/helpers/compiler_hw_info_config_base.inl index 6dcfe2fbc7..5696bb17cb 100644 --- a/shared/source/helpers/compiler_hw_info_config_base.inl +++ b/shared/source/helpers/compiler_hw_info_config_base.inl @@ -26,8 +26,8 @@ void CompilerHwInfoConfigHw::adjustHwInfoForIgc(HardwareInfo &hwInfo } template -const char *CompilerHwInfoConfigHw::getCachingPolicyOptions() const { - return L1CachePolicyHelper::getCachingPolicyOptions(); +const char *CompilerHwInfoConfigHw::getCachingPolicyOptions(bool isDebuggerActive) const { + return L1CachePolicyHelper::getCachingPolicyOptions(isDebuggerActive); }; } // namespace NEO diff --git a/shared/source/helpers/state_base_address.h b/shared/source/helpers/state_base_address.h index 13aea6c8eb..c7890f84e8 100644 --- a/shared/source/helpers/state_base_address.h +++ b/shared/source/helpers/state_base_address.h @@ -45,6 +45,7 @@ struct StateBaseAddressHelperArgs { bool useGlobalAtomics = false; bool areMultipleSubDevicesInContext = false; bool overrideSurfaceStateBaseAddress = false; + bool isDebuggerActive = false; }; template @@ -60,7 +61,7 @@ struct StateBaseAddressHelper { static void appendStateBaseAddressParameters(StateBaseAddressHelperArgs &args, bool overrideBindlessSurfaceStateBase); - static void appendExtraCacheSettings(STATE_BASE_ADDRESS *stateBaseAddress, const HardwareInfo *hwInfo); + static void appendExtraCacheSettings(StateBaseAddressHelperArgs &args); static void programBindingTableBaseAddress(LinearStream &commandStream, const IndirectHeap &ssh, GmmHelper *gmmHelper); diff --git a/shared/source/helpers/state_base_address_bdw_and_later.inl b/shared/source/helpers/state_base_address_bdw_and_later.inl index 154e801120..5f244cb346 100644 --- a/shared/source/helpers/state_base_address_bdw_and_later.inl +++ b/shared/source/helpers/state_base_address_bdw_and_later.inl @@ -29,6 +29,6 @@ void StateBaseAddressHelper::appendIohParameters(StateBaseAddressHelp } template -void StateBaseAddressHelper::appendExtraCacheSettings(STATE_BASE_ADDRESS *stateBaseAddress, const HardwareInfo *hwInfo) {} +void StateBaseAddressHelper::appendExtraCacheSettings(StateBaseAddressHelperArgs &args) {} } // namespace NEO diff --git a/shared/source/helpers/state_base_address_xe_hpg_core_and_later.inl b/shared/source/helpers/state_base_address_xe_hpg_core_and_later.inl index a727c337e1..a1235bbd95 100644 --- a/shared/source/helpers/state_base_address_xe_hpg_core_and_later.inl +++ b/shared/source/helpers/state_base_address_xe_hpg_core_and_later.inl @@ -6,13 +6,13 @@ */ template -void StateBaseAddressHelper::appendExtraCacheSettings(STATE_BASE_ADDRESS *stateBaseAddress, const HardwareInfo *hwInfo) { - auto hwInfoConfig = HwInfoConfig::get(hwInfo->platform.eProductFamily); - auto cachePolicy = hwInfoConfig->getL1CachePolicy(); - stateBaseAddress->setL1CachePolicyL1CacheControl(static_cast(cachePolicy)); +void StateBaseAddressHelper::appendExtraCacheSettings(StateBaseAddressHelperArgs &args) { + auto hwInfoConfig = HwInfoConfig::get(args.gmmHelper->getHardwareInfo()->platform.eProductFamily); + auto cachePolicy = hwInfoConfig->getL1CachePolicy(args.isDebuggerActive); + args.stateBaseAddressCmd->setL1CachePolicyL1CacheControl(static_cast(cachePolicy)); if (DebugManager.flags.ForceStatelessL1CachingPolicy.get() != -1 && DebugManager.flags.ForceAllResourcesUncached.get() == false) { - stateBaseAddress->setL1CachePolicyL1CacheControl(static_cast(DebugManager.flags.ForceStatelessL1CachingPolicy.get())); + args.stateBaseAddressCmd->setL1CachePolicyL1CacheControl(static_cast(DebugManager.flags.ForceStatelessL1CachingPolicy.get())); } } diff --git a/shared/source/helpers/state_base_address_xehp_and_later.inl b/shared/source/helpers/state_base_address_xehp_and_later.inl index c17656a0fc..2bd61ea76f 100644 --- a/shared/source/helpers/state_base_address_xehp_and_later.inl +++ b/shared/source/helpers/state_base_address_xehp_and_later.inl @@ -78,7 +78,7 @@ void StateBaseAddressHelper::appendStateBaseAddressParameters( args.stateBaseAddressCmd->setStatelessDataPortAccessMemoryObjectControlState(args.gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CONST)); } - appendExtraCacheSettings(args.stateBaseAddressCmd, args.gmmHelper->getHardwareInfo()); + appendExtraCacheSettings(args); } template diff --git a/shared/source/os_interface/hw_info_config.h b/shared/source/os_interface/hw_info_config.h index f034e45f56..82c2d964d2 100644 --- a/shared/source/os_interface/hw_info_config.h +++ b/shared/source/os_interface/hw_info_config.h @@ -133,7 +133,7 @@ class HwInfoConfig { virtual bool isCpuCopyNecessary(const void *ptr, MemoryManager *memoryManager) const = 0; virtual bool isAdjustWalkOrderAvailable(const HardwareInfo &hwInfo) const = 0; virtual bool isAssignEngineRoundRobinSupported() const = 0; - virtual uint32_t getL1CachePolicy() const = 0; + virtual uint32_t getL1CachePolicy(bool isDebuggerActive) const = 0; virtual bool isEvictionIfNecessaryFlagSupported() const = 0; virtual void adjustNumberOfCcs(HardwareInfo &hwInfo) const = 0; virtual bool isPrefetcherDisablingInDirectSubmissionRequired() const = 0; @@ -264,7 +264,7 @@ class HwInfoConfigHw : public HwInfoConfig { bool isCpuCopyNecessary(const void *ptr, MemoryManager *memoryManager) const override; bool isAdjustWalkOrderAvailable(const HardwareInfo &hwInfo) const override; bool isAssignEngineRoundRobinSupported() const override; - uint32_t getL1CachePolicy() const override; + uint32_t getL1CachePolicy(bool isDebuggerActive) const override; bool isEvictionIfNecessaryFlagSupported() const override; void adjustNumberOfCcs(HardwareInfo &hwInfo) const override; bool isPrefetcherDisablingInDirectSubmissionRequired() const override; diff --git a/shared/source/os_interface/hw_info_config.inl b/shared/source/os_interface/hw_info_config.inl index e08bde0771..1beba44f36 100644 --- a/shared/source/os_interface/hw_info_config.inl +++ b/shared/source/os_interface/hw_info_config.inl @@ -482,8 +482,8 @@ template bool HwInfoConfigHw::isAdjustWalkOrderAvailable(const HardwareInfo &hwInfo) const { return false; } template -uint32_t HwInfoConfigHw::getL1CachePolicy() const { - return L1CachePolicyHelper::getL1CachePolicy(); +uint32_t HwInfoConfigHw::getL1CachePolicy(bool isDebuggerActive) const { + return L1CachePolicyHelper::getL1CachePolicy(isDebuggerActive); } template diff --git a/shared/source/xe_hp_core/command_encoder_xe_hp_core.cpp b/shared/source/xe_hp_core/command_encoder_xe_hp_core.cpp index 3a271269e0..b3b25c7376 100644 --- a/shared/source/xe_hp_core/command_encoder_xe_hp_core.cpp +++ b/shared/source/xe_hp_core/command_encoder_xe_hp_core.cpp @@ -18,7 +18,7 @@ using Family = NEO::XeHpFamily; #include "shared/source/command_container/command_encoder_tgllp_and_later.inl" #include "shared/source/command_container/image_surface_state/compression_params_tgllp_and_later.inl" #include "shared/source/command_container/image_surface_state/compression_params_xehp_and_later.inl" - +#include "shared/source/helpers/cache_flush_xehp_and_later.inl" namespace NEO { template <> @@ -26,7 +26,7 @@ void EncodeDispatchKernel::adjustTimestampPacket(WALKER_TYPE &walkerCmd, } template <> -inline void EncodeSurfaceState::encodeExtraCacheSettings(R_SURFACE_STATE *surfaceState, const HardwareInfo &hwInfo) { +inline void EncodeSurfaceState::encodeExtraCacheSettings(R_SURFACE_STATE *surfaceState, const EncodeSurfaceStateArgs &args) { } template <> @@ -82,6 +82,11 @@ constexpr bool EncodeDispatchKernel::shouldUpdateGlobalAtomics(bool &cur return false; } +template <> +void adjustL3ControlField(void *l3ControlBuffer) { ; } + +template void flushGpuCache(LinearStream *commandStream, const Range &ranges, uint64_t postSyncAddress, const HardwareInfo &hwInfo); + template struct EncodeDispatchKernel; template struct EncodeStates; template struct EncodeMath; diff --git a/shared/source/xe_hp_core/state_base_address_xe_hp_core.cpp b/shared/source/xe_hp_core/state_base_address_xe_hp_core.cpp index 88ce30bb31..8580fa0870 100644 --- a/shared/source/xe_hp_core/state_base_address_xe_hp_core.cpp +++ b/shared/source/xe_hp_core/state_base_address_xe_hp_core.cpp @@ -11,7 +11,7 @@ namespace NEO { template <> -void StateBaseAddressHelper::appendExtraCacheSettings(STATE_BASE_ADDRESS *stateBaseAddress, const HardwareInfo *hwInfo) { +void StateBaseAddressHelper::appendExtraCacheSettings(StateBaseAddressHelperArgs &args) { } template struct StateBaseAddressHelper; diff --git a/shared/source/xe_hpg_core/command_encoder_xe_hpg_core.cpp b/shared/source/xe_hpg_core/command_encoder_xe_hpg_core.cpp index f7c01a7da4..457a81bcb2 100644 --- a/shared/source/xe_hpg_core/command_encoder_xe_hpg_core.cpp +++ b/shared/source/xe_hpg_core/command_encoder_xe_hpg_core.cpp @@ -10,6 +10,7 @@ #include "shared/source/command_container/command_encoder_xehp_and_later.inl" #include "shared/source/command_container/encode_compute_mode_tgllp_and_later.inl" #include "shared/source/command_stream/stream_properties.h" +#include "shared/source/helpers/cache_flush_xehp_and_later.inl" #include "shared/source/os_interface/hw_info_config.h" #include "shared/source/utilities/lookup_array.h" #include "shared/source/xe_hpg_core/hw_cmds_xe_hpg_core_base.h" @@ -185,6 +186,15 @@ void EncodeDispatchKernel::adjustWalkOrder(WALKER_TYPE &walkerCmd, uint3 } } +template <> +void adjustL3ControlField(void *l3ControlBuffer) { + using L3_CONTROL = typename Family::L3_CONTROL; + auto l3Control = reinterpret_cast(l3ControlBuffer); + l3Control->setUnTypedDataPortCacheFlush(true); +} + +template void flushGpuCache(LinearStream *commandStream, const Range &ranges, uint64_t postSyncAddress, const HardwareInfo &hwInfo); + template struct EncodeDispatchKernel; template struct EncodeStates; template struct EncodeMath; diff --git a/shared/source/xe_hpg_core/enable_xe_hpg_core.cpp b/shared/source/xe_hpg_core/enable_xe_hpg_core.cpp index a103b3ca4c..2a4af55bc4 100644 --- a/shared/source/xe_hpg_core/enable_xe_hpg_core.cpp +++ b/shared/source/xe_hpg_core/enable_xe_hpg_core.cpp @@ -18,9 +18,12 @@ namespace NEO { #ifdef SUPPORT_DG2 template <> -uint32_t L1CachePolicyHelper::getDefaultL1CachePolicy() { +uint32_t L1CachePolicyHelper::getDefaultL1CachePolicy(bool isDebuggerActive) { using GfxFamily = HwMapper::GfxFamily; - return GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP; + if (isDebuggerActive) { + return GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP; + } + return GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB; } template struct L1CachePolicyHelper; diff --git a/shared/test/common/mocks/mock_hw_info_config.cpp b/shared/test/common/mocks/mock_hw_info_config.cpp index d76c6e938a..c7cca96d19 100644 --- a/shared/test/common/mocks/mock_hw_info_config.cpp +++ b/shared/test/common/mocks/mock_hw_info_config.cpp @@ -393,12 +393,12 @@ bool HwInfoConfigHw::isEvictionIfNecessaryFlagSupported() const { } template <> -const char *L1CachePolicyHelper::getCachingPolicyOptions() { +const char *L1CachePolicyHelper::getCachingPolicyOptions(bool isDebuggerActive) { return nullptr; } template <> -uint32_t L1CachePolicyHelper::getDefaultL1CachePolicy() { +uint32_t L1CachePolicyHelper::getDefaultL1CachePolicy(bool isDebuggerActive) { return 0u; } @@ -408,8 +408,8 @@ bool HwInfoConfigHw::isPrefetcherDisablingInDirectSubmissionRequir } template <> -uint32_t L1CachePolicyHelper::getL1CachePolicy() { - return L1CachePolicyHelper::getDefaultL1CachePolicy(); +uint32_t L1CachePolicyHelper::getL1CachePolicy(bool isDebuggerActive) { + return L1CachePolicyHelper::getDefaultL1CachePolicy(isDebuggerActive); } template <> diff --git a/shared/test/unit_test/encoders/CMakeLists.txt b/shared/test/unit_test/encoders/CMakeLists.txt index 3415e108cd..0683e7a8c9 100644 --- a/shared/test/unit_test/encoders/CMakeLists.txt +++ b/shared/test/unit_test/encoders/CMakeLists.txt @@ -48,7 +48,10 @@ if(TESTS_DG2_AND_LATER) endif() if(TESTS_DG2) - target_sources(neo_shared_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/command_encoder_tests_dg2.cpp) + target_sources(neo_shared_tests PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/command_encoder_tests_dg2.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_encode_states_dg2.cpp + ) endif() if(TESTS_XE_HPG_CORE) diff --git a/shared/test/unit_test/encoders/test_encode_states_dg2.cpp b/shared/test/unit_test/encoders/test_encode_states_dg2.cpp new file mode 100644 index 0000000000..1c68c2f802 --- /dev/null +++ b/shared/test/unit_test/encoders/test_encode_states_dg2.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/gmm_helper/gmm_helper.h" +#include "shared/source/helpers/hw_helper.h" +#include "shared/test/common/cmd_parse/gen_cmd_parse.h" +#include "shared/test/common/mocks/mock_debugger.h" +#include "shared/test/unit_test/fixtures/command_container_fixture.h" + +#include "test_traits_common.h" + +using namespace NEO; + +using CommandEncodeStatesDG2Test = Test; + +HWTEST2_F(CommandEncodeStatesDG2Test, givenCommandContainerWhenSetStateBaseAddressCalledThenCachePolicyIsWB, IsDG2) { + using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; + cmdContainer->dirtyHeaps = 0; + + STATE_BASE_ADDRESS sba; + auto gmmHelper = cmdContainer->getDevice()->getRootDeviceEnvironment().getGmmHelper(); + uint32_t statelessMocsIndex = (gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER) >> 1); + + EncodeStateBaseAddressArgs args = createDefaultEncodeStateBaseAddressArgs(cmdContainer.get(), sba, statelessMocsIndex); + + EncodeStateBaseAddress::encode(args); + + GenCmdList commands; + CmdParse::parseCommandBuffer(commands, ptrOffset(cmdContainer->getCommandStream()->getCpuBase(), 0), cmdContainer->getCommandStream()->getUsed()); + + auto itorCmd = find(commands.begin(), commands.end()); + ASSERT_NE(itorCmd, commands.end()); + + auto cmd = genCmdCast(*itorCmd); + + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB, cmd->getL1CachePolicyL1CacheControl()); +} + +HWTEST2_F(CommandEncodeStatesDG2Test, givenCommandContainerAndDebuggerActiveWhenSetStateBaseAddressCalledThenCachePolicyIsWBP, IsDG2) { + using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; + cmdContainer->dirtyHeaps = 0; + auto debugger = new MockDebugger(); + + cmdContainer->getDevice()->getExecutionEnvironment()->rootDeviceEnvironments[0]->debugger.reset(debugger); + STATE_BASE_ADDRESS sba; + auto gmmHelper = cmdContainer->getDevice()->getRootDeviceEnvironment().getGmmHelper(); + uint32_t statelessMocsIndex = (gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER) >> 1); + + EncodeStateBaseAddressArgs args = createDefaultEncodeStateBaseAddressArgs(cmdContainer.get(), sba, statelessMocsIndex); + const_cast(pDevice->getDeviceInfo()).debuggerActive = true; + EncodeStateBaseAddress::encode(args); + + GenCmdList commands; + CmdParse::parseCommandBuffer(commands, ptrOffset(cmdContainer->getCommandStream()->getCpuBase(), 0), cmdContainer->getCommandStream()->getUsed()); + + auto itorCmd = find(commands.begin(), commands.end()); + ASSERT_NE(itorCmd, commands.end()); + + auto cmd = genCmdCast(*itorCmd); + + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP, cmd->getL1CachePolicyL1CacheControl()); +} diff --git a/shared/test/unit_test/helpers/cache_policy_tests.cpp b/shared/test/unit_test/helpers/cache_policy_tests.cpp index cac6a1cd82..dbd603f22e 100644 --- a/shared/test/unit_test/helpers/cache_policy_tests.cpp +++ b/shared/test/unit_test/helpers/cache_policy_tests.cpp @@ -13,7 +13,8 @@ using namespace NEO; HWTEST2_F(HwInfoConfigTest, givenL1CachePolicyHelperWhenUnsupportedL1PoliciesAndGetDefaultL1CachePolicyThenReturnZero, IsAtMostXeHpCore) { - EXPECT_EQ(L1CachePolicyHelper::getL1CachePolicy(), 0u); + EXPECT_EQ(L1CachePolicyHelper::getL1CachePolicy(false), 0u); + EXPECT_EQ(L1CachePolicyHelper::getL1CachePolicy(true), 0u); } HWTEST2_F(HwInfoConfigTest, givenL1CachePolicyHelperWhenUnsupportedL1PoliciesAndGetUncached1CachePolicyThenReturnOne, IsAtMostXeHpCore) { @@ -22,7 +23,8 @@ HWTEST2_F(HwInfoConfigTest, givenL1CachePolicyHelperWhenUnsupportedL1PoliciesAnd HWTEST2_F(HwInfoConfigTest, givenAtLeastXeHpgCoreWhenGetL1CachePolicyThenReturnCorrectValue, IsAtLeastXeHpgCore) { using GfxFamily = typename HwMapper::GfxFamily; - EXPECT_EQ(L1CachePolicyHelper::getL1CachePolicy(), GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP); + EXPECT_EQ(L1CachePolicyHelper::getL1CachePolicy(false), GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP); + EXPECT_EQ(L1CachePolicyHelper::getL1CachePolicy(true), GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP); } HWTEST2_F(HwInfoConfigTest, givenAtLeastXeHpgCoreWhenGetUncached1CachePolicyThenReturnCorrectValue, IsAtLeastXeHpgCore) { @@ -35,7 +37,8 @@ HWTEST2_F(HwInfoConfigTest, givenAtLeastXeHpgCoreAndWriteBackPolicyWhenGetL1Cach DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(2); const char *expectedStr = "-cl-store-cache-default=7 -cl-load-cache-default=4"; - EXPECT_EQ(0, memcmp(L1CachePolicyHelper::getCachingPolicyOptions(), expectedStr, strlen(expectedStr))); + EXPECT_EQ(0, memcmp(L1CachePolicyHelper::getCachingPolicyOptions(false), expectedStr, strlen(expectedStr))); + EXPECT_EQ(0, memcmp(L1CachePolicyHelper::getCachingPolicyOptions(true), expectedStr, strlen(expectedStr))); } HWTEST2_F(HwInfoConfigTest, givenAtLeastXeHpgCoreAndForceAllResourcesUncachedWhenGetL1CachePolicyThenReturnCorrectValue, IsAtLeastXeHpgCore) { @@ -44,21 +47,26 @@ HWTEST2_F(HwInfoConfigTest, givenAtLeastXeHpgCoreAndForceAllResourcesUncachedWhe DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(4); const char *expectedStr = "-cl-store-cache-default=1 -cl-load-cache-default=1"; - EXPECT_EQ(0, memcmp(L1CachePolicyHelper::getCachingPolicyOptions(), expectedStr, strlen(expectedStr))); + EXPECT_EQ(0, memcmp(L1CachePolicyHelper::getCachingPolicyOptions(false), expectedStr, strlen(expectedStr))); + EXPECT_EQ(0, memcmp(L1CachePolicyHelper::getCachingPolicyOptions(true), expectedStr, strlen(expectedStr))); } HWTEST2_F(HwInfoConfigTest, givenL1CachePolicyHelperWhenDebugFlagSetAndGetL1CachePolicyThenReturnCorrectValue, MatchAny) { DebugManagerStateRestore restorer; DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(0); - EXPECT_EQ(L1CachePolicyHelper::getL1CachePolicy(), 0u); + EXPECT_EQ(L1CachePolicyHelper::getL1CachePolicy(false), 0u); + EXPECT_EQ(L1CachePolicyHelper::getL1CachePolicy(true), 0u); DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(2); - EXPECT_EQ(L1CachePolicyHelper::getL1CachePolicy(), 2u); + EXPECT_EQ(L1CachePolicyHelper::getL1CachePolicy(false), 2u); + EXPECT_EQ(L1CachePolicyHelper::getL1CachePolicy(true), 2u); DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(3); - EXPECT_EQ(L1CachePolicyHelper::getL1CachePolicy(), 3u); + EXPECT_EQ(L1CachePolicyHelper::getL1CachePolicy(false), 3u); + EXPECT_EQ(L1CachePolicyHelper::getL1CachePolicy(true), 3u); DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(4); - EXPECT_EQ(L1CachePolicyHelper::getL1CachePolicy(), 4u); + EXPECT_EQ(L1CachePolicyHelper::getL1CachePolicy(false), 4u); + EXPECT_EQ(L1CachePolicyHelper::getL1CachePolicy(true), 4u); } diff --git a/shared/test/unit_test/helpers/state_base_address_tests.cpp b/shared/test/unit_test/helpers/state_base_address_tests.cpp index 8a1a02911c..cd008056c2 100644 --- a/shared/test/unit_test/helpers/state_base_address_tests.cpp +++ b/shared/test/unit_test/helpers/state_base_address_tests.cpp @@ -42,7 +42,8 @@ HWTEST2_F(SbaTest, WhenAppendStateBaseAddressParametersIsCalledThenSBACmdHasBind false, // isMultiOsContextCapable false, // useGlobalAtomics false, // areMultipleSubDevicesInContext - false // overrideSurfaceStateBaseAddress + false, // overrideSurfaceStateBaseAddress + false // isDebuggerActive }; StateBaseAddressHelper::appendStateBaseAddressParameters(args, true); @@ -84,7 +85,8 @@ HWTEST2_F(SbaTest, WhenProgramStateBaseAddressParametersIsCalledThenSBACmdHasBin false, // isMultiOsContextCapable false, // useGlobalAtomics false, // areMultipleSubDevicesInContext - false // overrideSurfaceStateBaseAddress + false, // overrideSurfaceStateBaseAddress + false // isDebuggerActive }; StateBaseAddressHelper::programStateBaseAddress(args); @@ -126,7 +128,8 @@ HWTEST2_F(SbaTest, false, // isMultiOsContextCapable false, // useGlobalAtomics false, // areMultipleSubDevicesInContext - true // overrideSurfaceStateBaseAddress + true, // overrideSurfaceStateBaseAddress + false // isDebuggerActive }; StateBaseAddressHelper::programStateBaseAddress(args); @@ -168,7 +171,8 @@ HWTEST2_F(SbaForBindlessTests, givenGlobalBindlessBaseAddressWhenProgramStateBas false, // isMultiOsContextCapable false, // useGlobalAtomics false, // areMultipleSubDevicesInContext - false // overrideSurfaceStateBaseAddress + false, // overrideSurfaceStateBaseAddress + false // isDebuggerActive }; StateBaseAddressHelper::programStateBaseAddress(args); @@ -223,7 +227,8 @@ HWTEST2_F(SbaForBindlessTests, false, // isMultiOsContextCapable false, // useGlobalAtomics false, // areMultipleSubDevicesInContext - true // overrideSurfaceStateBaseAddress + true, // overrideSurfaceStateBaseAddress + false // isDebuggerActive }; StateBaseAddressHelper::programStateBaseAddress(args); @@ -279,7 +284,8 @@ HWTEST2_F(SbaForBindlessTests, givenGlobalBindlessBaseAddressWhenPassingIndirect false, // isMultiOsContextCapable false, // useGlobalAtomics false, // areMultipleSubDevicesInContext - false // overrideSurfaceStateBaseAddress + false, // overrideSurfaceStateBaseAddress + false // isDebuggerActive }; StateBaseAddressHelper::programStateBaseAddress(args); @@ -316,7 +322,8 @@ HWTEST2_F(SbaTest, givenSbaWhenOverrideBindlessSurfaceBaseIsFalseThenBindlessSur false, // isMultiOsContextCapable false, // useGlobalAtomics false, // areMultipleSubDevicesInContext - false // overrideSurfaceStateBaseAddress + false, // overrideSurfaceStateBaseAddress + false // isDebuggerActive }; StateBaseAddressHelper::appendStateBaseAddressParameters(args, false); @@ -355,7 +362,8 @@ HWTEST2_F(SbaTest, givenGlobalBindlessBaseAddressWhenSshIsPassedThenBindlessSurf false, // isMultiOsContextCapable false, // useGlobalAtomics false, // areMultipleSubDevicesInContext - false // overrideSurfaceStateBaseAddress + false, // overrideSurfaceStateBaseAddress + false // isDebuggerActive }; StateBaseAddressHelper::programStateBaseAddress(args); @@ -393,7 +401,8 @@ HWTEST2_F(SbaTest, givenSurfaceStateHeapWhenNotUsingGlobalHeapBaseThenBindlessSu false, // isMultiOsContextCapable false, // useGlobalAtomics false, // areMultipleSubDevicesInContext - false // overrideSurfaceStateBaseAddress + false, // overrideSurfaceStateBaseAddress + false // isDebuggerActive }; StateBaseAddressHelper::programStateBaseAddress(args); @@ -407,41 +416,110 @@ HWTEST2_F(SbaTest, givenStateBaseAddressAndDebugFlagSetWhenAppendExtraCacheSetti auto expectedStateBaseAddress = FamilyType::cmdInitStateBaseAddress; DebugManagerStateRestore restore; - StateBaseAddressHelper::appendExtraCacheSettings(&stateBaseAddress, &hardwareInfo); + StateBaseAddressHelperArgs args = { + 0, // generalStateBase + 0, // indirectObjectHeapBaseAddress + 0, // instructionHeapBaseAddress + 0, // globalHeapsBaseAddress + 0, // surfaceStateBaseAddress + &stateBaseAddress, // stateBaseAddressCmd + nullptr, // dsh + nullptr, // ioh + &ssh, // ssh + pDevice->getGmmHelper(), // gmmHelper + 0, // statelessMocsIndex + MemoryCompressionState::NotApplicable, // memoryCompressionState + false, // setInstructionStateBaseAddress + false, // setGeneralStateBaseAddress + false, // useGlobalHeapsBaseAddress + false, // isMultiOsContextCapable + false, // useGlobalAtomics + false, // areMultipleSubDevicesInContext + false, // overrideSurfaceStateBaseAddress + false // isDebuggerActive + }; + + StateBaseAddressHelper::appendExtraCacheSettings(args); EXPECT_EQ(0, memcmp(&stateBaseAddress, &expectedStateBaseAddress, sizeof(STATE_BASE_ADDRESS))); DebugManager.flags.ForceStatelessL1CachingPolicy.set(2); - StateBaseAddressHelper::appendExtraCacheSettings(&stateBaseAddress, &hardwareInfo); + StateBaseAddressHelper::appendExtraCacheSettings(args); EXPECT_EQ(0, memcmp(&stateBaseAddress, &expectedStateBaseAddress, sizeof(STATE_BASE_ADDRESS))); DebugManager.flags.ForceAllResourcesUncached.set(true); - StateBaseAddressHelper::appendExtraCacheSettings(&stateBaseAddress, &hardwareInfo); + StateBaseAddressHelper::appendExtraCacheSettings(args); EXPECT_EQ(0, memcmp(&stateBaseAddress, &expectedStateBaseAddress, sizeof(STATE_BASE_ADDRESS))); } HWTEST2_F(SbaTest, givenStateBaseAddressAndDebugFlagSetWhenAppendExtraCacheSettingsThenProgramCorrectL1CachePolicy, IsAtLeastXeHpgCore) { using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; auto stateBaseAddress = FamilyType::cmdInitStateBaseAddress; - DebugManagerStateRestore restore; - StateBaseAddressHelper::appendExtraCacheSettings(&stateBaseAddress, &hardwareInfo); - EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP, stateBaseAddress.getL1CachePolicyL1CacheControl()); + StateBaseAddressHelperArgs args = { + 0, // generalStateBase + 0, // indirectObjectHeapBaseAddress + 0, // instructionHeapBaseAddress + 0, // globalHeapsBaseAddress + 0, // surfaceStateBaseAddress + &stateBaseAddress, // stateBaseAddressCmd + nullptr, // dsh + nullptr, // ioh + &ssh, // ssh + pDevice->getGmmHelper(), // gmmHelper + 0, // statelessMocsIndex + MemoryCompressionState::NotApplicable, // memoryCompressionState + false, // setInstructionStateBaseAddress + false, // setGeneralStateBaseAddress + false, // useGlobalHeapsBaseAddress + false, // isMultiOsContextCapable + false, // useGlobalAtomics + false, // areMultipleSubDevicesInContext + false, // overrideSurfaceStateBaseAddress + false // isDebuggerActive + }; + { + DebugManagerStateRestore restore; + StateBaseAddressHelper::appendExtraCacheSettings(args); + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP, stateBaseAddress.getL1CachePolicyL1CacheControl()); - DebugManager.flags.ForceStatelessL1CachingPolicy.set(2); - StateBaseAddressHelper::appendExtraCacheSettings(&stateBaseAddress, &hardwareInfo); - EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB, stateBaseAddress.getL1CachePolicyL1CacheControl()); + DebugManager.flags.ForceStatelessL1CachingPolicy.set(2); + StateBaseAddressHelper::appendExtraCacheSettings(args); + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB, stateBaseAddress.getL1CachePolicyL1CacheControl()); - DebugManager.flags.ForceStatelessL1CachingPolicy.set(3); - StateBaseAddressHelper::appendExtraCacheSettings(&stateBaseAddress, &hardwareInfo); - EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WT, stateBaseAddress.getL1CachePolicyL1CacheControl()); + DebugManager.flags.ForceStatelessL1CachingPolicy.set(3); + StateBaseAddressHelper::appendExtraCacheSettings(args); + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WT, stateBaseAddress.getL1CachePolicyL1CacheControl()); - DebugManager.flags.ForceStatelessL1CachingPolicy.set(4); - StateBaseAddressHelper::appendExtraCacheSettings(&stateBaseAddress, &hardwareInfo); - EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WS, stateBaseAddress.getL1CachePolicyL1CacheControl()); + DebugManager.flags.ForceStatelessL1CachingPolicy.set(4); + StateBaseAddressHelper::appendExtraCacheSettings(args); + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WS, stateBaseAddress.getL1CachePolicyL1CacheControl()); - DebugManager.flags.ForceAllResourcesUncached.set(true); - StateBaseAddressHelper::appendExtraCacheSettings(&stateBaseAddress, &hardwareInfo); - EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_UC, stateBaseAddress.getL1CachePolicyL1CacheControl()); + DebugManager.flags.ForceAllResourcesUncached.set(true); + StateBaseAddressHelper::appendExtraCacheSettings(args); + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_UC, stateBaseAddress.getL1CachePolicyL1CacheControl()); + } + args.isDebuggerActive = true; + { + DebugManagerStateRestore restore; + StateBaseAddressHelper::appendExtraCacheSettings(args); + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP, stateBaseAddress.getL1CachePolicyL1CacheControl()); + + DebugManager.flags.ForceStatelessL1CachingPolicy.set(2); + StateBaseAddressHelper::appendExtraCacheSettings(args); + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB, stateBaseAddress.getL1CachePolicyL1CacheControl()); + + DebugManager.flags.ForceStatelessL1CachingPolicy.set(3); + StateBaseAddressHelper::appendExtraCacheSettings(args); + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WT, stateBaseAddress.getL1CachePolicyL1CacheControl()); + + DebugManager.flags.ForceStatelessL1CachingPolicy.set(4); + StateBaseAddressHelper::appendExtraCacheSettings(args); + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WS, stateBaseAddress.getL1CachePolicyL1CacheControl()); + + DebugManager.flags.ForceAllResourcesUncached.set(true); + StateBaseAddressHelper::appendExtraCacheSettings(args); + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_UC, stateBaseAddress.getL1CachePolicyL1CacheControl()); + } } HWTEST2_F(SbaTest, givenDebugFlagSetWhenAppendingSbaThenProgramCorrectL1CachePolicy, IsAtLeastXeHpgCore) { @@ -475,7 +553,8 @@ HWTEST2_F(SbaTest, givenDebugFlagSetWhenAppendingSbaThenProgramCorrectL1CachePol false, // isMultiOsContextCapable false, // useGlobalAtomics false, // areMultipleSubDevicesInContext - false // overrideSurfaceStateBaseAddress + false, // overrideSurfaceStateBaseAddress + false // isDebuggerActive }; for (const auto &input : testInputs) { @@ -555,7 +634,8 @@ HWCMDTEST_F(IGFX_GEN8_CORE, SbaTest, whenGeneralStateBaseAddressIsProgrammedThen false, // isMultiOsContextCapable false, // useGlobalAtomics false, // areMultipleSubDevicesInContext - false // overrideSurfaceStateBaseAddress + false, // overrideSurfaceStateBaseAddress + false // isDebuggerActive }; StateBaseAddressHelper::programStateBaseAddress(args); @@ -586,7 +666,8 @@ HWTEST_F(SbaTest, givenNonZeroGeneralStateBaseAddressWhenProgrammingIsDisabledTh false, // isMultiOsContextCapable false, // useGlobalAtomics false, // areMultipleSubDevicesInContext - false // overrideSurfaceStateBaseAddress + false, // overrideSurfaceStateBaseAddress + false // isDebuggerActive }; StateBaseAddressHelper::programStateBaseAddress(args); @@ -619,7 +700,8 @@ HWTEST_F(SbaTest, givenNonZeroInternalHeapBaseAddressWhenProgrammingIsDisabledTh false, // isMultiOsContextCapable false, // useGlobalAtomics false, // areMultipleSubDevicesInContext - false // overrideSurfaceStateBaseAddress + false, // overrideSurfaceStateBaseAddress + false // isDebuggerActive }; StateBaseAddressHelper::programStateBaseAddress(args); @@ -658,7 +740,8 @@ HWCMDTEST_F(IGFX_GEN8_CORE, SbaTest, givenSbaProgrammingWhenHeapsAreNotProvidedT false, // isMultiOsContextCapable false, // useGlobalAtomics false, // areMultipleSubDevicesInContext - false // overrideSurfaceStateBaseAddress + false, // overrideSurfaceStateBaseAddress + false // isDebuggerActive }; StateBaseAddressHelper::programStateBaseAddress(args); @@ -717,7 +800,8 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, SbaTest, false, // isMultiOsContextCapable false, // useGlobalAtomics false, // areMultipleSubDevicesInContext - false // overrideSurfaceStateBaseAddress + false, // overrideSurfaceStateBaseAddress + false // isDebuggerActive }; StateBaseAddressHelper::programStateBaseAddress(args); 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 6381b893fd..25eab5d0cd 100644 --- a/shared/test/unit_test/helpers/test_hw_info_config.cpp +++ b/shared/test/unit_test/helpers/test_hw_info_config.cpp @@ -104,13 +104,15 @@ HWTEST_F(HwInfoConfigTest, givenHwInfoConfigWhenIsAdjustWalkOrderAvailableCallTh HWTEST2_F(HwInfoConfigTest, givenAtMostXeHPWhenGetCachingPolicyOptionsThenReturnNullptr, IsAtMostXeHpCore) { auto compilerHwInfoConfig = CompilerHwInfoConfig::get(defaultHwInfo->platform.eProductFamily); - EXPECT_EQ(compilerHwInfoConfig->getCachingPolicyOptions(), nullptr); + EXPECT_EQ(compilerHwInfoConfig->getCachingPolicyOptions(false), nullptr); + EXPECT_EQ(compilerHwInfoConfig->getCachingPolicyOptions(true), nullptr); } HWTEST2_F(HwInfoConfigTest, givenAtLeastXeHpgCoreWhenGetCachingPolicyOptionsThenReturnWriteByPassPolicyOption, IsAtLeastXeHpgCore) { auto compilerHwInfoConfig = CompilerHwInfoConfig::get(defaultHwInfo->platform.eProductFamily); const char *expectedStr = "-cl-store-cache-default=2 -cl-load-cache-default=4"; - EXPECT_EQ(0, memcmp(compilerHwInfoConfig->getCachingPolicyOptions(), expectedStr, strlen(expectedStr))); + EXPECT_EQ(0, memcmp(compilerHwInfoConfig->getCachingPolicyOptions(false), expectedStr, strlen(expectedStr))); + EXPECT_EQ(0, memcmp(compilerHwInfoConfig->getCachingPolicyOptions(true), expectedStr, strlen(expectedStr))); } HWTEST2_F(HwInfoConfigTest, givenAtLeastXeHpgCoreWhenGetCachingPolicyOptionsThenReturnWriteBackPolicyOption, IsAtLeastXeHpgCore) { @@ -119,7 +121,8 @@ HWTEST2_F(HwInfoConfigTest, givenAtLeastXeHpgCoreWhenGetCachingPolicyOptionsThen auto compilerHwInfoConfig = CompilerHwInfoConfig::get(defaultHwInfo->platform.eProductFamily); const char *expectedStr = "-cl-store-cache-default=7 -cl-load-cache-default=4"; - EXPECT_EQ(0, memcmp(compilerHwInfoConfig->getCachingPolicyOptions(), expectedStr, strlen(expectedStr))); + EXPECT_EQ(0, memcmp(compilerHwInfoConfig->getCachingPolicyOptions(false), expectedStr, strlen(expectedStr))); + EXPECT_EQ(0, memcmp(compilerHwInfoConfig->getCachingPolicyOptions(true), expectedStr, strlen(expectedStr))); } HWTEST2_F(HwInfoConfigTest, givenAtLeastXeHpgCoreAndDebugFlagSetForceAllResourcesUncachedWhenGetCachingPolicyOptionsThenReturnUncachedPolicyOption, IsAtLeastXeHpgCore) { @@ -129,7 +132,8 @@ HWTEST2_F(HwInfoConfigTest, givenAtLeastXeHpgCoreAndDebugFlagSetForceAllResource auto compilerHwInfoConfig = CompilerHwInfoConfig::get(defaultHwInfo->platform.eProductFamily); const char *expectedStr = "-cl-store-cache-default=1 -cl-load-cache-default=1"; - EXPECT_EQ(0, memcmp(compilerHwInfoConfig->getCachingPolicyOptions(), expectedStr, strlen(expectedStr))); + EXPECT_EQ(0, memcmp(compilerHwInfoConfig->getCachingPolicyOptions(false), expectedStr, strlen(expectedStr))); + EXPECT_EQ(0, memcmp(compilerHwInfoConfig->getCachingPolicyOptions(true), expectedStr, strlen(expectedStr))); } HWTEST2_F(HwInfoConfigTest, givenCachePolicyWithoutCorrespondingBuildOptionWhenGetCachingPolicyOptionsThenReturnNullptr, IsAtLeastXeHpgCore) { @@ -137,7 +141,8 @@ HWTEST2_F(HwInfoConfigTest, givenCachePolicyWithoutCorrespondingBuildOptionWhenG DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(5); auto compilerHwInfoConfig = CompilerHwInfoConfig::get(defaultHwInfo->platform.eProductFamily); - EXPECT_EQ(nullptr, compilerHwInfoConfig->getCachingPolicyOptions()); + EXPECT_EQ(nullptr, compilerHwInfoConfig->getCachingPolicyOptions(false)); + EXPECT_EQ(nullptr, compilerHwInfoConfig->getCachingPolicyOptions(true)); } HWTEST2_F(HwInfoConfigTest, givenHwInfoConfigAndDebugFlagWhenGetL1CachePolicyThenReturnCorrectPolicy, IsAtLeastXeHpgCore) { @@ -146,33 +151,40 @@ HWTEST2_F(HwInfoConfigTest, givenHwInfoConfigAndDebugFlagWhenGetL1CachePolicyThe auto hwInfoConfig = HwInfoConfig::get(hwInfo.platform.eProductFamily); DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(0); - EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP, hwInfoConfig->getL1CachePolicy()); + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP, hwInfoConfig->getL1CachePolicy(false)); + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP, hwInfoConfig->getL1CachePolicy(true)); DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(2); - EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB, hwInfoConfig->getL1CachePolicy()); + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB, hwInfoConfig->getL1CachePolicy(false)); + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB, hwInfoConfig->getL1CachePolicy(true)); DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(3); - EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WT, hwInfoConfig->getL1CachePolicy()); + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WT, hwInfoConfig->getL1CachePolicy(false)); + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WT, hwInfoConfig->getL1CachePolicy(true)); DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(4); - EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WS, hwInfoConfig->getL1CachePolicy()); + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WS, hwInfoConfig->getL1CachePolicy(false)); + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WS, hwInfoConfig->getL1CachePolicy(true)); DebugManager.flags.ForceAllResourcesUncached.set(true); - EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_UC, hwInfoConfig->getL1CachePolicy()); + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_UC, hwInfoConfig->getL1CachePolicy(false)); + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_UC, hwInfoConfig->getL1CachePolicy(true)); } HWTEST2_F(HwInfoConfigTest, givenHwInfoConfigWhenGetL1CachePolicyThenReturnWriteByPass, IsAtLeastXeHpgCore) { auto hwInfo = *defaultHwInfo; auto hwInfoConfig = HwInfoConfig::get(hwInfo.platform.eProductFamily); - EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP, hwInfoConfig->getL1CachePolicy()); + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP, hwInfoConfig->getL1CachePolicy(false)); + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP, hwInfoConfig->getL1CachePolicy(true)); } HWTEST2_F(HwInfoConfigTest, givenPlatformWithUnsupportedL1CachePoliciesWhenGetL1CachePolicyThenReturnZero, IsAtMostXeHpCore) { auto hwInfo = *defaultHwInfo; auto hwInfoConfig = HwInfoConfig::get(hwInfo.platform.eProductFamily); - EXPECT_EQ(0u, hwInfoConfig->getL1CachePolicy()); + EXPECT_EQ(0u, hwInfoConfig->getL1CachePolicy(false)); + EXPECT_EQ(0u, hwInfoConfig->getL1CachePolicy(true)); } HWTEST_F(HwInfoConfigTest, givenHwInfoConfigWhenIsPrefetcherDisablingInDirectSubmissionRequiredThenTrueIsReturned) { diff --git a/shared/test/unit_test/xe_hp_core/CMakeLists.txt b/shared/test/unit_test/xe_hp_core/CMakeLists.txt index 663d88d846..f7347c5b7b 100644 --- a/shared/test/unit_test/xe_hp_core/CMakeLists.txt +++ b/shared/test/unit_test/xe_hp_core/CMakeLists.txt @@ -7,6 +7,7 @@ if(TESTS_XE_HP_CORE) target_sources(neo_shared_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/command_encoder_tests_xe_hp_core.cpp ${CMAKE_CURRENT_SOURCE_DIR}/compute_mode_tests_xe_hp_core.cpp ${CMAKE_CURRENT_SOURCE_DIR}/excludes_xe_hp_core.cpp ${CMAKE_CURRENT_SOURCE_DIR}/hw_cmds_xe_hp_core_tests.cpp diff --git a/shared/test/unit_test/xe_hp_core/command_encoder_tests_xe_hp_core.cpp b/shared/test/unit_test/xe_hp_core/command_encoder_tests_xe_hp_core.cpp new file mode 100644 index 0000000000..60df0e9e4c --- /dev/null +++ b/shared/test/unit_test/xe_hp_core/command_encoder_tests_xe_hp_core.cpp @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/cache_flush_xehp_and_later.inl" +#include "shared/test/common/test_macros/hw_test.h" + +using namespace NEO; + +using L3ControlTests = ::testing::Test; + +HWTEST2_F(L3ControlTests, givenL3ControlWhenAdjustCalledThenItIsNotChanged, IsXeHpCore) { + using L3_CONTROL = typename FamilyType::L3_CONTROL; + auto l3Control = FamilyType::cmdInitL3Control; + auto l3ControlOnStart = l3Control; + + adjustL3ControlField(&l3Control); + EXPECT_EQ(0, memcmp(&l3ControlOnStart, &l3Control, sizeof(L3_CONTROL))); // no change +} diff --git a/shared/test/unit_test/xe_hpg_core/CMakeLists.txt b/shared/test/unit_test/xe_hpg_core/CMakeLists.txt index fc4e935cb8..7c3d97fdd3 100644 --- a/shared/test/unit_test/xe_hpg_core/CMakeLists.txt +++ b/shared/test/unit_test/xe_hpg_core/CMakeLists.txt @@ -11,6 +11,7 @@ if(TESTS_XE_HPG_CORE) target_sources(neo_shared_tests PRIVATE ${IGDRCL_SRCS_tests_xe_hpg_core_excludes} ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/command_encoder_tests_xe_hpg_core.cpp ${CMAKE_CURRENT_SOURCE_DIR}/compute_mode_tests_xe_hpg_core.cpp ${CMAKE_CURRENT_SOURCE_DIR}/hw_cmds_xe_hpg_core_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/hw_helper_tests_xe_hpg_core.cpp diff --git a/shared/test/unit_test/xe_hpg_core/command_encoder_tests_xe_hpg_core.cpp b/shared/test/unit_test/xe_hpg_core/command_encoder_tests_xe_hpg_core.cpp new file mode 100644 index 0000000000..5022662af7 --- /dev/null +++ b/shared/test/unit_test/xe_hpg_core/command_encoder_tests_xe_hpg_core.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/cache_flush_xehp_and_later.inl" +#include "shared/test/common/test_macros/hw_test.h" + +using namespace NEO; + +using L3ControlTests = ::testing::Test; + +HWTEST2_F(L3ControlTests, givenL3ControlWhenAdjustCalledThenUnTypedDataPortCacheFlushIsSet, IsXeHpgCore) { + using L3_CONTROL = typename FamilyType::L3_CONTROL; + auto l3Control = FamilyType::cmdInitL3Control; + auto l3ControlOnStart = l3Control; + + adjustL3ControlField(&l3Control); + EXPECT_NE(0, memcmp(&l3ControlOnStart, &l3Control, sizeof(L3_CONTROL))); // no change + + EXPECT_FALSE(l3ControlOnStart.getUnTypedDataPortCacheFlush()); + EXPECT_TRUE(l3Control.getUnTypedDataPortCacheFlush()); +} diff --git a/shared/test/unit_test/xe_hpg_core/dg2/cache_policy_tests_dg2.cpp b/shared/test/unit_test/xe_hpg_core/dg2/cache_policy_tests_dg2.cpp index 54db4d99ed..c1610cdd44 100644 --- a/shared/test/unit_test/xe_hpg_core/dg2/cache_policy_tests_dg2.cpp +++ b/shared/test/unit_test/xe_hpg_core/dg2/cache_policy_tests_dg2.cpp @@ -15,12 +15,16 @@ using namespace NEO; -DG2TEST_F(HwInfoConfigTest, givenDG2WhenGetL1CachePolicyThenReturnWbpPolicy) { +DG2TEST_F(HwInfoConfigTest, givenDG2WhenGetL1CachePolicyThenReturnWbPolicyUnlessDebuggerIsActive) { using GfxFamily = typename HwMapper::GfxFamily; - EXPECT_EQ(L1CachePolicyHelper::getL1CachePolicy(), GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP); + EXPECT_EQ(L1CachePolicyHelper::getL1CachePolicy(false), GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB); + EXPECT_EQ(L1CachePolicyHelper::getL1CachePolicy(true), GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP); } DG2TEST_F(HwInfoConfigTest, givenDG2WhenGetCachingPolicyOptionsThenReturnCorrectValue) { - const char *expectedStr = "-cl-store-cache-default=2 -cl-load-cache-default=4"; - EXPECT_EQ(0, memcmp(L1CachePolicyHelper::getCachingPolicyOptions(), expectedStr, strlen(expectedStr))); + const char *writeBackPolicyOptions = "-cl-store-cache-default=7 -cl-load-cache-default=4"; + EXPECT_EQ(0, memcmp(L1CachePolicyHelper::getCachingPolicyOptions(false), writeBackPolicyOptions, strlen(writeBackPolicyOptions))); + + const char *writeByPassPolicyOptions = "-cl-store-cache-default=2 -cl-load-cache-default=4"; + EXPECT_EQ(0, memcmp(L1CachePolicyHelper::getCachingPolicyOptions(true), writeByPassPolicyOptions, strlen(writeByPassPolicyOptions))); } \ No newline at end of file diff --git a/shared/test/unit_test/xe_hpg_core/dg2/excludes_xe_hpg_core_dg2.cpp b/shared/test/unit_test/xe_hpg_core/dg2/excludes_xe_hpg_core_dg2.cpp index 9f6b8317cb..921f29010b 100644 --- a/shared/test/unit_test/xe_hpg_core/dg2/excludes_xe_hpg_core_dg2.cpp +++ b/shared/test/unit_test/xe_hpg_core/dg2/excludes_xe_hpg_core_dg2.cpp @@ -18,8 +18,13 @@ HWTEST_EXCLUDE_PRODUCT(HwInfoConfigTest, givenHwInfoConfigWhenAskedIfTile64With3 HWTEST_EXCLUDE_PRODUCT(HwInfoConfigTest, WhenAllowRenderCompressionIsCalledThenTrueIsReturned, IGFX_DG2); HWTEST_EXCLUDE_PRODUCT(HwInfoConfigTest, whenConvertingTimestampsToCsDomainThenNothingIsChanged, IGFX_DG2); HWTEST_EXCLUDE_PRODUCT(HwInfoConfigTest, givenHwInfoConfigWhenAskedIfStorageInfoAdjustmentIsRequiredThenFalseIsReturned, IGFX_DG2); +HWTEST_EXCLUDE_PRODUCT(HwInfoConfigTest, givenAtLeastXeHpgCoreWhenGetCachingPolicyOptionsThenReturnWriteByPassPolicyOption_IsAtLeastXeHpgCore, IGFX_DG2); +HWTEST_EXCLUDE_PRODUCT(HwInfoConfigTest, givenHwInfoConfigWhenGetL1CachePolicyThenReturnWriteByPass_IsAtLeastXeHpgCore, IGFX_DG2); +HWTEST_EXCLUDE_PRODUCT(HwInfoConfigTest, givenAtLeastXeHpgCoreWhenGetL1CachePolicyThenReturnCorrectValue_IsAtLeastXeHpgCore, IGFX_DG2); HWTEST_EXCLUDE_PRODUCT(AILTests, whenModifyKernelIfRequiredIsCalledThenDontChangeKernelSources, IGFX_DG2); HWTEST_EXCLUDE_PRODUCT(CommandEncodeStatesTest, givenSlmTotalSizeEqualZeroWhenDispatchingKernelThenSharedMemorySizeIsSetCorrectly, IGFX_DG2); HWTEST_EXCLUDE_PRODUCT(MemoryManagerTests, givenEnabledLocalMemoryWhenAllocateInternalAllocationInDevicePoolThen32BitAllocationIsCreated, IGFX_DG2); HWTEST_EXCLUDE_PRODUCT(MemoryManagerTests, givenEnabledLocalMemoryWhenLinearStreamIsAllocatedInDevicePoolThenLocalMemoryPoolIsUsed, IGFX_DG2); -HWTEST_EXCLUDE_PRODUCT(MemoryManagerTests, givenEnabledLocalMemoryWhenAllocateKernelIsaInDevicePoolThenLocalMemoryPoolIsUsed, IGFX_DG2); \ No newline at end of file +HWTEST_EXCLUDE_PRODUCT(MemoryManagerTests, givenEnabledLocalMemoryWhenAllocateKernelIsaInDevicePoolThenLocalMemoryPoolIsUsed, IGFX_DG2); +HWTEST_EXCLUDE_PRODUCT(SbaTest, givenStateBaseAddressAndDebugFlagSetWhenAppendExtraCacheSettingsThenProgramCorrectL1CachePolicy_IsAtLeastXeHpgCore, IGFX_DG2); +HWTEST_EXCLUDE_PRODUCT(XeHpgSbaTest, givenSpecificProductFamilyWhenAppendingSbaThenProgramWBPL1CachePolicy, IGFX_DG2); diff --git a/shared/test/unit_test/xe_hpg_core/dg2/test_encode_dg2.cpp b/shared/test/unit_test/xe_hpg_core/dg2/test_encode_dg2.cpp index 6908bcede3..5abdf8d8d2 100644 --- a/shared/test/unit_test/xe_hpg_core/dg2/test_encode_dg2.cpp +++ b/shared/test/unit_test/xe_hpg_core/dg2/test_encode_dg2.cpp @@ -53,7 +53,7 @@ DG2TEST_F(CommandEncodeDG2Test, whenProgrammingStateComputeModeThenProperFieldsA using Dg2SbaTest = SbaTest; -DG2TEST_F(Dg2SbaTest, givenSpecificProductFamilyWhenAppendingSbaThenProgramWtL1CachePolicy) { +DG2TEST_F(Dg2SbaTest, givenSpecificProductFamilyWhenAppendingSbaThenProgramWBL1CachePolicyUnlessDebuggerIsActive) { auto sbaCmd = FamilyType::cmdInitStateBaseAddress; StateBaseAddressHelperArgs args = { 0, // generalStateBase @@ -74,10 +74,14 @@ DG2TEST_F(Dg2SbaTest, givenSpecificProductFamilyWhenAppendingSbaThenProgramWtL1C false, // isMultiOsContextCapable false, // useGlobalAtomics false, // areMultipleSubDevicesInContext - false // overrideSurfaceStateBaseAddress + false, // overrideSurfaceStateBaseAddress + false // isDebuggerActive }; StateBaseAddressHelper::appendStateBaseAddressParameters(args, true); + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB, sbaCmd.getL1CachePolicyL1CacheControl()); + args.isDebuggerActive = true; + StateBaseAddressHelper::appendStateBaseAddressParameters(args, true); EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP, sbaCmd.getL1CachePolicyL1CacheControl()); }