mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-11 08:07:19 +08:00
Move core part of MemoryPropertiesHelpers to shared
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
afa45bd9e7
commit
48f01f28f5
@@ -82,6 +82,9 @@ set(NEO_CORE_HELPERS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/local_id_gen_sse4.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/local_work_size.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/local_work_size.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}memory_properties_helpers.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/memory_properties_helpers.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/memory_properties_helpers_base.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/neo_driver_version.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/non_copyable_or_moveable.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/options.h
|
||||
|
||||
24
shared/source/helpers/memory_properties_helpers.cpp
Normal file
24
shared/source/helpers/memory_properties_helpers.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/memory_properties_helpers_base.inl"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
void MemoryPropertiesHelper::fillPoliciesInProperties(AllocationProperties &allocationProperties, const MemoryProperties &memoryProperties, const HardwareInfo &hwInfo, bool deviceOnlyVisibilty) {
|
||||
fillCachePolicyInProperties(allocationProperties,
|
||||
memoryProperties.flags.locallyUncachedResource,
|
||||
memoryProperties.flags.readOnly,
|
||||
deviceOnlyVisibilty,
|
||||
0);
|
||||
}
|
||||
|
||||
uint32_t MemoryPropertiesHelper::getCacheRegion(const MemoryProperties &memoryProperties) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
39
shared/source/helpers/memory_properties_helpers.h
Normal file
39
shared/source/helpers/memory_properties_helpers.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/helpers/bit_helpers.h"
|
||||
#include "shared/source/memory_manager/allocation_properties.h"
|
||||
|
||||
#include "memory_properties_flags.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class MemoryPropertiesHelper {
|
||||
public:
|
||||
enum class ObjType {
|
||||
UNKNOWN,
|
||||
BUFFER,
|
||||
IMAGE,
|
||||
};
|
||||
|
||||
static AllocationProperties getAllocationProperties(
|
||||
uint32_t rootDeviceIndex, MemoryProperties memoryProperties, bool allocateMemory, size_t size,
|
||||
GraphicsAllocation::AllocationType type, bool multiStorageResource, const HardwareInfo &hwInfo,
|
||||
DeviceBitfield subDevicesBitfieldParam, bool deviceOnlyVisibilty);
|
||||
|
||||
static DeviceBitfield adjustDeviceBitfield(uint32_t rootDeviceIndex, const MemoryProperties &memoryProperties,
|
||||
DeviceBitfield subDevicesBitfieldParam);
|
||||
|
||||
static void fillPoliciesInProperties(AllocationProperties &allocationProperties, const MemoryProperties &memoryProperties, const HardwareInfo &hwInfo, bool deviceOnlyVisibilty);
|
||||
|
||||
static void fillCachePolicyInProperties(AllocationProperties &allocationProperties, bool uncached, bool readOnly,
|
||||
bool deviceOnlyVisibilty, uint32_t cacheRegion);
|
||||
|
||||
static uint32_t getCacheRegion(const MemoryProperties &memoryProperties);
|
||||
};
|
||||
} // namespace NEO
|
||||
41
shared/source/helpers/memory_properties_helpers_base.inl
Normal file
41
shared/source/helpers/memory_properties_helpers_base.inl
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/bit_helpers.h"
|
||||
#include "shared/source/helpers/memory_properties_helpers.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
AllocationProperties MemoryPropertiesHelper::getAllocationProperties(
|
||||
uint32_t rootDeviceIndex, MemoryProperties memoryProperties, bool allocateMemory, size_t size,
|
||||
GraphicsAllocation::AllocationType type, bool multiStorageResource, const HardwareInfo &hwInfo,
|
||||
DeviceBitfield subDevicesBitfieldParam, bool deviceOnlyVisibilty) {
|
||||
|
||||
auto deviceBitfield = adjustDeviceBitfield(rootDeviceIndex, memoryProperties, subDevicesBitfieldParam);
|
||||
AllocationProperties allocationProperties(rootDeviceIndex, allocateMemory, size, type, multiStorageResource, deviceBitfield);
|
||||
fillPoliciesInProperties(allocationProperties, memoryProperties, hwInfo, deviceOnlyVisibilty);
|
||||
return allocationProperties;
|
||||
}
|
||||
|
||||
void MemoryPropertiesHelper::fillCachePolicyInProperties(AllocationProperties &allocationProperties, bool uncached, bool readOnly,
|
||||
bool deviceOnlyVisibilty, uint32_t cacheRegion) {
|
||||
allocationProperties.flags.uncacheable = uncached;
|
||||
auto cacheFlushRequired = !uncached && !readOnly && !deviceOnlyVisibilty;
|
||||
allocationProperties.flags.flushL3RequiredForRead = cacheFlushRequired;
|
||||
allocationProperties.flags.flushL3RequiredForWrite = cacheFlushRequired;
|
||||
allocationProperties.cacheRegion = cacheRegion;
|
||||
}
|
||||
|
||||
DeviceBitfield MemoryPropertiesHelper::adjustDeviceBitfield(uint32_t rootDeviceIndex, const MemoryProperties &memoryProperties,
|
||||
DeviceBitfield deviceBitfieldIn) {
|
||||
if (rootDeviceIndex == memoryProperties.pDevice->getRootDeviceIndex()) {
|
||||
return deviceBitfieldIn & memoryProperties.pDevice->getDeviceBitfield();
|
||||
}
|
||||
return deviceBitfieldIn;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "shared/source/command_stream/command_stream_receiver.h"
|
||||
#include "shared/source/helpers/aligned_memory.h"
|
||||
#include "shared/source/helpers/memory_properties_helpers.h"
|
||||
#include "shared/source/memory_manager/memory_manager.h"
|
||||
#include "shared/source/os_interface/hw_info_config.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user