From 939d10936215d80bdfbaebee174364553b441617 Mon Sep 17 00:00:00 2001 From: Bartosz Dunajski Date: Tue, 14 Jun 2022 14:18:28 +0000 Subject: [PATCH] Add LogicalStateHelper class Signed-off-by: Bartosz Dunajski --- .../source/command_queue/command_queue_hw.h | 5 ++++ .../command_queue/command_queue_tests.cpp | 10 +++++++ .../command_stream_receiver_hw_1_tests.cpp | 6 +++++ .../unit_test/helpers/hw_helper_tests.cpp | 8 ++++++ .../test/unit_test/mocks/mock_command_queue.h | 1 + .../command_stream_receiver_hw.h | 2 ++ .../command_stream_receiver_hw_base.inl | 4 +++ shared/source/gen11/hw_helper_gen11.cpp | 3 +++ shared/source/gen12lp/hw_helper_gen12lp.cpp | 3 +++ shared/source/gen8/hw_helper_gen8.cpp | 3 +++ shared/source/gen9/hw_helper_gen9.cpp | 3 +++ shared/source/helpers/CMakeLists.txt | 2 ++ shared/source/helpers/logical_state_helper.h | 26 +++++++++++++++++++ .../source/helpers/logical_state_helper.inl | 17 ++++++++++++ .../xe_hp_core/hw_helper_xe_hp_core.cpp | 3 +++ .../xe_hpc_core/hw_helper_xe_hpc_core.cpp | 3 +++ .../xe_hpg_core/hw_helper_xe_hpg_core.cpp | 3 +++ .../libult/ult_command_stream_receiver.h | 1 + 18 files changed, 103 insertions(+) create mode 100644 shared/source/helpers/logical_state_helper.h create mode 100644 shared/source/helpers/logical_state_helper.inl diff --git a/opencl/source/command_queue/command_queue_hw.h b/opencl/source/command_queue/command_queue_hw.h index 0b7bda5537..93c86361ec 100644 --- a/opencl/source/command_queue/command_queue_hw.h +++ b/opencl/source/command_queue/command_queue_hw.h @@ -10,6 +10,7 @@ #include "shared/source/command_stream/preemption.h" #include "shared/source/helpers/engine_control.h" #include "shared/source/helpers/hw_helper.h" +#include "shared/source/helpers/logical_state_helper.h" #include "shared/source/memory_manager/graphics_allocation.h" #include "opencl/source/cl_device/cl_device.h" @@ -37,6 +38,8 @@ class CommandQueueHw : public CommandQueue { const cl_queue_properties *properties, bool internalUsage) : BaseClass(context, device, properties, internalUsage) { + logicalStateHelper.reset(LogicalStateHelper::create(true)); + auto clPriority = getCmdQueueProperties(properties, CL_QUEUE_PRIORITY_KHR); if (clPriority & static_cast(CL_QUEUE_PRIORITY_LOW_KHR)) { @@ -502,5 +505,7 @@ class CommandQueueHw : public CommandQueue { void setupEvent(EventBuilder &eventBuilder, cl_event *outEvent, uint32_t cmdType); bool isBlitAuxTranslationRequired(const MultiDispatchInfo &multiDispatchInfo); + + std::unique_ptr logicalStateHelper; }; } // namespace NEO diff --git a/opencl/test/unit_test/command_queue/command_queue_tests.cpp b/opencl/test/unit_test/command_queue/command_queue_tests.cpp index 62ab7efb0d..fde7df6e5b 100644 --- a/opencl/test/unit_test/command_queue/command_queue_tests.cpp +++ b/opencl/test/unit_test/command_queue/command_queue_tests.cpp @@ -10,6 +10,7 @@ #include "shared/source/helpers/array_count.h" #include "shared/source/helpers/basic_math.h" #include "shared/source/helpers/engine_node_helper.h" +#include "shared/source/helpers/logical_state_helper.h" #include "shared/source/helpers/timestamp_packet.h" #include "shared/source/memory_manager/internal_allocation_storage.h" #include "shared/source/memory_manager/memory_manager.h" @@ -414,6 +415,15 @@ HWTEST_F(CommandQueueCommandStreamTest, givenCommandQueueThatWaitsOnAbortedUserE EXPECT_EQ(100u, cmdQ.taskLevel); } +HWTEST_F(CommandQueueCommandStreamTest, whenCreatingThenDontCreateLogicalStateHelper) { + MockContext context; + auto mockDevice = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr)); + + MockCommandQueueHw cmdQ(&context, mockDevice.get(), nullptr); + + EXPECT_EQ(nullptr, cmdQ.logicalStateHelper.get()); +} + HWTEST_F(CommandQueueCommandStreamTest, WhenCheckIsTextureCacheFlushNeededThenReturnProperValue) { MockContext context; auto mockDevice = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr)); 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 a651e04cab..f940afbc90 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 @@ -10,6 +10,7 @@ #include "shared/source/command_stream/scratch_space_controller_base.h" #include "shared/source/command_stream/wait_status.h" #include "shared/source/helpers/constants.h" +#include "shared/source/helpers/logical_state_helper.h" #include "shared/source/os_interface/hw_info_config.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/engine_descriptor_helper.h" @@ -489,6 +490,11 @@ HWTEST_F(UltCommandStreamReceiverTest, givenMultiplePartitionsWhenCallingWaitKmd EXPECT_EQ(2u, commandStreamReceiver.waitForCompletionWithTimeoutTaskCountCalled); } +HWTEST_F(UltCommandStreamReceiverTest, whenCreatingThenDontCreateLogicalStateHelper) { + auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); + EXPECT_EQ(nullptr, commandStreamReceiver.logicalStateHelper.get()); +} + typedef UltCommandStreamReceiverTest CommandStreamReceiverFlushTests; HWTEST_F(CommandStreamReceiverFlushTests, WhenAddingBatchBufferEndThenBatchBufferEndIsAppendedCorrectly) { diff --git a/opencl/test/unit_test/helpers/hw_helper_tests.cpp b/opencl/test/unit_test/helpers/hw_helper_tests.cpp index 104228e905..6c16d08ef8 100644 --- a/opencl/test/unit_test/helpers/hw_helper_tests.cpp +++ b/opencl/test/unit_test/helpers/hw_helper_tests.cpp @@ -11,6 +11,7 @@ #include "shared/source/gmm_helper/gmm_helper.h" #include "shared/source/gmm_helper/resource_info.h" #include "shared/source/helpers/aligned_memory.h" +#include "shared/source/helpers/logical_state_helper.h" #include "shared/source/helpers/pipe_control_args.h" #include "shared/source/helpers/string.h" #include "shared/source/memory_manager/graphics_allocation.h" @@ -1467,3 +1468,10 @@ HWTEST_F(HwHelperTest, givenHwHelperWhenPassingLinkedCopyEngineTypeThenItsCopyOn HWTEST_F(HwHelperTest, givenHwHelperWhenPassingComputeEngineTypeThenItsNotCopyOnly) { EXPECT_FALSE(EngineHelper::isCopyOnlyEngineType(EngineGroupType::Compute)); } + +using LogicalStateHelperTest = ::testing::Test; + +HWTEST_F(LogicalStateHelperTest, whenCreatingLogicalStateHelperThenReturnNullptr) { + EXPECT_EQ(nullptr, LogicalStateHelper::create(true)); + EXPECT_EQ(nullptr, LogicalStateHelper::create(false)); +} \ No newline at end of file diff --git a/opencl/test/unit_test/mocks/mock_command_queue.h b/opencl/test/unit_test/mocks/mock_command_queue.h index cfc3f8f362..f600a94080 100644 --- a/opencl/test/unit_test/mocks/mock_command_queue.h +++ b/opencl/test/unit_test/mocks/mock_command_queue.h @@ -243,6 +243,7 @@ class MockCommandQueueHw : public CommandQueueHw { using BaseClass::gpgpuEngine; using BaseClass::isBlitAuxTranslationRequired; using BaseClass::latestSentEnqueueType; + using BaseClass::logicalStateHelper; using BaseClass::obtainCommandStream; using BaseClass::obtainNewTimestampPacketNodes; using BaseClass::requiresCacheFlushAfterWalker; diff --git a/shared/source/command_stream/command_stream_receiver_hw.h b/shared/source/command_stream/command_stream_receiver_hw.h index 83551a5423..464b18369e 100644 --- a/shared/source/command_stream/command_stream_receiver_hw.h +++ b/shared/source/command_stream/command_stream_receiver_hw.h @@ -24,6 +24,7 @@ namespace NEO { template class DeviceCommandStreamReceiver; struct PipeControlArgs; +class LogicalStateHelper; template class CommandStreamReceiverHw : public CommandStreamReceiver { @@ -189,6 +190,7 @@ class CommandStreamReceiverHw : public CommandStreamReceiver { std::unique_ptr>> directSubmission; std::unique_ptr>> blitterDirectSubmission; + std::unique_ptr logicalStateHelper; size_t cmdStreamStart = 0; }; 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 71c3242cb3..5e470165a1 100644 --- a/shared/source/command_stream/command_stream_receiver_hw_base.inl +++ b/shared/source/command_stream/command_stream_receiver_hw_base.inl @@ -26,6 +26,7 @@ #include "shared/source/helpers/flat_batch_buffer_helper_hw.h" #include "shared/source/helpers/flush_stamp.h" #include "shared/source/helpers/hw_helper.h" +#include "shared/source/helpers/logical_state_helper.h" #include "shared/source/helpers/pause_on_gpu_properties.h" #include "shared/source/helpers/preamble.h" #include "shared/source/helpers/ptr_math.h" @@ -73,6 +74,9 @@ CommandStreamReceiverHw::CommandStreamReceiverHw(ExecutionEnvironment if (DebugManager.flags.EnableTimestampPacket.get() != -1) { timestampPacketWriteEnabled = !!DebugManager.flags.EnableTimestampPacket.get(); } + + logicalStateHelper.reset(LogicalStateHelper::create(false)); + createScratchSpaceController(); configurePostSyncWriteOffset(); } diff --git a/shared/source/gen11/hw_helper_gen11.cpp b/shared/source/gen11/hw_helper_gen11.cpp index 47ce6cfe54..ca4bf2c0da 100644 --- a/shared/source/gen11/hw_helper_gen11.cpp +++ b/shared/source/gen11/hw_helper_gen11.cpp @@ -11,6 +11,7 @@ #include "shared/source/helpers/hw_helper_base.inl" #include "shared/source/helpers/hw_helper_bdw_and_later.inl" #include "shared/source/helpers/hw_helper_bdw_to_icllp.inl" +#include "shared/source/helpers/logical_state_helper.inl" namespace NEO { typedef ICLFamily Family; @@ -39,4 +40,6 @@ template class HwHelperHw; template class FlatBatchBufferHelperHw; template struct MemorySynchronizationCommands; template struct LriHelper; + +template LogicalStateHelper *LogicalStateHelper::create(bool pipelinedState); } // namespace NEO diff --git a/shared/source/gen12lp/hw_helper_gen12lp.cpp b/shared/source/gen12lp/hw_helper_gen12lp.cpp index e35968762d..717b53f646 100644 --- a/shared/source/gen12lp/hw_helper_gen12lp.cpp +++ b/shared/source/gen12lp/hw_helper_gen12lp.cpp @@ -14,6 +14,7 @@ using Family = NEO::TGLLPFamily; #include "shared/source/helpers/hw_helper_base.inl" #include "shared/source/helpers/hw_helper_bdw_and_later.inl" #include "shared/source/helpers/hw_helper_tgllp_and_later.inl" +#include "shared/source/helpers/logical_state_helper.inl" #include "shared/source/os_interface/hw_info_config.h" #include "engine_node.h" @@ -212,4 +213,6 @@ template class HwHelperHw; template class FlatBatchBufferHelperHw; template struct MemorySynchronizationCommands; template struct LriHelper; + +template LogicalStateHelper *LogicalStateHelper::create(bool pipelinedState); } // namespace NEO diff --git a/shared/source/gen8/hw_helper_gen8.cpp b/shared/source/gen8/hw_helper_gen8.cpp index e13201d876..2fa856b8d3 100644 --- a/shared/source/gen8/hw_helper_gen8.cpp +++ b/shared/source/gen8/hw_helper_gen8.cpp @@ -12,6 +12,7 @@ #include "shared/source/helpers/hw_helper_base.inl" #include "shared/source/helpers/hw_helper_bdw_and_later.inl" #include "shared/source/helpers/hw_helper_bdw_to_icllp.inl" +#include "shared/source/helpers/logical_state_helper.inl" namespace NEO { typedef BDWFamily Family; @@ -80,4 +81,6 @@ template class HwHelperHw; template class FlatBatchBufferHelperHw; template struct MemorySynchronizationCommands; template struct LriHelper; + +template LogicalStateHelper *LogicalStateHelper::create(bool pipelinedState); } // namespace NEO diff --git a/shared/source/gen9/hw_helper_gen9.cpp b/shared/source/gen9/hw_helper_gen9.cpp index 54a131e563..50cb5d8aac 100644 --- a/shared/source/gen9/hw_helper_gen9.cpp +++ b/shared/source/gen9/hw_helper_gen9.cpp @@ -11,6 +11,7 @@ #include "shared/source/helpers/hw_helper_base.inl" #include "shared/source/helpers/hw_helper_bdw_and_later.inl" #include "shared/source/helpers/hw_helper_bdw_to_icllp.inl" +#include "shared/source/helpers/logical_state_helper.inl" #include @@ -50,4 +51,6 @@ template class HwHelperHw; template class FlatBatchBufferHelperHw; template struct MemorySynchronizationCommands; template struct LriHelper; + +template LogicalStateHelper *LogicalStateHelper::create(bool pipelinedState); } // namespace NEO diff --git a/shared/source/helpers/CMakeLists.txt b/shared/source/helpers/CMakeLists.txt index da7ded8c0e..1fa413299f 100644 --- a/shared/source/helpers/CMakeLists.txt +++ b/shared/source/helpers/CMakeLists.txt @@ -89,6 +89,8 @@ set(NEO_CORE_HELPERS ${CMAKE_CURRENT_SOURCE_DIR}/local_id_gen_sse4.cpp ${CMAKE_CURRENT_SOURCE_DIR}/local_work_size.cpp ${CMAKE_CURRENT_SOURCE_DIR}/local_work_size.h + ${CMAKE_CURRENT_SOURCE_DIR}/logical_state_helper.h + ${CMAKE_CURRENT_SOURCE_DIR}/logical_state_helper.inl ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}memory_properties_helpers.cpp ${CMAKE_CURRENT_SOURCE_DIR}/memory_properties_helpers.h ${CMAKE_CURRENT_SOURCE_DIR}/memory_properties_helpers_base.inl diff --git a/shared/source/helpers/logical_state_helper.h b/shared/source/helpers/logical_state_helper.h new file mode 100644 index 0000000000..c32e454d6b --- /dev/null +++ b/shared/source/helpers/logical_state_helper.h @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once + +namespace NEO { +class LinearStream; + +class LogicalStateHelper { + public: + template + static LogicalStateHelper *create(bool pipelinedState); + + virtual ~LogicalStateHelper() = default; + + virtual void writeStreamInline(LinearStream &linearStream) = 0; + + protected: + LogicalStateHelper() = default; +}; + +} // namespace NEO \ No newline at end of file diff --git a/shared/source/helpers/logical_state_helper.inl b/shared/source/helpers/logical_state_helper.inl new file mode 100644 index 0000000000..2b89997d7a --- /dev/null +++ b/shared/source/helpers/logical_state_helper.inl @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/logical_state_helper.h" + +namespace NEO { + +template +LogicalStateHelper *LogicalStateHelper::create(bool pipelinedState) { + return nullptr; +} + +} // namespace NEO \ No newline at end of file diff --git a/shared/source/xe_hp_core/hw_helper_xe_hp_core.cpp b/shared/source/xe_hp_core/hw_helper_xe_hp_core.cpp index 1fdd37cc49..3bef0d8a6d 100644 --- a/shared/source/xe_hp_core/hw_helper_xe_hp_core.cpp +++ b/shared/source/xe_hp_core/hw_helper_xe_hp_core.cpp @@ -17,6 +17,7 @@ using Family = NEO::XeHpFamily; #include "shared/source/helpers/hw_helper_base.inl" #include "shared/source/helpers/hw_helper_tgllp_and_later.inl" #include "shared/source/helpers/hw_helper_xehp_and_later.inl" +#include "shared/source/helpers/logical_state_helper.inl" #include "shared/source/os_interface/hw_info_config.h" namespace NEO { @@ -155,4 +156,6 @@ template class HwHelperHw; template class FlatBatchBufferHelperHw; template struct MemorySynchronizationCommands; template struct LriHelper; + +template LogicalStateHelper *LogicalStateHelper::create(bool pipelinedState); } // namespace NEO diff --git a/shared/source/xe_hpc_core/hw_helper_xe_hpc_core.cpp b/shared/source/xe_hpc_core/hw_helper_xe_hpc_core.cpp index 19614e9dcb..11acebaf66 100644 --- a/shared/source/xe_hpc_core/hw_helper_xe_hpc_core.cpp +++ b/shared/source/xe_hpc_core/hw_helper_xe_hpc_core.cpp @@ -17,6 +17,7 @@ using Family = NEO::XE_HPC_COREFamily; #include "shared/source/helpers/hw_helper_dg2_and_later.inl" #include "shared/source/helpers/hw_helper_tgllp_and_later.inl" #include "shared/source/helpers/hw_helper_xehp_and_later.inl" +#include "shared/source/helpers/logical_state_helper.inl" namespace NEO { @@ -458,4 +459,6 @@ template class HwHelperHw; template class FlatBatchBufferHelperHw; template struct MemorySynchronizationCommands; template struct LriHelper; + +template LogicalStateHelper *LogicalStateHelper::create(bool pipelinedState); } // namespace NEO diff --git a/shared/source/xe_hpg_core/hw_helper_xe_hpg_core.cpp b/shared/source/xe_hpg_core/hw_helper_xe_hpg_core.cpp index feb82e62ed..b0bd9c98f5 100644 --- a/shared/source/xe_hpg_core/hw_helper_xe_hpg_core.cpp +++ b/shared/source/xe_hpg_core/hw_helper_xe_hpg_core.cpp @@ -17,6 +17,7 @@ using Family = NEO::XE_HPG_COREFamily; #include "shared/source/helpers/hw_helper_dg2_and_later.inl" #include "shared/source/helpers/hw_helper_tgllp_and_later.inl" #include "shared/source/helpers/hw_helper_xehp_and_later.inl" +#include "shared/source/helpers/logical_state_helper.inl" namespace NEO { template <> @@ -139,4 +140,6 @@ template class HwHelperHw; template class FlatBatchBufferHelperHw; template struct MemorySynchronizationCommands; template struct LriHelper; + +template LogicalStateHelper *LogicalStateHelper::create(bool pipelinedState); } // namespace NEO diff --git a/shared/test/common/libult/ult_command_stream_receiver.h b/shared/test/common/libult/ult_command_stream_receiver.h index 1dbc02d17c..6661c29163 100644 --- a/shared/test/common/libult/ult_command_stream_receiver.h +++ b/shared/test/common/libult/ult_command_stream_receiver.h @@ -44,6 +44,7 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw, publ using BaseClass::isBlitterDirectSubmissionEnabled; using BaseClass::isDirectSubmissionEnabled; using BaseClass::isPerDssBackedBufferSent; + using BaseClass::logicalStateHelper; using BaseClass::makeResident; using BaseClass::perDssBackedBuffer; using BaseClass::postInitFlagsSetup;