From 61b2ee45cdd887e884ef52f3b2f0e36df77945da Mon Sep 17 00:00:00 2001 From: Bartosz Dunajski Date: Thu, 23 Jun 2022 09:44:45 +0000 Subject: [PATCH] Use LogicalStateHelper to encode SystemMemoryFence Signed-off-by: Bartosz Dunajski --- shared/source/command_container/command_encoder.h | 3 ++- shared/source/command_container/command_encoder.inl | 2 +- .../command_encoder_xe_hpc_core_and_later.inl | 2 +- .../command_stream/command_stream_receiver_hw_base.inl | 4 ++++ shared/source/direct_submission/direct_submission_hw.cpp | 1 + shared/source/direct_submission/direct_submission_hw.h | 3 +++ shared/source/direct_submission/direct_submission_hw.inl | 8 +++++++- .../command_stream_receiver_hw_xe_hpc_core.cpp | 2 +- shared/test/unit_test/encoders/test_command_encoder.cpp | 2 +- 9 files changed, 21 insertions(+), 6 deletions(-) diff --git a/shared/source/command_container/command_encoder.h b/shared/source/command_container/command_encoder.h index 7789eed4b5..e4c84fa5d2 100644 --- a/shared/source/command_container/command_encoder.h +++ b/shared/source/command_container/command_encoder.h @@ -27,6 +27,7 @@ namespace NEO { class BindlessHeapsHelper; class GmmHelper; +class LogicalStateHelper; class IndirectHeap; class Gmm; struct HardwareInfo; @@ -455,7 +456,7 @@ template struct EncodeMemoryFence { static size_t getSystemMemoryFenceSize(); - static void encodeSystemMemoryFence(LinearStream &commandStream, const GraphicsAllocation *globalFenceAllocation); + static void encodeSystemMemoryFence(LinearStream &commandStream, const GraphicsAllocation *globalFenceAllocation, LogicalStateHelper *logicalStateHelper); }; } // namespace NEO diff --git a/shared/source/command_container/command_encoder.inl b/shared/source/command_container/command_encoder.inl index 52feb6dadb..730389310f 100644 --- a/shared/source/command_container/command_encoder.inl +++ b/shared/source/command_container/command_encoder.inl @@ -884,7 +884,7 @@ size_t EncodeMemoryFence::getSystemMemoryFenceSize() { } template -void EncodeMemoryFence::encodeSystemMemoryFence(LinearStream &commandStream, const GraphicsAllocation *globalFenceAllocation) { +void EncodeMemoryFence::encodeSystemMemoryFence(LinearStream &commandStream, const GraphicsAllocation *globalFenceAllocation, LogicalStateHelper *logicalStateHelper) { } } // namespace NEO diff --git a/shared/source/command_container/command_encoder_xe_hpc_core_and_later.inl b/shared/source/command_container/command_encoder_xe_hpc_core_and_later.inl index ae4c7f3294..ab0db5ca1f 100644 --- a/shared/source/command_container/command_encoder_xe_hpc_core_and_later.inl +++ b/shared/source/command_container/command_encoder_xe_hpc_core_and_later.inl @@ -19,7 +19,7 @@ size_t EncodeMemoryFence::getSystemMemoryFenceSize() { } template <> -void EncodeMemoryFence::encodeSystemMemoryFence(LinearStream &commandStream, const GraphicsAllocation *globalFenceAllocation) { +void EncodeMemoryFence::encodeSystemMemoryFence(LinearStream &commandStream, const GraphicsAllocation *globalFenceAllocation, LogicalStateHelper *logicalStateHelper) { using STATE_SYSTEM_MEM_FENCE_ADDRESS = typename Family::STATE_SYSTEM_MEM_FENCE_ADDRESS; auto stateSystemFenceAddressSpace = commandStream.getSpaceForCmd(); 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 913e1cc455..d2b0d74824 100644 --- a/shared/source/command_stream/command_stream_receiver_hw_base.inl +++ b/shared/source/command_stream/command_stream_receiver_hw_base.inl @@ -1053,6 +1053,10 @@ std::optional CommandStreamReceiverHw::flushBcsTask(const B pageTableManagerInitialized = pageTableManager->initPageTableManagerRegisters(this); } + if (logicalStateHelper) { + logicalStateHelper->writeStreamInline(commandStream); + } + for (auto &blitProperties : blitPropertiesContainer) { TimestampPacketHelper::programCsrDependenciesForTimestampPacketContainer(commandStream, blitProperties.csrDependencies); TimestampPacketHelper::programCsrDependenciesForForTaskCountContainer(commandStream, blitProperties.csrDependencies); diff --git a/shared/source/direct_submission/direct_submission_hw.cpp b/shared/source/direct_submission/direct_submission_hw.cpp index ad16d42c92..176c0c4042 100644 --- a/shared/source/direct_submission/direct_submission_hw.cpp +++ b/shared/source/direct_submission/direct_submission_hw.cpp @@ -12,6 +12,7 @@ namespace NEO { DirectSubmissionInputParams::DirectSubmissionInputParams(const CommandStreamReceiver &commandStreamReceiver) : osContext(commandStreamReceiver.getOsContext()), rootDeviceEnvironment(commandStreamReceiver.peekRootDeviceEnvironment()), rootDeviceIndex(commandStreamReceiver.getRootDeviceIndex()) { memoryManager = commandStreamReceiver.getMemoryManager(); + logicalStateHelper = commandStreamReceiver.getLogicalStateHelper(); globalFenceAllocation = commandStreamReceiver.getGlobalFenceAllocation(); workPartitionAllocation = commandStreamReceiver.getWorkPartitionAllocation(); completionFenceAllocation = commandStreamReceiver.getTagAllocation(); diff --git a/shared/source/direct_submission/direct_submission_hw.h b/shared/source/direct_submission/direct_submission_hw.h index 54cccab8ed..3deff17059 100644 --- a/shared/source/direct_submission/direct_submission_hw.h +++ b/shared/source/direct_submission/direct_submission_hw.h @@ -54,6 +54,7 @@ struct BatchBuffer; class DirectSubmissionDiagnosticsCollector; class FlushStampTracker; class GraphicsAllocation; +class LogicalStateHelper; struct HardwareInfo; class OsContext; class MemoryOperationsHandler; @@ -62,6 +63,7 @@ struct DirectSubmissionInputParams : NonCopyableClass { DirectSubmissionInputParams(const CommandStreamReceiver &commandStreamReceiver); OsContext &osContext; const RootDeviceEnvironment &rootDeviceEnvironment; + LogicalStateHelper *logicalStateHelper = nullptr; MemoryManager *memoryManager = nullptr; const GraphicsAllocation *globalFenceAllocation = nullptr; GraphicsAllocation *workPartitionAllocation = nullptr; @@ -170,6 +172,7 @@ class DirectSubmissionHw { OsContext &osContext; const uint32_t rootDeviceIndex; MemoryManager *memoryManager = nullptr; + LogicalStateHelper *logicalStateHelper = nullptr; MemoryOperationsHandler *memoryOperationHandler = nullptr; const HardwareInfo *hwInfo = nullptr; const GraphicsAllocation *globalFenceAllocation = nullptr; diff --git a/shared/source/direct_submission/direct_submission_hw.inl b/shared/source/direct_submission/direct_submission_hw.inl index fbcb4f6669..1d5c8adbeb 100644 --- a/shared/source/direct_submission/direct_submission_hw.inl +++ b/shared/source/direct_submission/direct_submission_hw.inl @@ -13,6 +13,7 @@ #include "shared/source/direct_submission/direct_submission_hw.h" #include "shared/source/direct_submission/direct_submission_hw_diagnostic_mode.h" #include "shared/source/helpers/flush_stamp.h" +#include "shared/source/helpers/logical_state_helper.h" #include "shared/source/helpers/ptr_math.h" #include "shared/source/memory_manager/allocation_properties.h" #include "shared/source/memory_manager/graphics_allocation.h" @@ -34,6 +35,7 @@ DirectSubmissionHw::DirectSubmissionHw(const DirectSubmis : ringBuffers(RingBufferUse::initialRingBufferCount), osContext(inputParams.osContext), rootDeviceIndex(inputParams.rootDeviceIndex) { memoryManager = inputParams.memoryManager; globalFenceAllocation = inputParams.globalFenceAllocation; + logicalStateHelper = inputParams.logicalStateHelper; hwInfo = inputParams.rootDeviceEnvironment.getHardwareInfo(); memoryOperationHandler = inputParams.rootDeviceEnvironment.memoryOperationsInterface.get(); @@ -642,7 +644,11 @@ size_t DirectSubmissionHw::getDiagnosticModeSection() { template void DirectSubmissionHw::dispatchSystemMemoryFenceAddress() { UNRECOVERABLE_IF(!this->globalFenceAllocation); - EncodeMemoryFence::encodeSystemMemoryFence(ringCommandStream, this->globalFenceAllocation); + EncodeMemoryFence::encodeSystemMemoryFence(ringCommandStream, this->globalFenceAllocation, this->logicalStateHelper); + + if (logicalStateHelper) { + logicalStateHelper->writeStreamInline(ringCommandStream); + } } template diff --git a/shared/source/xe_hpc_core/command_stream_receiver_hw_xe_hpc_core.cpp b/shared/source/xe_hpc_core/command_stream_receiver_hw_xe_hpc_core.cpp index 54c2dfa23d..3971d391ee 100644 --- a/shared/source/xe_hpc_core/command_stream_receiver_hw_xe_hpc_core.cpp +++ b/shared/source/xe_hpc_core/command_stream_receiver_hw_xe_hpc_core.cpp @@ -34,7 +34,7 @@ template <> void CommandStreamReceiverHw::programEnginePrologue(LinearStream &csr) { if (!this->isEnginePrologueSent) { if (globalFenceAllocation) { - EncodeMemoryFence::encodeSystemMemoryFence(csr, globalFenceAllocation); + EncodeMemoryFence::encodeSystemMemoryFence(csr, globalFenceAllocation, nullptr); } this->isEnginePrologueSent = true; } diff --git a/shared/test/unit_test/encoders/test_command_encoder.cpp b/shared/test/unit_test/encoders/test_command_encoder.cpp index fcd0bbbcd5..c45e817ee5 100644 --- a/shared/test/unit_test/encoders/test_command_encoder.cpp +++ b/shared/test/unit_test/encoders/test_command_encoder.cpp @@ -154,7 +154,7 @@ HWTEST_F(CommandEncoderTest, givenPlatformSupportingMiMemFenceWhenEncodingThenPr size_t size = EncodeMemoryFence::getSystemMemoryFenceSize(); - EncodeMemoryFence::encodeSystemMemoryFence(cmdStream, &allocation); + EncodeMemoryFence::encodeSystemMemoryFence(cmdStream, &allocation, nullptr); if constexpr (FamilyType::isUsingMiMemFence) { using STATE_SYSTEM_MEM_FENCE_ADDRESS = typename FamilyType::STATE_SYSTEM_MEM_FENCE_ADDRESS;