diff --git a/level_zero/core/source/context/context_imp.cpp b/level_zero/core/source/context/context_imp.cpp index 0d54c07119..6b100e8cae 100644 --- a/level_zero/core/source/context/context_imp.cpp +++ b/level_zero/core/source/context/context_imp.cpp @@ -962,7 +962,7 @@ bool ContextImp::isAllocationSuitableForCompression(const StructuresLookupTable auto &gfxCoreHelper = device.getGfxCoreHelper(); auto &l0GfxCoreHelper = device.getNEODevice()->getRootDeviceEnvironment().getHelper(); - if (!l0GfxCoreHelper.usmCompressionSupported(hwInfo) || !gfxCoreHelper.isBufferSizeSuitableForCompression(allocSize, hwInfo) || structuresLookupTable.uncompressedHint) { + if (!l0GfxCoreHelper.usmCompressionSupported(hwInfo) || !gfxCoreHelper.isBufferSizeSuitableForCompression(allocSize) || structuresLookupTable.uncompressedHint) { return false; } diff --git a/level_zero/core/source/memory_manager/compression_selector_l0.cpp b/level_zero/core/source/memory_manager/compression_selector_l0.cpp index e4cd8d31a7..d6cd87b294 100644 --- a/level_zero/core/source/memory_manager/compression_selector_l0.cpp +++ b/level_zero/core/source/memory_manager/compression_selector_l0.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2022 Intel Corporation + * Copyright (C) 2020-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -11,7 +11,7 @@ #include "shared/source/memory_manager/graphics_allocation.h" namespace NEO { -bool CompressionSelector::preferCompressedAllocation(const AllocationProperties &properties, const HardwareInfo &hwInfo) { +bool CompressionSelector::preferCompressedAllocation(const AllocationProperties &properties) { bool preferredCompression = false; int32_t compressionEnabled = DebugManager.flags.EnableUsmCompression.get(); if (compressionEnabled == 1) { diff --git a/level_zero/core/test/unit_tests/sources/device/test_device.cpp b/level_zero/core/test/unit_tests/sources/device/test_device.cpp index af1242ecea..e5284c3ed4 100644 --- a/level_zero/core/test/unit_tests/sources/device/test_device.cpp +++ b/level_zero/core/test/unit_tests/sources/device/test_device.cpp @@ -1235,11 +1235,6 @@ TEST_F(DeviceTest, givenCallToDevicePropertiesThenMaximumMemoryToBeAllocatedIsCo EXPECT_EQ(deviceProperties.maxMemAllocSize, expectedSize); } -TEST_F(DeviceTest, whenCheckingIfStatelessCompressionIsSupportedThenReturnFalse) { - auto &productHelper = device->getProductHelper(); - EXPECT_FALSE(productHelper.allowStatelessCompression(*defaultHwInfo)); -} - TEST_F(DeviceTest, givenNodeOrdinalFlagWhenCallAdjustCommandQueueDescThenDescOrdinalProperlySet) { DebugManagerStateRestore restore; auto nodeOrdinal = EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, neoDevice->getRootDeviceEnvironment()); diff --git a/level_zero/core/test/unit_tests/sources/memory/test_memory.cpp b/level_zero/core/test/unit_tests/sources/memory/test_memory.cpp index 98ab901682..fa59aa23b1 100644 --- a/level_zero/core/test/unit_tests/sources/memory/test_memory.cpp +++ b/level_zero/core/test/unit_tests/sources/memory/test_memory.cpp @@ -368,7 +368,7 @@ HWTEST2_F(CompressionMemoryTest, givenDeviceUsmWhenAllocatingThenEnableCompressi auto allocation = allocDeviceMem(2048); - EXPECT_EQ(gfxCoreHelper.isBufferSizeSuitableForCompression(2048, hwInfo), allocation->isCompressionEnabled()); + EXPECT_EQ(gfxCoreHelper.isBufferSizeSuitableForCompression(2048), allocation->isCompressionEnabled()); context->freeMem(ptr); @@ -455,7 +455,7 @@ HWTEST2_F(CompressionMemoryTest, givenDeviceUsmWhenAllocatingThenEnableCompressi auto allocation = allocDeviceMem(1); - if (!gfxCoreHelper.isBufferSizeSuitableForCompression(1, hwInfo)) { + if (!gfxCoreHelper.isBufferSizeSuitableForCompression(1)) { EXPECT_FALSE(allocation->isCompressionEnabled()); } diff --git a/level_zero/core/test/unit_tests/sources/memory_manager/compression_selector_l0_tests.cpp b/level_zero/core/test/unit_tests/sources/memory_manager/compression_selector_l0_tests.cpp index 1e6b764bfe..3badd82a83 100644 --- a/level_zero/core/test/unit_tests/sources/memory_manager/compression_selector_l0_tests.cpp +++ b/level_zero/core/test/unit_tests/sources/memory_manager/compression_selector_l0_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2022 Intel Corporation + * Copyright (C) 2020-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -21,7 +21,7 @@ TEST(CompressionSelectorL0Tests, GivenDefaultDebugFlagWhenProvidingUsmAllocation deviceBitfield); properties.flags.isUSMDeviceAllocation = 1u; - EXPECT_FALSE(NEO::CompressionSelector::preferCompressedAllocation(properties, *defaultHwInfo)); + EXPECT_FALSE(NEO::CompressionSelector::preferCompressedAllocation(properties)); } TEST(CompressionSelectorL0Tests, GivenDisabledDebugFlagWhenProvidingUsmAllocationThenExpectCompressionDisabled) { @@ -34,7 +34,7 @@ TEST(CompressionSelectorL0Tests, GivenDisabledDebugFlagWhenProvidingUsmAllocatio deviceBitfield); properties.flags.isUSMDeviceAllocation = 1u; - EXPECT_FALSE(NEO::CompressionSelector::preferCompressedAllocation(properties, *defaultHwInfo)); + EXPECT_FALSE(NEO::CompressionSelector::preferCompressedAllocation(properties)); } TEST(CompressionSelectorL0Tests, GivenEnabledDebugFlagWhenProvidingUsmAllocationThenExpectCompressionEnabled) { @@ -47,7 +47,7 @@ TEST(CompressionSelectorL0Tests, GivenEnabledDebugFlagWhenProvidingUsmAllocation deviceBitfield); properties.flags.isUSMDeviceAllocation = 1u; - EXPECT_TRUE(NEO::CompressionSelector::preferCompressedAllocation(properties, *defaultHwInfo)); + EXPECT_TRUE(NEO::CompressionSelector::preferCompressedAllocation(properties)); } TEST(CompressionSelectorL0Tests, GivenEnabledDebugFlagWhenProvidingSvmGpuAllocationThenExpectCompressionEnabled) { @@ -59,7 +59,7 @@ TEST(CompressionSelectorL0Tests, GivenEnabledDebugFlagWhenProvidingSvmGpuAllocat AllocationType::SVM_GPU, deviceBitfield); - EXPECT_TRUE(NEO::CompressionSelector::preferCompressedAllocation(properties, *defaultHwInfo)); + EXPECT_TRUE(NEO::CompressionSelector::preferCompressedAllocation(properties)); } TEST(CompressionSelectorL0Tests, GivenEnabledDebugFlagWhenProvidingOtherAllocationThenExpectCompressionDisabled) { @@ -71,7 +71,7 @@ TEST(CompressionSelectorL0Tests, GivenEnabledDebugFlagWhenProvidingOtherAllocati AllocationType::BUFFER_HOST_MEMORY, deviceBitfield); - EXPECT_FALSE(NEO::CompressionSelector::preferCompressedAllocation(properties, *defaultHwInfo)); + EXPECT_FALSE(NEO::CompressionSelector::preferCompressedAllocation(properties)); } } // namespace ult diff --git a/opencl/source/cl_device/cl_device_info.cpp b/opencl/source/cl_device/cl_device_info.cpp index cefccf2873..378c8d8bdc 100644 --- a/opencl/source/cl_device/cl_device_info.cpp +++ b/opencl/source/cl_device/cl_device_info.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2022 Intel Corporation + * Copyright (C) 2020-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -282,9 +282,8 @@ cl_int ClDevice::getDeviceInfo(cl_device_info paramName, break; } case CL_DEVICE_FEATURE_CAPABILITIES_INTEL: { - auto &hwInfo = getHardwareInfo(); auto &clGfxCoreHelper = this->getRootDeviceEnvironment().getHelper(); - param.bitfield = clGfxCoreHelper.getSupportedDeviceFeatureCapabilities(hwInfo); + param.bitfield = clGfxCoreHelper.getSupportedDeviceFeatureCapabilities(this->getRootDeviceEnvironment()); src = ¶m.bitfield; retSize = srcSize = sizeof(cl_device_feature_capabilities_intel); break; diff --git a/opencl/source/command_queue/enqueue_common.h b/opencl/source/command_queue/enqueue_common.h index a21f5f6df6..889a177c36 100644 --- a/opencl/source/command_queue/enqueue_common.h +++ b/opencl/source/command_queue/enqueue_common.h @@ -786,7 +786,7 @@ CompletionStamp CommandQueueHw::enqueueNonBlocked( } } - auto memoryCompressionState = getGpgpuCommandStreamReceiver().getMemoryCompressionState(auxTranslationRequired, device->getHardwareInfo()); + auto memoryCompressionState = getGpgpuCommandStreamReceiver().getMemoryCompressionState(auxTranslationRequired); DispatchFlags dispatchFlags( {}, // csrDependencies diff --git a/opencl/source/gen12lp/cl_hw_helper_gen12lp.cpp b/opencl/source/gen12lp/cl_hw_helper_gen12lp.cpp index 3588d760ef..970216b024 100644 --- a/opencl/source/gen12lp/cl_hw_helper_gen12lp.cpp +++ b/opencl/source/gen12lp/cl_hw_helper_gen12lp.cpp @@ -24,7 +24,7 @@ void populateFactoryTable>() { } template <> -cl_device_feature_capabilities_intel ClGfxCoreHelperHw::getSupportedDeviceFeatureCapabilities(const HardwareInfo &hwInfo) const { +cl_device_feature_capabilities_intel ClGfxCoreHelperHw::getSupportedDeviceFeatureCapabilities(const RootDeviceEnvironment &rootDeviceEnvironment) const { return CL_DEVICE_FEATURE_FLAG_DP4A_INTEL; } diff --git a/opencl/source/helpers/cl_hw_helper.h b/opencl/source/helpers/cl_hw_helper.h index 1b928b46bb..d5898c5e0c 100644 --- a/opencl/source/helpers/cl_hw_helper.h +++ b/opencl/source/helpers/cl_hw_helper.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2022 Intel Corporation + * Copyright (C) 2020-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -30,8 +30,8 @@ class ClGfxCoreHelper { public: static ClGfxCoreHelper &get(GFXCORE_FAMILY gfxCore); - virtual bool requiresNonAuxMode(const ArgDescPointer &argAsPtr, const RootDeviceEnvironment &rootDeviceEnvironment) const = 0; - virtual bool requiresAuxResolves(const KernelInfo &kernelInfo, const RootDeviceEnvironment &rootDeviceEnvironment) const = 0; + virtual bool requiresNonAuxMode(const ArgDescPointer &argAsPtr) const = 0; + virtual bool requiresAuxResolves(const KernelInfo &kernelInfo) 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; @@ -40,7 +40,7 @@ class ClGfxCoreHelper { virtual bool isSupportedKernelThreadArbitrationPolicy() const = 0; virtual std::vector getSupportedThreadArbitrationPolicies() const = 0; virtual cl_version getDeviceIpVersion(const HardwareInfo &hwInfo) const = 0; - virtual cl_device_feature_capabilities_intel getSupportedDeviceFeatureCapabilities(const HardwareInfo &hwInfo) const = 0; + virtual cl_device_feature_capabilities_intel getSupportedDeviceFeatureCapabilities(const RootDeviceEnvironment &rootDeviceEnvironment) const = 0; virtual bool allowImageCompression(cl_image_format format) const = 0; virtual bool isFormatRedescribable(cl_image_format format) const = 0; @@ -61,8 +61,8 @@ class ClGfxCoreHelperHw : public ClGfxCoreHelper { return clGfxCoreHelper; } - bool requiresNonAuxMode(const ArgDescPointer &argAsPtr, const RootDeviceEnvironment &rootDeviceEnvironment) const override; - bool requiresAuxResolves(const KernelInfo &kernelInfo, const RootDeviceEnvironment &rootDeviceEnvironment) const override; + bool requiresNonAuxMode(const ArgDescPointer &argAsPtr) const override; + bool requiresAuxResolves(const KernelInfo &kernelInfo) 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; @@ -71,7 +71,7 @@ class ClGfxCoreHelperHw : public ClGfxCoreHelper { bool isSupportedKernelThreadArbitrationPolicy() const override; std::vector getSupportedThreadArbitrationPolicies() const override; cl_version getDeviceIpVersion(const HardwareInfo &hwInfo) const override; - cl_device_feature_capabilities_intel getSupportedDeviceFeatureCapabilities(const HardwareInfo &hwInfo) const override; + cl_device_feature_capabilities_intel getSupportedDeviceFeatureCapabilities(const RootDeviceEnvironment &rootDeviceEnvironment) const override; bool allowImageCompression(cl_image_format format) const override; bool isFormatRedescribable(cl_image_format format) const override; diff --git a/opencl/source/helpers/cl_hw_helper_base.inl b/opencl/source/helpers/cl_hw_helper_base.inl index f7e5f6096d..ab6500c1cf 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-2022 Intel Corporation + * Copyright (C) 2020-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -14,12 +14,12 @@ namespace NEO { template -inline bool ClGfxCoreHelperHw::requiresNonAuxMode(const ArgDescPointer &argAsPtr, const RootDeviceEnvironment &rootDeviceEnvironment) const { +inline bool ClGfxCoreHelperHw::requiresNonAuxMode(const ArgDescPointer &argAsPtr) const { return !argAsPtr.isPureStateful(); } template -inline bool ClGfxCoreHelperHw::requiresAuxResolves(const KernelInfo &kernelInfo, const RootDeviceEnvironment &rootDeviceEnvironment) const { +inline bool ClGfxCoreHelperHw::requiresAuxResolves(const KernelInfo &kernelInfo) const { return hasStatelessAccessToBuffer(kernelInfo); } diff --git a/opencl/source/helpers/cl_hw_helper_bdw_and_later.inl b/opencl/source/helpers/cl_hw_helper_bdw_and_later.inl index 6b6c1351ae..f3093d8ec4 100644 --- a/opencl/source/helpers/cl_hw_helper_bdw_and_later.inl +++ b/opencl/source/helpers/cl_hw_helper_bdw_and_later.inl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2022 Intel Corporation + * Copyright (C) 2021-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -24,7 +24,7 @@ cl_ulong ClGfxCoreHelperHw::getKernelPrivateMemSize(const KernelInfo } template -cl_device_feature_capabilities_intel ClGfxCoreHelperHw::getSupportedDeviceFeatureCapabilities(const HardwareInfo &hwInfo) const { +cl_device_feature_capabilities_intel ClGfxCoreHelperHw::getSupportedDeviceFeatureCapabilities(const RootDeviceEnvironment &rootDeviceEnvironment) const { return 0; } diff --git a/opencl/source/helpers/cl_hw_helper_xehp_and_later.inl b/opencl/source/helpers/cl_hw_helper_xehp_and_later.inl index 30f8aec294..af0ba9bb58 100644 --- a/opencl/source/helpers/cl_hw_helper_xehp_and_later.inl +++ b/opencl/source/helpers/cl_hw_helper_xehp_and_later.inl @@ -1,10 +1,11 @@ /* - * Copyright (C) 2021-2022 Intel Corporation + * Copyright (C) 2021-2023 Intel Corporation * * SPDX-License-Identifier: MIT * */ +#include "shared/source/execution_environment/root_device_environment.h" #include "shared/source/os_interface/hw_info_config.h" #include "opencl/source/helpers/cl_hw_helper.h" @@ -23,8 +24,9 @@ cl_ulong ClGfxCoreHelperHw::getKernelPrivateMemSize(const KernelInfo } template -cl_device_feature_capabilities_intel ClGfxCoreHelperHw::getSupportedDeviceFeatureCapabilities(const HardwareInfo &hwInfo) const { - auto &productHelper = *ProductHelper::get(hwInfo.platform.eProductFamily); +cl_device_feature_capabilities_intel ClGfxCoreHelperHw::getSupportedDeviceFeatureCapabilities(const RootDeviceEnvironment &rootDeviceEnvironment) const { + auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo(); + auto &productHelper = rootDeviceEnvironment.getHelper(); if (productHelper.isMatrixMultiplyAccumulateSupported(hwInfo)) { return CL_DEVICE_FEATURE_FLAG_DPAS_INTEL | CL_DEVICE_FEATURE_FLAG_DP4A_INTEL; } diff --git a/opencl/source/helpers/task_information.cpp b/opencl/source/helpers/task_information.cpp index 85da42fb82..1b0059a525 100644 --- a/opencl/source/helpers/task_information.cpp +++ b/opencl/source/helpers/task_information.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2022 Intel Corporation + * Copyright (C) 2018-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -178,7 +178,7 @@ CompletionStamp &CommandComputeKernel::submit(TaskCountType taskLevel, bool term const auto &kernelDescriptor = kernel->getKernelInfo().kernelDescriptor; - auto memoryCompressionState = commandStreamReceiver.getMemoryCompressionState(kernel->isAuxTranslationRequired(), commandQueue.getDevice().getHardwareInfo()); + auto memoryCompressionState = commandStreamReceiver.getMemoryCompressionState(kernel->isAuxTranslationRequired()); DispatchFlags dispatchFlags( {}, // csrDependencies diff --git a/opencl/source/kernel/kernel.cpp b/opencl/source/kernel/kernel.cpp index 98ee729393..44d25534af 100644 --- a/opencl/source/kernel/kernel.cpp +++ b/opencl/source/kernel/kernel.cpp @@ -26,6 +26,7 @@ #include "shared/source/kernel/kernel_arg_descriptor_extended_vme.h" #include "shared/source/kernel/local_ids_cache.h" #include "shared/source/memory_manager/allocation_properties.h" +#include "shared/source/memory_manager/compression_selector.h" #include "shared/source/memory_manager/memory_manager.h" #include "shared/source/memory_manager/unified_memory_manager.h" #include "shared/source/os_interface/hw_info_config.h" @@ -255,7 +256,7 @@ cl_int Kernel::initialize() { auto &clGfxCoreHelper = rootDeviceEnvironment.getHelper(); - auxTranslationRequired = !program->getIsBuiltIn() && GfxCoreHelper::compressedBuffersSupported(hwInfo) && clGfxCoreHelper.requiresAuxResolves(kernelInfo, rootDeviceEnvironment); + auxTranslationRequired = !program->getIsBuiltIn() && GfxCoreHelper::compressedBuffersSupported(hwInfo) && clGfxCoreHelper.requiresAuxResolves(kernelInfo); if (DebugManager.flags.ForceAuxTranslationEnabled.get() != -1) { auxTranslationRequired &= !!DebugManager.flags.ForceAuxTranslationEnabled.get(); @@ -935,7 +936,7 @@ cl_int Kernel::setArgSvmAlloc(uint32_t argIndex, void *svmPtr, GraphicsAllocatio forceNonAuxMode = true; } disableL3 = (argIndex == 0); - } else if (svmAlloc && svmAlloc->isCompressionEnabled() && clGfxCoreHelper.requiresNonAuxMode(argAsPtr, rootDeviceEnvironment)) { + } else if (svmAlloc && svmAlloc->isCompressionEnabled() && clGfxCoreHelper.requiresNonAuxMode(argAsPtr)) { forceNonAuxMode = true; } @@ -1492,7 +1493,7 @@ cl_int Kernel::setArgBuffer(uint32_t argIndex, forceNonAuxMode = true; } disableL3 = (argIndex == 0); - } else if (graphicsAllocation->isCompressionEnabled() && clGfxCoreHelper.requiresNonAuxMode(argAsPtr, rootDeviceEnvironment)) { + } else if (graphicsAllocation->isCompressionEnabled() && clGfxCoreHelper.requiresNonAuxMode(argAsPtr)) { forceNonAuxMode = true; } @@ -1949,8 +1950,8 @@ std::unique_ptr Kernel::fillWithKernelObjsForAuxTra } } } - const auto &productHelper = getDevice().getProductHelper(); - if (productHelper.allowStatelessCompression(getDevice().getHardwareInfo())) { + + if (CompressionSelector::allowStatelessCompression()) { for (auto gfxAllocation : kernelUnifiedMemoryGfxAllocations) { if (gfxAllocation->isCompressionEnabled()) { kernelObjsForAuxTranslation->insert({KernelObjForAuxTranslation::Type::GFX_ALLOC, gfxAllocation}); @@ -2273,8 +2274,7 @@ bool Kernel::requiresCacheFlushCommand(const CommandQueue &commandQueue) const { } void Kernel::updateAuxTranslationRequired() { - const auto &productHelper = getDevice().getProductHelper(); - if (productHelper.allowStatelessCompression(getDevice().getHardwareInfo())) { + if (CompressionSelector::allowStatelessCompression()) { if (hasDirectStatelessAccessToHostMemory() || hasIndirectStatelessAccessToHostMemory() || hasDirectStatelessAccessToSharedBuffer()) { diff --git a/opencl/source/mem_obj/buffer.cpp b/opencl/source/mem_obj/buffer.cpp index ee5e2f43e8..b68cad1681 100644 --- a/opencl/source/mem_obj/buffer.cpp +++ b/opencl/source/mem_obj/buffer.cpp @@ -313,7 +313,7 @@ Buffer *Buffer::create(Context *context, auto &gfxCoreHelper = rootDeviceEnvironment.getHelper(); bool compressionEnabled = MemObjHelper::isSuitableForCompression(GfxCoreHelper::compressedBuffersSupported(*hwInfo), memoryProperties, *context, - gfxCoreHelper.isBufferSizeSuitableForCompression(size, *hwInfo)); + gfxCoreHelper.isBufferSizeSuitableForCompression(size)); allocationInfo.allocationType = getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, *context, compressionEnabled, memoryManager->isLocalMemorySupported(rootDeviceIndex)); diff --git a/opencl/source/memory_manager/compression_selector_ocl.cpp b/opencl/source/memory_manager/compression_selector_ocl.cpp index eb852ce1f4..0ab708e201 100644 --- a/opencl/source/memory_manager/compression_selector_ocl.cpp +++ b/opencl/source/memory_manager/compression_selector_ocl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2022 Intel Corporation + * Copyright (C) 2020-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -11,14 +11,13 @@ #include "shared/source/os_interface/hw_info_config.h" namespace NEO { -bool CompressionSelector::preferCompressedAllocation(const AllocationProperties &properties, const HardwareInfo &hwInfo) { +bool CompressionSelector::preferCompressedAllocation(const AllocationProperties &properties) { switch (properties.allocationType) { case AllocationType::GLOBAL_SURFACE: case AllocationType::CONSTANT_SURFACE: case AllocationType::SVM_GPU: case AllocationType::PRINTF_SURFACE: { - const auto &productHelper = *ProductHelper::get(hwInfo.platform.eProductFamily); - return productHelper.allowStatelessCompression(hwInfo); + return CompressionSelector::allowStatelessCompression(); } default: return false; diff --git a/opencl/source/program/printf_handler.cpp b/opencl/source/program/printf_handler.cpp index 60580f9127..360ec19fa5 100644 --- a/opencl/source/program/printf_handler.cpp +++ b/opencl/source/program/printf_handler.cpp @@ -16,6 +16,7 @@ #include "shared/source/helpers/ptr_math.h" #include "shared/source/kernel/implicit_args.h" #include "shared/source/memory_manager/allocation_properties.h" +#include "shared/source/memory_manager/compression_selector.h" #include "shared/source/memory_manager/memory_manager.h" #include "shared/source/os_interface/hw_info_config.h" #include "shared/source/program/print_formatter.h" @@ -88,7 +89,7 @@ bool PrintfHandler::printEnqueueOutput() { auto printfOutputSize = static_cast(printfSurface->getUnderlyingBufferSize()); std::unique_ptr printfOutputDecompressed; - if (productHelper.allowStatelessCompression(hwInfo) || productHelper.isBlitCopyRequiredForLocalMemory(hwInfo, *printfSurface)) { + if (CompressionSelector::allowStatelessCompression() || productHelper.isBlitCopyRequiredForLocalMemory(hwInfo, *printfSurface)) { printfOutputDecompressed = std::make_unique(printfOutputSize); printfOutputBuffer = printfOutputDecompressed.get(); auto &bcsEngine = device.getEngine(EngineHelpers::getBcsEngineType(device.getRootDeviceEnvironment(), device.getDeviceBitfield(), device.getSelectorCopyEngine(), true), EngineUsage::Regular); 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 dacd9c3b41..059a33c405 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 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2022 Intel Corporation + * Copyright (C) 2021-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -25,7 +25,7 @@ void populateFactoryTable>() { } template <> -bool ClGfxCoreHelperHw::requiresAuxResolves(const KernelInfo &kernelInfo, const RootDeviceEnvironment &rootDeviceEnvironment) const { +bool ClGfxCoreHelperHw::requiresAuxResolves(const KernelInfo &kernelInfo) 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 db0b171d07..692de287df 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 @@ -9,6 +9,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/memory_manager/compression_selector.h" #include "shared/source/os_interface/hw_info_config.h" #include "shared/source/xe_hpg_core/hw_cmds_xe_hpg_core_base.h" @@ -28,11 +29,9 @@ void populateFactoryTable>() { } template <> -bool ClGfxCoreHelperHw::requiresNonAuxMode(const ArgDescPointer &argAsPtr, const RootDeviceEnvironment &rootDeviceEnvironment) const { - auto &productHelper = rootDeviceEnvironment.getHelper(); - auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo(); +bool ClGfxCoreHelperHw::requiresNonAuxMode(const ArgDescPointer &argAsPtr) const { - if (productHelper.allowStatelessCompression(hwInfo)) { + if (CompressionSelector::allowStatelessCompression()) { return false; } else { return !argAsPtr.isPureStateful(); @@ -40,11 +39,9 @@ bool ClGfxCoreHelperHw::requiresNonAuxMode(const ArgDescPointer &argAsPt } template <> -bool ClGfxCoreHelperHw::requiresAuxResolves(const KernelInfo &kernelInfo, const RootDeviceEnvironment &rootDeviceEnvironment) const { - auto &productHelper = rootDeviceEnvironment.getHelper(); - auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo(); +bool ClGfxCoreHelperHw::requiresAuxResolves(const KernelInfo &kernelInfo) const { - if (productHelper.allowStatelessCompression(hwInfo)) { + if (CompressionSelector::allowStatelessCompression()) { return false; } else { return hasStatelessAccessToBuffer(kernelInfo); diff --git a/opencl/test/unit_test/context/driver_diagnostics_tests.cpp b/opencl/test/unit_test/context/driver_diagnostics_tests.cpp index 91a89ea638..400dd016bb 100644 --- a/opencl/test/unit_test/context/driver_diagnostics_tests.cpp +++ b/opencl/test/unit_test/context/driver_diagnostics_tests.cpp @@ -696,7 +696,7 @@ HWTEST2_F(PerformanceHintTest, given64bitCompressedBufferWhenItsCreatedThenPrope snprintf(expectedHint, DriverDiagnostics::maxHintStringSize, DriverDiagnostics::hintFormat[BUFFER_IS_COMPRESSED], buffer.get()); auto &gfxCoreHelper = device->getGfxCoreHelper(); - auto compressionSupported = gfxCoreHelper.isBufferSizeSuitableForCompression(size, hwInfo) && + auto compressionSupported = gfxCoreHelper.isBufferSizeSuitableForCompression(size) && GfxCoreHelper::compressedBuffersSupported(hwInfo); if (compressionSupported) { EXPECT_TRUE(containsHint(expectedHint, userData)); @@ -730,7 +730,7 @@ TEST_F(PerformanceHintTest, givenUncompressedBufferWhenItsCreatedThenProperPerfo isCompressed = MemObjHelper::isSuitableForCompression( GfxCoreHelper::compressedBuffersSupported(hwInfo), memoryProperties, *context, - gfxCoreHelper.isBufferSizeSuitableForCompression(size, hwInfo)) && + gfxCoreHelper.isBufferSizeSuitableForCompression(size)) && !is32bit && !context->isSharedContext && (!memoryProperties.flags.useHostPtr || context->getMemoryManager()->isLocalMemorySupported(device->getRootDeviceIndex())) && !memoryProperties.flags.forceHostMemory; diff --git a/opencl/test/unit_test/device/get_device_info_tests.cpp b/opencl/test/unit_test/device/get_device_info_tests.cpp index bf1f6a90cd..7db847c106 100644 --- a/opencl/test/unit_test/device/get_device_info_tests.cpp +++ b/opencl/test/unit_test/device/get_device_info_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2022 Intel Corporation + * Copyright (C) 2018-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -1125,9 +1125,8 @@ struct DeviceAttributeQueryTest : public ::testing::TestWithParam(object.get()); - auto &hwInfo = device.getHardwareInfo(); auto &clGfxCoreHelper = device.getRootDeviceEnvironment().getHelper(); - EXPECT_EQ(clGfxCoreHelper.getSupportedDeviceFeatureCapabilities(hwInfo), *pCapabilities); + EXPECT_EQ(clGfxCoreHelper.getSupportedDeviceFeatureCapabilities(device.getRootDeviceEnvironment()), *pCapabilities); EXPECT_EQ(sizeof(cl_device_feature_capabilities_intel), sizeReturned); break; } diff --git a/opencl/test/unit_test/gen11/cl_hw_helper_tests_gen11.cpp b/opencl/test/unit_test/gen11/cl_hw_helper_tests_gen11.cpp index 5fd4d26d8a..760b934ecf 100644 --- a/opencl/test/unit_test/gen11/cl_hw_helper_tests_gen11.cpp +++ b/opencl/test/unit_test/gen11/cl_hw_helper_tests_gen11.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2022 Intel Corporation + * Copyright (C) 2019-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -22,5 +22,5 @@ GEN11TEST_F(ClGfxCoreHelperTestGen11, WhenGettingDeviceIpVersionThenMakeCorrectD GEN11TEST_F(ClGfxCoreHelperTestGen11, WhenGettingSupportedDeviceFeatureCapabilitiesThenReturnCorrectValue) { auto &clGfxCoreHelper = getHelper(); - EXPECT_EQ(0u, clGfxCoreHelper.getSupportedDeviceFeatureCapabilities(*defaultHwInfo)); + EXPECT_EQ(0u, clGfxCoreHelper.getSupportedDeviceFeatureCapabilities(getRootDeviceEnvironment())); } 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 e85d1dacdd..3f791ddeee 100644 --- a/opencl/test/unit_test/gen12lp/hw_helper_tests_gen12lp.inl +++ b/opencl/test/unit_test/gen12lp/hw_helper_tests_gen12lp.inl @@ -32,7 +32,7 @@ GEN12LPTEST_F(ClGfxCoreHelperTestsGen12Lp, givenTglLpThenAuxTranslationIsRequire arg.as(true).accessedUsingStatelessAddressingMode = accessedUsingStatelessAddressingMode; kernelInfo.kernelDescriptor.payloadMappings.explicitArgs.push_back(std::move(arg)); - EXPECT_EQ(accessedUsingStatelessAddressingMode, clGfxCoreHelper.requiresAuxResolves(kernelInfo, getRootDeviceEnvironment())); + EXPECT_EQ(accessedUsingStatelessAddressingMode, clGfxCoreHelper.requiresAuxResolves(kernelInfo)); } } @@ -64,7 +64,7 @@ HWTEST2_F(ClGfxCoreHelperTestsGen12Lp, WhenGettingDeviceIpVersionThenMakeCorrect GEN12LPTEST_F(ClGfxCoreHelperTestsGen12Lp, WhenGettingSupportedDeviceFeatureCapabilitiesThenReturnCorrectValue) { auto &clGfxCoreHelper = getHelper(); cl_device_feature_capabilities_intel expectedCapabilities = CL_DEVICE_FEATURE_FLAG_DP4A_INTEL; - EXPECT_EQ(expectedCapabilities, clGfxCoreHelper.getSupportedDeviceFeatureCapabilities(hardwareInfo)); + EXPECT_EQ(expectedCapabilities, clGfxCoreHelper.getSupportedDeviceFeatureCapabilities(getRootDeviceEnvironment())); } using GfxCoreHelperTestGen12Lp = GfxCoreHelperTest; @@ -98,7 +98,7 @@ GEN12LPTEST_F(GfxCoreHelperTestGen12Lp, givenDifferentSizesOfAllocationWhenCheck const size_t sizesToCheck[] = {128, 256, 512, 1023, 1024, 1025}; for (size_t size : sizesToCheck) { - EXPECT_FALSE(gfxCoreHelper.isBufferSizeSuitableForCompression(size, *defaultHwInfo)); + EXPECT_FALSE(gfxCoreHelper.isBufferSizeSuitableForCompression(size)); } } diff --git a/opencl/test/unit_test/gen8/cl_hw_helper_tests_gen8.cpp b/opencl/test/unit_test/gen8/cl_hw_helper_tests_gen8.cpp index 45bdb73880..d336510c1c 100644 --- a/opencl/test/unit_test/gen8/cl_hw_helper_tests_gen8.cpp +++ b/opencl/test/unit_test/gen8/cl_hw_helper_tests_gen8.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2022 Intel Corporation + * Copyright (C) 2021-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -25,5 +25,5 @@ GEN8TEST_F(ClGfxCoreHelperTestGen8, WhenGettingDeviceIpVersionThenMakeCorrectDev GEN8TEST_F(ClGfxCoreHelperTestGen8, WhenGettingSupportedDeviceFeatureCapabilitiesThenReturnCorrectValue) { auto &clGfxCoreHelper = getHelper(); - EXPECT_EQ(0u, clGfxCoreHelper.getSupportedDeviceFeatureCapabilities(*defaultHwInfo)); + EXPECT_EQ(0u, clGfxCoreHelper.getSupportedDeviceFeatureCapabilities(getRootDeviceEnvironment())); } diff --git a/opencl/test/unit_test/gen9/cl_hw_helper_tests_gen9.cpp b/opencl/test/unit_test/gen9/cl_hw_helper_tests_gen9.cpp index 1ddb0fa5d0..819e203fad 100644 --- a/opencl/test/unit_test/gen9/cl_hw_helper_tests_gen9.cpp +++ b/opencl/test/unit_test/gen9/cl_hw_helper_tests_gen9.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2022 Intel Corporation + * Copyright (C) 2018-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -21,5 +21,5 @@ GEN9TEST_F(ClGfxCoreHelperTestGen9, WhenGettingDeviceIpVersionThenMakeCorrectDev GEN9TEST_F(ClGfxCoreHelperTestGen9, WhenGettingSupportedDeviceFeatureCapabilitiesThenReturnCorrectValue) { auto &clGfxCoreHelper = getHelper(); - EXPECT_EQ(0u, clGfxCoreHelper.getSupportedDeviceFeatureCapabilities(*defaultHwInfo)); + EXPECT_EQ(0u, clGfxCoreHelper.getSupportedDeviceFeatureCapabilities(getRootDeviceEnvironment())); } diff --git a/opencl/test/unit_test/helpers/api_specific_config_ocl_tests.cpp b/opencl/test/unit_test/helpers/api_specific_config_ocl_tests.cpp index ada2bece7d..529cbd026d 100644 --- a/opencl/test/unit_test/helpers/api_specific_config_ocl_tests.cpp +++ b/opencl/test/unit_test/helpers/api_specific_config_ocl_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2022 Intel Corporation + * Copyright (C) 2021-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -59,7 +59,7 @@ TEST(ApiSpecificConfigOclTests, givenEnableStatelessCompressionWhenProvidingSvmG AllocationType::SVM_GPU, deviceBitfield); - EXPECT_TRUE(NEO::CompressionSelector::preferCompressedAllocation(properties, *defaultHwInfo)); + EXPECT_TRUE(NEO::CompressionSelector::preferCompressedAllocation(properties)); } TEST(ApiSpecificConfigOclTests, givenEnableStatelessCompressionWhenProvidingPrintfSurfaceThenPreferCompressedBuffer) { @@ -72,6 +72,6 @@ TEST(ApiSpecificConfigOclTests, givenEnableStatelessCompressionWhenProvidingPrin AllocationType::PRINTF_SURFACE, deviceBitfield); - EXPECT_TRUE(NEO::CompressionSelector::preferCompressedAllocation(properties, *defaultHwInfo)); + EXPECT_TRUE(NEO::CompressionSelector::preferCompressedAllocation(properties)); } } // namespace NEO diff --git a/opencl/test/unit_test/helpers/cl_helper_tests.cpp b/opencl/test/unit_test/helpers/cl_helper_tests.cpp index 3830161efd..fbbfb54365 100644 --- a/opencl/test/unit_test/helpers/cl_helper_tests.cpp +++ b/opencl/test/unit_test/helpers/cl_helper_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2022 Intel Corporation + * Copyright (C) 2018-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -114,12 +114,12 @@ HWTEST_F(ClGfxCoreHelperTest, givenKernelInfoWhenCheckingRequiresAuxResolvesThen ArgDescriptor argDescriptorValue(ArgDescriptor::ArgType::ArgTValue); kernelInfo.kernelDescriptor.payloadMappings.explicitArgs.push_back(argDescriptorValue); - EXPECT_FALSE(clGfxCoreHelper.requiresAuxResolves(kernelInfo, getRootDeviceEnvironment())); + EXPECT_FALSE(clGfxCoreHelper.requiresAuxResolves(kernelInfo)); ArgDescriptor argDescriptorPointer(ArgDescriptor::ArgType::ArgTPointer); argDescriptorPointer.as().accessedUsingStatelessAddressingMode = true; kernelInfo.kernelDescriptor.payloadMappings.explicitArgs.push_back(argDescriptorPointer); - EXPECT_TRUE(clGfxCoreHelper.requiresAuxResolves(kernelInfo, getRootDeviceEnvironment())); + EXPECT_TRUE(clGfxCoreHelper.requiresAuxResolves(kernelInfo)); } TEST_F(ClGfxCoreHelperTest, givenGenHelperWhenKernelArgumentIsNotPureStatefulThenRequireNonAuxMode) { @@ -129,7 +129,7 @@ TEST_F(ClGfxCoreHelperTest, givenGenHelperWhenKernelArgumentIsNotPureStatefulThe ArgDescPointer argAsPtr{}; argAsPtr.accessedUsingStatelessAddressingMode = !isPureStateful; - EXPECT_EQ(!argAsPtr.isPureStateful(), clGfxCoreHelper.requiresNonAuxMode(argAsPtr, getRootDeviceEnvironment())); + EXPECT_EQ(!argAsPtr.isPureStateful(), clGfxCoreHelper.requiresNonAuxMode(argAsPtr)); } } diff --git a/opencl/test/unit_test/helpers/cl_hw_helper_tests_xehp_and_later.cpp b/opencl/test/unit_test/helpers/cl_hw_helper_tests_xehp_and_later.cpp index 3730cb3d55..52394f2542 100644 --- a/opencl/test/unit_test/helpers/cl_hw_helper_tests_xehp_and_later.cpp +++ b/opencl/test/unit_test/helpers/cl_hw_helper_tests_xehp_and_later.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2022 Intel Corporation + * Copyright (C) 2021-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -32,5 +32,5 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, ClGfxCoreHelperTestXeHpAndLater, givenCLImageFormat HWTEST2_F(ClGfxCoreHelperTestXeHpAndLater, WhenGettingSupportedDeviceFeatureCapabilitiesThenReturnCorrectValue, IsAtLeastXeHpCore) { cl_device_feature_capabilities_intel expectedCapabilities = CL_DEVICE_FEATURE_FLAG_DPAS_INTEL | CL_DEVICE_FEATURE_FLAG_DP4A_INTEL; auto &clGfxCoreHelper = getHelper(); - EXPECT_EQ(expectedCapabilities, clGfxCoreHelper.getSupportedDeviceFeatureCapabilities(*defaultHwInfo)); + EXPECT_EQ(expectedCapabilities, clGfxCoreHelper.getSupportedDeviceFeatureCapabilities(getRootDeviceEnvironment())); } diff --git a/opencl/test/unit_test/kernel/kernel_tests.cpp b/opencl/test/unit_test/kernel/kernel_tests.cpp index 554b99c6b1..58e6503390 100644 --- a/opencl/test/unit_test/kernel/kernel_tests.cpp +++ b/opencl/test/unit_test/kernel/kernel_tests.cpp @@ -512,7 +512,7 @@ class CommandStreamReceiverMock : public CommandStreamReceiver { bool isMultiOsContextCapable() const override { return false; } - MemoryCompressionState getMemoryCompressionState(bool auxTranslationRequired, const HardwareInfo &hwInfo) const override { + MemoryCompressionState getMemoryCompressionState(bool auxTranslationRequired) const override { return MemoryCompressionState::NotApplicable; } @@ -2542,11 +2542,11 @@ TEST(KernelTest, givenFtrRenderCompressedBuffersWhenInitializingArgsWithNonState auto &rootDeviceEnvironment = device->getRootDeviceEnvironment(); auto &clGfxCoreHelper = rootDeviceEnvironment.getHelper(); - EXPECT_EQ(clGfxCoreHelper.requiresAuxResolves(kernel.kernelInfo, rootDeviceEnvironment), kernel.mockKernel->isAuxTranslationRequired()); + EXPECT_EQ(clGfxCoreHelper.requiresAuxResolves(kernel.kernelInfo), kernel.mockKernel->isAuxTranslationRequired()); DebugManager.flags.ForceAuxTranslationEnabled.set(-1); kernel.mockKernel->initialize(); - EXPECT_EQ(clGfxCoreHelper.requiresAuxResolves(kernel.kernelInfo, rootDeviceEnvironment), kernel.mockKernel->isAuxTranslationRequired()); + EXPECT_EQ(clGfxCoreHelper.requiresAuxResolves(kernel.kernelInfo), kernel.mockKernel->isAuxTranslationRequired()); DebugManager.flags.ForceAuxTranslationEnabled.set(0); kernel.mockKernel->initialize(); @@ -2572,7 +2572,7 @@ TEST(KernelTest, WhenAuxTranslationIsRequiredThenKernelSetsRequiredResolvesInCon auto &rootDeviceEnvironment = device->getRootDeviceEnvironment(); auto &clGfxCoreHelper = rootDeviceEnvironment.getHelper(); - if (clGfxCoreHelper.requiresAuxResolves(kernel.kernelInfo, rootDeviceEnvironment)) { + if (clGfxCoreHelper.requiresAuxResolves(kernel.kernelInfo)) { EXPECT_TRUE(context->getResolvesRequiredInKernels()); } else { EXPECT_FALSE(context->getResolvesRequiredInKernels()); @@ -2618,7 +2618,7 @@ TEST(KernelTest, givenDebugVariableSetWhenKernelHasStatefulBufferAccessThenMarkK auto &rootDeviceEnvironment = device->getRootDeviceEnvironment(); auto &clGfxCoreHelper = rootDeviceEnvironment.getHelper(); - if (clGfxCoreHelper.requiresAuxResolves(kernel.kernelInfo, rootDeviceEnvironment)) { + if (clGfxCoreHelper.requiresAuxResolves(kernel.kernelInfo)) { EXPECT_TRUE(kernel.mockKernel->isAuxTranslationRequired()); } else { EXPECT_FALSE(kernel.mockKernel->isAuxTranslationRequired()); diff --git a/opencl/test/unit_test/mem_obj/buffer_tests.cpp b/opencl/test/unit_test/mem_obj/buffer_tests.cpp index c13dc23049..2b9dc904cc 100644 --- a/opencl/test/unit_test/mem_obj/buffer_tests.cpp +++ b/opencl/test/unit_test/mem_obj/buffer_tests.cpp @@ -707,7 +707,7 @@ TEST_F(CompressedBuffersTests, givenBufferNotCompressedAllocationAndNoHostPtrWhe buffer.reset(Buffer::create(context.get(), 0, bufferSize, nullptr, retVal)); allocation = buffer->getGraphicsAllocation(device->getRootDeviceIndex()); auto &gfxCoreHelper = context->getDevice(0)->getGfxCoreHelper(); - if (gfxCoreHelper.isBufferSizeSuitableForCompression(bufferSize, *hwInfo)) { + if (gfxCoreHelper.isBufferSizeSuitableForCompression(bufferSize)) { EXPECT_FALSE(buffer->isMemObjZeroCopy()); EXPECT_EQ(allocation->getAllocationType(), AllocationType::BUFFER); EXPECT_EQ(!memoryManager->allocate32BitGraphicsMemoryImplCalled, allocation->isCompressionEnabled()); @@ -726,7 +726,7 @@ TEST_F(CompressedBuffersTests, givenBufferCompressedAllocationWhenSharedContextI buffer.reset(Buffer::create(context.get(), CL_MEM_READ_WRITE, bufferSize, nullptr, retVal)); auto graphicsAllocation = buffer->getGraphicsAllocation(context->getDevice(0)->getRootDeviceIndex()); auto &gfxCoreHelper = context->getDevice(0)->getGfxCoreHelper(); - if (gfxCoreHelper.isBufferSizeSuitableForCompression(bufferSize, *hwInfo)) { + if (gfxCoreHelper.isBufferSizeSuitableForCompression(bufferSize)) { EXPECT_EQ(graphicsAllocation->getAllocationType(), AllocationType::BUFFER); EXPECT_EQ(!memoryManager->allocate32BitGraphicsMemoryImplCalled, graphicsAllocation->isCompressionEnabled()); } else { @@ -749,7 +749,7 @@ TEST_F(CompressedBuffersTests, givenDebugVariableSetWhenHwFlagIsNotSetThenSelect buffer.reset(Buffer::create(context.get(), 0, bufferSize, nullptr, retVal)); auto graphicsAllocation = buffer->getGraphicsAllocation(context->getDevice(0)->getRootDeviceIndex()); auto &gfxCoreHelper = context->getDevice(0)->getGfxCoreHelper(); - if (gfxCoreHelper.isBufferSizeSuitableForCompression(bufferSize, *hwInfo)) { + if (gfxCoreHelper.isBufferSizeSuitableForCompression(bufferSize)) { EXPECT_EQ(graphicsAllocation->getAllocationType(), AllocationType::BUFFER); EXPECT_EQ(!memoryManager->allocate32BitGraphicsMemoryImplCalled, graphicsAllocation->isCompressionEnabled()); } else { @@ -808,7 +808,7 @@ TEST_F(CompressedBuffersCopyHostMemoryTests, givenCompressedBufferWhenCopyFromHo buffer.reset(Buffer::create(context.get(), CL_MEM_COPY_HOST_PTR, bufferSize, hostPtr, retVal)); auto graphicsAllocation = buffer->getGraphicsAllocation(context->getDevice(0)->getRootDeviceIndex()); auto &gfxCoreHelper = context->getDevice(0)->getGfxCoreHelper(); - if (gfxCoreHelper.isBufferSizeSuitableForCompression(bufferSize, *hwInfo)) { + if (gfxCoreHelper.isBufferSizeSuitableForCompression(bufferSize)) { EXPECT_TRUE(graphicsAllocation->isCompressionEnabled()); EXPECT_EQ(1u, mockCmdQ->writeBufferCounter); EXPECT_TRUE(mockCmdQ->writeBufferBlocking); @@ -849,7 +849,7 @@ TEST_F(CompressedBuffersCopyHostMemoryTests, givenNonCompressedBufferWhenCopyFro TEST_F(CompressedBuffersCopyHostMemoryTests, givenCompressedBufferWhenWriteBufferFailsThenReturnErrorCode) { auto &gfxCoreHelper = context->getDevice(0)->getGfxCoreHelper(); - if (is32bit || !gfxCoreHelper.isBufferSizeSuitableForCompression(bufferSize, *hwInfo)) { + if (is32bit || !gfxCoreHelper.isBufferSizeSuitableForCompression(bufferSize)) { return; } hwInfo->capabilityTable.ftrRenderCompressedBuffers = true; 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 334f73e471..f3ed4331ec 100644 --- a/opencl/test/unit_test/test_macros/test_checks_ocl.cpp +++ b/opencl/test/unit_test/test_macros/test_checks_ocl.cpp @@ -42,5 +42,5 @@ bool TestChecks::supportsAuxResolves(const RootDeviceEnvironment &rootDeviceEnvi kernelInfo.kernelDescriptor.payloadMappings.explicitArgs[0].as(true).accessedUsingStatelessAddressingMode = true; auto &clGfxCoreHelper = rootDeviceEnvironment.getHelper(); - return clGfxCoreHelper.requiresAuxResolves(kernelInfo, rootDeviceEnvironment); + return clGfxCoreHelper.requiresAuxResolves(kernelInfo); } 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 60894e805b..9535b3db3e 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 @@ -32,7 +32,7 @@ XE_HPC_CORETEST_F(ClGfxCoreHelperTestsXeHpcCore, givenXeHpcThenAuxTranslationIsN auto &clGfxCoreHelper = getHelper(); KernelInfo kernelInfo{}; - EXPECT_FALSE(clGfxCoreHelper.requiresAuxResolves(kernelInfo, getRootDeviceEnvironment())); + EXPECT_FALSE(clGfxCoreHelper.requiresAuxResolves(kernelInfo)); } XE_HPC_CORETEST_F(ClGfxCoreHelperTestsXeHpcCore, WhenCheckingPreferenceForBlitterForLocalToLocalTransfersThenReturnFalse) { 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 0f19fd8a3a..944c39f8f5 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 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Intel Corporation + * Copyright (C) 2022-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -39,7 +39,7 @@ XE_HPG_CORETEST_F(ClGfxCoreHelperTestsXeHpgCore, givenGenHelperWhenKernelArgumen ArgDescPointer argAsPtr{}; argAsPtr.accessedUsingStatelessAddressingMode = !isPureStateful; - EXPECT_EQ(!argAsPtr.isPureStateful(), clGfxCoreHelper.requiresNonAuxMode(argAsPtr, getRootDeviceEnvironment())); + EXPECT_EQ(!argAsPtr.isPureStateful(), clGfxCoreHelper.requiresNonAuxMode(argAsPtr)); } } @@ -52,7 +52,7 @@ XE_HPG_CORETEST_F(ClGfxCoreHelperTestsXeHpgCore, givenGenHelperWhenEnableStatele for (auto isPureStateful : ::testing::Bool()) { ArgDescPointer argAsPtr{}; argAsPtr.accessedUsingStatelessAddressingMode = !isPureStateful; - EXPECT_FALSE(clGfxCoreHelper.requiresNonAuxMode(argAsPtr, getRootDeviceEnvironment())); + EXPECT_FALSE(clGfxCoreHelper.requiresNonAuxMode(argAsPtr)); } } @@ -63,7 +63,7 @@ XE_HPG_CORETEST_F(ClGfxCoreHelperTestsXeHpgCore, givenGenHelperWhenCheckAuxTrans KernelInfo kernelInfo{}; kernelInfo.kernelDescriptor.payloadMappings.explicitArgs.resize(1); kernelInfo.kernelDescriptor.payloadMappings.explicitArgs[0].as(true).accessedUsingStatelessAddressingMode = !isPureStateful; - EXPECT_EQ(!isPureStateful, clGfxCoreHelper.requiresAuxResolves(kernelInfo, getRootDeviceEnvironment())); + EXPECT_EQ(!isPureStateful, clGfxCoreHelper.requiresAuxResolves(kernelInfo)); } } @@ -74,7 +74,7 @@ XE_HPG_CORETEST_F(ClGfxCoreHelperTestsXeHpgCore, givenGenHelperWhenEnableStatele auto &clGfxCoreHelper = getHelper(); KernelInfo kernelInfo{}; - EXPECT_FALSE(clGfxCoreHelper.requiresAuxResolves(kernelInfo, getRootDeviceEnvironment())); + EXPECT_FALSE(clGfxCoreHelper.requiresAuxResolves(kernelInfo)); } XE_HPG_CORETEST_F(ClGfxCoreHelperTestsXeHpgCore, givenDifferentCLImageFormatsWhenCallingAllowImageCompressionThenCorrectValueReturned) { diff --git a/opencl/test/unit_test/xe_hpg_core/command_stream_receiver_hw_tests_xe_hpg_core.cpp b/opencl/test/unit_test/xe_hpg_core/command_stream_receiver_hw_tests_xe_hpg_core.cpp index 5ff55093ef..e7a22b32a7 100644 --- a/opencl/test/unit_test/xe_hpg_core/command_stream_receiver_hw_tests_xe_hpg_core.cpp +++ b/opencl/test/unit_test/xe_hpg_core/command_stream_receiver_hw_tests_xe_hpg_core.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2022 Intel Corporation + * Copyright (C) 2021-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -36,13 +36,13 @@ XE_HPG_CORETEST_F(CommandStreamReceiverHwTestXeHpgCore, givenEnableStatelessComp DebugManager.flags.EnableStatelessCompression.set(0); for (bool auxTranslationRequired : {false, true}) { - auto memoryCompressionState = commandStreamReceiver.getMemoryCompressionState(auxTranslationRequired, pDevice->getHardwareInfo()); + auto memoryCompressionState = commandStreamReceiver.getMemoryCompressionState(auxTranslationRequired); EXPECT_EQ(MemoryCompressionState::NotApplicable, memoryCompressionState); } DebugManager.flags.EnableStatelessCompression.set(1); for (bool auxTranslationRequired : {false, true}) { - auto memoryCompressionState = commandStreamReceiver.getMemoryCompressionState(auxTranslationRequired, pDevice->getHardwareInfo()); + auto memoryCompressionState = commandStreamReceiver.getMemoryCompressionState(auxTranslationRequired); if (auxTranslationRequired) { EXPECT_EQ(MemoryCompressionState::Disabled, memoryCompressionState); } else { diff --git a/shared/source/command_stream/command_stream_receiver.h b/shared/source/command_stream/command_stream_receiver.h index b91ca820ac..f251a52b0a 100644 --- a/shared/source/command_stream/command_stream_receiver.h +++ b/shared/source/command_stream/command_stream_receiver.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2022 Intel Corporation + * Copyright (C) 2018-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -226,7 +226,7 @@ class CommandStreamReceiver { virtual bool isMultiOsContextCapable() const = 0; - virtual MemoryCompressionState getMemoryCompressionState(bool auxTranslationRequired, const HardwareInfo &hwInfo) const = 0; + virtual MemoryCompressionState getMemoryCompressionState(bool auxTranslationRequired) const = 0; void setLatestSentTaskCount(TaskCountType latestSentTaskCount) { this->latestSentTaskCount = latestSentTaskCount; diff --git a/shared/source/command_stream/command_stream_receiver_hw.h b/shared/source/command_stream/command_stream_receiver_hw.h index ebdc83f0b8..9da3c83fb2 100644 --- a/shared/source/command_stream/command_stream_receiver_hw.h +++ b/shared/source/command_stream/command_stream_receiver_hw.h @@ -110,7 +110,7 @@ class CommandStreamReceiverHw : public CommandStreamReceiver { bool isMultiOsContextCapable() const override; - MemoryCompressionState getMemoryCompressionState(bool auxTranslationRequired, const HardwareInfo &hwInfo) const override; + MemoryCompressionState getMemoryCompressionState(bool auxTranslationRequired) const override; bool isDirectSubmissionEnabled() const override { return directSubmission.get() != nullptr; 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 e476e6a9be..45136e4d9a 100644 --- a/shared/source/command_stream/command_stream_receiver_hw_base.inl +++ b/shared/source/command_stream/command_stream_receiver_hw_base.inl @@ -1425,7 +1425,7 @@ inline void CommandStreamReceiverHw::updateTagFromWait() { } template -inline MemoryCompressionState CommandStreamReceiverHw::getMemoryCompressionState(bool auxTranslationRequired, const HardwareInfo &hwInfo) const { +inline MemoryCompressionState CommandStreamReceiverHw::getMemoryCompressionState(bool auxTranslationRequired) const { return MemoryCompressionState::NotApplicable; } diff --git a/shared/source/gen12lp/hw_helper_gen12lp.cpp b/shared/source/gen12lp/hw_helper_gen12lp.cpp index b3464c0882..2372ab027d 100644 --- a/shared/source/gen12lp/hw_helper_gen12lp.cpp +++ b/shared/source/gen12lp/hw_helper_gen12lp.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2022 Intel Corporation + * Copyright (C) 2019-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -68,7 +68,7 @@ bool GfxCoreHelperHw::isLocalMemoryEnabled(const HardwareInfo &hwInfo) c } template <> -bool GfxCoreHelperHw::isBufferSizeSuitableForCompression(const size_t size, const HardwareInfo &hwInfo) const { +bool GfxCoreHelperHw::isBufferSizeSuitableForCompression(const size_t size) const { if (DebugManager.flags.OverrideBufferSuitableForRenderCompression.get() != -1) { return !!DebugManager.flags.OverrideBufferSuitableForRenderCompression.get(); } diff --git a/shared/source/helpers/extra_allocation_data_xehp_and_later.inl b/shared/source/helpers/extra_allocation_data_xehp_and_later.inl index 7d582406e8..b6757d132d 100644 --- a/shared/source/helpers/extra_allocation_data_xehp_and_later.inl +++ b/shared/source/helpers/extra_allocation_data_xehp_and_later.inl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2022 Intel Corporation + * Copyright (C) 2021-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -8,6 +8,7 @@ #include "shared/source/helpers/hw_helper.h" #include "shared/source/helpers/local_memory_access_modes.h" #include "shared/source/memory_manager/allocation_properties.h" +#include "shared/source/memory_manager/compression_selector.h" #include "shared/source/os_interface/hw_info_config.h" namespace NEO { @@ -37,7 +38,7 @@ void GfxCoreHelperHw::setExtraAllocationData(AllocationData &allocationD allocationData.flags.requiresCpuAccess = true; } - if (productHelper.allowStatelessCompression(hwInfo)) { + if (CompressionSelector::allowStatelessCompression()) { if (properties.allocationType == AllocationType::GLOBAL_SURFACE || properties.allocationType == AllocationType::CONSTANT_SURFACE || properties.allocationType == AllocationType::PRINTF_SURFACE) { diff --git a/shared/source/helpers/hw_helper.h b/shared/source/helpers/hw_helper.h index b8e3700b58..5448674a68 100644 --- a/shared/source/helpers/hw_helper.h +++ b/shared/source/helpers/hw_helper.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2022 Intel Corporation + * Copyright (C) 2018-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -58,7 +58,7 @@ class GfxCoreHelper { virtual const AubMemDump::LrcaHelper &getCsTraits(aub_stream::EngineType engineType) const = 0; virtual bool hvAlign4Required() const = 0; virtual bool preferSmallWorkgroupSizeForKernel(const size_t size, const HardwareInfo &hwInfo) const = 0; - virtual bool isBufferSizeSuitableForCompression(const size_t size, const HardwareInfo &hwInfo) const = 0; + virtual bool isBufferSizeSuitableForCompression(const size_t size) const = 0; virtual bool checkResourceCompatibility(GraphicsAllocation &graphicsAllocation) const = 0; static bool compressedBuffersSupported(const HardwareInfo &hwInfo); static bool compressedImagesSupported(const HardwareInfo &hwInfo); @@ -221,7 +221,7 @@ class GfxCoreHelperHw : public GfxCoreHelper { bool hvAlign4Required() const override; - bool isBufferSizeSuitableForCompression(const size_t size, const HardwareInfo &hwInfo) const override; + bool isBufferSizeSuitableForCompression(const size_t size) const override; bool checkResourceCompatibility(GraphicsAllocation &graphicsAllocation) const override; diff --git a/shared/source/helpers/hw_helper_base.inl b/shared/source/helpers/hw_helper_base.inl index 8986511c3b..2d898c3b25 100644 --- a/shared/source/helpers/hw_helper_base.inl +++ b/shared/source/helpers/hw_helper_base.inl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2022 Intel Corporation + * Copyright (C) 2019-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -30,7 +30,7 @@ template const AuxTranslationMode GfxCoreHelperHw::defaultAuxTranslationMode = AuxTranslationMode::Builtin; template -bool GfxCoreHelperHw::isBufferSizeSuitableForCompression(const size_t size, const HardwareInfo &hwInfo) const { +bool GfxCoreHelperHw::isBufferSizeSuitableForCompression(const size_t size) const { if (DebugManager.flags.OverrideBufferSuitableForRenderCompression.get() != -1) { return !!DebugManager.flags.OverrideBufferSuitableForRenderCompression.get(); } diff --git a/shared/source/memory_manager/CMakeLists.txt b/shared/source/memory_manager/CMakeLists.txt index a061cfca63..4dc754e480 100644 --- a/shared/source/memory_manager/CMakeLists.txt +++ b/shared/source/memory_manager/CMakeLists.txt @@ -15,6 +15,7 @@ set(NEO_CORE_MEMORY_MANAGER ${CMAKE_CURRENT_SOURCE_DIR}/alignment_selector.h ${CMAKE_CURRENT_SOURCE_DIR}/allocation_properties.h ${CMAKE_CURRENT_SOURCE_DIR}/compression_selector.h + ${CMAKE_CURRENT_SOURCE_DIR}/compression_selector.cpp ${CMAKE_CURRENT_SOURCE_DIR}/deferrable_allocation_deletion.h ${CMAKE_CURRENT_SOURCE_DIR}/deferrable_allocation_deletion.cpp ${CMAKE_CURRENT_SOURCE_DIR}/deferrable_deletion.h diff --git a/shared/source/memory_manager/compression_selector.cpp b/shared/source/memory_manager/compression_selector.cpp new file mode 100644 index 0000000000..dbc26dc7fb --- /dev/null +++ b/shared/source/memory_manager/compression_selector.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2023 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/memory_manager/compression_selector.h" + +#include "shared/source/debug_settings/debug_settings_manager.h" +#include "shared/source/helpers/api_specific_config.h" + +namespace NEO { + +bool CompressionSelector::allowStatelessCompression() { + if (!NEO::ApiSpecificConfig::isStatelessCompressionSupported()) { + return false; + } + if (DebugManager.flags.EnableStatelessCompression.get() != -1) { + return static_cast(DebugManager.flags.EnableStatelessCompression.get()); + } + return false; +} + +} // namespace NEO diff --git a/shared/source/memory_manager/compression_selector.h b/shared/source/memory_manager/compression_selector.h index 324db0b075..cca2698e9d 100644 --- a/shared/source/memory_manager/compression_selector.h +++ b/shared/source/memory_manager/compression_selector.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2022 Intel Corporation + * Copyright (C) 2020-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -10,11 +10,11 @@ namespace NEO { struct AllocationProperties; -struct HardwareInfo; class CompressionSelector { public: - static bool preferCompressedAllocation(const AllocationProperties &properties, const HardwareInfo &hwInfo); + static bool preferCompressedAllocation(const AllocationProperties &properties); + static bool allowStatelessCompression(); }; } // namespace NEO diff --git a/shared/source/memory_manager/memory_manager.cpp b/shared/source/memory_manager/memory_manager.cpp index 45d72b8d03..35d46c4936 100644 --- a/shared/source/memory_manager/memory_manager.cpp +++ b/shared/source/memory_manager/memory_manager.cpp @@ -342,9 +342,9 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo UNRECOVERABLE_IF(hostPtr == nullptr && !properties.flags.allocateMemory); UNRECOVERABLE_IF(properties.allocationType == AllocationType::UNKNOWN); - auto &rootDeviceEnvironments = *executionEnvironment.rootDeviceEnvironments[properties.rootDeviceIndex]; - auto &hwInfo = *rootDeviceEnvironments.getHardwareInfo(); - auto &helper = rootDeviceEnvironments.getHelper(); + auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[properties.rootDeviceIndex]; + auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo(); + auto &helper = rootDeviceEnvironment.getHelper(); bool allow64KbPages = false; bool allow32Bit = false; @@ -477,7 +477,7 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo allocationData.flags.flushL3 = (mayRequireL3Flush ? properties.flags.flushL3RequiredForRead | properties.flags.flushL3RequiredForWrite : 0u); allocationData.flags.preferCompressed = properties.flags.preferCompressed; - allocationData.flags.preferCompressed |= CompressionSelector::preferCompressedAllocation(properties, hwInfo); + allocationData.flags.preferCompressed |= CompressionSelector::preferCompressedAllocation(properties); allocationData.flags.multiOsContextCapable = properties.flags.multiOsContextCapable; allocationData.usmInitialPlacement = properties.usmInitialPlacement; diff --git a/shared/source/memory_manager/unified_memory_manager.cpp b/shared/source/memory_manager/unified_memory_manager.cpp index 32c186105d..f9eb8d6eda 100644 --- a/shared/source/memory_manager/unified_memory_manager.cpp +++ b/shared/source/memory_manager/unified_memory_manager.cpp @@ -15,6 +15,7 @@ #include "shared/source/helpers/api_specific_config.h" #include "shared/source/helpers/basic_math.h" #include "shared/source/helpers/memory_properties_helpers.h" +#include "shared/source/memory_manager/compression_selector.h" #include "shared/source/memory_manager/memory_manager.h" #include "shared/source/os_interface/hw_info_config.h" #include "shared/source/page_fault_manager/cpu_page_fault_manager.h" @@ -668,8 +669,7 @@ AllocationType SVMAllocsManager::getGraphicsAllocationTypeAndCompressionPreferen allocationType = AllocationType::WRITE_COMBINED; } else { UNRECOVERABLE_IF(nullptr == unifiedMemoryProperties.device); - const auto &productHelper = *ProductHelper::get(unifiedMemoryProperties.device->getHardwareInfo().platform.eProductFamily); - if (productHelper.allowStatelessCompression(unifiedMemoryProperties.device->getHardwareInfo())) { + if (CompressionSelector::allowStatelessCompression()) { compressionEnabled = true; } allocationType = AllocationType::BUFFER; diff --git a/shared/source/os_interface/hw_info_config.h b/shared/source/os_interface/hw_info_config.h index 39b6e76d83..02bcab9839 100644 --- a/shared/source/os_interface/hw_info_config.h +++ b/shared/source/os_interface/hw_info_config.h @@ -90,7 +90,6 @@ class ProductHelper { virtual std::string getDeviceMemoryName() const = 0; virtual bool isDisableOverdispatchAvailable(const HardwareInfo &hwInfo) const = 0; virtual bool allowCompression(const HardwareInfo &hwInfo) const = 0; - virtual bool allowStatelessCompression(const HardwareInfo &hwInfo) const = 0; virtual LocalMemoryAccessMode getLocalMemoryAccessMode(const HardwareInfo &hwInfo) const = 0; virtual bool isAllocationSizeAdjustmentRequired(const HardwareInfo &hwInfo) const = 0; virtual bool isPrefetchDisablingRequired(const HardwareInfo &hwInfo) const = 0; @@ -235,7 +234,6 @@ class ProductHelperHw : public ProductHelper { std::string getDeviceMemoryName() const override; bool isDisableOverdispatchAvailable(const HardwareInfo &hwInfo) const override; bool allowCompression(const HardwareInfo &hwInfo) const override; - bool allowStatelessCompression(const HardwareInfo &hwInfo) const override; LocalMemoryAccessMode getLocalMemoryAccessMode(const HardwareInfo &hwInfo) const override; bool isAllocationSizeAdjustmentRequired(const HardwareInfo &hwInfo) const override; bool isPrefetchDisablingRequired(const HardwareInfo &hwInfo) const override; diff --git a/shared/source/os_interface/hw_info_config.inl b/shared/source/os_interface/hw_info_config.inl index cac6101ee0..256db2df10 100644 --- a/shared/source/os_interface/hw_info_config.inl +++ b/shared/source/os_interface/hw_info_config.inl @@ -238,17 +238,6 @@ bool ProductHelperHw::allowCompression(const HardwareInfo &hwInfo) c return true; } -template -bool ProductHelperHw::allowStatelessCompression(const HardwareInfo &hwInfo) const { - if (!NEO::ApiSpecificConfig::isStatelessCompressionSupported()) { - return false; - } - if (DebugManager.flags.EnableStatelessCompression.get() != -1) { - return static_cast(DebugManager.flags.EnableStatelessCompression.get()); - } - return false; -} - template LocalMemoryAccessMode ProductHelperHw::getDefaultLocalMemoryAccessMode(const HardwareInfo &hwInfo) const { return LocalMemoryAccessMode::Default; diff --git a/shared/source/xe_hpg_core/command_stream_receiver_hw_xe_hpg_core.cpp b/shared/source/xe_hpg_core/command_stream_receiver_hw_xe_hpg_core.cpp index 1cce19fbf4..015cde5d09 100644 --- a/shared/source/xe_hpg_core/command_stream_receiver_hw_xe_hpg_core.cpp +++ b/shared/source/xe_hpg_core/command_stream_receiver_hw_xe_hpg_core.cpp @@ -1,10 +1,11 @@ /* - * Copyright (C) 2021-2022 Intel Corporation + * Copyright (C) 2021-2023 Intel Corporation * * SPDX-License-Identifier: MIT * */ +#include "shared/source/memory_manager/compression_selector.h" #include "shared/source/xe_hpg_core/hw_cmds_xe_hpg_core_base.h" #include "shared/source/xe_hpg_core/hw_info.h" @@ -33,10 +34,10 @@ void populateFactoryTable>() { } template <> -MemoryCompressionState CommandStreamReceiverHw::getMemoryCompressionState(bool auxTranslationRequired, const HardwareInfo &hwInfo) const { +MemoryCompressionState CommandStreamReceiverHw::getMemoryCompressionState(bool auxTranslationRequired) const { auto memoryCompressionState = MemoryCompressionState::NotApplicable; - const auto &productHelper = getProductHelper(); - if (productHelper.allowStatelessCompression(hwInfo)) { + + if (CompressionSelector::allowStatelessCompression()) { memoryCompressionState = auxTranslationRequired ? MemoryCompressionState::Disabled : MemoryCompressionState::Enabled; } return memoryCompressionState; 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 3a187b58d4..81d26d1912 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 @@ -1,10 +1,11 @@ /* - * Copyright (C) 2021-2022 Intel Corporation + * Copyright (C) 2021-2023 Intel Corporation * * SPDX-License-Identifier: MIT * */ +#include "shared/source/memory_manager/compression_selector.h" #include "shared/source/xe_hpg_core/aub_mapper.h" #include "shared/source/xe_hpg_core/hw_cmds_xe_hpg_core_base.h" @@ -112,12 +113,12 @@ std::string GfxCoreHelperHw::getExtensions(const HardwareInfo &hwInfo) c } template <> -bool GfxCoreHelperHw::isBufferSizeSuitableForCompression(const size_t size, const HardwareInfo &hwInfo) const { +bool GfxCoreHelperHw::isBufferSizeSuitableForCompression(const size_t size) const { if (DebugManager.flags.OverrideBufferSuitableForRenderCompression.get() != -1) { return !!DebugManager.flags.OverrideBufferSuitableForRenderCompression.get(); } - if (ProductHelper::get(hwInfo.platform.eProductFamily)->allowStatelessCompression(hwInfo)) { + if (CompressionSelector::allowStatelessCompression()) { return true; } else { return false; diff --git a/shared/test/common/mocks/mock_command_stream_receiver.h b/shared/test/common/mocks/mock_command_stream_receiver.h index ae0dc02349..b413a2140f 100644 --- a/shared/test/common/mocks/mock_command_stream_receiver.h +++ b/shared/test/common/mocks/mock_command_stream_receiver.h @@ -89,7 +89,7 @@ class MockCommandStreamReceiver : public CommandStreamReceiver { } } - MemoryCompressionState getMemoryCompressionState(bool auxTranslationRequired, const HardwareInfo &hwInfo) const override { + MemoryCompressionState getMemoryCompressionState(bool auxTranslationRequired) const override { return MemoryCompressionState::NotApplicable; }; diff --git a/shared/test/common/mocks/mock_hw_info_config.cpp b/shared/test/common/mocks/mock_hw_info_config.cpp index 9f7b941bdc..08d5ae13a8 100644 --- a/shared/test/common/mocks/mock_hw_info_config.cpp +++ b/shared/test/common/mocks/mock_hw_info_config.cpp @@ -164,11 +164,6 @@ bool ProductHelperHw::allowCompression(const HardwareInfo &hwInfo) return false; } -template <> -bool ProductHelperHw::allowStatelessCompression(const HardwareInfo &hwInfo) const { - return false; -} - template <> bool ProductHelperHw::isDirectSubmissionSupported(const HardwareInfo &hwInfo) const { return false; diff --git a/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp b/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp index 1736e23588..9509418bc9 100644 --- a/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp +++ b/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp @@ -626,7 +626,7 @@ HWTEST_F(CommandStreamReceiverTest, givenCommandStreamReceiverWhenCallingGetMemo CommandStreamReceiverHw commandStreamReceiver(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); for (bool auxTranslationRequired : {false, true}) { - auto memoryCompressionState = commandStreamReceiver.getMemoryCompressionState(auxTranslationRequired, *defaultHwInfo); + auto memoryCompressionState = commandStreamReceiver.getMemoryCompressionState(auxTranslationRequired); EXPECT_EQ(MemoryCompressionState::NotApplicable, memoryCompressionState); } } diff --git a/shared/test/unit_test/helpers/hw_helper_tests.cpp b/shared/test/unit_test/helpers/hw_helper_tests.cpp index 3e38205cfa..6bdfc24dbd 100644 --- a/shared/test/unit_test/helpers/hw_helper_tests.cpp +++ b/shared/test/unit_test/helpers/hw_helper_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Intel Corporation + * Copyright (C) 2022-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -851,14 +851,14 @@ HWTEST_F(GfxCoreHelperTest, givenDebugFlagWhenCheckingIfBufferIsSuitableForCompr auto &gfxCoreHelper = getHelper(); DebugManager.flags.OverrideBufferSuitableForRenderCompression.set(0); - EXPECT_FALSE(gfxCoreHelper.isBufferSizeSuitableForCompression(0, *defaultHwInfo)); - EXPECT_FALSE(gfxCoreHelper.isBufferSizeSuitableForCompression(KB, *defaultHwInfo)); - EXPECT_FALSE(gfxCoreHelper.isBufferSizeSuitableForCompression(KB + 1, *defaultHwInfo)); + EXPECT_FALSE(gfxCoreHelper.isBufferSizeSuitableForCompression(0)); + EXPECT_FALSE(gfxCoreHelper.isBufferSizeSuitableForCompression(KB)); + EXPECT_FALSE(gfxCoreHelper.isBufferSizeSuitableForCompression(KB + 1)); DebugManager.flags.OverrideBufferSuitableForRenderCompression.set(1); - EXPECT_TRUE(gfxCoreHelper.isBufferSizeSuitableForCompression(0, *defaultHwInfo)); - EXPECT_TRUE(gfxCoreHelper.isBufferSizeSuitableForCompression(KB, *defaultHwInfo)); - EXPECT_TRUE(gfxCoreHelper.isBufferSizeSuitableForCompression(KB + 1, *defaultHwInfo)); + EXPECT_TRUE(gfxCoreHelper.isBufferSizeSuitableForCompression(0)); + EXPECT_TRUE(gfxCoreHelper.isBufferSizeSuitableForCompression(KB)); + EXPECT_TRUE(gfxCoreHelper.isBufferSizeSuitableForCompression(KB + 1)); } HWTEST_F(GfxCoreHelperTest, WhenIsBankOverrideRequiredIsCalledThenFalseIsReturned) { diff --git a/shared/test/unit_test/helpers/memory_management_tests.cpp b/shared/test/unit_test/helpers/memory_management_tests.cpp index 0fb48d52ec..fde045a7e9 100644 --- a/shared/test/unit_test/helpers/memory_management_tests.cpp +++ b/shared/test/unit_test/helpers/memory_management_tests.cpp @@ -1,11 +1,13 @@ /* - * Copyright (C) 2018-2022 Intel Corporation + * Copyright (C) 2018-2023 Intel Corporation * * SPDX-License-Identifier: MIT * */ +#include "shared/source/memory_manager/compression_selector.h" #include "shared/test/common/fixtures/memory_management_fixture.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/memory_management.h" #include "gtest/gtest.h" @@ -45,6 +47,22 @@ TEST(allocation, GivenFailingAllocationOneWhenCreatingAllocationsThenOnlyOneAllo MemoryManagement::detailedAllocationLoggingActive = false; } +TEST(CompressionSelector, WhenAllowStatelessCompressionIsCalledThenReturnCorrectValue) { + DebugManagerStateRestore restore; + + EXPECT_FALSE(CompressionSelector::allowStatelessCompression()); + + for (auto enable : {-1, 0, 1}) { + DebugManager.flags.EnableStatelessCompression.set(enable); + + if (enable > 0) { + EXPECT_TRUE(CompressionSelector::allowStatelessCompression()); + } else { + EXPECT_FALSE(CompressionSelector::allowStatelessCompression()); + } + } +} + struct MemoryManagementTest : public MemoryManagementFixture, public ::testing::Test { void SetUp() override { diff --git a/shared/test/unit_test/os_interface/hw_info_config_tests.cpp b/shared/test/unit_test/os_interface/hw_info_config_tests.cpp index 602c21d59f..ae41e9215b 100644 --- a/shared/test/unit_test/os_interface/hw_info_config_tests.cpp +++ b/shared/test/unit_test/os_interface/hw_info_config_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Intel Corporation + * Copyright (C) 2022-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -291,22 +291,6 @@ HWTEST_F(ProductHelperTest, WhenAllowRenderCompressionIsCalledThenTrueIsReturned EXPECT_TRUE(productHelper->allowCompression(pInHwInfo)); } -HWTEST_F(ProductHelperTest, WhenAllowStatelessCompressionIsCalledThenReturnCorrectValue) { - DebugManagerStateRestore restore; - - EXPECT_FALSE(productHelper->allowStatelessCompression(pInHwInfo)); - - for (auto enable : {-1, 0, 1}) { - DebugManager.flags.EnableStatelessCompression.set(enable); - - if (enable > 0) { - EXPECT_TRUE(productHelper->allowStatelessCompression(pInHwInfo)); - } else { - EXPECT_FALSE(productHelper->allowStatelessCompression(pInHwInfo)); - } - } -} - HWTEST_F(ProductHelperTest, givenVariousDebugKeyValuesWhenGettingLocalMemoryAccessModeThenCorrectValueIsReturned) { DebugManagerStateRestore restore{}; diff --git a/shared/test/unit_test/os_interface/linux/drm_memory_manager_localmem_prelim_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_memory_manager_localmem_prelim_tests.cpp index 141c84fa96..9937d22e10 100644 --- a/shared/test/unit_test/os_interface/linux/drm_memory_manager_localmem_prelim_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_memory_manager_localmem_prelim_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Intel Corporation + * Copyright (C) 2022-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -1108,7 +1108,7 @@ HWTEST_F(DrmMemoryManagerLocalMemoryPrelimTest, givenNotSetUseSystemMemoryWhenGr MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success; - allocData.flags.preferCompressed = CompressionSelector::preferCompressedAllocation(properties, *defaultHwInfo); + allocData.flags.preferCompressed = CompressionSelector::preferCompressedAllocation(properties); auto buffer = memoryManager->allocateGraphicsMemoryInDevicePool(allocData, status); ASSERT_NE(nullptr, buffer); EXPECT_EQ(0u, buffer->getDefaultGmm()->resourceParams.Flags.Info.RenderCompressed); diff --git a/shared/test/unit_test/ult_specific_config.cpp b/shared/test/unit_test/ult_specific_config.cpp index 386993d7d7..2499ff64f0 100644 --- a/shared/test/unit_test/ult_specific_config.cpp +++ b/shared/test/unit_test/ult_specific_config.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Intel Corporation + * Copyright (C) 2021-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -15,7 +15,7 @@ namespace NEO { namespace ImplicitScaling { bool apiSupport = false; } // namespace ImplicitScaling -bool CompressionSelector::preferCompressedAllocation(const AllocationProperties &properties, const HardwareInfo &hwInfo) { +bool CompressionSelector::preferCompressedAllocation(const AllocationProperties &properties) { return false; } void PageFaultManager::transferToCpu(void *ptr, size_t size, void *cmdQ) { diff --git a/shared/test/unit_test/xe_hpg_core/hw_helper_tests_xe_hpg_core.cpp b/shared/test/unit_test/xe_hpg_core/hw_helper_tests_xe_hpg_core.cpp index 682599aff7..d22e4cac63 100644 --- a/shared/test/unit_test/xe_hpg_core/hw_helper_tests_xe_hpg_core.cpp +++ b/shared/test/unit_test/xe_hpg_core/hw_helper_tests_xe_hpg_core.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2022 Intel Corporation + * Copyright (C) 2021-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -30,7 +30,7 @@ XE_HPG_CORETEST_F(GfxCoreHelperTestXeHpgCore, givenDifferentBufferSizesWhenEnabl const size_t sizesToCheck[] = {1, 128, 256, 1024, 2048}; for (size_t size : sizesToCheck) { - EXPECT_TRUE(gfxCoreHelper.isBufferSizeSuitableForCompression(size, *defaultHwInfo)); + EXPECT_TRUE(gfxCoreHelper.isBufferSizeSuitableForCompression(size)); } } @@ -45,9 +45,9 @@ XE_HPG_CORETEST_F(GfxCoreHelperTestXeHpgCore, givenDebugFlagWhenCheckingIfBuffer for (size_t size : sizesToCheck) { if (debugFlag == 1) { - EXPECT_TRUE(gfxCoreHelper.isBufferSizeSuitableForCompression(size, *defaultHwInfo)); + EXPECT_TRUE(gfxCoreHelper.isBufferSizeSuitableForCompression(size)); } else { - EXPECT_FALSE(gfxCoreHelper.isBufferSizeSuitableForCompression(size, *defaultHwInfo)); + EXPECT_FALSE(gfxCoreHelper.isBufferSizeSuitableForCompression(size)); } } }