feature: Add logic around cpu side allocations

Group allocation types related to cpu side allocations in function to
query gmm usage type. These types will have caching enabled even if
CPU caching is not preferred by GPU.

Add logic to query whether the cpu access is allowed for an allocation
(in cases when it is not preffered by GPU).

Related-To: NEO-7194

Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
Filip Hazubski
2023-07-26 14:27:51 +00:00
committed by Compute-Runtime-Automation
parent b4d6822991
commit 8dd23f4b4d
14 changed files with 138 additions and 51 deletions

View File

@@ -29,12 +29,17 @@ GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getGmmUsageType(AllocationType
}
}
bool CacheSettingsHelper::isResourceCacheableOnCpu(GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsageType, const ProductHelper &productHelper, bool isWsl) {
bool isCachingOnCpuAvailable = isWsl ? true : productHelper.isCachingOnCpuAvailable();
bool CacheSettingsHelper::preferNoCpuAccess(GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsageType, const ProductHelper &productHelper, bool isWsl) {
if (DebugManager.flags.EnableCpuCacheForResources.get()) {
isCachingOnCpuAvailable = true;
return false;
}
return isCachingOnCpuAvailable && !CacheSettingsHelper::isUncachedType(gmmResourceUsageType);
if (isWsl) {
return false;
}
if (productHelper.isCachingOnCpuAvailable()) {
return false;
}
return (gmmResourceUsageType != GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER);
}
GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getDefaultUsageTypeWithCachingEnabled(AllocationType allocationType, const ProductHelper &productHelper) {
@@ -54,20 +59,24 @@ GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getDefaultUsageTypeWithCaching
}
return GMM_RESOURCE_USAGE_OCL_BUFFER_CONST;
case AllocationType::BUFFER:
case AllocationType::BUFFER_HOST_MEMORY:
case AllocationType::EXTERNAL_HOST_PTR:
case AllocationType::FILL_PATTERN:
case AllocationType::INTERNAL_HOST_MEMORY:
case AllocationType::MAP_ALLOCATION:
case AllocationType::SHARED_BUFFER:
case AllocationType::SVM_CPU:
case AllocationType::SVM_GPU:
case AllocationType::SVM_ZERO_COPY:
case AllocationType::UNIFIED_SHARED_MEMORY:
case AllocationType::EXTERNAL_HOST_PTR:
if (DebugManager.flags.DisableCachingForStatefulBufferAccess.get()) {
return getDefaultUsageTypeWithCachingDisabled(allocationType);
}
return GMM_RESOURCE_USAGE_OCL_BUFFER;
case AllocationType::BUFFER_HOST_MEMORY:
case AllocationType::INTERNAL_HOST_MEMORY:
case AllocationType::MAP_ALLOCATION:
case AllocationType::FILL_PATTERN:
case AllocationType::SVM_CPU:
case AllocationType::SVM_ZERO_COPY:
if (DebugManager.flags.DisableCachingForStatefulBufferAccess.get()) {
return getDefaultUsageTypeWithCachingDisabled(allocationType);
}
return GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER;
case AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER:
case AllocationType::TIMESTAMP_PACKET_TAG_BUFFER:
if (productHelper.isDcFlushAllowed()) {

View File

@@ -26,7 +26,7 @@ struct CacheSettingsHelper {
(gmmResourceUsageType == GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED));
}
static bool isResourceCacheableOnCpu(GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsageType, const ProductHelper &productHelper, bool isWsl);
static bool preferNoCpuAccess(GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsageType, const ProductHelper &productHelper, bool isWsl);
protected:
static GMM_RESOURCE_USAGE_TYPE_ENUM getDefaultUsageTypeWithCachingEnabled(AllocationType allocationType, const ProductHelper &productHelper);

View File

@@ -40,7 +40,8 @@ Gmm::Gmm(GmmHelper *gmmHelper, const void *alignedPtr, size_t alignedSize, size_
resourceParams.Usage = gmmResourceUsage;
resourceParams.Flags.Info.Linear = 1;
auto &productHelper = gmmHelper->getRootDeviceEnvironment().getHelper<ProductHelper>();
resourceParams.Flags.Info.Cacheable = CacheSettingsHelper::isResourceCacheableOnCpu(gmmResourceUsage, productHelper, gmmHelper->getRootDeviceEnvironment().isWddmOnLinux());
this->preferNoCpuAccess = CacheSettingsHelper::preferNoCpuAccess(gmmResourceUsage, productHelper, gmmHelper->getRootDeviceEnvironment().isWddmOnLinux());
resourceParams.Flags.Info.Cacheable = !this->preferNoCpuAccess && !CacheSettingsHelper::isUncachedType(gmmResourceUsage);
resourceParams.Flags.Gpu.Texture = 1;
if (alignedPtr) {

View File

@@ -47,6 +47,7 @@ class Gmm {
uint32_t getUnifiedAuxPitchTiles();
uint32_t getAuxQPitch();
bool getPreferNoCpuAccess() const { return preferNoCpuAccess; }
GMM_RESCREATE_PARAMS resourceParams = {};
std::unique_ptr<GmmResourceInfo> gmmResourceInfo;
@@ -60,5 +61,7 @@ class Gmm {
void applyExtraMemoryFlags(const StorageInfo &storageInfo);
void applyDebugOverrides();
GmmHelper *gmmHelper = nullptr;
bool preferNoCpuAccess = false;
};
} // namespace NEO