Files
compute-runtime/shared/source/gmm_helper/cache_settings_helper.cpp
Bartosz Dunajski 71f48c89c8 CacheSettingsHelper - timestamp allocations
Related-To: NEO-6664

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
2022-02-09 19:32:39 +01:00

60 lines
2.1 KiB
C++

/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/gmm_helper/cache_settings_helper.h"
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/helpers/hw_info.h"
#include "shared/source/memory_manager/allocation_type.h"
#include "shared/source/os_interface/hw_info_config.h"
namespace NEO {
GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getGmmUsageType(AllocationType allocationType, bool forceUncached, const HardwareInfo &hwInfo) {
if (forceUncached) {
return getDefaultUsageTypeWithCachingDisabled(allocationType);
} else {
return getDefaultUsageTypeWithCachingEnabled(allocationType, hwInfo);
}
}
GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getDefaultUsageTypeWithCachingEnabled(AllocationType allocationType, const HardwareInfo &hwInfo) {
const auto hwInfoConfig = HwInfoConfig::get(hwInfo.platform.eProductFamily);
switch (allocationType) {
case AllocationType::IMAGE:
return GMM_RESOURCE_USAGE_OCL_IMAGE;
case AllocationType::INTERNAL_HEAP:
case AllocationType::LINEAR_STREAM:
if (DebugManager.flags.DisableCachingForHeaps.get()) {
return getDefaultUsageTypeWithCachingDisabled(allocationType);
}
return GMM_RESOURCE_USAGE_OCL_STATE_HEAP_BUFFER;
case AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER:
case AllocationType::TIMESTAMP_PACKET_TAG_BUFFER:
if (hwInfoConfig->isDcFlushAllowed()) {
return getDefaultUsageTypeWithCachingDisabled(allocationType);
}
[[fallthrough]];
default:
return GMM_RESOURCE_USAGE_OCL_BUFFER;
}
}
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;
}
}
} // namespace NEO