From 026d50c7b9a172b108fbe35454c01365b72ebc1e Mon Sep 17 00:00:00 2001 From: Kamil Kopryk Date: Thu, 26 Jan 2023 13:39:28 +0000 Subject: [PATCH] refactor: don't use global ProductHelper getter 13/n Related-To: NEO-6853 Signed-off-by: Kamil Kopryk --- .../hardware_interface_bdw_and_later.inl | 7 ++++--- .../hardware_interface_xehp_and_later.inl | 7 ++++--- .../dispatch_walker_tests_dg2_and_later.cpp | 8 ++++++-- .../command_stream_receiver_hw_1_tests.cpp | 4 ++-- ...stream_receiver_hw_tests_xehp_and_later.cpp | 2 +- .../helpers/timestamp_packet_1_tests.cpp | 12 ++++++------ .../helpers/timestamp_packet_2_tests.cpp | 6 +++--- .../unit_test/mem_obj/buffer_bcs_tests.cpp | 10 +++++----- .../source/command_container/command_encoder.h | 2 +- .../command_encoder_bdw_and_later.inl | 2 +- .../command_encoder_xehp_and_later.inl | 14 +++++++------- .../command_encoder_xe_hpc_core.cpp | 6 +++--- .../command_encoder_xe_hpg_core.cpp | 6 ++++-- shared/test/common/helpers/unit_test_helper.h | 5 +++-- .../test/common/helpers/unit_test_helper.inl | 4 ++-- .../unit_test_helper_xe_hpc_core.cpp | 8 +++++--- .../test_implicit_scaling_xehp_and_later.cpp | 6 +++--- .../helpers/hw_helper_tests_dg2_and_later.cpp | 2 +- .../dispatch_walker_tests_xe_hpc_core.cpp | 13 +++++++------ .../pvc/dispatch_walker_tests_pvc.cpp | 18 +++++++++++++----- .../xe_hpg_core/dg2/test_encode_dg2.cpp | 5 +++-- 21 files changed, 84 insertions(+), 63 deletions(-) diff --git a/opencl/source/command_queue/hardware_interface_bdw_and_later.inl b/opencl/source/command_queue/hardware_interface_bdw_and_later.inl index 03e261c1b8..5626b1bba5 100644 --- a/opencl/source/command_queue/hardware_interface_bdw_and_later.inl +++ b/opencl/source/command_queue/hardware_interface_bdw_and_later.inl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2022 Intel Corporation + * Copyright (C) 2019-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -61,6 +61,7 @@ inline void HardwareInterface::programWalker( WALKER_TYPE walkerCmd = GfxFamily::cmdInitGpgpuWalker; uint32_t dim = dispatchInfo.getDim(); uint32_t simd = kernel.getKernelInfo().getMaxSimdSize(); + auto &rootDeviceEnvironment = commandQueue.getDevice().getRootDeviceEnvironment(); size_t globalOffsets[3] = {dispatchInfo.getOffset().x, dispatchInfo.getOffset().y, dispatchInfo.getOffset().z}; size_t startWorkGroups[3] = {walkerArgs.startOfWorkgroups->x, walkerArgs.startOfWorkgroups->y, walkerArgs.startOfWorkgroups->z}; @@ -69,7 +70,7 @@ inline void HardwareInterface::programWalker( if (walkerArgs.currentTimestampPacketNodes && commandQueue.getGpgpuCommandStreamReceiver().peekTimestampPacketWriteEnabled()) { auto timestampPacketNode = walkerArgs.currentTimestampPacketNodes->peekNodes().at(walkerArgs.currentDispatchIndex); - GpgpuWalkerHelper::setupTimestampPacket(&commandStream, &walkerCmd, timestampPacketNode, commandQueue.getDevice().getRootDeviceEnvironment()); + GpgpuWalkerHelper::setupTimestampPacket(&commandStream, &walkerCmd, timestampPacketNode, rootDeviceEnvironment); } auto isCcsUsed = EngineHelpers::isCcs(commandQueue.getGpgpuEngine().osContext->getEngineType()); @@ -99,7 +100,7 @@ inline void HardwareInterface::programWalker( false, false, 0u); EncodeWalkerArgs encodeWalkerArgs{kernel.getExecutionType(), false, kernel.getKernelInfo().kernelDescriptor}; - EncodeDispatchKernel::encodeAdditionalWalkerFields(commandQueue.getDevice().getHardwareInfo(), walkerCmd, encodeWalkerArgs); + EncodeDispatchKernel::encodeAdditionalWalkerFields(rootDeviceEnvironment, walkerCmd, encodeWalkerArgs); *walkerCmdBuf = walkerCmd; } } // namespace NEO diff --git a/opencl/source/command_queue/hardware_interface_xehp_and_later.inl b/opencl/source/command_queue/hardware_interface_xehp_and_later.inl index be254c6729..107afa2242 100644 --- a/opencl/source/command_queue/hardware_interface_xehp_and_later.inl +++ b/opencl/source/command_queue/hardware_interface_xehp_and_later.inl @@ -78,16 +78,17 @@ inline void HardwareInterface::programWalker( auto idd = &walkerCmd.getInterfaceDescriptor(); auto &queueCsr = commandQueue.getGpgpuCommandStreamReceiver(); + auto &rootDeviceEnvironment = commandQueue.getDevice().getRootDeviceEnvironment(); if (walkerArgs.currentTimestampPacketNodes && queueCsr.peekTimestampPacketWriteEnabled()) { auto timestampPacket = walkerArgs.currentTimestampPacketNodes->peekNodes().at(walkerArgs.currentDispatchIndex); - GpgpuWalkerHelper::setupTimestampPacket(&commandStream, &walkerCmd, timestampPacket, commandQueue.getDevice().getRootDeviceEnvironment()); + GpgpuWalkerHelper::setupTimestampPacket(&commandStream, &walkerCmd, timestampPacket, rootDeviceEnvironment); } auto isCcsUsed = EngineHelpers::isCcs(commandQueue.getGpgpuEngine().osContext->getEngineType()); const auto &hwInfo = commandQueue.getDevice().getHardwareInfo(); if (auto kernelAllocation = kernelInfo.getGraphicsAllocation()) { - EncodeMemoryPrefetch::programMemoryPrefetch(commandStream, *kernelAllocation, kernelInfo.heapInfo.KernelHeapSize, 0, commandQueue.getDevice().getRootDeviceEnvironment()); + EncodeMemoryPrefetch::programMemoryPrefetch(commandStream, *kernelAllocation, kernelInfo.heapInfo.KernelHeapSize, 0, rootDeviceEnvironment); } HardwareCommandsHelper::sendIndirectState( @@ -119,7 +120,7 @@ inline void HardwareInterface::programWalker( } bool requiredSystemFence = kernelSystemAllocation && walkerArgs.event != nullptr; EncodeWalkerArgs encodeWalkerArgs{kernel.getExecutionType(), requiredSystemFence, kernelInfo.kernelDescriptor}; - EncodeDispatchKernel::encodeAdditionalWalkerFields(hwInfo, walkerCmd, encodeWalkerArgs); + EncodeDispatchKernel::encodeAdditionalWalkerFields(rootDeviceEnvironment, walkerCmd, encodeWalkerArgs); auto devices = queueCsr.getOsContext().getDeviceBitfield(); auto partitionWalker = ImplicitScalingHelper::isImplicitScalingEnabled(devices, true); diff --git a/opencl/test/unit_test/command_queue/dispatch_walker_tests_dg2_and_later.cpp b/opencl/test/unit_test/command_queue/dispatch_walker_tests_dg2_and_later.cpp index 6a713a320e..869ba69bf8 100644 --- a/opencl/test/unit_test/command_queue/dispatch_walker_tests_dg2_and_later.cpp +++ b/opencl/test/unit_test/command_queue/dispatch_walker_tests_dg2_and_later.cpp @@ -16,6 +16,7 @@ #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/mocks/mock_allocation_properties.h" #include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/mocks/mock_execution_environment.h" #include "opencl/source/command_queue/hardware_interface.h" #include "opencl/test/unit_test/command_queue/hardware_interface_helper.h" @@ -23,6 +24,7 @@ #include "opencl/test/unit_test/mocks/mock_command_queue.h" #include "opencl/test/unit_test/mocks/mock_kernel.h" #include "opencl/test/unit_test/mocks/mock_mdi.h" + using namespace NEO; struct Dg2AndLaterDispatchWalkerBasicFixture : public LinearStreamFixture { @@ -73,17 +75,19 @@ struct Dg2AndLaterDispatchWalkerBasicFixture : public LinearStreamFixture { using WalkerDispatchTestDg2AndLater = ::testing::Test; using Dg2AndLaterDispatchWalkerBasicTest = Test; using matcherDG2AndLater = IsAtLeastXeHpgCore; + HWTEST2_F(WalkerDispatchTestDg2AndLater, givenDebugVariableSetWhenProgramComputeWalkerThenApplyL3PrefetchAppropriately, matcherDG2AndLater) { using COMPUTE_WALKER = typename FamilyType::COMPUTE_WALKER; DebugManagerStateRestore restore; auto walkerCmd = FamilyType::cmdInitGpgpuWalker; - auto hwInfo = *defaultHwInfo; + MockExecutionEnvironment mockExecutionEnvironment{}; + auto &rootDeviceEnvironment = *mockExecutionEnvironment.rootDeviceEnvironments[0]; KernelDescriptor kernelDescriptor; EncodeWalkerArgs walkerArgs{KernelExecutionType::Default, true, kernelDescriptor}; for (auto forceL3PrefetchForComputeWalker : {false, true}) { DebugManager.flags.ForceL3PrefetchForComputeWalker.set(forceL3PrefetchForComputeWalker); - EncodeDispatchKernel::encodeAdditionalWalkerFields(hwInfo, walkerCmd, walkerArgs); + EncodeDispatchKernel::encodeAdditionalWalkerFields(rootDeviceEnvironment, walkerCmd, walkerArgs); EXPECT_EQ(!forceL3PrefetchForComputeWalker, walkerCmd.getL3PrefetchDisable()); } } diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_1_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_1_tests.cpp index 0d4e97f7da..986712b6cb 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_1_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_1_tests.cpp @@ -1072,7 +1072,7 @@ HWTEST_F(BcsTests, givenBltSizeWithLeftoverWhenDispatchedThenProgramAllRequiredC } if (UnitTestHelper::isAdditionalSynchronizationRequired()) { - if (UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(*defaultHwInfo)) { + if (UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(pDevice->getRootDeviceEnvironment())) { auto miSemaphoreWaitCmd = genCmdCast(*(cmdIterator++)); EXPECT_NE(nullptr, miSemaphoreWaitCmd); EXPECT_TRUE(UnitTestHelper::isAdditionalMiSemaphoreWait(*miSemaphoreWaitCmd)); @@ -1101,7 +1101,7 @@ HWTEST_F(BcsTests, givenBltSizeWithLeftoverWhenDispatchedThenProgramAllRequiredC EXPECT_EQ(newTaskCount, miFlushCmd->getImmediateData()); if (UnitTestHelper::isAdditionalSynchronizationRequired()) { - if (UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(*defaultHwInfo)) { + if (UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(pDevice->getRootDeviceEnvironment())) { auto miSemaphoreWaitCmd = genCmdCast(*(cmdIterator++)); EXPECT_NE(nullptr, miSemaphoreWaitCmd); EXPECT_TRUE(UnitTestHelper::isAdditionalMiSemaphoreWait(*miSemaphoreWaitCmd)); diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests_xehp_and_later.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests_xehp_and_later.cpp index 8f81c6086b..27e4e4466d 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests_xehp_and_later.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests_xehp_and_later.cpp @@ -684,7 +684,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverHwTestXeHPAndLater, givenBlock { auto queueSemaphores = findAll(hwParserCmdQ.cmdList.begin(), hwParserCmdQ.cmdList.end()); auto expectedQueueSemaphoresCount = 1u; - if (UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(pDevice->getHardwareInfo())) { + if (UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(pDevice->getRootDeviceEnvironment())) { expectedQueueSemaphoresCount += 1; } EXPECT_EQ(expectedQueueSemaphoresCount, queueSemaphores.size()); diff --git a/opencl/test/unit_test/helpers/timestamp_packet_1_tests.cpp b/opencl/test/unit_test/helpers/timestamp_packet_1_tests.cpp index deb63285cd..0241dcfee2 100644 --- a/opencl/test/unit_test/helpers/timestamp_packet_1_tests.cpp +++ b/opencl/test/unit_test/helpers/timestamp_packet_1_tests.cpp @@ -1449,12 +1449,12 @@ HWTEST_F(TimestampPacketTests, givenAlreadyAssignedNodeWhenEnqueueingToOoqThenDo hwParser.parseCommands(*cmdQ.commandStream, 0); uint32_t semaphoresFound = 0; - for (auto it = hwParser.cmdList.begin(); it != hwParser.cmdList.end(); it++) { - if (genCmdCast(*it)) { + for (auto &it : hwParser.cmdList) { + if (genCmdCast(it)) { semaphoresFound++; } } - uint32_t expectedSemaphoresCount = (UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(device->getHardwareInfo()) ? 1 : 0); + uint32_t expectedSemaphoresCount = (UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(device->getRootDeviceEnvironment()) ? 1 : 0); EXPECT_EQ(expectedSemaphoresCount, semaphoresFound); } @@ -1475,12 +1475,12 @@ HWTEST_F(TimestampPacketTests, givenAlreadyAssignedNodeWhenEnqueueingWithOmitTim hwParser.parseCommands(*cmdQ.commandStream, 0); uint32_t semaphoresFound = 0; - for (auto it = hwParser.cmdList.begin(); it != hwParser.cmdList.end(); it++) { - if (genCmdCast(*it)) { + for (auto &it : hwParser.cmdList) { + if (genCmdCast(it)) { semaphoresFound++; } } - uint32_t expectedSemaphoresCount = (UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(device->getHardwareInfo()) ? 1 : 0); + uint32_t expectedSemaphoresCount = (UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(device->getRootDeviceEnvironment()) ? 1 : 0); EXPECT_EQ(expectedSemaphoresCount, semaphoresFound); } diff --git a/opencl/test/unit_test/helpers/timestamp_packet_2_tests.cpp b/opencl/test/unit_test/helpers/timestamp_packet_2_tests.cpp index cb0f947c70..4894e93559 100644 --- a/opencl/test/unit_test/helpers/timestamp_packet_2_tests.cpp +++ b/opencl/test/unit_test/helpers/timestamp_packet_2_tests.cpp @@ -541,7 +541,7 @@ HWTEST_F(TimestampPacketTests, givenBlockedEnqueueWithoutKernelWhenSubmittingThe auto queueSemaphores = findAll(hwParserCmdQ.cmdList.begin(), hwParserCmdQ.cmdList.end()); auto expectedQueueSemaphoresCount = 1u; - if (UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(device->getHardwareInfo())) { + if (UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(device->getRootDeviceEnvironment())) { expectedQueueSemaphoresCount += 1; } EXPECT_EQ(expectedQueueSemaphoresCount, queueSemaphores.size()); @@ -598,7 +598,7 @@ HWTEST_F(TimestampPacketTests, givenWaitlistAndOutputEventWhenEnqueueingMarkerWi auto queueSemaphores = findAll(hwParserCmdQ.cmdList.begin(), hwParserCmdQ.cmdList.end()); auto expectedQueueSemaphoresCount = 1u; - if (UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(device->getHardwareInfo())) { + if (UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(device->getRootDeviceEnvironment())) { expectedQueueSemaphoresCount += 1; } EXPECT_EQ(expectedQueueSemaphoresCount, queueSemaphores.size()); @@ -643,7 +643,7 @@ HWTEST_F(TimestampPacketTests, givenWaitlistAndOutputEventWhenEnqueueingBarrierW auto queueSemaphores = findAll(hwParserCmdQ.cmdList.begin(), hwParserCmdQ.cmdList.end()); auto expectedQueueSemaphoresCount = 1u; - if (UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(device->getHardwareInfo())) { + if (UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(device->getRootDeviceEnvironment())) { expectedQueueSemaphoresCount += 1; } EXPECT_EQ(expectedQueueSemaphoresCount, queueSemaphores.size()); diff --git a/opencl/test/unit_test/mem_obj/buffer_bcs_tests.cpp b/opencl/test/unit_test/mem_obj/buffer_bcs_tests.cpp index 615fda489a..6f8b7fe8c8 100644 --- a/opencl/test/unit_test/mem_obj/buffer_bcs_tests.cpp +++ b/opencl/test/unit_test/mem_obj/buffer_bcs_tests.cpp @@ -599,7 +599,7 @@ void BcsBufferTests::waitForCacheFlushFromBcsTest(MockCommandQueueHw } auto bcsSemaphores = findAll(hwParserBcs.cmdList.begin(), hwParserBcs.cmdList.end()); - size_t additionalSemaphores = UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(device->getHardwareInfo()) ? 2 : 0; + size_t additionalSemaphores = UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(device->getRootDeviceEnvironment()) ? 2 : 0; if (isCacheFlushForBcsRequired) { EXPECT_NE(0u, cacheFlushWriteAddress); @@ -666,10 +666,10 @@ HWTEST_TEMPLATED_F(BcsBufferTests, givenPipeControlRequestWhenDispatchingBlitEnq auto semaphores = findAll(bcsHwParser.cmdList.begin(), bcsHwParser.cmdList.end()); if (cmdQ->isCacheFlushForBcsRequired()) { - EXPECT_EQ(UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(device->getHardwareInfo()) ? 4u : 2u, semaphores.size()); + EXPECT_EQ(UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(device->getRootDeviceEnvironment()) ? 4u : 2u, semaphores.size()); EXPECT_EQ(pipeControlWriteAddress, genCmdCast(*(semaphores[1]))->getSemaphoreGraphicsAddress()); } else { - EXPECT_EQ(UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(device->getHardwareInfo()) ? 3u : 1u, semaphores.size()); + EXPECT_EQ(UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(device->getRootDeviceEnvironment()) ? 3u : 1u, semaphores.size()); EXPECT_EQ(pipeControlWriteAddress, genCmdCast(*(semaphores[0]))->getSemaphoreGraphicsAddress()); } } @@ -751,9 +751,9 @@ HWTEST_TEMPLATED_F(BcsBufferTests, givenPipeControlRequestWhenDispatchingBlocked auto semaphores = findAll(bcsHwParser.cmdList.begin(), bcsHwParser.cmdList.end()); if (cmdQ->isCacheFlushForBcsRequired()) { - EXPECT_EQ(UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(device->getHardwareInfo()) ? 4u : 2u, semaphores.size()); + EXPECT_EQ(UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(device->getRootDeviceEnvironment()) ? 4u : 2u, semaphores.size()); } else { - EXPECT_EQ(UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(device->getHardwareInfo()) ? 3u : 1u, semaphores.size()); + EXPECT_EQ(UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(device->getRootDeviceEnvironment()) ? 3u : 1u, semaphores.size()); } cmdQ->isQueueBlocked(); diff --git a/shared/source/command_container/command_encoder.h b/shared/source/command_container/command_encoder.h index d74cd7ae29..9c82598cd9 100644 --- a/shared/source/command_container/command_encoder.h +++ b/shared/source/command_container/command_encoder.h @@ -88,7 +88,7 @@ struct EncodeDispatchKernel { static void encode(CommandContainer &container, EncodeDispatchKernelArgs &args, LogicalStateHelper *logicalStateHelper); - static void encodeAdditionalWalkerFields(const HardwareInfo &hwInfo, WALKER_TYPE &walkerCmd, const EncodeWalkerArgs &walkerArgs); + static void encodeAdditionalWalkerFields(const RootDeviceEnvironment &rootDeviceEnvironment, WALKER_TYPE &walkerCmd, const EncodeWalkerArgs &walkerArgs); static void appendAdditionalIDDFields(INTERFACE_DESCRIPTOR_DATA *pInterfaceDescriptor, const RootDeviceEnvironment &rootDeviceEnvironment, const uint32_t threadsPerThreadGroup, uint32_t slmTotalSize, SlmPolicy slmPolicy); 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 ce23f1846d..bd805bd6b8 100644 --- a/shared/source/command_container/command_encoder_bdw_and_later.inl +++ b/shared/source/command_container/command_encoder_bdw_and_later.inl @@ -376,7 +376,7 @@ void EncodeDispatchKernel::programBarrierEnable(INTERFACE_DESCRIPTOR_DAT } template -inline void EncodeDispatchKernel::encodeAdditionalWalkerFields(const HardwareInfo &hwInfo, WALKER_TYPE &walkerCmd, const EncodeWalkerArgs &walkerArgs) {} +inline void EncodeDispatchKernel::encodeAdditionalWalkerFields(const RootDeviceEnvironment &rootDeviceEnvironment, WALKER_TYPE &walkerCmd, const EncodeWalkerArgs &walkerArgs) {} template void EncodeDispatchKernel::appendAdditionalIDDFields(INTERFACE_DESCRIPTOR_DATA *pInterfaceDescriptor, const RootDeviceEnvironment &rootDeviceEnvironment, const uint32_t threadsPerThreadGroup, uint32_t slmTotalSize, SlmPolicy slmPolicy) {} 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 37e370d0be..ba64cf1dd5 100644 --- a/shared/source/command_container/command_encoder_xehp_and_later.inl +++ b/shared/source/command_container/command_encoder_xehp_and_later.inl @@ -50,6 +50,7 @@ void EncodeDispatchKernel::encode(CommandContainer &container, EncodeDis using INLINE_DATA = typename Family::INLINE_DATA; const HardwareInfo &hwInfo = args.device->getHardwareInfo(); + auto &rootDeviceEnvironment = args.device->getRootDeviceEnvironment(); const auto &kernelDescriptor = args.dispatchInterface->getKernelDescriptor(); auto sizeCrossThreadData = args.dispatchInterface->getCrossThreadDataSize(); @@ -103,7 +104,6 @@ void EncodeDispatchKernel::encode(CommandContainer &container, EncodeDis hwInfo); auto &gfxCoreHelper = args.device->getGfxCoreHelper(); - auto slmSize = static_cast( gfxCoreHelper.computeSlmValues(hwInfo, args.dispatchInterface->getSlmTotalSize())); @@ -145,7 +145,7 @@ void EncodeDispatchKernel::encode(CommandContainer &container, EncodeDis heap, kernelDescriptor.payloadMappings.samplerTable.tableOffset, kernelDescriptor.payloadMappings.samplerTable.numSamplers, kernelDescriptor.payloadMappings.samplerTable.borderColor, args.dispatchInterface->getDynamicStateHeapData(), - args.device->getBindlessHeapsHelper(), args.device->getRootDeviceEnvironment()); + args.device->getBindlessHeapsHelper(), rootDeviceEnvironment); if (ApiSpecificConfig::getBindlessConfiguration()) { container.getResidencyContainer().push_back(args.device->getBindlessHeapsHelper()->getHeap(NEO::BindlessHeapsHelper::BindlesHeapType::GLOBAL_DSH)->getGraphicsAllocation()); } @@ -279,7 +279,7 @@ void EncodeDispatchKernel::encode(CommandContainer &container, EncodeDis UNRECOVERABLE_IF(!(isAligned(args.eventAddress))); postSync.setDestinationAddress(args.eventAddress); - EncodeDispatchKernel::setupPostSyncMocs(walkerCmd, args.device->getRootDeviceEnvironment(), args.dcFlushEnable); + EncodeDispatchKernel::setupPostSyncMocs(walkerCmd, rootDeviceEnvironment, args.dcFlushEnable); EncodeDispatchKernel::adjustTimestampPacket(walkerCmd, hwInfo); } @@ -293,7 +293,7 @@ void EncodeDispatchKernel::encode(CommandContainer &container, EncodeDis auto threadGroupCount = walkerCmd.getThreadGroupIdXDimension() * walkerCmd.getThreadGroupIdYDimension() * walkerCmd.getThreadGroupIdZDimension(); EncodeDispatchKernel::adjustInterfaceDescriptorData(idd, *args.device, hwInfo, threadGroupCount, kernelDescriptor.kernelAttributes.numGrfRequired); - EncodeDispatchKernel::appendAdditionalIDDFields(&idd, args.device->getRootDeviceEnvironment(), threadsPerThreadGroup, + EncodeDispatchKernel::appendAdditionalIDDFields(&idd, rootDeviceEnvironment, threadsPerThreadGroup, args.dispatchInterface->getSlmTotalSize(), args.dispatchInterface->getSlmPolicy()); @@ -301,7 +301,7 @@ void EncodeDispatchKernel::encode(CommandContainer &container, EncodeDis args.isCooperative ? KernelExecutionType::Concurrent : KernelExecutionType::Default, args.isHostScopeSignalEvent && args.isKernelUsingSystemAllocation, kernelDescriptor}; - EncodeDispatchKernel::encodeAdditionalWalkerFields(hwInfo, walkerCmd, walkerArgs); + EncodeDispatchKernel::encodeAdditionalWalkerFields(rootDeviceEnvironment, walkerCmd, walkerArgs); PreemptionHelper::applyPreemptionWaCmdsBegin(listCmdBufferStream, *args.device); @@ -330,7 +330,7 @@ void EncodeDispatchKernel::encode(CommandContainer &container, EncodeDis PreemptionHelper::applyPreemptionWaCmdsEnd(listCmdBufferStream, *args.device); if (NEO::PauseOnGpuProperties::pauseModeAllowed(NEO::DebugManager.flags.PauseOnEnqueue.get(), args.device->debugExecutionCounter.load(), NEO::PauseOnGpuProperties::PauseMode::AfterWorkload)) { - void *commandBuffer = listCmdBufferStream->getSpace(MemorySynchronizationCommands::getSizeForBarrierWithPostSyncOperation(args.device->getRootDeviceEnvironment(), false)); + void *commandBuffer = listCmdBufferStream->getSpace(MemorySynchronizationCommands::getSizeForBarrierWithPostSyncOperation(rootDeviceEnvironment, false)); args.additionalCommands->push_back(commandBuffer); using MI_SEMAPHORE_WAIT = typename Family::MI_SEMAPHORE_WAIT; @@ -356,7 +356,7 @@ inline void EncodeDispatchKernel::setupPostSyncMocs(WALKER_TYPE &walkerC } template -inline void EncodeDispatchKernel::encodeAdditionalWalkerFields(const HardwareInfo &hwInfo, WALKER_TYPE &walkerCmd, const EncodeWalkerArgs &walkerArgs) { +inline void EncodeDispatchKernel::encodeAdditionalWalkerFields(const RootDeviceEnvironment &rootDeviceEnvironment, WALKER_TYPE &walkerCmd, const EncodeWalkerArgs &walkerArgs) { } template diff --git a/shared/source/xe_hpc_core/command_encoder_xe_hpc_core.cpp b/shared/source/xe_hpc_core/command_encoder_xe_hpc_core.cpp index bfd3859aff..32b2e67e98 100644 --- a/shared/source/xe_hpc_core/command_encoder_xe_hpc_core.cpp +++ b/shared/source/xe_hpc_core/command_encoder_xe_hpc_core.cpp @@ -221,9 +221,9 @@ void EncodeDispatchKernel::programBarrierEnable(INTERFACE_DESCRIPTOR_DAT } template <> -void EncodeDispatchKernel::encodeAdditionalWalkerFields(const HardwareInfo &hwInfo, WALKER_TYPE &walkerCmd, const EncodeWalkerArgs &walkerArgs) { - const auto &productHelper = *ProductHelper::get(hwInfo.platform.eProductFamily); - +void EncodeDispatchKernel::encodeAdditionalWalkerFields(const RootDeviceEnvironment &rootDeviceEnvironment, WALKER_TYPE &walkerCmd, const EncodeWalkerArgs &walkerArgs) { + const auto &productHelper = rootDeviceEnvironment.getHelper(); + auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo(); auto programGlobalFenceAsPostSyncOperationInComputeWalker = productHelper.isGlobalFenceInCommandStreamRequired(hwInfo) && walkerArgs.requiredSystemFence; int32_t overrideProgramSystemMemoryFence = DebugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.get(); 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 e9848e95ef..fae06fe3d3 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 @@ -113,8 +113,10 @@ void EncodeDispatchKernel::programBarrierEnable(INTERFACE_DESCRIPTOR_DAT } template <> -void EncodeDispatchKernel::encodeAdditionalWalkerFields(const HardwareInfo &hwInfo, WALKER_TYPE &walkerCmd, const EncodeWalkerArgs &walkerArgs) { - bool l3PrefetchDisable = ProductHelper::get(hwInfo.platform.eProductFamily)->isPrefetchDisablingRequired(hwInfo); +void EncodeDispatchKernel::encodeAdditionalWalkerFields(const RootDeviceEnvironment &rootDeviceEnvironment, WALKER_TYPE &walkerCmd, const EncodeWalkerArgs &walkerArgs) { + auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo(); + auto &productHelper = rootDeviceEnvironment.getHelper(); + bool l3PrefetchDisable = productHelper.isPrefetchDisablingRequired(hwInfo); int32_t overrideL3PrefetchDisable = DebugManager.flags.ForceL3PrefetchForComputeWalker.get(); if (overrideL3PrefetchDisable != -1) { l3PrefetchDisable = !overrideL3PrefetchDisable; diff --git a/shared/test/common/helpers/unit_test_helper.h b/shared/test/common/helpers/unit_test_helper.h index 9a58f75d87..49f8742005 100644 --- a/shared/test/common/helpers/unit_test_helper.h +++ b/shared/test/common/helpers/unit_test_helper.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2022 Intel Corporation + * Copyright (C) 2018-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -18,6 +18,7 @@ class CommandStreamReceiver; class LinearStream; struct KernelDescriptor; struct HardwareInfo; +struct RootDeviceEnvironment; template struct UnitTestHelper { @@ -45,7 +46,7 @@ struct UnitTestHelper { static bool isAdditionalSynchronizationRequired(); - static bool isAdditionalMiSemaphoreWaitRequired(const HardwareInfo &hwInfo); + static bool isAdditionalMiSemaphoreWaitRequired(const RootDeviceEnvironment &rootDeviceEnvironment); static bool isAdditionalMiSemaphoreWait(const typename GfxFamily::MI_SEMAPHORE_WAIT &semaphoreWait); diff --git a/shared/test/common/helpers/unit_test_helper.inl b/shared/test/common/helpers/unit_test_helper.inl index de5551105e..de4c879e95 100644 --- a/shared/test/common/helpers/unit_test_helper.inl +++ b/shared/test/common/helpers/unit_test_helper.inl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2022 Intel Corporation + * Copyright (C) 2018-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -34,7 +34,7 @@ bool UnitTestHelper::isAdditionalSynchronizationRequired() { } template -bool UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(const HardwareInfo &hwInfo) { +bool UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(const RootDeviceEnvironment &rootDeviceEnvironment) { return false; } diff --git a/shared/test/common/xe_hpc_core/unit_test_helper_xe_hpc_core.cpp b/shared/test/common/xe_hpc_core/unit_test_helper_xe_hpc_core.cpp index 29892e21a1..583bf4352f 100644 --- a/shared/test/common/xe_hpc_core/unit_test_helper_xe_hpc_core.cpp +++ b/shared/test/common/xe_hpc_core/unit_test_helper_xe_hpc_core.cpp @@ -1,10 +1,11 @@ /* - * Copyright (C) 2021-2022 Intel Corporation + * Copyright (C) 2021-2023 Intel Corporation * * SPDX-License-Identifier: MIT * */ +#include "shared/source/execution_environment/root_device_environment.h" #include "shared/source/os_interface/hw_info_config.h" #include "shared/source/xe_hpc_core/hw_cmds_xe_hpc_core_base.h" #include "shared/source/xe_hpc_core/hw_info.h" @@ -58,8 +59,9 @@ bool UnitTestHelper::isAdditionalSynchronizationRequired() { } template <> -bool UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(const HardwareInfo &hwInfo) { - const auto &productHelper = *ProductHelper::get(hwInfo.platform.eProductFamily); +bool UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(const RootDeviceEnvironment &rootDeviceEnvironment) { + const auto &productHelper = rootDeviceEnvironment.getHelper(); + auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo(); auto programGlobalFenceAsMiMemFenceCommandInCommandStream = productHelper.isGlobalFenceInCommandStreamRequired(hwInfo); if (DebugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.get() != -1) { programGlobalFenceAsMiMemFenceCommandInCommandStream = !!DebugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.get(); diff --git a/shared/test/unit_test/encoders/test_implicit_scaling_xehp_and_later.cpp b/shared/test/unit_test/encoders/test_implicit_scaling_xehp_and_later.cpp index 36a63af6a9..61836bb3b2 100644 --- a/shared/test/unit_test/encoders/test_implicit_scaling_xehp_and_later.cpp +++ b/shared/test/unit_test/encoders/test_implicit_scaling_xehp_and_later.cpp @@ -1192,7 +1192,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, ImplicitScalingTests, size_t expectedPipeControls = 1u; size_t expectedSemaphores = 1u; - bool semaphoreAsAdditionalSync = UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(testHardwareInfo); + bool semaphoreAsAdditionalSync = UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(this->pDevice->getRootDeviceEnvironment()); if (semaphoreAsAdditionalSync) { expectedSemaphores++; } @@ -1275,7 +1275,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, ImplicitScalingTests, size_t expectedPipeControls = 1u; size_t expectedSemaphores = 3u; - bool semaphoreAsAdditionalSync = UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(testHardwareInfo); + bool semaphoreAsAdditionalSync = UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(this->pDevice->getRootDeviceEnvironment()); if (semaphoreAsAdditionalSync) { expectedSemaphores++; } @@ -1356,7 +1356,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, ImplicitScalingTests, size_t expectedPipeControls = 1u; size_t expectedSemaphores = 3u; - bool semaphoreAsAdditionalSync = UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(testHardwareInfo); + bool semaphoreAsAdditionalSync = UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(this->pDevice->getRootDeviceEnvironment()); if (semaphoreAsAdditionalSync) { expectedSemaphores++; } diff --git a/shared/test/unit_test/helpers/hw_helper_tests_dg2_and_later.cpp b/shared/test/unit_test/helpers/hw_helper_tests_dg2_and_later.cpp index 03d5dd4e2c..f1b8dbc953 100644 --- a/shared/test/unit_test/helpers/hw_helper_tests_dg2_and_later.cpp +++ b/shared/test/unit_test/helpers/hw_helper_tests_dg2_and_later.cpp @@ -100,7 +100,7 @@ HWTEST2_F(PipeControlHelperTestsDg2AndLater, WhenAddingPipeControlWAThenCorrectC EXPECT_TRUE(memcmp(&expectedPipeControl, pPipeControl, sizeof(PIPE_CONTROL)) == 0); if (requiresMemorySynchronization) { - if (UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(hardwareInfo)) { + if (UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(rootDeviceEnvironment)) { MI_SEMAPHORE_WAIT expectedMiSemaphoreWait; EncodeSempahore::programMiSemaphoreWait(&expectedMiSemaphoreWait, address, EncodeSempahore::invalidHardwareTag, diff --git a/shared/test/unit_test/xe_hpc_core/dispatch_walker_tests_xe_hpc_core.cpp b/shared/test/unit_test/xe_hpc_core/dispatch_walker_tests_xe_hpc_core.cpp index 39812fd9f5..3f1ae36fbf 100644 --- a/shared/test/unit_test/xe_hpc_core/dispatch_walker_tests_xe_hpc_core.cpp +++ b/shared/test/unit_test/xe_hpc_core/dispatch_walker_tests_xe_hpc_core.cpp @@ -24,27 +24,28 @@ XE_HPC_CORETEST_F(WalkerDispatchTestsXeHpcCore, givenXeHpcWhenEncodeAdditionalWa using COMPUTE_WALKER = typename FamilyType::COMPUTE_WALKER; DebugManagerStateRestore debugRestorer; auto walkerCmd = FamilyType::cmdInitGpgpuWalker; - auto hwInfo = *defaultHwInfo; + MockExecutionEnvironment mockExecutionEnvironment{}; + auto &rootDeviceEnvironment = *mockExecutionEnvironment.rootDeviceEnvironments[0]; + const auto &productHelper = rootDeviceEnvironment.getHelper(); + auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo(); KernelDescriptor kernelDescriptor; EncodeWalkerArgs walkerArgs{KernelExecutionType::Default, true, kernelDescriptor}; { - EncodeDispatchKernel::encodeAdditionalWalkerFields(hwInfo, walkerCmd, walkerArgs); + EncodeDispatchKernel::encodeAdditionalWalkerFields(rootDeviceEnvironment, walkerCmd, walkerArgs); EXPECT_FALSE(walkerCmd.getComputeDispatchAllWalkerEnable()); } { - MockExecutionEnvironment mockExecutionEnvironment{}; - const auto &productHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getHelper(); uint32_t expectedValue = productHelper.isComputeDispatchAllWalkerEnableInComputeWalkerRequired(hwInfo); walkerArgs.kernelExecutionType = KernelExecutionType::Concurrent; - EncodeDispatchKernel::encodeAdditionalWalkerFields(hwInfo, walkerCmd, walkerArgs); + EncodeDispatchKernel::encodeAdditionalWalkerFields(rootDeviceEnvironment, walkerCmd, walkerArgs); EXPECT_EQ(expectedValue, walkerCmd.getComputeDispatchAllWalkerEnable()); } { DebugManager.flags.ComputeDispatchAllWalkerEnableInComputeWalker.set(1); - EncodeDispatchKernel::encodeAdditionalWalkerFields(hwInfo, walkerCmd, walkerArgs); + EncodeDispatchKernel::encodeAdditionalWalkerFields(rootDeviceEnvironment, walkerCmd, walkerArgs); EXPECT_TRUE(walkerCmd.getComputeDispatchAllWalkerEnable()); } } diff --git a/shared/test/unit_test/xe_hpc_core/pvc/dispatch_walker_tests_pvc.cpp b/shared/test/unit_test/xe_hpc_core/pvc/dispatch_walker_tests_pvc.cpp index 83666c64e8..7a27146d4a 100644 --- a/shared/test/unit_test/xe_hpc_core/pvc/dispatch_walker_tests_pvc.cpp +++ b/shared/test/unit_test/xe_hpc_core/pvc/dispatch_walker_tests_pvc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Intel Corporation + * Copyright (C) 2022-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -12,6 +12,7 @@ #include "shared/source/xe_hpc_core/hw_cmds_pvc.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/default_hw_info.h" +#include "shared/test/common/mocks/mock_execution_environment.h" #include "shared/test/common/test_macros/header/per_product_test_definitions.h" #include "shared/test/common/test_macros/test.h" @@ -36,7 +37,10 @@ PVCTEST_F(WalkerDispatchTestsPvc, givenPvcWhenEncodeAdditionalWalkerFieldsThenPo DebugManagerStateRestore debugRestorer; auto walkerCmd = FamilyType::cmdInitGpgpuWalker; auto &postSyncData = walkerCmd.getPostSync(); - auto hwInfo = *defaultHwInfo; + + MockExecutionEnvironment mockExecutionEnvironment{}; + auto &rootDeviceEnvironment = *mockExecutionEnvironment.rootDeviceEnvironments[0]; + auto &hwInfo = *rootDeviceEnvironment.getMutableHardwareInfo(); KernelDescriptor kernelDescriptor; EncodeWalkerArgs walkerArgs{KernelExecutionType::Default, true, kernelDescriptor}; @@ -48,7 +52,7 @@ PVCTEST_F(WalkerDispatchTestsPvc, givenPvcWhenEncodeAdditionalWalkerFieldsThenPo testInput.programGlobalFenceAsPostSyncOperationInComputeWalker); postSyncData.setSystemMemoryFenceRequest(false); - EncodeDispatchKernel::encodeAdditionalWalkerFields(hwInfo, walkerCmd, walkerArgs); + EncodeDispatchKernel::encodeAdditionalWalkerFields(rootDeviceEnvironment, walkerCmd, walkerArgs); EXPECT_EQ(testInput.expectSystemMemoryFenceRequest, postSyncData.getSystemMemoryFenceRequest()); } } @@ -57,7 +61,11 @@ PVCTEST_F(WalkerDispatchTestsPvc, givenPvcWhenEncodeAdditionalWalkerFieldsThenPo PVCTEST_F(WalkerDispatchTestsPvc, givenPvcSupportsSystemMemoryFenceWhenNoSystemFenceRequiredThenEncodedWalkerFenceFieldSetToFalse) { auto walkerCmd = FamilyType::cmdInitGpgpuWalker; auto &postSyncData = walkerCmd.getPostSync(); - auto hwInfo = *defaultHwInfo; + + MockExecutionEnvironment mockExecutionEnvironment{}; + auto &rootDeviceEnvironment = *mockExecutionEnvironment.rootDeviceEnvironments[0]; + auto &hwInfo = *rootDeviceEnvironment.getMutableHardwareInfo(); + hwInfo.platform.usRevId = 0x3; KernelDescriptor kernelDescriptor; @@ -66,7 +74,7 @@ PVCTEST_F(WalkerDispatchTestsPvc, givenPvcSupportsSystemMemoryFenceWhenNoSystemF hwInfo.platform.usDeviceID = deviceId; postSyncData.setSystemMemoryFenceRequest(true); - EncodeDispatchKernel::encodeAdditionalWalkerFields(hwInfo, walkerCmd, walkerArgs); + EncodeDispatchKernel::encodeAdditionalWalkerFields(rootDeviceEnvironment, walkerCmd, walkerArgs); EXPECT_FALSE(postSyncData.getSystemMemoryFenceRequest()); } } 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 eb73d040c6..b98a4b7092 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 @@ -60,7 +60,8 @@ DG2TEST_F(CommandEncodeDG2Test, whenProgramComputeWalkerThenApplyL3WAForDg2G10A0 auto walkerCmd = FamilyType::cmdInitGpgpuWalker; MockExecutionEnvironment executionEnvironment{}; auto &productHelper = executionEnvironment.rootDeviceEnvironments[0]->getHelper(); - auto hwInfo = *defaultHwInfo; + auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0]; + auto &hwInfo = *rootDeviceEnvironment.getMutableHardwareInfo(); KernelDescriptor kernelDescriptor; EncodeWalkerArgs walkerArgs{KernelExecutionType::Default, true, kernelDescriptor}; @@ -68,7 +69,7 @@ DG2TEST_F(CommandEncodeDG2Test, whenProgramComputeWalkerThenApplyL3WAForDg2G10A0 for (auto deviceId : {dg2G10DeviceIds[0], dg2G11DeviceIds[0], dg2G12DeviceIds[0]}) { hwInfo.platform.usRevId = productHelper.getHwRevIdFromStepping(revision, hwInfo); hwInfo.platform.usDeviceID = deviceId; - EncodeDispatchKernel::encodeAdditionalWalkerFields(hwInfo, walkerCmd, walkerArgs); + EncodeDispatchKernel::encodeAdditionalWalkerFields(rootDeviceEnvironment, walkerCmd, walkerArgs); if (DG2::isG10(hwInfo) && revision < REVISION_B) { EXPECT_TRUE(walkerCmd.getL3PrefetchDisable());