mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-07 21:27:04 +08:00
Isolate host allocations with respect to context
Related-To: LOCI-1996 Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
bf90fabcd2
commit
0dc73ad686
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -39,18 +39,27 @@ DriverHandle *ContextImp::getDriverHandle() {
|
||||
}
|
||||
|
||||
ContextImp::ContextImp(DriverHandle *driverHandle) {
|
||||
this->driverHandle = driverHandle;
|
||||
this->driverHandle = static_cast<DriverHandleImp *>(driverHandle);
|
||||
}
|
||||
|
||||
ze_result_t ContextImp::allocHostMem(const ze_host_mem_alloc_desc_t *hostDesc,
|
||||
size_t size,
|
||||
size_t alignment,
|
||||
void **ptr) {
|
||||
DEBUG_BREAK_IF(nullptr == this->driverHandle);
|
||||
return this->driverHandle->allocHostMem(hostDesc,
|
||||
size,
|
||||
alignment,
|
||||
ptr);
|
||||
|
||||
NEO::SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::HOST_UNIFIED_MEMORY,
|
||||
this->rootDeviceIndices,
|
||||
this->subDeviceBitfields);
|
||||
|
||||
auto usmPtr = this->driverHandle->svmAllocsManager->createHostUnifiedMemoryAllocation(size,
|
||||
unifiedMemoryProperties);
|
||||
if (usmPtr == nullptr) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
}
|
||||
|
||||
*ptr = usmPtr;
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t ContextImp::allocDeviceMem(ze_device_handle_t hDevice,
|
||||
|
||||
@@ -113,9 +113,12 @@ struct ContextImp : Context {
|
||||
return devices;
|
||||
}
|
||||
|
||||
std::set<uint32_t> rootDeviceIndices = {};
|
||||
std::map<uint32_t, NEO::DeviceBitfield> subDeviceBitfields;
|
||||
|
||||
protected:
|
||||
std::vector<Device *> devices;
|
||||
DriverHandle *driverHandle = nullptr;
|
||||
DriverHandleImp *driverHandle = nullptr;
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
|
||||
@@ -38,8 +38,6 @@ struct DriverHandle : _ze_driver_handle_t {
|
||||
ze_memory_allocation_properties_t *pMemAllocProperties,
|
||||
ze_device_handle_t *phDevice) = 0;
|
||||
|
||||
virtual ze_result_t allocHostMem(const ze_host_mem_alloc_desc_t *hostDesc, size_t size, size_t alignment, void **ptr) = 0;
|
||||
|
||||
virtual ze_result_t allocDeviceMem(ze_device_handle_t hDevice, const ze_device_mem_alloc_desc_t *deviceDesc, size_t size,
|
||||
size_t alignment, void **ptr) = 0;
|
||||
|
||||
|
||||
@@ -52,6 +52,13 @@ ze_result_t DriverHandleImp::createContext(const ze_context_desc_t *desc,
|
||||
}
|
||||
}
|
||||
|
||||
for (auto device : context->getDevices()) {
|
||||
auto neoDevice = device->getNEODevice();
|
||||
context->rootDeviceIndices.insert(neoDevice->getRootDeviceIndex());
|
||||
context->subDeviceBitfields.insert({neoDevice->getRootDeviceIndex(),
|
||||
neoDevice->getDeviceBitfield()});
|
||||
}
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,6 @@ struct DriverHandleImp : public DriverHandle {
|
||||
ze_memory_allocation_properties_t *pMemAllocProperties,
|
||||
ze_device_handle_t *phDevice) override;
|
||||
|
||||
ze_result_t allocHostMem(const ze_host_mem_alloc_desc_t *hostDesc, size_t size, size_t alignment, void **ptr) override;
|
||||
|
||||
ze_result_t allocDeviceMem(ze_device_handle_t hDevice, const ze_device_mem_alloc_desc_t *deviceDesc, size_t size,
|
||||
size_t alignment, void **ptr) override;
|
||||
|
||||
|
||||
@@ -112,25 +112,6 @@ ze_result_t DriverHandleImp::getMemAddressRange(const void *ptr, void **pBase, s
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
ze_result_t DriverHandleImp::allocHostMem(const ze_host_mem_alloc_desc_t *hostDesc, size_t size, size_t alignment,
|
||||
void **ptr) {
|
||||
if (size > this->devices[0]->getDeviceInfo().maxMemAllocSize) {
|
||||
*ptr = nullptr;
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_SIZE;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
*ptr = usmPtr;
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t DriverHandleImp::allocDeviceMem(ze_device_handle_t hDevice, const ze_device_mem_alloc_desc_t *deviceDesc,
|
||||
size_t size, size_t alignment, void **ptr) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user