mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 15:53:45 +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
@@ -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