diff --git a/opencl/source/helpers/cl_hw_helper.cpp b/opencl/source/helpers/cl_hw_helper.cpp index ff3d456a3e..a1dc305b79 100644 --- a/opencl/source/helpers/cl_hw_helper.cpp +++ b/opencl/source/helpers/cl_hw_helper.cpp @@ -27,7 +27,7 @@ cl_version ClHwHelper::makeDeviceIpVersion(uint16_t major, uint8_t minor, uint8_ } template <> -ClHwHelper &RootDeviceEnvironment::getHelper() const { +ClCoreHelper &RootDeviceEnvironment::getHelper() const { auto &apiHelper = ClHwHelper::get(this->getHardwareInfo()->platform.eRenderCoreFamily); return apiHelper; } diff --git a/opencl/source/helpers/cl_hw_helper.h b/opencl/source/helpers/cl_hw_helper.h index 3ca3bc0855..962a08140e 100644 --- a/opencl/source/helpers/cl_hw_helper.h +++ b/opencl/source/helpers/cl_hw_helper.h @@ -24,13 +24,17 @@ struct ArgDescPointer; struct HardwareInfo; struct KernelInfo; struct MultiDispatchInfo; +class ClHwHelper; +struct RootDeviceEnvironment; + +using ClCoreHelper = ClHwHelper; class ClHwHelper { public: static ClHwHelper &get(GFXCORE_FAMILY gfxCore); - virtual bool requiresNonAuxMode(const ArgDescPointer &argAsPtr, const HardwareInfo &hwInfo) const = 0; - virtual bool requiresAuxResolves(const KernelInfo &kernelInfo, const HardwareInfo &hwInfo) const = 0; + virtual bool requiresNonAuxMode(const ArgDescPointer &argAsPtr, const RootDeviceEnvironment &rootDeviceEnvironment) const = 0; + virtual bool requiresAuxResolves(const KernelInfo &kernelInfo, const RootDeviceEnvironment &rootDeviceEnvironment) const = 0; virtual bool allowCompressionForContext(const ClDevice &clDevice, const Context &context) const = 0; virtual cl_command_queue_capabilities_intel getAdditionalDisabledQueueFamilyCapabilities(EngineGroupType type) const = 0; virtual bool getQueueFamilyName(std::string &name, EngineGroupType type) const = 0; @@ -60,8 +64,8 @@ class ClHwHelperHw : public ClHwHelper { return clHwHelper; } - bool requiresNonAuxMode(const ArgDescPointer &argAsPtr, const HardwareInfo &hwInfo) const override; - bool requiresAuxResolves(const KernelInfo &kernelInfo, const HardwareInfo &hwInfo) const override; + bool requiresNonAuxMode(const ArgDescPointer &argAsPtr, const RootDeviceEnvironment &rootDeviceEnvironment) const override; + bool requiresAuxResolves(const KernelInfo &kernelInfo, const RootDeviceEnvironment &rootDeviceEnvironment) const override; bool allowCompressionForContext(const ClDevice &clDevice, const Context &context) const override; cl_command_queue_capabilities_intel getAdditionalDisabledQueueFamilyCapabilities(EngineGroupType type) const override; bool getQueueFamilyName(std::string &name, 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 192a129040..563bc544b4 100644 --- a/opencl/source/helpers/cl_hw_helper_base.inl +++ b/opencl/source/helpers/cl_hw_helper_base.inl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 Intel Corporation + * Copyright (C) 2020-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -14,12 +14,12 @@ namespace NEO { template -inline bool ClHwHelperHw::requiresNonAuxMode(const ArgDescPointer &argAsPtr, const HardwareInfo &hwInfo) const { +inline bool ClHwHelperHw::requiresNonAuxMode(const ArgDescPointer &argAsPtr, const RootDeviceEnvironment &rootDeviceEnvironment) const { return !argAsPtr.isPureStateful(); } template -inline bool ClHwHelperHw::requiresAuxResolves(const KernelInfo &kernelInfo, const HardwareInfo &hwInfo) const { +inline bool ClHwHelperHw::requiresAuxResolves(const KernelInfo &kernelInfo, const RootDeviceEnvironment &rootDeviceEnvironment) const { return hasStatelessAccessToBuffer(kernelInfo); } diff --git a/opencl/source/kernel/kernel.cpp b/opencl/source/kernel/kernel.cpp index 7a9767de07..8827f91c96 100644 --- a/opencl/source/kernel/kernel.cpp +++ b/opencl/source/kernel/kernel.cpp @@ -138,14 +138,15 @@ cl_int Kernel::initialize() { auto rootDeviceIndex = pClDevice->getRootDeviceIndex(); reconfigureKernel(); auto &hwInfo = pClDevice->getHardwareInfo(); - auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily); + auto &rootDeviceEnvironment = pClDevice->getRootDeviceEnvironment(); + auto &coreHelper = rootDeviceEnvironment.getHelper(); auto &kernelDescriptor = kernelInfo.kernelDescriptor; const auto &implicitArgs = kernelDescriptor.payloadMappings.implicitArgs; const auto &explicitArgs = kernelDescriptor.payloadMappings.explicitArgs; auto maxSimdSize = kernelInfo.getMaxSimdSize(); const auto &heapInfo = kernelInfo.heapInfo; - if (maxSimdSize != 1 && maxSimdSize < hwHelper.getMinimalSIMDSize()) { + if (maxSimdSize != 1 && maxSimdSize < coreHelper.getMinimalSIMDSize()) { return CL_INVALID_KERNEL; } @@ -238,15 +239,15 @@ cl_int Kernel::initialize() { auto &threadArbitrationPolicy = const_cast(kernelInfo.kernelDescriptor.kernelAttributes.threadArbitrationPolicy); if (threadArbitrationPolicy == ThreadArbitrationPolicy::NotPresent) { - threadArbitrationPolicy = static_cast(hwHelper.getDefaultThreadArbitrationPolicy()); + threadArbitrationPolicy = static_cast(coreHelper.getDefaultThreadArbitrationPolicy()); } if (false == kernelInfo.kernelDescriptor.kernelAttributes.flags.requiresSubgroupIndependentForwardProgress) { threadArbitrationPolicy = ThreadArbitrationPolicy::AgeBased; } - auto &clHwHelper = ClHwHelper::get(hwInfo.platform.eRenderCoreFamily); + auto &clCoreHelper = rootDeviceEnvironment.getHelper(); - auxTranslationRequired = !program->getIsBuiltIn() && HwHelper::compressedBuffersSupported(hwInfo) && clHwHelper.requiresAuxResolves(kernelInfo, hwInfo); + auxTranslationRequired = !program->getIsBuiltIn() && HwHelper::compressedBuffersSupported(hwInfo) && clCoreHelper.requiresAuxResolves(kernelInfo, rootDeviceEnvironment); if (DebugManager.flags.ForceAuxTranslationEnabled.get() != -1) { auxTranslationRequired &= !!DebugManager.flags.ForceAuxTranslationEnabled.get(); @@ -919,8 +920,8 @@ 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); + auto &rootDeviceEnvironment = getDevice().getRootDeviceEnvironment(); + auto &clCoreHelper = rootDeviceEnvironment.getHelper(); if (isAuxTranslationKernel) { if (((AuxTranslationDirection::AuxToNonAux == auxTranslationDirection) && argIndex == 1) || @@ -928,7 +929,7 @@ cl_int Kernel::setArgSvmAlloc(uint32_t argIndex, void *svmPtr, GraphicsAllocatio forceNonAuxMode = true; } disableL3 = (argIndex == 0); - } else if (svmAlloc && svmAlloc->isCompressionEnabled() && clHwHelper.requiresNonAuxMode(argAsPtr, hwInfo)) { + } else if (svmAlloc && svmAlloc->isCompressionEnabled() && clCoreHelper.requiresNonAuxMode(argAsPtr, rootDeviceEnvironment)) { forceNonAuxMode = true; } @@ -1476,8 +1477,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); + auto &rootDeviceEnvironment = getDevice().getRootDeviceEnvironment(); + auto &clCoreHelper = rootDeviceEnvironment.getHelper(); if (isAuxTranslationKernel) { if (((AuxTranslationDirection::AuxToNonAux == auxTranslationDirection) && argIndex == 1) || @@ -1485,7 +1486,7 @@ cl_int Kernel::setArgBuffer(uint32_t argIndex, forceNonAuxMode = true; } disableL3 = (argIndex == 0); - } else if (graphicsAllocation->isCompressionEnabled() && clHwHelper.requiresNonAuxMode(argAsPtr, hwInfo)) { + } else if (graphicsAllocation->isCompressionEnabled() && clCoreHelper.requiresNonAuxMode(argAsPtr, rootDeviceEnvironment)) { forceNonAuxMode = true; } diff --git a/opencl/source/xe_hp_core/cl_hw_helper_xe_hp_core.cpp b/opencl/source/xe_hp_core/cl_hw_helper_xe_hp_core.cpp index cfa4abedeb..8fee78728a 100644 --- a/opencl/source/xe_hp_core/cl_hw_helper_xe_hp_core.cpp +++ b/opencl/source/xe_hp_core/cl_hw_helper_xe_hp_core.cpp @@ -6,6 +6,7 @@ */ #include "shared/source/debug_settings/debug_settings_manager.h" +#include "shared/source/execution_environment/root_device_environment.h" #include "shared/source/helpers/populate_factory.h" #include "shared/source/os_interface/hw_info_config.h" #include "shared/source/xe_hp_core/hw_cmds.h" @@ -26,8 +27,11 @@ void populateFactoryTable>() { } template <> -bool ClHwHelperHw::requiresNonAuxMode(const ArgDescPointer &argAsPtr, const HardwareInfo &hwInfo) const { - if (HwInfoConfig::get(hwInfo.platform.eProductFamily)->allowStatelessCompression(hwInfo)) { +bool ClHwHelperHw::requiresNonAuxMode(const ArgDescPointer &argAsPtr, const RootDeviceEnvironment &rootDeviceEnvironment) const { + auto &productHelper = rootDeviceEnvironment.getHelper(); + auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo(); + + if (productHelper.allowStatelessCompression(hwInfo)) { return false; } else { return !argAsPtr.isPureStateful(); @@ -35,8 +39,11 @@ bool ClHwHelperHw::requiresNonAuxMode(const ArgDescPointer &argAsPtr, co } template <> -bool ClHwHelperHw::requiresAuxResolves(const KernelInfo &kernelInfo, const HardwareInfo &hwInfo) const { - if (HwInfoConfig::get(hwInfo.platform.eProductFamily)->allowStatelessCompression(hwInfo)) { +bool ClHwHelperHw::requiresAuxResolves(const KernelInfo &kernelInfo, const RootDeviceEnvironment &rootDeviceEnvironment) const { + auto &productHelper = rootDeviceEnvironment.getHelper(); + auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo(); + + if (productHelper.allowStatelessCompression(hwInfo)) { return false; } else { return hasStatelessAccessToBuffer(kernelInfo); diff --git a/opencl/source/xe_hpc_core/cl_hw_helper_xe_hpc_core.cpp b/opencl/source/xe_hpc_core/cl_hw_helper_xe_hpc_core.cpp index 575ed0c61c..649da115cf 100644 --- a/opencl/source/xe_hpc_core/cl_hw_helper_xe_hpc_core.cpp +++ b/opencl/source/xe_hpc_core/cl_hw_helper_xe_hpc_core.cpp @@ -25,7 +25,7 @@ void populateFactoryTable>() { } template <> -bool ClHwHelperHw::requiresAuxResolves(const KernelInfo &kernelInfo, const HardwareInfo &hwInfo) const { +bool ClHwHelperHw::requiresAuxResolves(const KernelInfo &kernelInfo, const RootDeviceEnvironment &rootDeviceEnvironment) const { return false; } diff --git a/opencl/source/xe_hpg_core/cl_hw_helper_xe_hpg_core.cpp b/opencl/source/xe_hpg_core/cl_hw_helper_xe_hpg_core.cpp index 0e233ebbca..1388e1eb01 100644 --- a/opencl/source/xe_hpg_core/cl_hw_helper_xe_hpg_core.cpp +++ b/opencl/source/xe_hpg_core/cl_hw_helper_xe_hpg_core.cpp @@ -26,8 +26,11 @@ void populateFactoryTable>() { } template <> -bool ClHwHelperHw::requiresNonAuxMode(const ArgDescPointer &argAsPtr, const HardwareInfo &hwInfo) const { - if (HwInfoConfig::get(hwInfo.platform.eProductFamily)->allowStatelessCompression(hwInfo)) { +bool ClHwHelperHw::requiresNonAuxMode(const ArgDescPointer &argAsPtr, const RootDeviceEnvironment &rootDeviceEnvironment) const { + auto &productHelper = rootDeviceEnvironment.getHelper(); + auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo(); + + if (productHelper.allowStatelessCompression(hwInfo)) { return false; } else { return !argAsPtr.isPureStateful(); @@ -35,8 +38,11 @@ bool ClHwHelperHw::requiresNonAuxMode(const ArgDescPointer &argAsPtr, co } template <> -bool ClHwHelperHw::requiresAuxResolves(const KernelInfo &kernelInfo, const HardwareInfo &hwInfo) const { - if (HwInfoConfig::get(hwInfo.platform.eProductFamily)->allowStatelessCompression(hwInfo)) { +bool ClHwHelperHw::requiresAuxResolves(const KernelInfo &kernelInfo, const RootDeviceEnvironment &rootDeviceEnvironment) const { + auto &productHelper = rootDeviceEnvironment.getHelper(); + auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo(); + + if (productHelper.allowStatelessCompression(hwInfo)) { return false; } else { return hasStatelessAccessToBuffer(kernelInfo); diff --git a/opencl/test/unit_test/command_queue/blit_enqueue_fixture.h b/opencl/test/unit_test/command_queue/blit_enqueue_fixture.h index 4b72603cf1..1c000fd7ef 100644 --- a/opencl/test/unit_test/command_queue/blit_enqueue_fixture.h +++ b/opencl/test/unit_test/command_queue/blit_enqueue_fixture.h @@ -74,7 +74,6 @@ struct BlitEnqueueTests : public ::testing::Test { if (is32bit) { GTEST_SKIP(); } - REQUIRE_AUX_RESOLVES(); DebugManager.flags.EnableTimestampPacket.set(timestampPacketEnabled); DebugManager.flags.EnableBlitterForEnqueueOperations.set(1); @@ -83,7 +82,11 @@ struct BlitEnqueueTests : public ::testing::Test { DebugManager.flags.ForceGpgpuSubmissionForBcsEnqueue.set(1); DebugManager.flags.CsrDispatchMode.set(static_cast(DispatchMode::ImmediateDispatch)); DebugManager.flags.EnableLocalMemory.set(1); + device = std::make_unique(MockClDevice::createWithNewExecutionEnvironment(nullptr)); + + REQUIRE_AUX_RESOLVES(device->getRootDeviceEnvironment()); + auto &capabilityTable = device->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable; bool createBcsEngine = !capabilityTable.blitterOperationsSupported; capabilityTable.blitterOperationsSupported = true; diff --git a/opencl/test/unit_test/command_queue/enqueue_kernel_2_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_kernel_2_tests.cpp index f79ca3779e..507b998332 100644 --- a/opencl/test/unit_test/command_queue/enqueue_kernel_2_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_kernel_2_tests.cpp @@ -362,7 +362,7 @@ HWCMDTEST_P(IGFX_GEN8_CORE, EnqueueScratchSpaceTests, GivenKernelRequiringScratc // Generically validate this command PARSE::template validateCommand(cmdList.begin(), itorCmd); - //skip if size to big 4MB, no point in stressing memory allocator. + // skip if size to big 4MB, no point in stressing memory allocator. if (allocationSize > 4194304) { return; } @@ -382,7 +382,7 @@ HWCMDTEST_P(IGFX_GEN8_CORE, EnqueueScratchSpaceTests, GivenKernelRequiringScratc if constexpr (is64bit) { ASSERT_NE(itorCmdForStateBase, itorCmd); } else { - //no SBA not dirty + // no SBA not dirty ASSERT_EQ(itorCmdForStateBase, cmdList.end()); } @@ -511,7 +511,7 @@ HWCMDTEST_P(IGFX_GEN8_CORE, EnqueueKernelWithScratch, givenDeviceForcing32bitAll EXPECT_EQ(memoryManager->getExternalHeapBaseAddress(graphicsAllocation->getRootDeviceIndex(), graphicsAllocation->isAllocatedInLocalMemoryPool()), gsHaddress); - //now re-try to see if SBA is not programmed + // now re-try to see if SBA is not programmed scratchSize *= 2; mockKernel.kernelInfo.setPerThreadScratchSize(scratchSize, 0); @@ -841,7 +841,8 @@ HWTEST_F(EnqueueAuxKernelTests, givenKernelWithRequiredAuxTranslationAndWithoutA } HWTEST_F(EnqueueAuxKernelTests, givenMultipleArgsWhenAuxTranslationIsRequiredThenPickOnlyApplicableBuffers) { - REQUIRE_AUX_RESOLVES(); + + REQUIRE_AUX_RESOLVES(this->getRootDeviceEnvironment()); DebugManagerStateRestore dbgRestore; DebugManager.flags.RenderCompressedBuffersEnabled.set(1); diff --git a/opencl/test/unit_test/fixtures/cl_device_fixture.cpp b/opencl/test/unit_test/fixtures/cl_device_fixture.cpp index 6c4dc11851..e4daa6fed7 100644 --- a/opencl/test/unit_test/fixtures/cl_device_fixture.cpp +++ b/opencl/test/unit_test/fixtures/cl_device_fixture.cpp @@ -9,6 +9,8 @@ #include "shared/source/built_ins/sip.h" +#include "opencl/source/helpers/cl_hw_helper.h" + #include "gtest/gtest.h" namespace NEO { @@ -42,6 +44,10 @@ MockDevice *ClDeviceFixture::createWithUsDeviceId(unsigned short usDeviceId) { return MockDevice::createWithNewExecutionEnvironment(&hardwareInfo, rootDeviceIndex); } +const RootDeviceEnvironment &ClDeviceFixture::getRootDeviceEnvironment() const { + return pClDevice->getRootDeviceEnvironment(); +} + template HelperType &ClDeviceFixture::getHelper() const { auto &helper = pClDevice->getRootDeviceEnvironment().getHelper(); @@ -50,5 +56,5 @@ HelperType &ClDeviceFixture::getHelper() const { template ProductHelper &ClDeviceFixture::getHelper() const; template CoreHelper &ClDeviceFixture::getHelper() const; - +template ClCoreHelper &ClDeviceFixture::getHelper() const; } // namespace NEO diff --git a/opencl/test/unit_test/fixtures/cl_device_fixture.h b/opencl/test/unit_test/fixtures/cl_device_fixture.h index 87af870e6b..74ffd756ea 100644 --- a/opencl/test/unit_test/fixtures/cl_device_fixture.h +++ b/opencl/test/unit_test/fixtures/cl_device_fixture.h @@ -31,6 +31,8 @@ struct ClDeviceFixture { OsContext *osContext = nullptr; const uint32_t rootDeviceIndex = 0u; MockClExecutionEnvironment *pClExecutionEnvironment = nullptr; + + const RootDeviceEnvironment &getRootDeviceEnvironment() const; }; } // namespace NEO diff --git a/opencl/test/unit_test/gen12lp/hw_helper_tests_gen12lp.inl b/opencl/test/unit_test/gen12lp/hw_helper_tests_gen12lp.inl index 140a1c9808..aab7f306da 100644 --- a/opencl/test/unit_test/gen12lp/hw_helper_tests_gen12lp.inl +++ b/opencl/test/unit_test/gen12lp/hw_helper_tests_gen12lp.inl @@ -12,16 +12,17 @@ #include "shared/test/common/mocks/mock_memory_manager.h" #include "opencl/source/helpers/cl_hw_helper.h" +#include "opencl/test/unit_test/fixtures/cl_device_fixture.h" #include "opencl/test/unit_test/mocks/mock_cl_hw_helper.h" #include "opencl/test/unit_test/mocks/mock_context.h" #include "opencl/test/unit_test/mocks/mock_platform.h" #include "engine_node.h" -using HwHelperTestGen12Lp = HwHelperTest; +using ClHwHelperTestsGen12Lp = Test; -GEN12LPTEST_F(HwHelperTestGen12Lp, givenTglLpThenAuxTranslationIsRequired) { - auto &clHwHelper = ClHwHelper::get(renderCoreFamily); +GEN12LPTEST_F(ClHwHelperTestsGen12Lp, givenTglLpThenAuxTranslationIsRequired) { + auto &clCoreHelper = getHelper(); for (auto accessedUsingStatelessAddressingMode : {true, false}) { KernelInfo kernelInfo{}; @@ -30,10 +31,12 @@ GEN12LPTEST_F(HwHelperTestGen12Lp, givenTglLpThenAuxTranslationIsRequired) { arg.as(true).accessedUsingStatelessAddressingMode = accessedUsingStatelessAddressingMode; kernelInfo.kernelDescriptor.payloadMappings.explicitArgs.push_back(std::move(arg)); - EXPECT_EQ(accessedUsingStatelessAddressingMode, clHwHelper.requiresAuxResolves(kernelInfo, hardwareInfo)); + EXPECT_EQ(accessedUsingStatelessAddressingMode, clCoreHelper.requiresAuxResolves(kernelInfo, getRootDeviceEnvironment())); } } +using HwHelperTestGen12Lp = HwHelperTest; + GEN12LPTEST_F(HwHelperTestGen12Lp, WhenGettingMaxBarriersPerSliceThenCorrectSizeIsReturned) { auto &helper = getHelper(); EXPECT_EQ(32u, helper.getMaxBarrierRegisterPerSlice()); diff --git a/opencl/test/unit_test/helpers/cl_helper_tests.cpp b/opencl/test/unit_test/helpers/cl_helper_tests.cpp index 4098970752..7f68a1ee5b 100644 --- a/opencl/test/unit_test/helpers/cl_helper_tests.cpp +++ b/opencl/test/unit_test/helpers/cl_helper_tests.cpp @@ -17,6 +17,7 @@ #include "opencl/source/helpers/cl_helper.h" #include "opencl/source/helpers/cl_hw_helper.h" #include "opencl/source/mem_obj/image.h" +#include "opencl/test/unit_test/fixtures/cl_device_fixture.h" #include "opencl/test/unit_test/mocks/mock_context.h" #include @@ -106,30 +107,29 @@ HWTEST_F(HwHelperTest, givenHwHelperWhenIsLinearStoragePreferredThenReturnValidV } } -using ClHwHelperTest = ::testing::Test; +using ClHwHelperTest = Test; HWTEST_F(ClHwHelperTest, givenKernelInfoWhenCheckingRequiresAuxResolvesThenCorrectValuesAreReturned) { - auto &clHwHelper = ClHwHelper::get(renderCoreFamily); - HardwareInfo hwInfo = *defaultHwInfo; + auto &clCoreHelper = getHelper(); KernelInfo kernelInfo{}; ArgDescriptor argDescriptorValue(ArgDescriptor::ArgType::ArgTValue); kernelInfo.kernelDescriptor.payloadMappings.explicitArgs.push_back(argDescriptorValue); - EXPECT_FALSE(clHwHelper.requiresAuxResolves(kernelInfo, hwInfo)); + EXPECT_FALSE(clCoreHelper.requiresAuxResolves(kernelInfo, getRootDeviceEnvironment())); ArgDescriptor argDescriptorPointer(ArgDescriptor::ArgType::ArgTPointer); argDescriptorPointer.as().accessedUsingStatelessAddressingMode = true; kernelInfo.kernelDescriptor.payloadMappings.explicitArgs.push_back(argDescriptorPointer); - EXPECT_TRUE(clHwHelper.requiresAuxResolves(kernelInfo, hwInfo)); + EXPECT_TRUE(clCoreHelper.requiresAuxResolves(kernelInfo, getRootDeviceEnvironment())); } TEST_F(ClHwHelperTest, givenGenHelperWhenKernelArgumentIsNotPureStatefulThenRequireNonAuxMode) { - auto &clHwHelper = ClHwHelper::get(renderCoreFamily); + auto &clCoreHelper = getHelper(); for (auto isPureStateful : {false, true}) { ArgDescPointer argAsPtr{}; argAsPtr.accessedUsingStatelessAddressingMode = !isPureStateful; - EXPECT_EQ(!argAsPtr.isPureStateful(), clHwHelper.requiresNonAuxMode(argAsPtr, *defaultHwInfo)); + EXPECT_EQ(!argAsPtr.isPureStateful(), clCoreHelper.requiresNonAuxMode(argAsPtr, getRootDeviceEnvironment())); } } diff --git a/opencl/test/unit_test/kernel/kernel_tests.cpp b/opencl/test/unit_test/kernel/kernel_tests.cpp index 40459b06e0..0a42a1807d 100644 --- a/opencl/test/unit_test/kernel/kernel_tests.cpp +++ b/opencl/test/unit_test/kernel/kernel_tests.cpp @@ -2517,11 +2517,14 @@ TEST(KernelTest, givenFtrRenderCompressedBuffersWhenInitializingArgsWithNonState capabilityTable.ftrRenderCompressedBuffers = true; kernel.mockKernel->initialize(); - EXPECT_EQ(ClHwHelper::get(hwInfo->platform.eRenderCoreFamily).requiresAuxResolves(kernel.kernelInfo, *hwInfo), kernel.mockKernel->isAuxTranslationRequired()); + + auto &rootDeviceEnvironment = device->getRootDeviceEnvironment(); + auto &clCoreHelper = rootDeviceEnvironment.getHelper(); + EXPECT_EQ(clCoreHelper.requiresAuxResolves(kernel.kernelInfo, rootDeviceEnvironment), kernel.mockKernel->isAuxTranslationRequired()); DebugManager.flags.ForceAuxTranslationEnabled.set(-1); kernel.mockKernel->initialize(); - EXPECT_EQ(ClHwHelper::get(hwInfo->platform.eRenderCoreFamily).requiresAuxResolves(kernel.kernelInfo, *hwInfo), kernel.mockKernel->isAuxTranslationRequired()); + EXPECT_EQ(clCoreHelper.requiresAuxResolves(kernel.kernelInfo, rootDeviceEnvironment), kernel.mockKernel->isAuxTranslationRequired()); DebugManager.flags.ForceAuxTranslationEnabled.set(0); kernel.mockKernel->initialize(); @@ -2544,7 +2547,10 @@ TEST(KernelTest, WhenAuxTranslationIsRequiredThenKernelSetsRequiredResolvesInCon kernel.mockKernel->initialize(); - if (ClHwHelper::get(device->getHardwareInfo().platform.eRenderCoreFamily).requiresAuxResolves(kernel.kernelInfo, *hwInfo)) { + auto &rootDeviceEnvironment = device->getRootDeviceEnvironment(); + auto &clCoreHelper = rootDeviceEnvironment.getHelper(); + + if (clCoreHelper.requiresAuxResolves(kernel.kernelInfo, rootDeviceEnvironment)) { EXPECT_TRUE(context->getResolvesRequiredInKernels()); } else { EXPECT_FALSE(context->getResolvesRequiredInKernels()); @@ -2587,7 +2593,10 @@ TEST(KernelTest, givenDebugVariableSetWhenKernelHasStatefulBufferAccessThenMarkK kernel.mockKernel->initialize(); - if (ClHwHelper::get(localHwInfo.platform.eRenderCoreFamily).requiresAuxResolves(kernel.kernelInfo, localHwInfo)) { + auto &rootDeviceEnvironment = device->getRootDeviceEnvironment(); + auto &clCoreHelper = rootDeviceEnvironment.getHelper(); + + if (clCoreHelper.requiresAuxResolves(kernel.kernelInfo, rootDeviceEnvironment)) { EXPECT_TRUE(kernel.mockKernel->isAuxTranslationRequired()); } else { EXPECT_FALSE(kernel.mockKernel->isAuxTranslationRequired()); diff --git a/opencl/test/unit_test/test_macros/test_checks_ocl.cpp b/opencl/test/unit_test/test_macros/test_checks_ocl.cpp index 5706d350b6..8b245d23ed 100644 --- a/opencl/test/unit_test/test_macros/test_checks_ocl.cpp +++ b/opencl/test/unit_test/test_macros/test_checks_ocl.cpp @@ -31,11 +31,11 @@ bool TestChecks::supportsOcl21(const std::unique_ptr &pHardwareInf pHardwareInfo->capabilityTable.supportsIndependentForwardProgress); } -bool TestChecks::supportsAuxResolves() { +bool TestChecks::supportsAuxResolves(const RootDeviceEnvironment &rootDeviceEnvironment) { KernelInfo kernelInfo{}; kernelInfo.kernelDescriptor.payloadMappings.explicitArgs.resize(1); kernelInfo.kernelDescriptor.payloadMappings.explicitArgs[0].as(true).accessedUsingStatelessAddressingMode = true; - auto &clHwHelper = ClHwHelper::get(defaultHwInfo->platform.eRenderCoreFamily); - return clHwHelper.requiresAuxResolves(kernelInfo, *defaultHwInfo); + auto &clCoreHelper = rootDeviceEnvironment.getHelper(); + return clCoreHelper.requiresAuxResolves(kernelInfo, rootDeviceEnvironment); } diff --git a/opencl/test/unit_test/test_macros/test_checks_ocl.h b/opencl/test/unit_test/test_macros/test_checks_ocl.h index dfd627b4be..72a09e6742 100644 --- a/opencl/test/unit_test/test_macros/test_checks_ocl.h +++ b/opencl/test/unit_test/test_macros/test_checks_ocl.h @@ -13,13 +13,14 @@ namespace NEO { class ClDevice; class Context; struct HardwareInfo; +struct RootDeviceEnvironment; namespace TestChecks { bool supportsSvm(const ClDevice *pClDevice); bool supportsImages(const Context *pContext); bool supportsOcl21(const std::unique_ptr &pHardwareInfo); bool supportsPipes(const ClDevice *pClDevice); -bool supportsAuxResolves(); +bool supportsAuxResolves(const RootDeviceEnvironment &rootDeviceEnvironment); } // namespace TestChecks } // namespace NEO @@ -37,7 +38,7 @@ bool supportsAuxResolves(); GTEST_SKIP(); \ } -#define REQUIRE_AUX_RESOLVES() \ - if (NEO::TestChecks::supportsAuxResolves() == false) { \ - GTEST_SKIP(); \ +#define REQUIRE_AUX_RESOLVES(rootDeviceEnvironment) \ + if (NEO::TestChecks::supportsAuxResolves(rootDeviceEnvironment) == false) { \ + GTEST_SKIP(); \ } diff --git a/opencl/test/unit_test/xe_hp_core/hw_helper_tests_xe_hp_core.cpp b/opencl/test/unit_test/xe_hp_core/hw_helper_tests_xe_hp_core.cpp index 9f56f3d5a9..c8927b2124 100644 --- a/opencl/test/unit_test/xe_hp_core/hw_helper_tests_xe_hp_core.cpp +++ b/opencl/test/unit_test/xe_hp_core/hw_helper_tests_xe_hp_core.cpp @@ -19,55 +19,58 @@ #include "shared/test/common/test_macros/hw_test.h" #include "opencl/source/helpers/cl_hw_helper.h" +#include "opencl/test/unit_test/fixtures/cl_device_fixture.h" #include "opencl/test/unit_test/mocks/mock_cl_hw_helper.h" -using HwHelperTestXE_HP_CORE = HwHelperTest; +using ClHwHelperTestsXeHpCore = Test; -XE_HP_CORE_TEST_F(HwHelperTestXE_HP_CORE, givenGenHelperWhenKernelArgumentIsNotPureStatefulThenRequireNonAuxMode) { - auto &clHwHelper = ClHwHelper::get(renderCoreFamily); +XE_HP_CORE_TEST_F(ClHwHelperTestsXeHpCore, givenGenHelperWhenKernelArgumentIsNotPureStatefulThenRequireNonAuxMode) { + auto &clCoreHelper = getHelper(); for (auto isPureStateful : {false, true}) { ArgDescPointer argAsPtr{}; argAsPtr.accessedUsingStatelessAddressingMode = !isPureStateful; - EXPECT_EQ(!argAsPtr.isPureStateful(), clHwHelper.requiresNonAuxMode(argAsPtr, *defaultHwInfo)); + EXPECT_EQ(!argAsPtr.isPureStateful(), clCoreHelper.requiresNonAuxMode(argAsPtr, getRootDeviceEnvironment())); } } -XE_HP_CORE_TEST_F(HwHelperTestXE_HP_CORE, givenGenHelperWhenEnableStatelessCompressionThenDontRequireNonAuxMode) { +XE_HP_CORE_TEST_F(ClHwHelperTestsXeHpCore, givenGenHelperWhenEnableStatelessCompressionThenDontRequireNonAuxMode) { DebugManagerStateRestore restore; DebugManager.flags.EnableStatelessCompression.set(1); - auto &clHwHelper = ClHwHelper::get(renderCoreFamily); + auto &clCoreHelper = getHelper(); for (auto isPureStateful : {false, true}) { ArgDescPointer argAsPtr{}; argAsPtr.accessedUsingStatelessAddressingMode = !isPureStateful; - EXPECT_FALSE(clHwHelper.requiresNonAuxMode(argAsPtr, *defaultHwInfo)); + EXPECT_FALSE(clCoreHelper.requiresNonAuxMode(argAsPtr, getRootDeviceEnvironment())); } } -XE_HP_CORE_TEST_F(HwHelperTestXE_HP_CORE, givenXE_HP_COREThenAuxTranslationIsRequired) { - auto &clHwHelper = ClHwHelper::get(renderCoreFamily); +XE_HP_CORE_TEST_F(ClHwHelperTestsXeHpCore, givenXE_HP_COREThenAuxTranslationIsRequired) { + auto &clCoreHelper = getHelper(); for (auto isPureStateful : {false, true}) { KernelInfo kernelInfo{}; kernelInfo.kernelDescriptor.payloadMappings.explicitArgs.resize(1); kernelInfo.kernelDescriptor.payloadMappings.explicitArgs[0].as(true).accessedUsingStatelessAddressingMode = !isPureStateful; - EXPECT_EQ(!isPureStateful, clHwHelper.requiresAuxResolves(kernelInfo, *defaultHwInfo)); + EXPECT_EQ(!isPureStateful, clCoreHelper.requiresAuxResolves(kernelInfo, getRootDeviceEnvironment())); } } -XE_HP_CORE_TEST_F(HwHelperTestXE_HP_CORE, givenXE_HP_COREWhenEnableStatelessCompressionThenAuxTranslationIsNotRequired) { +XE_HP_CORE_TEST_F(ClHwHelperTestsXeHpCore, givenXE_HP_COREWhenEnableStatelessCompressionThenAuxTranslationIsNotRequired) { DebugManagerStateRestore restore; DebugManager.flags.EnableStatelessCompression.set(1); - auto &clHwHelper = ClHwHelper::get(renderCoreFamily); + auto &clCoreHelper = getHelper(); KernelInfo kernelInfo{}; - EXPECT_FALSE(clHwHelper.requiresAuxResolves(kernelInfo, *defaultHwInfo)); + EXPECT_FALSE(clCoreHelper.requiresAuxResolves(kernelInfo, getRootDeviceEnvironment())); } +using HwHelperTestXE_HP_CORE = HwHelperTest; + XE_HP_CORE_TEST_F(HwHelperTestXE_HP_CORE, givenDifferentBufferSizesWhenEnableStatelessCompressionThenEveryBufferSizeIsSuitableForCompression) { DebugManagerStateRestore restore; DebugManager.flags.EnableStatelessCompression.set(1); diff --git a/opencl/test/unit_test/xe_hpc_core/hw_helper_tests_xe_hpc_core.cpp b/opencl/test/unit_test/xe_hpc_core/hw_helper_tests_xe_hpc_core.cpp index 65b0957895..869d805860 100644 --- a/opencl/test/unit_test/xe_hpc_core/hw_helper_tests_xe_hpc_core.cpp +++ b/opencl/test/unit_test/xe_hpc_core/hw_helper_tests_xe_hpc_core.cpp @@ -27,10 +27,10 @@ using HwHelperTestsXeHpcCore = Test; XE_HPC_CORETEST_F(HwHelperTestsXeHpcCore, givenXeHpcThenAuxTranslationIsNotRequired) { - auto &clHwHelper = ClHwHelper::get(renderCoreFamily); + auto &clCoreHelper = getHelper(); KernelInfo kernelInfo{}; - EXPECT_FALSE(clHwHelper.requiresAuxResolves(kernelInfo, *defaultHwInfo)); + EXPECT_FALSE(clCoreHelper.requiresAuxResolves(kernelInfo, getRootDeviceEnvironment())); } XE_HPC_CORETEST_F(HwHelperTestsXeHpcCore, givenHwHelperwhenAskingForDcFlushThenReturnFalse) { diff --git a/opencl/test/unit_test/xe_hpg_core/cl_hw_helper_tests_xe_hpg_core.cpp b/opencl/test/unit_test/xe_hpg_core/cl_hw_helper_tests_xe_hpg_core.cpp index 402d3fc0d1..6047209cd6 100644 --- a/opencl/test/unit_test/xe_hpg_core/cl_hw_helper_tests_xe_hpg_core.cpp +++ b/opencl/test/unit_test/xe_hpg_core/cl_hw_helper_tests_xe_hpg_core.cpp @@ -12,12 +12,13 @@ #include "shared/test/common/test_macros/test.h" #include "opencl/source/cl_device/cl_device.h" +#include "opencl/test/unit_test/fixtures/cl_device_fixture.h" #include "opencl/test/unit_test/mocks/mock_cl_hw_helper.h" #include "opencl/test/unit_test/mocks/mock_context.h" #include "hw_cmds_xe_hpg_core_base.h" -using ClHwHelperTestsXeHpgCore = ::testing::Test; +using ClHwHelperTestsXeHpgCore = Test; using namespace NEO; @@ -30,13 +31,13 @@ XE_HPG_CORETEST_F(ClHwHelperTestsXeHpgCore, WhenGettingDeviceIpVersionThenMakeCo } XE_HPG_CORETEST_F(ClHwHelperTestsXeHpgCore, givenGenHelperWhenKernelArgumentIsNotPureStatefulThenRequireNonAuxMode) { - auto &clHwHelper = ClHwHelper::get(renderCoreFamily); + auto &clCoreHelper = getHelper(); for (auto isPureStateful : ::testing::Bool()) { ArgDescPointer argAsPtr{}; argAsPtr.accessedUsingStatelessAddressingMode = !isPureStateful; - EXPECT_EQ(!argAsPtr.isPureStateful(), clHwHelper.requiresNonAuxMode(argAsPtr, *defaultHwInfo)); + EXPECT_EQ(!argAsPtr.isPureStateful(), clCoreHelper.requiresNonAuxMode(argAsPtr, getRootDeviceEnvironment())); } } @@ -44,23 +45,23 @@ XE_HPG_CORETEST_F(ClHwHelperTestsXeHpgCore, givenGenHelperWhenEnableStatelessCom DebugManagerStateRestore restore; DebugManager.flags.EnableStatelessCompression.set(1); - auto &clHwHelper = ClHwHelper::get(renderCoreFamily); + auto &clCoreHelper = getHelper(); for (auto isPureStateful : ::testing::Bool()) { ArgDescPointer argAsPtr{}; argAsPtr.accessedUsingStatelessAddressingMode = !isPureStateful; - EXPECT_FALSE(clHwHelper.requiresNonAuxMode(argAsPtr, *defaultHwInfo)); + EXPECT_FALSE(clCoreHelper.requiresNonAuxMode(argAsPtr, getRootDeviceEnvironment())); } } XE_HPG_CORETEST_F(ClHwHelperTestsXeHpgCore, givenGenHelperWhenCheckAuxTranslationThenAuxResolvesIsRequired) { - auto &clHwHelper = ClHwHelper::get(renderCoreFamily); + auto &clCoreHelper = getHelper(); for (auto isPureStateful : ::testing::Bool()) { KernelInfo kernelInfo{}; kernelInfo.kernelDescriptor.payloadMappings.explicitArgs.resize(1); kernelInfo.kernelDescriptor.payloadMappings.explicitArgs[0].as(true).accessedUsingStatelessAddressingMode = !isPureStateful; - EXPECT_EQ(!isPureStateful, clHwHelper.requiresAuxResolves(kernelInfo, *defaultHwInfo)); + EXPECT_EQ(!isPureStateful, clCoreHelper.requiresAuxResolves(kernelInfo, getRootDeviceEnvironment())); } } @@ -68,10 +69,10 @@ XE_HPG_CORETEST_F(ClHwHelperTestsXeHpgCore, givenGenHelperWhenEnableStatelessCom DebugManagerStateRestore restore; DebugManager.flags.EnableStatelessCompression.set(1); - auto &clHwHelper = ClHwHelper::get(renderCoreFamily); + auto &clCoreHelper = getHelper(); KernelInfo kernelInfo{}; - EXPECT_FALSE(clHwHelper.requiresAuxResolves(kernelInfo, *defaultHwInfo)); + EXPECT_FALSE(clCoreHelper.requiresAuxResolves(kernelInfo, getRootDeviceEnvironment())); } XE_HPG_CORETEST_F(ClHwHelperTestsXeHpgCore, givenDifferentCLImageFormatsWhenCallingAllowImageCompressionThenCorrectValueReturned) {