2022-02-04 21:50:19 +08:00
|
|
|
/*
|
2023-01-24 02:44:33 +08:00
|
|
|
* Copyright (C) 2022-2023 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"
|
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"
|
2022-02-10 02:03:05 +08:00
|
|
|
#include "shared/source/os_interface/hw_info_config.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) {
|
2022-05-18 19:22:39 +08:00
|
|
|
if (DebugManager.flags.ForceUncachedGmmUsageType.get()) {
|
|
|
|
if ((1llu << (static_cast<int64_t>(allocationType) - 1)) & DebugManager.flags.ForceUncachedGmmUsageType.get()) {
|
|
|
|
forceUncached = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-11 22:50:33 +08:00
|
|
|
if (forceUncached || DebugManager.flags.ForceAllResourcesUncached.get()) {
|
2022-02-09 01:15:22 +08:00
|
|
|
return getDefaultUsageTypeWithCachingDisabled(allocationType);
|
|
|
|
} 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-01-24 02:44:33 +08:00
|
|
|
GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getDefaultUsageTypeWithCachingEnabled(AllocationType allocationType, const ProductHelper &productHelper) {
|
2022-02-10 02:03:05 +08:00
|
|
|
|
2022-02-09 01:15:22 +08:00
|
|
|
switch (allocationType) {
|
|
|
|
case AllocationType::IMAGE:
|
2022-02-04 21:50:19 +08:00
|
|
|
return GMM_RESOURCE_USAGE_OCL_IMAGE;
|
2022-02-09 01:15:22 +08: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 19:11:43 +08:00
|
|
|
case AllocationType::CONSTANT_SURFACE:
|
|
|
|
if (DebugManager.flags.ForceL1Caching.get() == 0) {
|
|
|
|
return getDefaultUsageTypeWithCachingDisabled(allocationType);
|
|
|
|
}
|
|
|
|
return GMM_RESOURCE_USAGE_OCL_BUFFER_CONST;
|
2022-02-10 20:15:33 +08: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-10 02:03:05 +08:00
|
|
|
case AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER:
|
|
|
|
case AllocationType::TIMESTAMP_PACKET_TAG_BUFFER:
|
2023-01-24 02:44:33 +08:00
|
|
|
if (productHelper.isDcFlushAllowed()) {
|
2022-02-10 02:03:05 +08:00
|
|
|
return getDefaultUsageTypeWithCachingDisabled(allocationType);
|
|
|
|
}
|
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
|
|
|
|
2022-02-09 01:15:22 +08: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 21:50:19 +08:00
|
|
|
}
|
2022-02-09 01:15:22 +08:00
|
|
|
|
2022-02-04 21:50:19 +08:00
|
|
|
} // namespace NEO
|