mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
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:
committed by
Compute-Runtime-Automation
parent
06dad67c5a
commit
1b7d7afc07
@@ -268,6 +268,8 @@ ze_result_t DriverHandleImp::initialize(std::vector<std::unique_ptr<NEO::Device>
|
||||
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->debugger = DebuggerL0::create(neoDevice.get());
|
||||
}
|
||||
|
||||
this->rootDeviceIndices.insert(neoDevice->getRootDeviceIndex());
|
||||
this->deviceBitfields.insert({neoDevice->getRootDeviceIndex(), neoDevice->getDeviceBitfield()});
|
||||
auto device = Device::create(this, neoDevice.release(), currentDeviceMask, false);
|
||||
this->devices.push_back(device);
|
||||
}
|
||||
|
||||
@@ -105,6 +105,9 @@ struct DriverHandleImp : public DriverHandle {
|
||||
|
||||
uint32_t numDevices = 0;
|
||||
|
||||
std::set<uint32_t> rootDeviceIndices = {};
|
||||
std::map<uint32_t, NEO::DeviceBitfield> deviceBitfields;
|
||||
|
||||
// Environment Variables
|
||||
bool enableProgramDebugging = false;
|
||||
bool enableSysman = false;
|
||||
|
||||
@@ -59,18 +59,16 @@ ze_result_t EventPoolImp::initialize(DriverHandle *driver, uint32_t numDevices,
|
||||
eventPoolAllocations = new NEO::MultiGraphicsAllocation(maxRootDeviceIndex);
|
||||
|
||||
uint32_t rootDeviceIndex = rootDeviceIndices.at(0);
|
||||
|
||||
NEO::SVMAllocsManager::UnifiedMemoryProperties memoryProperties(InternalMemoryType::HOST_UNIFIED_MEMORY,
|
||||
devices[0]->getNEODevice()->getDeviceBitfield());
|
||||
auto deviceBitfield = devices[0]->getNEODevice()->getDeviceBitfield();
|
||||
|
||||
NEO::AllocationProperties unifiedMemoryProperties{rootDeviceIndex,
|
||||
true,
|
||||
alignUp<size_t>(numEvents * eventSize, MemoryConstants::pageSize64k),
|
||||
isEventPoolUsedForTimestamp ? NEO::GraphicsAllocation::AllocationType::TIMESTAMP_PACKET_TAG_BUFFER
|
||||
: NEO::GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY,
|
||||
memoryProperties.subdeviceBitfield.count() > 1,
|
||||
memoryProperties.subdeviceBitfield.count() > 1,
|
||||
memoryProperties.subdeviceBitfield};
|
||||
deviceBitfield.count() > 1,
|
||||
deviceBitfield.count() > 1,
|
||||
deviceBitfield};
|
||||
unifiedMemoryProperties.alignment = eventAlignment;
|
||||
|
||||
void *eventPoolPtr = driver->getMemoryManager()->createMultiGraphicsAllocation(rootDeviceIndices,
|
||||
|
||||
@@ -114,11 +114,10 @@ ze_result_t DriverHandleImp::allocHostMem(const ze_host_mem_alloc_desc_t *hostDe
|
||||
*ptr = nullptr;
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_SIZE;
|
||||
}
|
||||
NEO::SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::HOST_UNIFIED_MEMORY, this->devices[0]->getNEODevice()->getDeviceBitfield());
|
||||
|
||||
auto usmPtr = svmAllocsManager->createHostUnifiedMemoryAllocation(static_cast<uint32_t>(this->devices.size() - 1),
|
||||
size,
|
||||
unifiedMemoryProperties);
|
||||
NEO::SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::HOST_UNIFIED_MEMORY, this->rootDeviceIndices, this->deviceBitfields);
|
||||
|
||||
auto usmPtr = svmAllocsManager->createHostUnifiedMemoryAllocation(size, unifiedMemoryProperties);
|
||||
if (usmPtr == nullptr) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
}
|
||||
@@ -160,18 +159,22 @@ ze_result_t DriverHandleImp::allocDeviceMem(ze_device_handle_t hDevice, const ze
|
||||
}
|
||||
}
|
||||
|
||||
NEO::SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::DEVICE_UNIFIED_MEMORY,
|
||||
Device::fromHandle(hDevice)->getNEODevice()->getDeviceBitfield());
|
||||
auto neoDevice = Device::fromHandle(hDevice)->getNEODevice();
|
||||
auto rootDeviceIndex = neoDevice->getRootDeviceIndex();
|
||||
auto deviceBitfields = this->deviceBitfields;
|
||||
|
||||
deviceBitfields[rootDeviceIndex] = neoDevice->getDeviceBitfield();
|
||||
|
||||
NEO::SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::DEVICE_UNIFIED_MEMORY, this->rootDeviceIndices, deviceBitfields);
|
||||
unifiedMemoryProperties.allocationFlags.flags.shareable = 1u;
|
||||
unifiedMemoryProperties.device = Device::fromHandle(hDevice)->getNEODevice();
|
||||
unifiedMemoryProperties.device = neoDevice;
|
||||
|
||||
if (deviceDesc->flags & ZE_DEVICE_MEM_ALLOC_FLAG_BIAS_UNCACHED) {
|
||||
unifiedMemoryProperties.allocationFlags.flags.locallyUncachedResource = 1;
|
||||
}
|
||||
|
||||
void *usmPtr =
|
||||
svmAllocsManager->createUnifiedMemoryAllocation(Device::fromHandle(hDevice)->getRootDeviceIndex(),
|
||||
size, unifiedMemoryProperties);
|
||||
svmAllocsManager->createUnifiedMemoryAllocation(size, unifiedMemoryProperties);
|
||||
if (usmPtr == nullptr) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY;
|
||||
}
|
||||
@@ -185,31 +188,33 @@ ze_result_t DriverHandleImp::allocSharedMem(ze_device_handle_t hDevice, const ze
|
||||
size_t size,
|
||||
size_t alignment,
|
||||
void **ptr) {
|
||||
ze_device_handle_t device;
|
||||
void *unifiedMemoryPropertiesDevice = nullptr;
|
||||
if (hDevice == nullptr) {
|
||||
device = this->devices[0];
|
||||
} else {
|
||||
device = hDevice;
|
||||
unifiedMemoryPropertiesDevice = Device::fromHandle(device)->getNEODevice();
|
||||
auto neoDevice = this->devices[0]->getNEODevice();
|
||||
|
||||
auto deviceBitfields = this->deviceBitfields;
|
||||
NEO::Device *unifiedMemoryPropertiesDevice = nullptr;
|
||||
if (hDevice) {
|
||||
neoDevice = Device::fromHandle(hDevice)->getNEODevice();
|
||||
auto rootDeviceIndex = neoDevice->getRootDeviceIndex();
|
||||
unifiedMemoryPropertiesDevice = neoDevice;
|
||||
deviceBitfields[rootDeviceIndex] = neoDevice->getDeviceBitfield();
|
||||
}
|
||||
NEO::SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::SHARED_UNIFIED_MEMORY, Device::fromHandle(device)->getNEODevice()->getDeviceBitfield());
|
||||
|
||||
NEO::SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::SHARED_UNIFIED_MEMORY, this->rootDeviceIndices, deviceBitfields);
|
||||
unifiedMemoryProperties.device = unifiedMemoryPropertiesDevice;
|
||||
|
||||
if (deviceDesc->flags & ZE_DEVICE_MEM_ALLOC_FLAG_BIAS_UNCACHED) {
|
||||
unifiedMemoryProperties.allocationFlags.flags.locallyUncachedResource = 1;
|
||||
}
|
||||
|
||||
if (size > this->devices[0]->getDeviceInfo().maxMemAllocSize) {
|
||||
if (size > neoDevice->getDeviceInfo().maxMemAllocSize) {
|
||||
*ptr = nullptr;
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_SIZE;
|
||||
}
|
||||
|
||||
auto usmPtr =
|
||||
svmAllocsManager->createSharedUnifiedMemoryAllocation(Device::fromHandle(device)->getRootDeviceIndex(),
|
||||
size,
|
||||
svmAllocsManager->createSharedUnifiedMemoryAllocation(size,
|
||||
unifiedMemoryProperties,
|
||||
static_cast<void *>(L0::Device::fromHandle(device)));
|
||||
static_cast<void *>(neoDevice->getSpecializedDevice<L0::Device>()));
|
||||
|
||||
if (usmPtr == nullptr) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY;
|
||||
|
||||
Reference in New Issue
Block a user