Move core part of MemoryPropertiesHelpers to shared

Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2021-10-06 17:00:24 +00:00
committed by Compute-Runtime-Automation
parent afa45bd9e7
commit 48f01f28f5
69 changed files with 454 additions and 411 deletions

View File

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

View 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

View 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

View 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

View File

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