2022-02-04 21:50:19 +08:00
|
|
|
/*
|
2024-01-26 01:07:26 +08:00
|
|
|
* Copyright (C) 2022-2024 Intel Corporation
|
2022-02-04 21:50:19 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "shared/source/gmm_helper/cache_settings_helper.h"
|
|
|
|
|
2022-02-09 01:15:22 +08:00
|
|
|
#include "shared/source/debug_settings/debug_settings_manager.h"
|
2023-09-13 16:37:04 +08:00
|
|
|
#include "shared/source/execution_environment/root_device_environment.h"
|
2023-05-17 23:36:43 +08:00
|
|
|
#include "shared/source/helpers/gfx_core_helper.h"
|
2022-02-10 02:03:05 +08:00
|
|
|
#include "shared/source/helpers/hw_info.h"
|
2022-02-04 21:50:19 +08:00
|
|
|
#include "shared/source/memory_manager/allocation_type.h"
|
2023-03-10 20:28:11 +08:00
|
|
|
#include "shared/source/os_interface/product_helper.h"
|
2023-09-13 17:55:17 +08:00
|
|
|
#include "shared/source/release_helper/release_helper.h"
|
2022-02-04 21:50:19 +08:00
|
|
|
|
|
|
|
namespace NEO {
|
|
|
|
|
2023-01-24 02:44:33 +08:00
|
|
|
GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getGmmUsageType(AllocationType allocationType, bool forceUncached, const ProductHelper &productHelper) {
|
2023-11-30 16:32:25 +08:00
|
|
|
if (debugManager.flags.ForceUncachedGmmUsageType.get()) {
|
2023-12-11 22:24:36 +08:00
|
|
|
UNRECOVERABLE_IF(allocationType == AllocationType::unknown);
|
2023-11-30 16:32:25 +08:00
|
|
|
if ((1llu << (static_cast<int64_t>(allocationType) - 1)) & debugManager.flags.ForceUncachedGmmUsageType.get()) {
|
2022-05-18 19:22:39 +08:00
|
|
|
forceUncached = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-30 16:32:25 +08:00
|
|
|
if (forceUncached || debugManager.flags.ForceAllResourcesUncached.get()) {
|
2024-01-31 22:17:57 +08:00
|
|
|
return getDefaultUsageTypeWithCachingDisabled(allocationType, productHelper);
|
2022-02-09 01:15:22 +08:00
|
|
|
} else {
|
2023-01-24 02:44:33 +08:00
|
|
|
return getDefaultUsageTypeWithCachingEnabled(allocationType, productHelper);
|
2022-02-04 21:50:19 +08:00
|
|
|
}
|
2022-02-09 01:15:22 +08:00
|
|
|
}
|
2022-02-04 21:50:19 +08:00
|
|
|
|
2023-09-13 16:37:04 +08:00
|
|
|
bool CacheSettingsHelper::preferNoCpuAccess(GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsageType, const RootDeviceEnvironment &rootDeviceEnvironment) {
|
2023-11-30 16:32:25 +08:00
|
|
|
if (debugManager.flags.EnableCpuCacheForResources.get()) {
|
2023-07-26 22:27:51 +08:00
|
|
|
return false;
|
2023-05-15 21:22:05 +08:00
|
|
|
}
|
2023-09-13 16:37:04 +08:00
|
|
|
if (rootDeviceEnvironment.isWddmOnLinux()) {
|
2023-07-26 22:27:51 +08:00
|
|
|
return false;
|
|
|
|
}
|
2024-01-26 01:07:26 +08:00
|
|
|
auto &productHelper = rootDeviceEnvironment.getProductHelper();
|
|
|
|
if (productHelper.isCachingOnCpuAvailable()) {
|
2023-07-26 22:27:51 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return (gmmResourceUsageType != GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER);
|
2023-05-15 21:22:05 +08:00
|
|
|
}
|
|
|
|
|
2023-01-24 02:44:33 +08:00
|
|
|
GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getDefaultUsageTypeWithCachingEnabled(AllocationType allocationType, const ProductHelper &productHelper) {
|
2024-04-15 20:46:28 +08:00
|
|
|
if (productHelper.overridePatAndUsageForDcFlushMitigation(allocationType)) {
|
2024-04-12 19:05:44 +08:00
|
|
|
return getDefaultUsageTypeWithCachingDisabled(allocationType, productHelper);
|
|
|
|
}
|
2022-02-10 02:03:05 +08:00
|
|
|
|
2022-02-09 01:15:22 +08:00
|
|
|
switch (allocationType) {
|
2023-12-11 22:24:36 +08:00
|
|
|
case AllocationType::image:
|
2022-02-04 21:50:19 +08:00
|
|
|
return GMM_RESOURCE_USAGE_OCL_IMAGE;
|
2023-12-11 22:24:36 +08:00
|
|
|
case AllocationType::internalHeap:
|
|
|
|
case AllocationType::linearStream:
|
2023-11-30 16:32:25 +08:00
|
|
|
if (debugManager.flags.DisableCachingForHeaps.get()) {
|
2024-01-31 22:17:57 +08:00
|
|
|
return getDefaultUsageTypeWithCachingDisabled(allocationType, productHelper);
|
2022-02-09 01:15:22 +08:00
|
|
|
}
|
|
|
|
return GMM_RESOURCE_USAGE_OCL_STATE_HEAP_BUFFER;
|
2023-12-11 22:24:36 +08:00
|
|
|
case AllocationType::constantSurface:
|
2023-11-30 16:32:25 +08:00
|
|
|
if (debugManager.flags.ForceL1Caching.get() == 0) {
|
2024-01-31 22:17:57 +08:00
|
|
|
return getDefaultUsageTypeWithCachingDisabled(allocationType, productHelper);
|
2022-02-14 19:11:43 +08:00
|
|
|
}
|
|
|
|
return GMM_RESOURCE_USAGE_OCL_BUFFER_CONST;
|
2023-12-11 22:24:36 +08:00
|
|
|
case AllocationType::buffer:
|
|
|
|
case AllocationType::sharedBuffer:
|
|
|
|
case AllocationType::svmGpu:
|
|
|
|
case AllocationType::unifiedSharedMemory:
|
2023-11-30 16:32:25 +08:00
|
|
|
if (debugManager.flags.DisableCachingForStatefulBufferAccess.get()) {
|
2024-01-31 22:17:57 +08:00
|
|
|
return getDefaultUsageTypeWithCachingDisabled(allocationType, productHelper);
|
2023-07-26 22:27:51 +08:00
|
|
|
}
|
|
|
|
return GMM_RESOURCE_USAGE_OCL_BUFFER;
|
2024-05-22 21:31:31 +08:00
|
|
|
case AllocationType::externalHostPtr:
|
2023-12-11 22:24:36 +08:00
|
|
|
case AllocationType::bufferHostMemory:
|
|
|
|
case AllocationType::internalHostMemory:
|
|
|
|
case AllocationType::mapAllocation:
|
|
|
|
case AllocationType::fillPattern:
|
|
|
|
case AllocationType::svmCpu:
|
|
|
|
case AllocationType::svmZeroCopy:
|
2024-06-18 23:48:47 +08:00
|
|
|
case AllocationType::tagBuffer:
|
2023-11-30 16:32:25 +08:00
|
|
|
if (debugManager.flags.DisableCachingForStatefulBufferAccess.get()) {
|
2024-01-31 22:17:57 +08:00
|
|
|
return getDefaultUsageTypeWithCachingDisabled(allocationType, productHelper);
|
2022-02-10 20:15:33 +08:00
|
|
|
}
|
2023-07-26 22:27:51 +08:00
|
|
|
return GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER;
|
2023-12-11 22:24:36 +08:00
|
|
|
case AllocationType::gpuTimestampDeviceBuffer:
|
|
|
|
case AllocationType::timestampPacketTagBuffer:
|
2023-01-24 02:44:33 +08:00
|
|
|
if (productHelper.isDcFlushAllowed()) {
|
2024-01-31 22:17:57 +08:00
|
|
|
return getDefaultUsageTypeWithCachingDisabled(allocationType, productHelper);
|
2022-02-10 02:03:05 +08:00
|
|
|
}
|
2022-02-10 20:15:33 +08:00
|
|
|
return GMM_RESOURCE_USAGE_OCL_BUFFER;
|
2022-02-09 01:15:22 +08:00
|
|
|
default:
|
|
|
|
return GMM_RESOURCE_USAGE_OCL_BUFFER;
|
2022-02-04 21:50:19 +08:00
|
|
|
}
|
2022-02-09 01:15:22 +08:00
|
|
|
}
|
2022-02-04 21:50:19 +08:00
|
|
|
|
2024-01-31 22:17:57 +08:00
|
|
|
GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getDefaultUsageTypeWithCachingDisabled(AllocationType allocationType, const ProductHelper &productHelper) {
|
2022-02-09 01:15:22 +08:00
|
|
|
switch (allocationType) {
|
2023-12-11 22:24:36 +08:00
|
|
|
case AllocationType::preemption:
|
2022-02-09 01:15:22 +08:00
|
|
|
return GMM_RESOURCE_USAGE_OCL_BUFFER_CSR_UC;
|
2023-12-11 22:24:36 +08:00
|
|
|
case AllocationType::internalHeap:
|
|
|
|
case AllocationType::linearStream:
|
2022-02-09 01:15:22 +08:00
|
|
|
return GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER_CACHELINE_MISALIGNED;
|
|
|
|
default:
|
2024-01-31 22:17:57 +08:00
|
|
|
return productHelper.isNewCoherencyModelSupported() ? GMM_RESOURCE_USAGE_OCL_BUFFER_CSR_UC : GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED;
|
2022-02-09 01:15:22 +08:00
|
|
|
}
|
2022-02-04 21:50:19 +08:00
|
|
|
}
|
2022-02-09 01:15:22 +08:00
|
|
|
|
2023-10-04 16:46:56 +08:00
|
|
|
} // namespace NEO
|