Add createMultiGraphicsAllocation function in memory_manager

Related-To: NEO-4589
Change-Id: I0019437e565c06ac2494630182c4df685487853d
Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
Krzysztof Gibala
2020-08-21 13:10:59 +02:00
committed by sys_ocldev
parent a7e15b250c
commit 1c0e2430c5
3 changed files with 43 additions and 23 deletions

View File

@@ -135,6 +135,36 @@ GraphicsAllocation *MemoryManager::createPaddedAllocation(GraphicsAllocation *in
return allocateGraphicsMemoryWithProperties({inputGraphicsAllocation->getRootDeviceIndex(), sizeWithPadding, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY, systemMemoryBitfield});
}
void *MemoryManager::createMultiGraphicsAllocation(std::vector<uint32_t> &rootDeviceIndices, AllocationProperties &properties, MultiGraphicsAllocation &multiGraphicsAllocation) {
void *ptr = nullptr;
for (auto &rootDeviceIndex : rootDeviceIndices) {
properties.rootDeviceIndex = rootDeviceIndex;
if (!ptr) {
auto graphicsAllocation = allocateGraphicsMemoryWithProperties(properties);
if (!graphicsAllocation) {
return nullptr;
}
multiGraphicsAllocation.addAllocation(graphicsAllocation);
ptr = reinterpret_cast<void *>(graphicsAllocation->getGpuAddress());
} else {
properties.flags.allocateMemory = false;
auto graphicsAllocation = allocateGraphicsMemoryWithProperties(properties, ptr);
if (!graphicsAllocation) {
for (auto gpuAllocation : multiGraphicsAllocation.getGraphicsAllocations()) {
freeGraphicsMemory(gpuAllocation);
}
return nullptr;
}
multiGraphicsAllocation.addAllocation(graphicsAllocation);
}
}
return ptr;
}
void MemoryManager::freeSystemMemory(void *ptr) {
::alignedFree(ptr);
}