mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-30 09:58:55 +08:00
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:
committed by
sys_ocldev
parent
a7e15b250c
commit
1c0e2430c5
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user