From 4011f0361e25879f35beb7757d9176713a4c1cc4 Mon Sep 17 00:00:00 2001 From: Filip Hazubski Date: Fri, 17 Jul 2020 15:43:35 +0200 Subject: [PATCH] Add HwHelper::getLocalMemoryAccessMode helper function Change-Id: Ia181cfca11f648f1631e1fcd82458024d019e038 Signed-off-by: Bartosz Dunajski --- .../test/unit_test/helpers/hw_helper_tests.cpp | 17 +++++++++++++++++ opencl/test/unit_test/test_files/igdrcl.config | 1 + .../debug_settings/debug_variables_base.inl | 1 + shared/source/helpers/hw_helper.h | 13 +++++++++++++ shared/source/helpers/hw_helper_base.inl | 16 ++++++++++++++++ 5 files changed, 48 insertions(+) diff --git a/opencl/test/unit_test/helpers/hw_helper_tests.cpp b/opencl/test/unit_test/helpers/hw_helper_tests.cpp index 52b5d919b5..3d835394e0 100644 --- a/opencl/test/unit_test/helpers/hw_helper_tests.cpp +++ b/opencl/test/unit_test/helpers/hw_helper_tests.cpp @@ -911,6 +911,23 @@ HWTEST_F(HwHelperTest, givenDefaultHwHelperHwWhenMinimalSIMDSizeIsQueriedThen8Is EXPECT_EQ(8u, helper.getMinimalSIMDSize()); } +HWTEST_F(HwHelperTest, givenVariousDebugKeyValuesWhenGettingLocalMemoryAccessModeThenCorrectValueIsReturned) { + struct MockHwHelper : HwHelperHw { + using HwHelper::getDefaultLocalMemoryAccessMode; + }; + + DebugManagerStateRestore restore{}; + auto hwHelper = static_cast(HwHelper::get(renderCoreFamily)); + EXPECT_EQ(hwHelper.getDefaultLocalMemoryAccessMode(*defaultHwInfo), hwHelper.getLocalMemoryAccessMode(*defaultHwInfo)); + + DebugManager.flags.ForceLocalMemoryAccessMode.set(0); + EXPECT_EQ(LocalMemoryAccessMode::Default, hwHelper.getLocalMemoryAccessMode(*defaultHwInfo)); + DebugManager.flags.ForceLocalMemoryAccessMode.set(1); + EXPECT_EQ(LocalMemoryAccessMode::CpuAccessAllowed, hwHelper.getLocalMemoryAccessMode(*defaultHwInfo)); + DebugManager.flags.ForceLocalMemoryAccessMode.set(3); + EXPECT_EQ(LocalMemoryAccessMode::CpuAccessDisallowed, hwHelper.getLocalMemoryAccessMode(*defaultHwInfo)); +} + HWTEST2_F(HwHelperTest, givenSingleEnginePlatformWhenGettingComputeEngineIndexByOrdinalThenZeroIndexIsReturned, IsAtMostGen11) { auto &helper = HwHelper::get(renderCoreFamily); EXPECT_EQ(0u, helper.getComputeEngineIndexByOrdinal(*defaultHwInfo, 0)); diff --git a/opencl/test/unit_test/test_files/igdrcl.config b/opencl/test/unit_test/test_files/igdrcl.config index f00838c3b0..676d3a4a38 100644 --- a/opencl/test/unit_test/test_files/igdrcl.config +++ b/opencl/test/unit_test/test_files/igdrcl.config @@ -175,3 +175,4 @@ OverrideRevision = -1 ForceCacheFlushForBcs = -1 ForceGpgpuSubmissionForBcsEnqueue = -1 ForceSemaphoreDelayBetweenWaits = -1 +ForceLocalMemoryAccessMode = -1 \ No newline at end of file diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index 5f140bd1c4..7491d243a8 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -192,3 +192,4 @@ DECLARE_DEBUG_VARIABLE(int32_t, AllocateSharedAllocationsWithCpuAndGpuStorage, - DECLARE_DEBUG_VARIABLE(bool, UseMaxSimdSizeToDeduceMaxWorkgroupSize, false, "With this flag on, max workgroup size is deduced using SIMD32 instead of SIMD8, this causes the max wkg size to be 4 times bigger") DECLARE_DEBUG_VARIABLE(bool, ReturnRawGpuTimestamps, false, "Driver returns raw GPU tiemstamps instead of calculated ones.") DECLARE_DEBUG_VARIABLE(int32_t, ForceSemaphoreDelayBetweenWaits, -1, "Specifies the minimum number of microseconds allowed for command streamer to wait before re-fetching the data. 0 - poll interval will be equal to the memory latency of the read completion") +DECLARE_DEBUG_VARIABLE(int32_t, ForceLocalMemoryAccessMode, -1, "-1: don't override, 0: default rules apply, 1: CPU can access local memory, 3: CPU never accesses local memory") diff --git a/shared/source/helpers/hw_helper.h b/shared/source/helpers/hw_helper.h index 2f2fd294be..89a19eb85f 100644 --- a/shared/source/helpers/hw_helper.h +++ b/shared/source/helpers/hw_helper.h @@ -29,6 +29,12 @@ struct HardwareCapabilities; struct RootDeviceEnvironment; struct PipeControlArgs; +enum class LocalMemoryAccessMode { + Default = 0, + CpuAccessAllowed = 1, + CpuAccessDisallowed = 3 +}; + class HwHelper { public: using EngineInstancesContainer = StackVec; @@ -57,6 +63,7 @@ class HwHelper { virtual bool checkResourceCompatibility(GraphicsAllocation &graphicsAllocation) = 0; virtual bool allowRenderCompression(const HardwareInfo &hwInfo) const = 0; virtual bool isBlitCopyRequiredForLocalMemory(const HardwareInfo &hwInfo) const = 0; + virtual LocalMemoryAccessMode getLocalMemoryAccessMode(const HardwareInfo &hwInfo) const = 0; static bool renderCompressedBuffersSupported(const HardwareInfo &hwInfo); static bool renderCompressedImagesSupported(const HardwareInfo &hwInfo); static bool cacheFlushAfterWalkerSupported(const HardwareInfo &hwInfo); @@ -111,6 +118,8 @@ class HwHelper { static constexpr uint32_t internalUsageEngineIndex = 2; protected: + virtual LocalMemoryAccessMode getDefaultLocalMemoryAccessMode(const HardwareInfo &hwInfo) const = 0; + HwHelper() = default; }; @@ -273,9 +282,13 @@ class HwHelperHw : public HwHelper { bool isBlitCopyRequiredForLocalMemory(const HardwareInfo &hwInfo) const override; + LocalMemoryAccessMode getLocalMemoryAccessMode(const HardwareInfo &hwInfo) const override; + bool isBankOverrideRequired(const HardwareInfo &hwInfo) const override; protected: + LocalMemoryAccessMode getDefaultLocalMemoryAccessMode(const HardwareInfo &hwInfo) const override; + static const AuxTranslationMode defaultAuxTranslationMode; HwHelperHw() = default; }; diff --git a/shared/source/helpers/hw_helper_base.inl b/shared/source/helpers/hw_helper_base.inl index 5d6fbed4da..dc92933cfe 100644 --- a/shared/source/helpers/hw_helper_base.inl +++ b/shared/source/helpers/hw_helper_base.inl @@ -392,6 +392,22 @@ inline bool HwHelperHw::isBlitCopyRequiredForLocalMemory(const Hardwa return false; } +template +LocalMemoryAccessMode HwHelperHw::getLocalMemoryAccessMode(const HardwareInfo &hwInfo) const { + switch (static_cast(DebugManager.flags.ForceLocalMemoryAccessMode.get())) { + case LocalMemoryAccessMode::Default: + case LocalMemoryAccessMode::CpuAccessAllowed: + case LocalMemoryAccessMode::CpuAccessDisallowed: + return static_cast(DebugManager.flags.ForceLocalMemoryAccessMode.get()); + } + return getDefaultLocalMemoryAccessMode(hwInfo); +} + +template +inline LocalMemoryAccessMode HwHelperHw::getDefaultLocalMemoryAccessMode(const HardwareInfo &hwInfo) const { + return LocalMemoryAccessMode::Default; +} + template size_t MemorySynchronizationCommands::getSizeForFullCacheFlush() { return sizeof(typename GfxFamily::PIPE_CONTROL);