mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 23:03:02 +08:00
Initial implementation of CacheSettingsHelper
Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
c88fce0def
commit
a95198521e
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2019-2021 Intel Corporation
|
||||
# Copyright (C) 2019-2022 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
@@ -9,6 +9,8 @@ set(NEO_CORE_GMM_HELPER
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}resource_info_${DRIVER_MODEL}.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/client_context/gmm_client_context.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/client_context/gmm_client_context.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cache_settings_helper.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cache_settings_helper.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gmm.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gmm.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gmm_helper.cpp
|
||||
|
||||
28
shared/source/gmm_helper/cache_settings_helper.cpp
Normal file
28
shared/source/gmm_helper/cache_settings_helper.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/gmm_helper/cache_settings_helper.h"
|
||||
|
||||
#include "shared/source/memory_manager/allocation_type.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
namespace CacheSettingsHelper {
|
||||
GMM_RESOURCE_USAGE_TYPE_ENUM getGmmUsageType(AllocationType allocationType, bool forceUncached) {
|
||||
if (forceUncached) {
|
||||
return (allocationType == AllocationType::PREEMPTION) ? GMM_RESOURCE_USAGE_OCL_BUFFER_CSR_UC
|
||||
: GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED;
|
||||
}
|
||||
|
||||
if (allocationType == AllocationType::IMAGE) {
|
||||
return GMM_RESOURCE_USAGE_OCL_IMAGE;
|
||||
}
|
||||
|
||||
return GMM_RESOURCE_USAGE_OCL_BUFFER;
|
||||
}
|
||||
} // namespace CacheSettingsHelper
|
||||
} // namespace NEO
|
||||
17
shared/source/gmm_helper/cache_settings_helper.h
Normal file
17
shared/source/gmm_helper/cache_settings_helper.h
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/gmm_helper/gmm_lib.h"
|
||||
|
||||
namespace NEO {
|
||||
enum class AllocationType;
|
||||
|
||||
namespace CacheSettingsHelper {
|
||||
GMM_RESOURCE_USAGE_TYPE_ENUM getGmmUsageType(AllocationType allocationType, bool forceUncached);
|
||||
}
|
||||
} // namespace NEO
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "shared/source/gmm_helper/gmm.h"
|
||||
|
||||
#include "shared/source/gmm_helper/cache_settings_helper.h"
|
||||
#include "shared/source/gmm_helper/client_context/gmm_client_context.h"
|
||||
#include "shared/source/gmm_helper/gmm_helper.h"
|
||||
#include "shared/source/gmm_helper/resource_info.h"
|
||||
@@ -16,9 +17,11 @@
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/helpers/ptr_math.h"
|
||||
#include "shared/source/helpers/surface_format_info.h"
|
||||
#include "shared/source/memory_manager/allocation_type.h"
|
||||
|
||||
namespace NEO {
|
||||
Gmm::Gmm(GmmClientContext *clientContext, const void *alignedPtr, size_t alignedSize, size_t alignment, bool uncacheable, bool preferCompressed, StorageInfo storageInfo, bool allowLargePages) : clientContext(clientContext) {
|
||||
Gmm::Gmm(GmmClientContext *clientContext, const void *alignedPtr, size_t alignedSize, size_t alignment, GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsage,
|
||||
bool preferCompressed, StorageInfo storageInfo, bool allowLargePages) : clientContext(clientContext) {
|
||||
resourceParams.Type = RESOURCE_BUFFER;
|
||||
resourceParams.Format = GMM_FORMAT_GENERIC_8BIT;
|
||||
resourceParams.BaseWidth64 = static_cast<uint64_t>(alignedSize);
|
||||
@@ -32,11 +35,7 @@ Gmm::Gmm(GmmClientContext *clientContext, const void *alignedPtr, size_t aligned
|
||||
}
|
||||
}
|
||||
|
||||
if (!uncacheable) {
|
||||
resourceParams.Usage = GMM_RESOURCE_USAGE_OCL_BUFFER;
|
||||
} else {
|
||||
resourceParams.Usage = GMM_RESOURCE_USAGE_OCL_BUFFER_CSR_UC;
|
||||
}
|
||||
resourceParams.Usage = gmmResourceUsage;
|
||||
resourceParams.Flags.Info.Linear = 1;
|
||||
resourceParams.Flags.Info.Cacheable = 1;
|
||||
resourceParams.Flags.Gpu.Texture = 1;
|
||||
@@ -118,7 +117,7 @@ void Gmm::setupImageResourceParams(ImageInfo &imgInfo, bool preferCompressed) {
|
||||
|
||||
resourceParams.NoGfxMemory = 1; // dont allocate, only query for params
|
||||
|
||||
resourceParams.Usage = GMM_RESOURCE_USAGE_TYPE::GMM_RESOURCE_USAGE_OCL_IMAGE;
|
||||
resourceParams.Usage = CacheSettingsHelper::getGmmUsageType(AllocationType::IMAGE, false);
|
||||
|
||||
resourceParams.Format = imgInfo.surfaceFormat->GMMSurfaceFormat;
|
||||
resourceParams.Flags.Gpu.Texture = 1;
|
||||
|
||||
@@ -25,7 +25,8 @@ class Gmm {
|
||||
virtual ~Gmm();
|
||||
Gmm() = delete;
|
||||
Gmm(GmmClientContext *clientContext, ImageInfo &inputOutputImgInfo, StorageInfo storageInfo, bool preferCompressed);
|
||||
Gmm(GmmClientContext *clientContext, const void *alignedPtr, size_t alignedSize, size_t alignment, bool uncacheable, bool preferCompressed, StorageInfo storageInfo, bool allowLargePages);
|
||||
Gmm(GmmClientContext *clientContext, const void *alignedPtr, size_t alignedSize, size_t alignment,
|
||||
GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsage, bool preferCompressed, StorageInfo storageInfo, bool allowLargePages);
|
||||
Gmm(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmm);
|
||||
|
||||
void queryImageParams(ImageInfo &inputOutputImgInfo);
|
||||
|
||||
Reference in New Issue
Block a user