mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 15:53:45 +08:00
feature: add tile-to-lmem-region map in MemoryInfo
Arguments names refreshed to be more explanatory. Related-To: NEO-9754 Signed-off-by: Maciej Bielski <maciej.bielski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
a8e9246f65
commit
ff494d5c50
@@ -60,6 +60,7 @@ set(NEO_CORE_OS_INTERFACE_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/engine_info.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/memory_info.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/memory_info.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}memory_info_populate_tile_to_lmem_region_map.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/numa_library.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/numa_library.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_context_linux.cpp
|
||||
|
||||
@@ -31,6 +31,8 @@ MemoryInfo::MemoryInfo(const RegionContainer ®ionInfo, const Drm &inputDrm)
|
||||
return (memoryRegionInfo.region.memoryClass == memoryClassDevice);
|
||||
});
|
||||
|
||||
populateTileToLocalMemoryRegionIndexMap();
|
||||
|
||||
memPolicySupported = false;
|
||||
if (debugManager.flags.EnableHostAllocationMemPolicy.get()) {
|
||||
memPolicySupported = Linux::NumaLibrary::init();
|
||||
@@ -78,35 +80,37 @@ int MemoryInfo::createGemExt(const MemRegionsVec &memClassInstances, size_t allo
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t MemoryInfo::getTileIndex(uint32_t memoryBank) const {
|
||||
uint32_t MemoryInfo::getLocalMemoryRegionIndex(DeviceBitfield deviceBitfield) const {
|
||||
UNRECOVERABLE_IF(deviceBitfield.count() != 1u);
|
||||
auto &hwInfo = *this->drm.getRootDeviceEnvironment().getHardwareInfo();
|
||||
auto &gfxCoreHelper = this->drm.getRootDeviceEnvironment().getHelper<GfxCoreHelper>();
|
||||
auto &productHelper = this->drm.getRootDeviceEnvironment().getHelper<ProductHelper>();
|
||||
bool bankOverrideRequired{gfxCoreHelper.isBankOverrideRequired(hwInfo, productHelper)};
|
||||
|
||||
auto tileIndex = Math::log2(memoryBank);
|
||||
tileIndex = gfxCoreHelper.isBankOverrideRequired(hwInfo, productHelper) ? 0 : tileIndex;
|
||||
uint32_t tileIndex{bankOverrideRequired ? 0u : Math::log2(deviceBitfield.to_ulong())};
|
||||
if (debugManager.flags.OverrideDrmRegion.get() != -1) {
|
||||
tileIndex = debugManager.flags.OverrideDrmRegion.get();
|
||||
}
|
||||
return tileIndex;
|
||||
UNRECOVERABLE_IF(tileIndex >= tileToLocalMemoryRegionIndexMap.size());
|
||||
return tileToLocalMemoryRegionIndexMap[tileIndex];
|
||||
}
|
||||
|
||||
MemoryClassInstance MemoryInfo::getMemoryRegionClassAndInstance(uint32_t memoryBank, const HardwareInfo &hwInfo) {
|
||||
MemoryClassInstance MemoryInfo::getMemoryRegionClassAndInstance(DeviceBitfield deviceBitfield, const HardwareInfo &hwInfo) {
|
||||
|
||||
auto &gfxCoreHelper = this->drm.getRootDeviceEnvironment().getHelper<GfxCoreHelper>();
|
||||
if (!gfxCoreHelper.getEnableLocalMemory(hwInfo)) {
|
||||
memoryBank = 0;
|
||||
deviceBitfield = 0u;
|
||||
}
|
||||
|
||||
return getMemoryRegion(memoryBank).region;
|
||||
return getMemoryRegion(deviceBitfield).region;
|
||||
}
|
||||
|
||||
const MemoryRegion &MemoryInfo::getMemoryRegion(uint32_t memoryBank) const {
|
||||
if (memoryBank == 0) {
|
||||
const MemoryRegion &MemoryInfo::getMemoryRegion(DeviceBitfield deviceBitfield) const {
|
||||
if (deviceBitfield.count() == 0) {
|
||||
return systemMemoryRegion;
|
||||
}
|
||||
|
||||
auto index = getTileIndex(memoryBank);
|
||||
auto index = getLocalMemoryRegionIndex(deviceBitfield);
|
||||
|
||||
UNRECOVERABLE_IF(index >= localMemoryRegions.size());
|
||||
return localMemoryRegions[index];
|
||||
@@ -134,7 +138,7 @@ int MemoryInfo::createGemExtWithSingleRegion(uint32_t memoryBanks, size_t allocS
|
||||
std::optional<uint32_t> vmId;
|
||||
if (!this->drm.isPerContextVMRequired()) {
|
||||
if (memoryBanks != 0 && debugManager.flags.EnablePrivateBO.get()) {
|
||||
auto tileIndex = getTileIndex(memoryBanks);
|
||||
auto tileIndex = getLocalMemoryRegionIndex(memoryBanks);
|
||||
vmId = this->drm.getVirtualMemoryAddressSpace(tileIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,19 +28,20 @@ class MemoryInfo {
|
||||
|
||||
MOCKABLE_VIRTUAL int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, bool isUSMHostAllocation);
|
||||
|
||||
MemoryClassInstance getMemoryRegionClassAndInstance(uint32_t memoryBank, const HardwareInfo &hwInfo);
|
||||
MemoryClassInstance getMemoryRegionClassAndInstance(DeviceBitfield deviceBitfield, const HardwareInfo &hwInfo);
|
||||
|
||||
MOCKABLE_VIRTUAL size_t getMemoryRegionSize(uint32_t memoryBank) const;
|
||||
|
||||
const MemoryRegion &getMemoryRegion(uint32_t memoryBank) const;
|
||||
const MemoryRegion &getMemoryRegion(DeviceBitfield deviceBitfield) const;
|
||||
|
||||
void printRegionSizes() const;
|
||||
|
||||
uint32_t getTileIndex(uint32_t memoryBank) const;
|
||||
uint32_t getLocalMemoryRegionIndex(DeviceBitfield deviceBitfield) const;
|
||||
|
||||
MOCKABLE_VIRTUAL int createGemExtWithSingleRegion(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, int32_t pairHandle, bool isUSMHostAllocation);
|
||||
MOCKABLE_VIRTUAL int createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, bool isUSMHostAllocation);
|
||||
MOCKABLE_VIRTUAL int createGemExtWithMultipleRegions(uint32_t memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, bool isUSMHostAllocation);
|
||||
void populateTileToLocalMemoryRegionIndexMap();
|
||||
|
||||
const RegionContainer &getLocalMemoryRegions() const { return localMemoryRegions; }
|
||||
const RegionContainer &getDrmRegionInfos() const { return drmQueryRegions; }
|
||||
@@ -54,6 +55,7 @@ class MemoryInfo {
|
||||
bool memPolicySupported;
|
||||
int memPolicyMode;
|
||||
RegionContainer localMemoryRegions;
|
||||
std::array<uint32_t, 4> tileToLocalMemoryRegionIndexMap{};
|
||||
};
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/os_interface/linux/memory_info.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
void MemoryInfo::populateTileToLocalMemoryRegionIndexMap() {
|
||||
for (uint32_t i{0u}; i < tileToLocalMemoryRegionIndexMap.size(); i++) {
|
||||
tileToLocalMemoryRegionIndexMap[i] = i;
|
||||
}
|
||||
}
|
||||
} // namespace NEO
|
||||
Reference in New Issue
Block a user