2022-02-04 13:50:19 +00:00
|
|
|
/*
|
2023-01-23 18:44:33 +00:00
|
|
|
* Copyright (C) 2022-2023 Intel Corporation
|
2022-02-04 13:50:19 +00:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "shared/source/gmm_helper/cache_settings_helper.h"
|
|
|
|
|
|
2022-02-08 17:15:22 +00:00
|
|
|
#include "shared/source/debug_settings/debug_settings_manager.h"
|
2023-05-17 15:36:43 +00:00
|
|
|
#include "shared/source/helpers/gfx_core_helper.h"
|
2022-02-09 18:03:05 +00:00
|
|
|
#include "shared/source/helpers/hw_info.h"
|
2022-02-04 13:50:19 +00:00
|
|
|
#include "shared/source/memory_manager/allocation_type.h"
|
2023-03-10 12:28:11 +00:00
|
|
|
#include "shared/source/os_interface/product_helper.h"
|
2022-02-04 13:50:19 +00:00
|
|
|
|
|
|
|
|
namespace NEO {
|
|
|
|
|
|
2023-01-23 18:44:33 +00:00
|
|
|
GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getGmmUsageType(AllocationType allocationType, bool forceUncached, const ProductHelper &productHelper) {
|
2022-05-18 11:22:39 +00:00
|
|
|
if (DebugManager.flags.ForceUncachedGmmUsageType.get()) {
|
|
|
|
|
if ((1llu << (static_cast<int64_t>(allocationType) - 1)) & DebugManager.flags.ForceUncachedGmmUsageType.get()) {
|
|
|
|
|
forceUncached = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-11 14:50:33 +00:00
|
|
|
if (forceUncached || DebugManager.flags.ForceAllResourcesUncached.get()) {
|
2022-02-08 17:15:22 +00:00
|
|
|
return getDefaultUsageTypeWithCachingDisabled(allocationType);
|
|
|
|
|
} else {
|
2023-01-23 18:44:33 +00:00
|
|
|
return getDefaultUsageTypeWithCachingEnabled(allocationType, productHelper);
|
2022-02-04 13:50:19 +00:00
|
|
|
}
|
2022-02-08 17:15:22 +00:00
|
|
|
}
|
2022-02-04 13:50:19 +00:00
|
|
|
|
2023-05-17 15:36:43 +00:00
|
|
|
bool CacheSettingsHelper::isResourceCacheableOnCpu(GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsageType, const GfxCoreHelper &gfxCoreHelper) {
|
|
|
|
|
bool isCachingOnCpuAvailable = gfxCoreHelper.isCachingOnCpuAvailable();
|
2023-05-15 13:22:05 +00:00
|
|
|
if (DebugManager.flags.EnableCpuCacheForResources.get()) {
|
2023-05-17 15:36:43 +00:00
|
|
|
isCachingOnCpuAvailable = true;
|
2023-05-15 13:22:05 +00:00
|
|
|
}
|
2023-05-17 15:36:43 +00:00
|
|
|
return isCachingOnCpuAvailable && !CacheSettingsHelper::isUncachedType(gmmResourceUsageType);
|
2023-05-15 13:22:05 +00:00
|
|
|
}
|
|
|
|
|
|
2023-01-23 18:44:33 +00:00
|
|
|
GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getDefaultUsageTypeWithCachingEnabled(AllocationType allocationType, const ProductHelper &productHelper) {
|
2022-02-09 18:03:05 +00:00
|
|
|
|
2022-02-08 17:15:22 +00:00
|
|
|
switch (allocationType) {
|
|
|
|
|
case AllocationType::IMAGE:
|
2022-02-04 13:50:19 +00:00
|
|
|
return GMM_RESOURCE_USAGE_OCL_IMAGE;
|
2022-02-08 17:15:22 +00:00
|
|
|
case AllocationType::INTERNAL_HEAP:
|
|
|
|
|
case AllocationType::LINEAR_STREAM:
|
|
|
|
|
if (DebugManager.flags.DisableCachingForHeaps.get()) {
|
|
|
|
|
return getDefaultUsageTypeWithCachingDisabled(allocationType);
|
|
|
|
|
}
|
|
|
|
|
return GMM_RESOURCE_USAGE_OCL_STATE_HEAP_BUFFER;
|
2022-02-14 11:11:43 +00:00
|
|
|
case AllocationType::CONSTANT_SURFACE:
|
|
|
|
|
if (DebugManager.flags.ForceL1Caching.get() == 0) {
|
|
|
|
|
return getDefaultUsageTypeWithCachingDisabled(allocationType);
|
|
|
|
|
}
|
|
|
|
|
return GMM_RESOURCE_USAGE_OCL_BUFFER_CONST;
|
2022-02-10 12:15:33 +00:00
|
|
|
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:
|
|
|
|
|
if (DebugManager.flags.DisableCachingForStatefulBufferAccess.get()) {
|
|
|
|
|
return getDefaultUsageTypeWithCachingDisabled(allocationType);
|
|
|
|
|
}
|
|
|
|
|
return GMM_RESOURCE_USAGE_OCL_BUFFER;
|
2022-02-09 18:03:05 +00:00
|
|
|
case AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER:
|
|
|
|
|
case AllocationType::TIMESTAMP_PACKET_TAG_BUFFER:
|
2023-01-23 18:44:33 +00:00
|
|
|
if (productHelper.isDcFlushAllowed()) {
|
2022-02-09 18:03:05 +00:00
|
|
|
return getDefaultUsageTypeWithCachingDisabled(allocationType);
|
|
|
|
|
}
|
2022-02-10 12:15:33 +00:00
|
|
|
return GMM_RESOURCE_USAGE_OCL_BUFFER;
|
2022-02-08 17:15:22 +00:00
|
|
|
default:
|
|
|
|
|
return GMM_RESOURCE_USAGE_OCL_BUFFER;
|
2022-02-04 13:50:19 +00:00
|
|
|
}
|
2022-02-08 17:15:22 +00:00
|
|
|
}
|
2022-02-04 13:50:19 +00:00
|
|
|
|
2022-02-08 17:15:22 +00:00
|
|
|
GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getDefaultUsageTypeWithCachingDisabled(AllocationType allocationType) {
|
|
|
|
|
switch (allocationType) {
|
|
|
|
|
case AllocationType::PREEMPTION:
|
|
|
|
|
return GMM_RESOURCE_USAGE_OCL_BUFFER_CSR_UC;
|
|
|
|
|
case AllocationType::INTERNAL_HEAP:
|
|
|
|
|
case AllocationType::LINEAR_STREAM:
|
|
|
|
|
return GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER_CACHELINE_MISALIGNED;
|
|
|
|
|
default:
|
|
|
|
|
return GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED;
|
|
|
|
|
}
|
2022-02-04 13:50:19 +00:00
|
|
|
}
|
2022-02-08 17:15:22 +00:00
|
|
|
|
2022-02-04 13:50:19 +00:00
|
|
|
} // namespace NEO
|