From 0602a9c2850c230c92a0385b0bdffc9ed4bda480 Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Tue, 25 May 2021 17:22:20 +0000 Subject: [PATCH] Use only one device when creating context from type Related-To: NEO-3691 Signed-off-by: Mateusz Jablonski --- opencl/source/api/api.cpp | 11 +++----- .../api/cl_create_context_from_type_tests.inl | 27 +------------------ 2 files changed, 4 insertions(+), 34 deletions(-) diff --git a/opencl/source/api/api.cpp b/opencl/source/api/api.cpp index e315761da9..8440cefca0 100644 --- a/opencl/source/api/api.cpp +++ b/opencl/source/api/api.cpp @@ -438,17 +438,12 @@ cl_context CL_API_CALL clCreateContextFromType(const cl_context_properties *prop } DEBUG_BREAK_IF(numDevices <= 0); - StackVec supportedDevs; - supportedDevs.resize(numDevices); + cl_device_id device = nullptr; - retVal = clGetDeviceIDs(pPlatform, deviceType, numDevices, supportedDevs.begin(), nullptr); + retVal = clGetDeviceIDs(pPlatform, deviceType, 1, &device, nullptr); DEBUG_BREAK_IF(retVal != CL_SUCCESS); - if (!DebugManager.flags.EnableMultiRootDeviceContexts.get()) { - numDevices = 1u; - } - - ClDeviceVector deviceVector(supportedDevs.begin(), numDevices); + ClDeviceVector deviceVector(&device, 1); pContext = Context::create(properties, deviceVector, funcNotify, userData, retVal); } while (false); diff --git a/opencl/test/unit_test/api/cl_create_context_from_type_tests.inl b/opencl/test/unit_test/api/cl_create_context_from_type_tests.inl index 3da1539cb6..91611c76bd 100644 --- a/opencl/test/unit_test/api/cl_create_context_from_type_tests.inl +++ b/opencl/test/unit_test/api/cl_create_context_from_type_tests.inl @@ -104,34 +104,9 @@ TEST_F(clCreateContextFromTypeTests, GivenNonDefaultPlatformWithInvalidIcdDispat EXPECT_EQ(nullptr, clContext); } -TEST(clCreateContextFromTypeTest, GivenPlatformWithMultipleDevicesAndMultiRootDeviceContextsAreEnabledWhenCreatingContextFromTypeThenContextContainsAllDevices) { +TEST(clCreateContextFromTypeTest, GivenPlatformWithMultipleDevicesWhenCreatingContextFromTypeThenContextContainsOnlyOneDevice) { 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); - 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();