From b7883bf8386f14383c3f957c1fefb25e86414c8d Mon Sep 17 00:00:00 2001 From: "Milczarek, Slawomir" Date: Mon, 26 Apr 2021 15:38:33 +0000 Subject: [PATCH] Add helper to check if non-AUX mode is required Signed-off-by: Milczarek, Slawomir --- opencl/source/helpers/cl_hw_helper.h | 3 +++ opencl/source/helpers/cl_hw_helper_base.inl | 5 +++++ opencl/source/kernel/kernel.cpp | 10 ++++++++-- opencl/test/unit_test/helpers/hw_helper_tests.cpp | 11 +++++++++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/opencl/source/helpers/cl_hw_helper.h b/opencl/source/helpers/cl_hw_helper.h index bce1dc4aba..d60828b1bd 100644 --- a/opencl/source/helpers/cl_hw_helper.h +++ b/opencl/source/helpers/cl_hw_helper.h @@ -19,6 +19,7 @@ namespace NEO { class Context; class ClDevice; +struct ArgDescPointer; struct HardwareInfo; struct KernelInfo; struct MultiDispatchInfo; @@ -27,6 +28,7 @@ class ClHwHelper { public: static ClHwHelper &get(GFXCORE_FAMILY gfxCore); + virtual bool requiresNonAuxMode(const ArgDescPointer &argAsPtr) const = 0; virtual bool requiresAuxResolves(const KernelInfo &kernelInfo) const = 0; virtual bool allowRenderCompressionForContext(const ClDevice &clDevice, const Context &context) const = 0; virtual cl_command_queue_capabilities_intel getAdditionalDisabledQueueFamilyCapabilities(EngineGroupType type) const = 0; @@ -55,6 +57,7 @@ class ClHwHelperHw : public ClHwHelper { return clHwHelper; } + bool requiresNonAuxMode(const ArgDescPointer &argAsPtr) const override; bool requiresAuxResolves(const KernelInfo &kernelInfo) const override; bool allowRenderCompressionForContext(const ClDevice &clDevice, const Context &context) const override; cl_command_queue_capabilities_intel getAdditionalDisabledQueueFamilyCapabilities(EngineGroupType type) const override; diff --git a/opencl/source/helpers/cl_hw_helper_base.inl b/opencl/source/helpers/cl_hw_helper_base.inl index 5d4d3e9bd7..fbf4c4c5a5 100644 --- a/opencl/source/helpers/cl_hw_helper_base.inl +++ b/opencl/source/helpers/cl_hw_helper_base.inl @@ -13,6 +13,11 @@ namespace NEO { +template +inline bool ClHwHelperHw::requiresNonAuxMode(const ArgDescPointer &argAsPtr) const { + return !argAsPtr.isPureStateful(); +} + template inline bool ClHwHelperHw::requiresAuxResolves(const KernelInfo &kernelInfo) const { return hasStatelessAccessToBuffer(kernelInfo); diff --git a/opencl/source/kernel/kernel.cpp b/opencl/source/kernel/kernel.cpp index 0153585323..a718bf59ae 100644 --- a/opencl/source/kernel/kernel.cpp +++ b/opencl/source/kernel/kernel.cpp @@ -889,13 +889,17 @@ cl_int Kernel::setArgSvmAlloc(uint32_t argIndex, void *svmPtr, GraphicsAllocatio bool disableL3 = false; bool forceNonAuxMode = false; bool isAuxTranslationKernel = (AuxTranslationDirection::None != auxTranslationDirection); + auto &hwInfo = getDevice().getHardwareInfo(); + auto &clHwHelper = ClHwHelper::get(hwInfo.platform.eRenderCoreFamily); + if (isAuxTranslationKernel) { if (((AuxTranslationDirection::AuxToNonAux == auxTranslationDirection) && argIndex == 1) || ((AuxTranslationDirection::NonAuxToAux == auxTranslationDirection) && argIndex == 0)) { forceNonAuxMode = true; } disableL3 = (argIndex == 0); - } else if (svmAlloc && svmAlloc->getAllocationType() == GraphicsAllocation::AllocationType::BUFFER_COMPRESSED && !argAsPtr.isPureStateful()) { + } else if (svmAlloc && svmAlloc->getAllocationType() == GraphicsAllocation::AllocationType::BUFFER_COMPRESSED && + clHwHelper.requiresNonAuxMode(argAsPtr)) { forceNonAuxMode = true; } @@ -1376,6 +1380,8 @@ cl_int Kernel::setArgBuffer(uint32_t argIndex, bool forceNonAuxMode = false; bool isAuxTranslationKernel = (AuxTranslationDirection::None != auxTranslationDirection); auto graphicsAllocation = buffer->getGraphicsAllocation(rootDeviceIndex); + auto &hwInfo = pClDevice->getHardwareInfo(); + auto &clHwHelper = ClHwHelper::get(hwInfo.platform.eRenderCoreFamily); if (isAuxTranslationKernel) { if (((AuxTranslationDirection::AuxToNonAux == auxTranslationDirection) && argIndex == 1) || @@ -1384,7 +1390,7 @@ cl_int Kernel::setArgBuffer(uint32_t argIndex, } disableL3 = (argIndex == 0); } else if (graphicsAllocation->getAllocationType() == GraphicsAllocation::AllocationType::BUFFER_COMPRESSED && - !argAsPtr.isPureStateful()) { + clHwHelper.requiresNonAuxMode(argAsPtr)) { forceNonAuxMode = true; } diff --git a/opencl/test/unit_test/helpers/hw_helper_tests.cpp b/opencl/test/unit_test/helpers/hw_helper_tests.cpp index 59d5dd0b4f..48789a0f90 100644 --- a/opencl/test/unit_test/helpers/hw_helper_tests.cpp +++ b/opencl/test/unit_test/helpers/hw_helper_tests.cpp @@ -1243,3 +1243,14 @@ TEST_F(HwHelperTest, whenGettingNumberOfCacheRegionsThenReturnZero) { auto &hwHelper = HwHelper::get(renderCoreFamily); EXPECT_EQ(0u, hwHelper.getNumCacheRegions(*defaultHwInfo)); } + +TEST_F(HwHelperTest, givenGenHelperWhenKernelArgumentIsNotPureStatefulThenRequireNonAuxMode) { + auto &clHwHelper = ClHwHelper::get(renderCoreFamily); + + for (auto isPureStateful : {false, true}) { + ArgDescPointer argAsPtr{}; + argAsPtr.accessedUsingStatelessAddressingMode = !isPureStateful; + + EXPECT_EQ(!argAsPtr.isPureStateful(), clHwHelper.requiresNonAuxMode(argAsPtr)); + } +}