Initial implementation of CacheSettingsHelper

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski
2022-02-04 13:50:19 +00:00
committed by Compute-Runtime-Automation
parent c88fce0def
commit a95198521e
41 changed files with 250 additions and 163 deletions

View File

@@ -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

View 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

View 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

View File

@@ -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;

View File

@@ -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);