Refactor USM properties

store reference to std of root device indices and device bitfields
store NEO::Device in USM properties

Related-To: NEO-3691
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2020-12-23 13:47:18 +00:00
committed by Compute-Runtime-Automation
parent 06dad67c5a
commit 1b7d7afc07
27 changed files with 312 additions and 246 deletions

View File

@@ -22,6 +22,8 @@ GraphicsAllocation *allocateGlobalsSurface(NEO::SVMAllocsManager *const svmAlloc
LinkerInput *const linkerInput, const void *initData) {
bool globalsAreExported = false;
GraphicsAllocation *gpuAllocation = nullptr;
auto rootDeviceIndex = device.getRootDeviceIndex();
auto deviceBitfield = device.getDeviceBitfield();
if (linkerInput != nullptr) {
globalsAreExported = constant ? linkerInput->getTraits().exportsGlobalConstants : linkerInput->getTraits().exportsGlobalVariables;
@@ -32,21 +34,26 @@ GraphicsAllocation *allocateGlobalsSurface(NEO::SVMAllocsManager *const svmAlloc
svmProps.coherent = false;
svmProps.readOnly = constant;
svmProps.hostPtrReadOnly = constant;
auto ptr = svmAllocManager->createSVMAlloc(device.getRootDeviceIndex(), size, svmProps, device.getDeviceBitfield());
std::set<uint32_t> rootDeviceIndices;
rootDeviceIndices.insert(rootDeviceIndex);
std::map<uint32_t, DeviceBitfield> subDeviceBitfields;
subDeviceBitfields.insert({rootDeviceIndex, deviceBitfield});
auto ptr = svmAllocManager->createSVMAlloc(size, svmProps, rootDeviceIndices, subDeviceBitfields);
DEBUG_BREAK_IF(ptr == nullptr);
if (ptr == nullptr) {
return nullptr;
}
auto svmAlloc = svmAllocManager->getSVMAlloc(ptr);
UNRECOVERABLE_IF(svmAlloc == nullptr);
gpuAllocation = svmAlloc->gpuAllocations.getGraphicsAllocation(device.getRootDeviceIndex());
gpuAllocation = svmAlloc->gpuAllocations.getGraphicsAllocation(rootDeviceIndex);
} else {
auto allocationType = constant ? GraphicsAllocation::AllocationType::CONSTANT_SURFACE : GraphicsAllocation::AllocationType::GLOBAL_SURFACE;
gpuAllocation = device.getMemoryManager()->allocateGraphicsMemoryWithProperties({device.getRootDeviceIndex(),
gpuAllocation = device.getMemoryManager()->allocateGraphicsMemoryWithProperties({rootDeviceIndex,
true, // allocateMemory
size, allocationType,
false, // isMultiStorageAllocation
device.getDeviceBitfield()});
deviceBitfield});
}
if (!gpuAllocation) {