Associate shared-allocations with device in multi-device systems

When a shared-allocation is created in a multi-device system and
no device is passed during the call, then the allocation needs to be
associated with all the devices. For now, that means we default to
creating the shared-allocation in the host, with no device-backing
memory, so all devices can access it.

However, if a device is passed, then the shared-allocation is
expected to be accessed only by that device, and there is no need
to allocate it solely in the host.

Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
This commit is contained in:
Jaime Arteaga
2021-07-29 04:08:26 +00:00
committed by Compute-Runtime-Automation
parent 6024ac536a
commit b057935c7c
2 changed files with 3 additions and 3 deletions

View File

@@ -2629,7 +2629,7 @@ TEST_F(SharedAllocMultiDeviceTests, whenAllocatinSharedMemoryWithNullDeviceInAMu
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
}
TEST_F(SharedAllocMultiDeviceTests, whenAllocatinSharedMemoryWithNonNullDeviceInAMultiDeviceSystemThenHostAllocationIsCreated) {
TEST_F(SharedAllocMultiDeviceTests, whenAllocatinSharedMemoryWithNonNullDeviceInAMultiDeviceSystemThenDeviceAllocationIsCreated) {
ze_device_mem_alloc_desc_t deviceDesc = {};
ze_host_mem_alloc_desc_t hostDesc = {};
void *ptr = nullptr;
@@ -2637,7 +2637,7 @@ TEST_F(SharedAllocMultiDeviceTests, whenAllocatinSharedMemoryWithNonNullDeviceIn
EXPECT_EQ(currSvmAllocsManager->createHostUnifiedMemoryAllocationTimes, 0u);
ze_result_t res = context->allocSharedMem(driverHandle->devices[0]->toHandle(), &deviceDesc, &hostDesc, size, 0u, &ptr);
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
EXPECT_EQ(currSvmAllocsManager->createHostUnifiedMemoryAllocationTimes, 1u);
EXPECT_EQ(currSvmAllocsManager->createHostUnifiedMemoryAllocationTimes, 0u);
res = context->freeMem(ptr);
EXPECT_EQ(res, ZE_RESULT_SUCCESS);

View File

@@ -227,7 +227,7 @@ void *SVMAllocsManager::createUnifiedMemoryAllocation(size_t size,
void *SVMAllocsManager::createSharedUnifiedMemoryAllocation(size_t size,
const UnifiedMemoryProperties &memoryProperties,
void *cmdQ) {
if (memoryProperties.rootDeviceIndices.size() > 1) {
if (memoryProperties.rootDeviceIndices.size() > 1 && memoryProperties.device == nullptr) {
return createHostUnifiedMemoryAllocation(size, memoryProperties);
}