From 2e729bcb4c0d6232b4329016dba1d11f8aaf600e Mon Sep 17 00:00:00 2001 From: Kamil Kopryk Date: Tue, 18 Mar 2025 15:45:27 +0000 Subject: [PATCH] refactor: move isTimestampWaitSupportedForQueues to productHelper Related-to: NEO-13163 Signed-off-by: Kamil Kopryk --- opencl/source/command_queue/command_queue.cpp | 4 ++-- .../command_queue/command_queue_tests.cpp | 3 +-- shared/source/gen12lp/gfx_core_helper_gen12lp.cpp | 5 ----- shared/source/helpers/gfx_core_helper.h | 2 -- .../helpers/gfx_core_helper_xehp_and_later.inl | 7 +------ shared/source/os_interface/CMakeLists.txt | 4 ++++ shared/source/os_interface/product_helper.h | 2 ++ shared/source/os_interface/product_helper.inl | 5 +++++ .../product_helper_from_xe_hpg_to_xe3.inl | 15 +++++++++++++++ shared/source/os_interface/product_helper_hw.h | 1 + .../xe2_hpg_core/gfx_core_helper_xe2_hpg_core.cpp | 5 ----- .../os_agnostic_product_helper_xe2_hpg_core.inl | 3 ++- .../os_agnostic_product_helper_xe3_core.inl | 1 + .../os_agnostic_product_helper_xe_hpc_core.inl | 1 + .../dg2/os_agnostic_product_helper_dg2.inl | 1 + .../xe_lpg/os_agnostic_product_helper_xe_lpg.inl | 1 + .../gfx_core_helper_tests_xe2_hpg_core.cpp | 10 +++++----- .../xe3_core/gfx_core_helper_xe3_core_tests.cpp | 10 +++++----- .../gfx_core_helper_xe_hpc_core_tests.cpp | 11 +++++------ .../gfx_core_helper_tests_xe_hpg_core.cpp | 10 +++++----- 20 files changed, 57 insertions(+), 44 deletions(-) create mode 100644 shared/source/os_interface/product_helper_from_xe_hpg_to_xe3.inl diff --git a/opencl/source/command_queue/command_queue.cpp b/opencl/source/command_queue/command_queue.cpp index b7c9d0c7db..c7c0fc5121 100644 --- a/opencl/source/command_queue/command_queue.cpp +++ b/opencl/source/command_queue/command_queue.cpp @@ -1331,10 +1331,10 @@ void CommandQueue::assignDataToOverwrittenBcsNode(TagNodeBase *node) { } bool CommandQueue::isWaitForTimestampsEnabled() const { - const auto &gfxCoreHelper = getDevice().getGfxCoreHelper(); auto &productHelper = getDevice().getProductHelper(); + auto enabled = CommandQueue::isTimestampWaitEnabled(); - enabled &= gfxCoreHelper.isTimestampWaitSupportedForQueues(); + enabled &= productHelper.isTimestampWaitSupportedForQueues(false); enabled &= !productHelper.isDcFlushAllowed(); enabled &= !getDevice().getRootDeviceEnvironment().isWddmOnLinux(); enabled &= !this->isOOQEnabled(); // TSP for OOQ dispatch is optional. We need to wait for task count. 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 597364618f..7ec9ac884e 100644 --- a/opencl/test/unit_test/command_queue/command_queue_tests.cpp +++ b/opencl/test/unit_test/command_queue/command_queue_tests.cpp @@ -169,9 +169,8 @@ TEST(CommandQueue, givenEnableTimestampWaitWhenCheckIsTimestampWaitEnabledThenRe { debugManager.flags.EnableTimestampWaitForQueues.set(-1); - const auto &gfxCoreHelper = mockDevice->getGfxCoreHelper(); const auto &productHelper = mockDevice->getProductHelper(); - EXPECT_EQ(cmdQ.isWaitForTimestampsEnabled(), gfxCoreHelper.isTimestampWaitSupportedForQueues() && !productHelper.isDcFlushAllowed()); + EXPECT_EQ(cmdQ.isWaitForTimestampsEnabled(), productHelper.isTimestampWaitSupportedForQueues(false) && !productHelper.isDcFlushAllowed()); } { diff --git a/shared/source/gen12lp/gfx_core_helper_gen12lp.cpp b/shared/source/gen12lp/gfx_core_helper_gen12lp.cpp index d0481ba01e..04af2fbaa8 100644 --- a/shared/source/gen12lp/gfx_core_helper_gen12lp.cpp +++ b/shared/source/gen12lp/gfx_core_helper_gen12lp.cpp @@ -41,11 +41,6 @@ bool GfxCoreHelperHw::timestampPacketWriteSupported() const { return false; } -template -bool GfxCoreHelperHw::isTimestampWaitSupportedForQueues() const { - return false; -} - template bool GfxCoreHelperHw::isUpdateTaskCountFromWaitSupported() const { return false; diff --git a/shared/source/helpers/gfx_core_helper.h b/shared/source/helpers/gfx_core_helper.h index 0fbb70c243..ec1238d4b7 100644 --- a/shared/source/helpers/gfx_core_helper.h +++ b/shared/source/helpers/gfx_core_helper.h @@ -74,7 +74,6 @@ class GfxCoreHelper { static uint32_t getHighestEnabledSlice(const HardwareInfo &hwInfo); static uint32_t getHighestEnabledDualSubSlice(const HardwareInfo &hwInfo); virtual bool timestampPacketWriteSupported() const = 0; - virtual bool isTimestampWaitSupportedForQueues() const = 0; virtual bool isUpdateTaskCountFromWaitSupported() const = 0; virtual bool makeResidentBeforeLockNeeded(bool precondition) const = 0; virtual size_t getRenderSurfaceStateSize() const = 0; @@ -273,7 +272,6 @@ class GfxCoreHelperHw : public GfxCoreHelper { bool timestampPacketWriteSupported() const override; - bool isTimestampWaitSupportedForQueues() const override; bool isUpdateTaskCountFromWaitSupported() const override; bool is1MbAlignmentSupported(const HardwareInfo &hwInfo, bool isCompressionEnabled) const override; diff --git a/shared/source/helpers/gfx_core_helper_xehp_and_later.inl b/shared/source/helpers/gfx_core_helper_xehp_and_later.inl index 4cd3466de2..7beaa79f5a 100644 --- a/shared/source/helpers/gfx_core_helper_xehp_and_later.inl +++ b/shared/source/helpers/gfx_core_helper_xehp_and_later.inl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2024 Intel Corporation + * Copyright (C) 2021-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -53,11 +53,6 @@ bool GfxCoreHelperHw::timestampPacketWriteSupported() const { return true; } -template -bool GfxCoreHelperHw::isTimestampWaitSupportedForQueues() const { - return true; -} - template uint32_t GfxCoreHelperHw::getAmountOfAllocationsToFill() const { if (debugManager.flags.SetAmountOfReusableAllocations.get() != -1) { diff --git a/shared/source/os_interface/CMakeLists.txt b/shared/source/os_interface/CMakeLists.txt index a4a71b580b..869a80ec6a 100644 --- a/shared/source/os_interface/CMakeLists.txt +++ b/shared/source/os_interface/CMakeLists.txt @@ -55,5 +55,9 @@ if(SUPPORT_XE_HPC_CORE OR SUPPORT_XE_HPG_CORE) list(APPEND NEO_CORE_OS_INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/product_helper_xe_hpg_and_xe_hpc.inl) endif() +if(SUPPORT_XE_HPC_CORE OR SUPPORT_XE_HPG_CORE OR SUPPORT_XE2_HPG_CORE OR SUPPORT_XE3_CORE) + list(APPEND NEO_CORE_OS_INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/product_helper_from_xe_hpg_to_xe3.inl) +endif() + set_property(GLOBAL PROPERTY NEO_CORE_OS_INTERFACE ${NEO_CORE_OS_INTERFACE}) add_subdirectories() diff --git a/shared/source/os_interface/product_helper.h b/shared/source/os_interface/product_helper.h index 6525db5b1d..9554f35594 100644 --- a/shared/source/os_interface/product_helper.h +++ b/shared/source/os_interface/product_helper.h @@ -187,6 +187,8 @@ class ProductHelper { virtual bool isHostUsmAllocationReuseSupported() const = 0; virtual bool useLocalPreferredForCacheableBuffers() const = 0; virtual bool useGemCreateExtInAllocateMemoryByKMD() const = 0; + virtual bool isTimestampWaitSupportedForQueues(bool heaplessEnabled) const = 0; + virtual bool isTlbFlushRequired() const = 0; virtual bool isDetectIndirectAccessInKernelSupported(const KernelDescriptor &kernelDescriptor, const bool isPrecompiled, const uint32_t precompiledKernelIndirectDetectionVersion) const = 0; virtual uint32_t getRequiredDetectIndirectVersion() const = 0; diff --git a/shared/source/os_interface/product_helper.inl b/shared/source/os_interface/product_helper.inl index 257bf18ec7..f9ae08ce49 100644 --- a/shared/source/os_interface/product_helper.inl +++ b/shared/source/os_interface/product_helper.inl @@ -1019,4 +1019,9 @@ template void ProductHelperHw::overrideDirectSubmissionTimeouts(std::chrono::microseconds &timeout, std::chrono::microseconds &maxTimeout) const { } +template +bool ProductHelperHw::isTimestampWaitSupportedForQueues(bool heaplessEnabled) const { + return false; +} + } // namespace NEO diff --git a/shared/source/os_interface/product_helper_from_xe_hpg_to_xe3.inl b/shared/source/os_interface/product_helper_from_xe_hpg_to_xe3.inl new file mode 100644 index 0000000000..f021074d14 --- /dev/null +++ b/shared/source/os_interface/product_helper_from_xe_hpg_to_xe3.inl @@ -0,0 +1,15 @@ +/* + * Copyright (C) 2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/os_interface/product_helper.h" +namespace NEO { + +template <> +bool ProductHelperHw::isTimestampWaitSupportedForQueues(bool heaplessEnabled) const { + return true; +} +} // namespace NEO diff --git a/shared/source/os_interface/product_helper_hw.h b/shared/source/os_interface/product_helper_hw.h index 53cb1ea084..6d55af51b7 100644 --- a/shared/source/os_interface/product_helper_hw.h +++ b/shared/source/os_interface/product_helper_hw.h @@ -89,6 +89,7 @@ class ProductHelperHw : public ProductHelper { bool isCopyEngineSelectorEnabled(const HardwareInfo &hwInfo) const override; bool isGlobalFenceInCommandStreamRequired(const HardwareInfo &hwInfo) const override; bool isGlobalFenceInDirectSubmissionRequired(const HardwareInfo &hwInfo) const override; + bool isTimestampWaitSupportedForQueues(bool heaplessEnabled) const override; uint32_t getThreadEuRatioForScratch(const HardwareInfo &hwInfo) const override; void adjustScratchSize(size_t &requiredScratchSize) const override; size_t getSvmCpuAlignment() const override; diff --git a/shared/source/xe2_hpg_core/gfx_core_helper_xe2_hpg_core.cpp b/shared/source/xe2_hpg_core/gfx_core_helper_xe2_hpg_core.cpp index 6240621b6f..468acd92da 100644 --- a/shared/source/xe2_hpg_core/gfx_core_helper_xe2_hpg_core.cpp +++ b/shared/source/xe2_hpg_core/gfx_core_helper_xe2_hpg_core.cpp @@ -84,11 +84,6 @@ uint32_t GfxCoreHelperHw::getMocsIndex(const GmmHelper &gmmHelper, bool return gmmHelper.getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED) >> 1; } -template <> -bool GfxCoreHelperHw::isTimestampWaitSupportedForQueues() const { - return true; -} - template <> const StackVec GfxCoreHelperHw::getDeviceSubGroupSizes() const { return {16, 32}; diff --git a/shared/source/xe2_hpg_core/os_agnostic_product_helper_xe2_hpg_core.inl b/shared/source/xe2_hpg_core/os_agnostic_product_helper_xe2_hpg_core.inl index eb3365d104..44badf8c35 100644 --- a/shared/source/xe2_hpg_core/os_agnostic_product_helper_xe2_hpg_core.inl +++ b/shared/source/xe2_hpg_core/os_agnostic_product_helper_xe2_hpg_core.inl @@ -1,10 +1,11 @@ /* - * Copyright (C) 2024 Intel Corporation + * Copyright (C) 2024-2025 Intel Corporation * * SPDX-License-Identifier: MIT * */ +#include "shared/source/os_interface/product_helper_from_xe_hpg_to_xe3.inl" #include "shared/source/os_interface/product_helper_xe_hpc_and_later.inl" namespace NEO { diff --git a/shared/source/xe3_core/os_agnostic_product_helper_xe3_core.inl b/shared/source/xe3_core/os_agnostic_product_helper_xe3_core.inl index e2386c5f9f..873e727c12 100644 --- a/shared/source/xe3_core/os_agnostic_product_helper_xe3_core.inl +++ b/shared/source/xe3_core/os_agnostic_product_helper_xe3_core.inl @@ -5,6 +5,7 @@ * */ +#include "shared/source/os_interface/product_helper_from_xe_hpg_to_xe3.inl" #include "shared/source/os_interface/product_helper_xe_hpc_and_later.inl" namespace NEO { diff --git a/shared/source/xe_hpc_core/os_agnostic_product_helper_xe_hpc_core.inl b/shared/source/xe_hpc_core/os_agnostic_product_helper_xe_hpc_core.inl index 6fbbc13ed9..c5e37b73fd 100644 --- a/shared/source/xe_hpc_core/os_agnostic_product_helper_xe_hpc_core.inl +++ b/shared/source/xe_hpc_core/os_agnostic_product_helper_xe_hpc_core.inl @@ -5,6 +5,7 @@ * */ +#include "shared/source/os_interface/product_helper_from_xe_hpg_to_xe3.inl" #include "shared/source/os_interface/product_helper_xe_hpc_and_later.inl" namespace NEO { diff --git a/shared/source/xe_hpg_core/dg2/os_agnostic_product_helper_dg2.inl b/shared/source/xe_hpg_core/dg2/os_agnostic_product_helper_dg2.inl index e6c1642a06..22ad731fdd 100644 --- a/shared/source/xe_hpg_core/dg2/os_agnostic_product_helper_dg2.inl +++ b/shared/source/xe_hpg_core/dg2/os_agnostic_product_helper_dg2.inl @@ -8,6 +8,7 @@ #include "shared/source/command_stream/command_stream_receiver.h" #include "shared/source/helpers/gfx_core_helper.h" #include "shared/source/memory_manager/memory_manager.h" +#include "shared/source/os_interface/product_helper_from_xe_hpg_to_xe3.inl" #include "shared/source/os_interface/product_helper_xe_hpg_and_xe_hpc.inl" #include "aubstream/product_family.h" diff --git a/shared/source/xe_hpg_core/xe_lpg/os_agnostic_product_helper_xe_lpg.inl b/shared/source/xe_hpg_core/xe_lpg/os_agnostic_product_helper_xe_lpg.inl index d66a5632d9..a9a8db6923 100644 --- a/shared/source/xe_hpg_core/xe_lpg/os_agnostic_product_helper_xe_lpg.inl +++ b/shared/source/xe_hpg_core/xe_lpg/os_agnostic_product_helper_xe_lpg.inl @@ -11,6 +11,7 @@ #include "shared/source/memory_manager/allocation_type.h" #include "shared/source/os_interface/product_helper.h" #include "shared/source/os_interface/product_helper.inl" +#include "shared/source/os_interface/product_helper_from_xe_hpg_to_xe3.inl" #include "shared/source/os_interface/product_helper_xe_hpg_and_xe_hpc.inl" #include "aubstream/product_family.h" diff --git a/shared/test/unit_test/xe2_hpg_core/gfx_core_helper_tests_xe2_hpg_core.cpp b/shared/test/unit_test/xe2_hpg_core/gfx_core_helper_tests_xe2_hpg_core.cpp index 3532a76405..a80a90244a 100644 --- a/shared/test/unit_test/xe2_hpg_core/gfx_core_helper_tests_xe2_hpg_core.cpp +++ b/shared/test/unit_test/xe2_hpg_core/gfx_core_helper_tests_xe2_hpg_core.cpp @@ -31,11 +31,6 @@ XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenGfxCoreHelperWhenAskingFor EXPECT_EQ(expectedAlignment, gfxCoreHelper.getTimestampPacketAllocatorAlignment()); } -XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenGfxCoreHelperWhenCheckTimestampWaitSupportThenReturnTrue) { - auto &gfxCoreHelper = getHelper(); - EXPECT_TRUE(gfxCoreHelper.isTimestampWaitSupportedForQueues()); -} - XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenXe2HpgCoreWhenAskedForMinimialSimdThen16IsReturned) { auto &gfxCoreHelper = getHelper(); EXPECT_EQ(16u, gfxCoreHelper.getMinimalSIMDSize()); @@ -613,6 +608,11 @@ XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenProgramGlobalFenceAsMiMemF using ProductHelperTestXe2HpgCore = Test; +XE2_HPG_CORETEST_F(ProductHelperTestXe2HpgCore, givenProductHelperWhenCheckTimestampWaitSupportThenReturnTrue) { + auto &productHelper = getHelper(); + EXPECT_TRUE(productHelper.isTimestampWaitSupportedForQueues(false)); +} + XE2_HPG_CORETEST_F(ProductHelperTestXe2HpgCore, givenProductHelperWhenGettingIsBlitCopyRequiredForLocalMemoryThenFalseIsReturned) { auto &productHelper = getHelper(); MockGraphicsAllocation allocation; diff --git a/shared/test/unit_test/xe3_core/gfx_core_helper_xe3_core_tests.cpp b/shared/test/unit_test/xe3_core/gfx_core_helper_xe3_core_tests.cpp index 5c18743f2e..dbc02e223d 100644 --- a/shared/test/unit_test/xe3_core/gfx_core_helper_xe3_core_tests.cpp +++ b/shared/test/unit_test/xe3_core/gfx_core_helper_xe3_core_tests.cpp @@ -44,11 +44,6 @@ XE3_CORETEST_F(GfxCoreHelperTestsXe3Core, givenGfxCoreHelperWhenAskingForTimesta EXPECT_EQ(expectedAlignment, gfxCoreHelper.getTimestampPacketAllocatorAlignment()); } -XE3_CORETEST_F(GfxCoreHelperTestsXe3Core, givenGfxCoreHelperWhenCheckTimestampWaitSupportThenReturnTrue) { - auto &gfxCoreHelper = getHelper(); - EXPECT_TRUE(gfxCoreHelper.isTimestampWaitSupportedForQueues()); -} - XE3_CORETEST_F(GfxCoreHelperTestsXe3Core, givenXe3CoreWhenAskedForMinimialSimdThen16IsReturned) { auto &gfxCoreHelper = getHelper(); EXPECT_EQ(16u, gfxCoreHelper.getMinimalSIMDSize()); @@ -609,6 +604,11 @@ XE3_CORETEST_F(GfxCoreHelperTestsXe3Core, givenProgramGlobalFenceAsMiMemFenceCom using ProductHelperTestXe3Core = Test; +XE3_CORETEST_F(ProductHelperTestXe3Core, givenProductHelperWhenCheckTimestampWaitForQueuesSupportThenReturnTrue) { + auto &productHelper = getHelper(); + EXPECT_TRUE(productHelper.isTimestampWaitSupportedForQueues(false)); +} + XE3_CORETEST_F(ProductHelperTestXe3Core, givenProductHelperWhenCheckTimestampWaitSupportThenReturnTrue) { auto &productHelper = getHelper(); EXPECT_TRUE(productHelper.isTimestampWaitSupportedForEvents()); diff --git a/shared/test/unit_test/xe_hpc_core/gfx_core_helper_xe_hpc_core_tests.cpp b/shared/test/unit_test/xe_hpc_core/gfx_core_helper_xe_hpc_core_tests.cpp index c5fdc108e8..5b5e9580bb 100644 --- a/shared/test/unit_test/xe_hpc_core/gfx_core_helper_xe_hpc_core_tests.cpp +++ b/shared/test/unit_test/xe_hpc_core/gfx_core_helper_xe_hpc_core_tests.cpp @@ -63,14 +63,13 @@ XE_HPC_CORETEST_F(GfxCoreHelperXeHpcCoreTest, WhenGettingIsCpuImageTransferPrefe EXPECT_TRUE(gfxCoreHelper.isCpuImageTransferPreferred(*defaultHwInfo)); } -XE_HPC_CORETEST_F(GfxCoreHelperXeHpcCoreTest, givenGfxCoreHelperWhenCheckTimestampWaitSupportThenReturnTrue) { - MockExecutionEnvironment mockExecutionEnvironment{}; - auto &gfxCoreHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getHelper(); - EXPECT_TRUE(gfxCoreHelper.isTimestampWaitSupportedForQueues()); -} - using ProductHelperTestXeHpcCore = Test; +XE_HPC_CORETEST_F(ProductHelperTestXeHpcCore, givenProductHelperWhenCheckTimestampWaitSupportThenReturnTrue) { + auto &helper = getHelper(); + EXPECT_TRUE(helper.isTimestampWaitSupportedForQueues(false)); +} + XE_HPC_CORETEST_F(ProductHelperTestXeHpcCore, givenProductHelperWhenCheckTimestampWaitSupportForEventsThenReturnTrue) { auto &helper = getHelper(); EXPECT_TRUE(helper.isTimestampWaitSupportedForEvents()); diff --git a/shared/test/unit_test/xe_hpg_core/gfx_core_helper_tests_xe_hpg_core.cpp b/shared/test/unit_test/xe_hpg_core/gfx_core_helper_tests_xe_hpg_core.cpp index 234b018d80..554e89917b 100644 --- a/shared/test/unit_test/xe_hpg_core/gfx_core_helper_tests_xe_hpg_core.cpp +++ b/shared/test/unit_test/xe_hpg_core/gfx_core_helper_tests_xe_hpg_core.cpp @@ -58,6 +58,11 @@ XE_HPG_CORETEST_F(GfxCoreHelperTestXeHpgCore, givenDebugFlagWhenCheckingIfBuffer using ProductHelperTestXeHpgCore = Test; +XE_HPG_CORETEST_F(ProductHelperTestXeHpgCore, givenProductHelperWhenCheckTimestampWaitSupportForQueuesThenReturnTrue) { + auto &productHelper = getHelper(); + EXPECT_TRUE(productHelper.isTimestampWaitSupportedForQueues(false)); +} + XE_HPG_CORETEST_F(ProductHelperTestXeHpgCore, givenDebugVariableSetWhenConfigureIsCalledThenSetupBlitterOperationsSupportedFlag) { DebugManagerStateRestore restore; auto &productHelper = getHelper(); @@ -142,11 +147,6 @@ XE_HPG_CORETEST_F(GfxCoreHelperTestXeHpgCore, GivenVariousValuesWhenAlignSlmSize EXPECT_EQ(65536u, gfxCoreHelper.alignSlmSize(65536)); } -XE_HPG_CORETEST_F(GfxCoreHelperTestXeHpgCore, givenGfxCoreHelperWhenCheckTimestampWaitSupportForQueuesThenReturnTrue) { - auto &gfxCoreHelper = getHelper(); - EXPECT_TRUE(gfxCoreHelper.isTimestampWaitSupportedForQueues()); -} - XE_HPG_CORETEST_F(GfxCoreHelperTestXeHpgCore, givenDisablePipeControlFlagIsEnabledWhenLocalMemoryIsEnabledThenReturnTrueAndProgramPipeControl) { using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; DebugManagerStateRestore restore;