mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-19 06:24:51 +08:00
feature: prepare StorageInfo for Drm-specific customization
Get the local memory regions count from the primary source (MemoryInfo) and store for further use when using DrmMemoryManager. Add a point of dispatch (virtual `createStorageInfoFromProperties`) for further Drm-specific customizations related to StorageInfo. As the function became virtual, move one of its callers (`isLocalMemoryUsedForIsa()`) from the constructor of `MemoryManager` to respective constructors of all derivative classes. This prevents bypassing the virtual call dispatch. Related-To: NEO-9754 Signed-off-by: Maciej Bielski <maciej.bielski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
caea55015f
commit
dc32da2507
@@ -72,7 +72,6 @@ MemoryManager::MemoryManager(ExecutionEnvironment &executionEnvironment) : execu
|
||||
gfxPartitions.push_back(std::make_unique<GfxPartition>(reservedCpuAddressRange));
|
||||
|
||||
anyLocalMemorySupported |= this->localMemorySupported[rootDeviceIndex];
|
||||
isLocalMemoryUsedForIsa(rootDeviceIndex);
|
||||
|
||||
auto globalHeap = ApiSpecificConfig::getGlobalBindlessHeapConfiguration(rootDeviceEnvironment.getReleaseHelper());
|
||||
heapAssigners.push_back(std::make_unique<HeapAssigner>(globalHeap));
|
||||
|
||||
@@ -300,7 +300,7 @@ class MemoryManager {
|
||||
static bool isCopyRequired(ImageInfo &imgInfo, const void *hostPtr);
|
||||
|
||||
bool useNonSvmHostPtrAlloc(AllocationType allocationType, uint32_t rootDeviceIndex);
|
||||
StorageInfo createStorageInfoFromProperties(const AllocationProperties &properties);
|
||||
virtual StorageInfo createStorageInfoFromProperties(const AllocationProperties &properties);
|
||||
|
||||
virtual GraphicsAllocation *createGraphicsAllocation(OsHandleStorage &handleStorage, const AllocationData &allocationData) = 0;
|
||||
virtual GraphicsAllocation *allocateGraphicsMemoryForNonSvmHostPtr(const AllocationData &allocationData) = 0;
|
||||
|
||||
@@ -51,6 +51,7 @@ void OsAgnosticMemoryManager::initialize(bool aubUsage) {
|
||||
initialized = false;
|
||||
return;
|
||||
}
|
||||
isLocalMemoryUsedForIsa(rootDeviceIndex);
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
|
||||
@@ -100,6 +100,7 @@ DrmMemoryManager::DrmMemoryManager(GemCloseWorkerMode mode,
|
||||
void DrmMemoryManager::initialize(GemCloseWorkerMode mode) {
|
||||
bool disableGemCloseWorker = true;
|
||||
|
||||
localMemBanksCount.resize(localMemorySupported.size());
|
||||
for (uint32_t rootDeviceIndex = 0; rootDeviceIndex < gfxPartitions.size(); ++rootDeviceIndex) {
|
||||
auto gpuAddressSpace = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo()->capabilityTable.gpuAddressSpace;
|
||||
uint64_t gfxTop{};
|
||||
@@ -109,7 +110,9 @@ void DrmMemoryManager::initialize(GemCloseWorkerMode mode) {
|
||||
return;
|
||||
}
|
||||
localMemAllocs.emplace_back();
|
||||
setLocalMemBanksCount(rootDeviceIndex);
|
||||
disableGemCloseWorker &= getDrm(rootDeviceIndex).isVmBindAvailable();
|
||||
isLocalMemoryUsedForIsa(rootDeviceIndex);
|
||||
}
|
||||
|
||||
if (disableGemCloseWorker) {
|
||||
@@ -140,6 +143,13 @@ void DrmMemoryManager::initialize(GemCloseWorkerMode mode) {
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
void DrmMemoryManager::setLocalMemBanksCount(uint32_t rootDeviceIndex) {
|
||||
const auto &drm = getDrm(rootDeviceIndex);
|
||||
if (localMemorySupported[rootDeviceIndex] && drm.getMemoryInfo()) {
|
||||
localMemBanksCount[rootDeviceIndex] = drm.getMemoryInfo()->getLocalMemoryRegions().size();
|
||||
}
|
||||
};
|
||||
|
||||
BufferObject *DrmMemoryManager::createRootDeviceBufferObject(uint32_t rootDeviceIndex) {
|
||||
BufferObject *bo = nullptr;
|
||||
if (forcePinEnabled || validateHostPtrMemory) {
|
||||
@@ -339,6 +349,12 @@ void DrmMemoryManager::emitPinningRequest(BufferObject *bo, const AllocationData
|
||||
}
|
||||
}
|
||||
|
||||
StorageInfo DrmMemoryManager::createStorageInfoFromProperties(const AllocationProperties &properties) {
|
||||
auto storageInfo{MemoryManager::createStorageInfoFromProperties(properties)};
|
||||
|
||||
return storageInfo;
|
||||
}
|
||||
|
||||
GraphicsAllocation *DrmMemoryManager::createGraphicsAllocation(OsHandleStorage &handleStorage, const AllocationData &allocationData) {
|
||||
auto hostPtr = const_cast<void *>(allocationData.hostPtr);
|
||||
auto gmmHelper = getGmmHelper(allocationData.rootDeviceIndex);
|
||||
|
||||
@@ -118,6 +118,7 @@ class DrmMemoryManager : public MemoryManager {
|
||||
OsContextLinux *getDefaultOsContext(uint32_t rootDeviceIndex) const;
|
||||
size_t getUserptrAlignment();
|
||||
|
||||
StorageInfo createStorageInfoFromProperties(const AllocationProperties &properties) override;
|
||||
GraphicsAllocation *createGraphicsAllocation(OsHandleStorage &handleStorage, const AllocationData &allocationData) override;
|
||||
GraphicsAllocation *allocateGraphicsMemoryForNonSvmHostPtr(const AllocationData &allocationData) override;
|
||||
GraphicsAllocation *allocateGraphicsMemoryWithAlignment(const AllocationData &allocationData) override;
|
||||
@@ -159,6 +160,7 @@ class DrmMemoryManager : public MemoryManager {
|
||||
void releaseBufferObject(uint32_t rootDeviceIndex);
|
||||
bool retrieveMmapOffsetForBufferObject(uint32_t rootDeviceIndex, BufferObject &bo, uint64_t flags, uint64_t &offset);
|
||||
BufferObject::BOType getBOTypeFromPatIndex(uint64_t patIndex, bool isPatIndexSupported) const;
|
||||
void setLocalMemBanksCount(uint32_t rootDeviceIndex);
|
||||
|
||||
std::vector<BufferObject *> pinBBs;
|
||||
std::vector<void *> memoryForPinBBs;
|
||||
@@ -174,6 +176,7 @@ class DrmMemoryManager : public MemoryManager {
|
||||
|
||||
std::map<int, BufferObjectHandleWrapper> sharedBoHandles;
|
||||
std::vector<std::vector<GraphicsAllocation *>> localMemAllocs;
|
||||
std::vector<size_t> localMemBanksCount;
|
||||
std::vector<GraphicsAllocation *> sysMemAllocs;
|
||||
std::mutex allocMutex;
|
||||
};
|
||||
|
||||
@@ -58,6 +58,7 @@ WddmMemoryManager::WddmMemoryManager(ExecutionEnvironment &executionEnvironment)
|
||||
for (uint32_t rootDeviceIndex = 0; rootDeviceIndex < gfxPartitions.size(); ++rootDeviceIndex) {
|
||||
mallocRestrictions.minAddress = std::max(mallocRestrictions.minAddress, getWddm(rootDeviceIndex).getWddmMinAddress());
|
||||
getWddm(rootDeviceIndex).initGfxPartition(*getGfxPartition(rootDeviceIndex), rootDeviceIndex, gfxPartitions.size(), heapAssigners[rootDeviceIndex]->apiAllowExternalHeapForSshAndDsh);
|
||||
isLocalMemoryUsedForIsa(rootDeviceIndex);
|
||||
}
|
||||
|
||||
alignmentSelector.addCandidateAlignment(MemoryConstants::pageSize64k, true, AlignmentSelector::anyWastage);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2023 Intel Corporation
|
||||
* Copyright (C) 2019-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "shared/test/common/mocks/linux/mock_drm_command_stream_receiver.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
#include "shared/test/common/mocks/mock_execution_environment.h"
|
||||
#include "shared/test/common/os_interface/linux/drm_mock_memory_info.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
@@ -62,11 +63,13 @@ class DrmCommandStreamTest : public ::testing::Test {
|
||||
csr->setupContext(*osContext);
|
||||
|
||||
mock->ioctlCallsCount = 0u;
|
||||
mock->memoryInfo.reset(new MockMemoryInfo{*mock});
|
||||
memoryManager = new DrmMemoryManager(GemCloseWorkerMode::gemCloseWorkerActive,
|
||||
debugManager.flags.EnableForcePin.get(),
|
||||
true,
|
||||
executionEnvironment);
|
||||
executionEnvironment.memoryManager.reset(memoryManager);
|
||||
mock->memoryInfo.reset();
|
||||
// Memory manager creates pinBB with ioctl, expect one call
|
||||
EXPECT_EQ(1u, mock->ioctlCallsCount);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user