Skip to content

Commit 5c6018b

Browse files
OCL: Enable creating context with multiple devices without subdevices
Related-To: NEO-3691 Signed-off-by: Mateusz Jablonski <[email protected]>
1 parent 2ce63fd commit 5c6018b

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

opencl/source/context/context.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,15 @@ bool Context::createImpl(const cl_context_properties *properties,
178178
return false;
179179
}
180180

181+
bool containsDeviceWithSubdevices = false;
181182
for (const auto &device : inputDevices) {
182183
rootDeviceIndices.insert(device->getRootDeviceIndex());
184+
containsDeviceWithSubdevices |= device->getNumAvailableDevices() > 1;
183185
}
184186

185187
this->driverDiagnostics = driverDiagnostics.release();
186-
if (rootDeviceIndices.size() > 1 && !DebugManager.flags.EnableMultiRootDeviceContexts.get()) {
187-
DEBUG_BREAK_IF("No support for context with multiple root devices");
188+
if (rootDeviceIndices.size() > 1 && containsDeviceWithSubdevices && !DebugManager.flags.EnableMultiRootDeviceContexts.get()) {
189+
DEBUG_BREAK_IF("No support for context with multiple devices with subdevices");
188190
errcodeRet = CL_OUT_OF_HOST_MEMORY;
189191
return false;
190192
}

opencl/test/unit_test/api/cl_create_context_tests.inl

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,34 @@ TEST_F(clCreateContextTests, GivenNullUserDataWhenCreatingContextThenContextIsCr
8383
EXPECT_EQ(CL_SUCCESS, retVal);
8484
}
8585

86-
TEST_F(clCreateContextTests, givenMultipleRootDevicesWhenCreateContextThenOutOrHostMemoryErrorIsReturned) {
86+
TEST_F(clCreateContextTests, givenMultipleRootDevicesWithoutSubDevicesWhenCreatingContextThenContextIsCreated) {
8787
UltClDeviceFactory deviceFactory{2, 0};
8888
cl_device_id devices[] = {deviceFactory.rootDevices[0], deviceFactory.rootDevices[1]};
8989
auto context = clCreateContext(nullptr, 2u, devices, eventCallBack, nullptr, &retVal);
90+
EXPECT_NE(nullptr, context);
91+
EXPECT_EQ(CL_SUCCESS, retVal);
92+
clReleaseContext(context);
93+
}
94+
95+
TEST_F(clCreateContextTests, givenMultipleSubDevicesFromDifferentRootDevicesWhenCreatingContextThenContextIsCreated) {
96+
UltClDeviceFactory deviceFactory{2, 2};
97+
cl_device_id devices[] = {deviceFactory.subDevices[0], deviceFactory.subDevices[1], deviceFactory.subDevices[2], deviceFactory.subDevices[3]};
98+
auto context = clCreateContext(nullptr, 4u, devices, eventCallBack, nullptr, &retVal);
99+
EXPECT_NE(nullptr, context);
100+
EXPECT_EQ(CL_SUCCESS, retVal);
101+
clReleaseContext(context);
102+
}
103+
104+
TEST_F(clCreateContextTests, givenMultipleRootDevicesWithSubDevicesWhenCreatingContextThenOutOfHostMemoryErrorIsReturned) {
105+
UltClDeviceFactory deviceFactory{2, 2};
106+
cl_device_id devices[] = {deviceFactory.rootDevices[0], deviceFactory.rootDevices[1]};
107+
auto context = clCreateContext(nullptr, 2u, devices, eventCallBack, nullptr, &retVal);
90108
EXPECT_EQ(nullptr, context);
91109
EXPECT_EQ(CL_OUT_OF_HOST_MEMORY, retVal);
92110
}
93111

94-
TEST_F(clCreateContextTests, givenEnabledMultipleRootDeviceSupportWhenCreateContextWithMultipleRootDevicesThenContextIsCreated) {
95-
UltClDeviceFactory deviceFactory{2, 0};
112+
TEST_F(clCreateContextTests, givenEnabledMultipleRootDeviceSupportWhenCreateContextWithMultipleRootDevicesWithSubDevicesThenContextIsCreated) {
113+
UltClDeviceFactory deviceFactory{2, 2};
96114
DebugManager.flags.EnableMultiRootDeviceContexts.set(true);
97115
cl_device_id devices[] = {deviceFactory.rootDevices[0], deviceFactory.rootDevices[1]};
98116
auto context = clCreateContext(nullptr, 2u, devices, eventCallBack, nullptr, &retVal);

0 commit comments

Comments
 (0)