fix: allow ringBuffer in coherent memory only for Xe2+

Related-To: NEO-9421

Signed-off-by: Tomasz Biernacik <tomasz.biernacik@intel.com>
This commit is contained in:
Tomasz Biernacik 2025-05-05 13:31:20 +00:00 committed by Compute-Runtime-Automation
parent ccedc7c8f7
commit 310d8c2e58
8 changed files with 49 additions and 5 deletions

View File

@ -60,7 +60,7 @@ GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getDefaultUsageTypeWithCaching
} }
if (hwInfo->capabilityTable.isIntegratedDevice) { if (hwInfo->capabilityTable.isIntegratedDevice) {
if (AllocationType::ringBuffer == allocationType || AllocationType::semaphoreBuffer == allocationType) { if (AllocationType::semaphoreBuffer == allocationType || (AllocationType::ringBuffer == allocationType && productHelper.allowSharedResourcesInCoherentMemory())) {
return GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER; return GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER;
} }
} }

View File

@ -246,6 +246,7 @@ class ProductHelper {
virtual std::optional<GfxMemoryAllocationMethod> getPreferredAllocationMethod(AllocationType allocationType) const = 0; virtual std::optional<GfxMemoryAllocationMethod> getPreferredAllocationMethod(AllocationType allocationType) const = 0;
virtual bool isCachingOnCpuAvailable() const = 0; virtual bool isCachingOnCpuAvailable() const = 0;
virtual bool isNewCoherencyModelSupported() const = 0; virtual bool isNewCoherencyModelSupported() const = 0;
virtual bool allowSharedResourcesInCoherentMemory() const = 0;
virtual bool deferMOCSToPatIndex() const = 0; virtual bool deferMOCSToPatIndex() const = 0;
virtual const std::vector<uint32_t> getSupportedLocalDispatchSizes(const HardwareInfo &hwInfo) const = 0; virtual const std::vector<uint32_t> getSupportedLocalDispatchSizes(const HardwareInfo &hwInfo) const = 0;
virtual uint32_t getMaxLocalRegionSize(const HardwareInfo &hwInfo) const = 0; virtual uint32_t getMaxLocalRegionSize(const HardwareInfo &hwInfo) const = 0;

View File

@ -45,4 +45,9 @@ bool ProductHelperHw<gfxProduct>::isCompressionForbidden(const HardwareInfo &hwI
return isCompressionForbiddenCommon(true); return isCompressionForbiddenCommon(true);
} }
template <PRODUCT_FAMILY gfxProduct>
bool ProductHelperHw<gfxProduct>::allowSharedResourcesInCoherentMemory() const {
return false;
}
} // namespace NEO } // namespace NEO

View File

@ -184,6 +184,7 @@ class ProductHelperHw : public ProductHelper {
std::optional<GfxMemoryAllocationMethod> getPreferredAllocationMethod(AllocationType allocationType) const override; std::optional<GfxMemoryAllocationMethod> getPreferredAllocationMethod(AllocationType allocationType) const override;
bool isCachingOnCpuAvailable() const override; bool isCachingOnCpuAvailable() const override;
bool isNewCoherencyModelSupported() const override; bool isNewCoherencyModelSupported() const override;
bool allowSharedResourcesInCoherentMemory() const override;
bool deferMOCSToPatIndex() const override; bool deferMOCSToPatIndex() const override;
bool supportReadOnlyAllocations() const override; bool supportReadOnlyAllocations() const override;
const std::vector<uint32_t> getSupportedLocalDispatchSizes(const HardwareInfo &hwInfo) const override; const std::vector<uint32_t> getSupportedLocalDispatchSizes(const HardwareInfo &hwInfo) const override;

View File

@ -49,4 +49,9 @@ bool ProductHelperHw<gfxProduct>::isCompressionForbidden(const HardwareInfo &hwI
return isCompressionForbiddenCommon(false); return isCompressionForbiddenCommon(false);
} }
template <PRODUCT_FAMILY gfxProduct>
bool ProductHelperHw<gfxProduct>::allowSharedResourcesInCoherentMemory() const {
return true;
}
} // namespace NEO } // namespace NEO

View File

@ -508,6 +508,11 @@ bool ProductHelperHw<IGFX_UNKNOWN>::isCompressionForbidden(const HardwareInfo &h
template <> template <>
void ProductHelperHw<IGFX_UNKNOWN>::setRenderCompressedFlags(HardwareInfo &hwInfo) const {} void ProductHelperHw<IGFX_UNKNOWN>::setRenderCompressedFlags(HardwareInfo &hwInfo) const {}
template <>
bool ProductHelperHw<IGFX_UNKNOWN>::allowSharedResourcesInCoherentMemory() const {
return false;
}
} // namespace NEO } // namespace NEO
#include "shared/source/os_interface/product_helper.inl" #include "shared/source/os_interface/product_helper.inl"

View File

@ -766,13 +766,23 @@ TEST(GmmTest, givenAllocationTypeWhenGettingUsageTypeThenReturnCorrectValue) {
case AllocationType::fillPattern: case AllocationType::fillPattern:
case AllocationType::internalHostMemory: case AllocationType::internalHostMemory:
case AllocationType::mapAllocation: case AllocationType::mapAllocation:
case AllocationType::ringBuffer:
case AllocationType::semaphoreBuffer: case AllocationType::semaphoreBuffer:
case AllocationType::svmCpu: case AllocationType::svmCpu:
case AllocationType::svmZeroCopy: case AllocationType::svmZeroCopy:
case AllocationType::tagBuffer: case AllocationType::tagBuffer:
expectedUsage = forceUncached ? uncachedGmmUsageType : GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER; expectedUsage = forceUncached ? uncachedGmmUsageType : GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER;
break; break;
case AllocationType::ringBuffer:
if (forceUncached) {
expectedUsage = uncachedGmmUsageType;
break;
}
if (productHelper.allowSharedResourcesInCoherentMemory()) {
expectedUsage = GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER;
break;
}
[[fallthrough]];
default: default:
expectedUsage = forceUncached ? uncachedGmmUsageType : GMM_RESOURCE_USAGE_OCL_BUFFER; expectedUsage = forceUncached ? uncachedGmmUsageType : GMM_RESOURCE_USAGE_OCL_BUFFER;
break; break;
@ -883,7 +893,6 @@ TEST(GmmTest, givenAllocationTypeAndMitigatedDcFlushWhenGettingUsageTypeThenRetu
case AllocationType::timestampPacketTagBuffer: case AllocationType::timestampPacketTagBuffer:
expectedUsage = uncachedGmmUsageType; expectedUsage = uncachedGmmUsageType;
break; break;
case AllocationType::linearStream: case AllocationType::linearStream:
case AllocationType::internalHeap: case AllocationType::internalHeap:
expectedUsage = GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER_CACHELINE_MISALIGNED; expectedUsage = GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER_CACHELINE_MISALIGNED;
@ -895,10 +904,15 @@ TEST(GmmTest, givenAllocationTypeAndMitigatedDcFlushWhenGettingUsageTypeThenRetu
expectedUsage = GMM_RESOURCE_USAGE_OCL_IMAGE; expectedUsage = GMM_RESOURCE_USAGE_OCL_IMAGE;
break; break;
case AllocationType::fillPattern: case AllocationType::fillPattern:
case AllocationType::ringBuffer:
case AllocationType::semaphoreBuffer: case AllocationType::semaphoreBuffer:
expectedUsage = GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER; expectedUsage = GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER;
break; break;
case AllocationType::ringBuffer:
if (productHelper.allowSharedResourcesInCoherentMemory()) {
expectedUsage = GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER;
break;
}
[[fallthrough]];
default: default:
expectedUsage = GMM_RESOURCE_USAGE_OCL_BUFFER; expectedUsage = GMM_RESOURCE_USAGE_OCL_BUFFER;
break; break;
@ -920,13 +934,18 @@ TEST(GmmTest, givenAllocationTypeAndMitigatedDcFlushWhenGettingUsageTypeThenRetu
case AllocationType::fillPattern: case AllocationType::fillPattern:
case AllocationType::internalHostMemory: case AllocationType::internalHostMemory:
case AllocationType::mapAllocation: case AllocationType::mapAllocation:
case AllocationType::ringBuffer:
case AllocationType::semaphoreBuffer: case AllocationType::semaphoreBuffer:
case AllocationType::svmCpu: case AllocationType::svmCpu:
case AllocationType::svmZeroCopy: case AllocationType::svmZeroCopy:
case AllocationType::tagBuffer: case AllocationType::tagBuffer:
expectedUsage = GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER; expectedUsage = GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER;
break; break;
case AllocationType::ringBuffer:
if (productHelper.allowSharedResourcesInCoherentMemory()) {
expectedUsage = GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER;
break;
}
[[fallthrough]];
default: default:
expectedUsage = GMM_RESOURCE_USAGE_OCL_BUFFER; expectedUsage = GMM_RESOURCE_USAGE_OCL_BUFFER;
break; break;

View File

@ -1180,3 +1180,11 @@ HWTEST_F(ProductHelperTest, givenProductHelperWhenGettingIsPrimaryContextsAggreg
HWTEST_F(ProductHelperTest, givenProductHelperWhenCallingUseAdditionalBlitPropertiesThenFalseReturned) { HWTEST_F(ProductHelperTest, givenProductHelperWhenCallingUseAdditionalBlitPropertiesThenFalseReturned) {
EXPECT_FALSE(productHelper->useAdditionalBlitProperties()); EXPECT_FALSE(productHelper->useAdditionalBlitProperties());
} }
HWTEST2_F(ProductHelperTest, givenProductHelperWhenCallingAllowSharedResourcesInCoherentMemoryThenFalseReturned, IsBeforeXe2HpgCore) {
EXPECT_FALSE(productHelper->allowSharedResourcesInCoherentMemory());
}
HWTEST2_F(ProductHelperTest, givenProductHelperWhenCallingAllowSharedResourcesInCoherentMemoryThenTrueReturned, IsAtLeastXe2HpgCore) {
EXPECT_TRUE(productHelper->allowSharedResourcesInCoherentMemory());
}