fix: do not force root device when opening IPC handles

Related-To: NEO-9422

Signed-off-by: Lu, Wenbin <wenbin.lu@intel.com>
This commit is contained in:
Lu, Wenbin 2024-01-11 22:33:05 +00:00 committed by Compute-Runtime-Automation
parent 4af79b99cc
commit 0db5b630c9
2 changed files with 48 additions and 3 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Intel Corporation
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -721,7 +721,7 @@ ze_result_t ContextImp::openIpcMemHandles(ze_device_handle_t hDevice,
handles.push_back(static_cast<NEO::osHandle>(handle));
}
auto neoDevice = Device::fromHandle(hDevice)->getNEODevice()->getRootDevice();
auto neoDevice = Device::fromHandle(hDevice)->getNEODevice();
NEO::SvmAllocationData allocDataInternal(neoDevice->getRootDeviceIndex());
*pptr = this->driverHandle->importFdHandles(neoDevice, flags, handles, nullptr, nullptr, allocDataInternal);
if (nullptr == *pptr) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Intel Corporation
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -4670,6 +4670,51 @@ TEST_F(MultipleDevicePeerAllocationTest,
ASSERT_EQ(result, ZE_RESULT_SUCCESS);
}
TEST_F(MultipleDevicePeerAllocationTest,
whenGettingAllocationProperityOfAnIpcBufferThenTheSameSubDeviceIsReturned) {
for (auto l0Device : driverHandle->devices) {
uint32_t nSubDevices = 0;
EXPECT_EQ(ZE_RESULT_SUCCESS, l0Device->getSubDevices(&nSubDevices, nullptr));
EXPECT_EQ(numSubDevices, nSubDevices);
std::vector<ze_device_handle_t> subDevices(nSubDevices);
EXPECT_EQ(ZE_RESULT_SUCCESS, l0Device->getSubDevices(&nSubDevices, subDevices.data()));
for (auto subDevice : subDevices) {
constexpr size_t size = 1ul << 18;
ze_device_mem_alloc_desc_t deviceDesc{};
void *ptr = nullptr;
EXPECT_EQ(ZE_RESULT_SUCCESS, context->allocDeviceMem(subDevice, &deviceDesc, size, 1ul, &ptr));
EXPECT_NE(nullptr, ptr);
uint32_t numIpcHandles = 0;
EXPECT_EQ(ZE_RESULT_SUCCESS, context->getIpcMemHandles(ptr, &numIpcHandles, nullptr));
EXPECT_EQ(numIpcHandles, 2u);
std::vector<ze_ipc_mem_handle_t> ipcHandles(numIpcHandles);
EXPECT_EQ(ZE_RESULT_SUCCESS, context->getIpcMemHandles(ptr, &numIpcHandles, ipcHandles.data()));
void *ipcPtr = nullptr;
EXPECT_EQ(ZE_RESULT_SUCCESS, context->openIpcMemHandles(subDevice, numIpcHandles, ipcHandles.data(), 0, &ipcPtr));
EXPECT_NE(nullptr, ipcPtr);
ze_device_handle_t registeredDevice = nullptr;
ze_memory_allocation_properties_t allocProp{};
EXPECT_EQ(ZE_RESULT_SUCCESS, context->getMemAllocProperties(ipcPtr, &allocProp, &registeredDevice));
EXPECT_EQ(ZE_MEMORY_TYPE_DEVICE, allocProp.type);
EXPECT_EQ(subDevice, registeredDevice);
EXPECT_EQ(ZE_RESULT_SUCCESS, context->closeIpcMemHandle(ipcPtr));
for (auto &ipcHandle : ipcHandles) {
EXPECT_EQ(ZE_RESULT_SUCCESS, context->putIpcMemHandle(ipcHandle));
}
EXPECT_EQ(ZE_RESULT_SUCCESS, context->freeMem(ptr));
}
}
}
struct MemoryFailedOpenIpcHandleTest : public ::testing::Test {
void SetUp() override {