Respect EnableMultiRootDeviceContexts when creating context from type

Related-To: NEO-3691
Change-Id: Ib61ddfe1e5df5ed7611ed785fadd305a49ef204a
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2020-10-26 16:10:06 +01:00
committed by sys_ocldev
parent 2eea76e086
commit 3bcc073b26
2 changed files with 54 additions and 3 deletions

View File

@ -100,4 +100,51 @@ TEST_F(clCreateContextFromTypeTests, GivenNonDefaultPlatformWithInvalidIcdDispat
EXPECT_EQ(nullptr, clContext);
}
TEST(clCreateContextFromTypeTest, GivenPlatformWithMultipleDevicesAndMultiRootDeviceContextsAreEnabledWhenCreatingContextFromTypeThenContextContainsAllDevices) {
DebugManagerStateRestore restorer;
DebugManager.flags.CreateMultipleRootDevices.set(2);
DebugManager.flags.EnableMultiRootDeviceContexts.set(true);
initPlatform();
cl_int retVal = CL_INVALID_CONTEXT;
auto context =
clCreateContextFromType(nullptr, CL_DEVICE_TYPE_GPU, nullptr, nullptr, &retVal);
ASSERT_EQ(CL_SUCCESS, retVal);
ASSERT_NE(nullptr, context);
auto pContext = castToObject<Context>(context);
EXPECT_EQ(2u, pContext->getNumDevices());
EXPECT_EQ(platform()->getClDevice(0), pContext->getDevice(0));
EXPECT_EQ(platform()->getClDevice(1), pContext->getDevice(1));
retVal = clReleaseContext(context);
ASSERT_EQ(CL_SUCCESS, retVal);
}
TEST(clCreateContextFromTypeTest, GivenPlatformWithMultipleDevicesAndMultiRootDeviceContextsAreDisabledWhenCreatingContextFromTypeThenContextContainsOnlyOneDevice) {
DebugManagerStateRestore restorer;
DebugManager.flags.CreateMultipleRootDevices.set(2);
DebugManager.flags.EnableMultiRootDeviceContexts.set(false);
initPlatform();
cl_int retVal = CL_INVALID_CONTEXT;
auto context =
clCreateContextFromType(nullptr, CL_DEVICE_TYPE_GPU, nullptr, nullptr, &retVal);
ASSERT_EQ(CL_SUCCESS, retVal);
ASSERT_NE(nullptr, context);
auto pContext = castToObject<Context>(context);
EXPECT_EQ(1u, pContext->getNumDevices());
EXPECT_EQ(platform()->getClDevice(0), pContext->getDevice(0));
retVal = clReleaseContext(context);
ASSERT_EQ(CL_SUCCESS, retVal);
}
} // namespace ULT