diff --git a/opencl/source/api/api.cpp b/opencl/source/api/api.cpp index b4014b2af1..1267f085d9 100644 --- a/opencl/source/api/api.cpp +++ b/opencl/source/api/api.cpp @@ -494,12 +494,12 @@ cl_context CL_API_CALL clCreateContextFromType(const cl_context_properties *prop } DEBUG_BREAK_IF(numDevices <= 0); - cl_device_id device = nullptr; + std::vector devices(numDevices, nullptr); - retVal = clGetDeviceIDs(pPlatform, deviceType, 1, &device, nullptr); + retVal = clGetDeviceIDs(pPlatform, deviceType, numDevices, devices.data(), nullptr); DEBUG_BREAK_IF(retVal != CL_SUCCESS); - ClDeviceVector deviceVector(&device, 1); + ClDeviceVector deviceVector(devices.data(), numDevices); context = 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 3b8d05ab48..e7b9acf390 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 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2023 Intel Corporation + * Copyright (C) 2018-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -106,7 +106,7 @@ TEST_F(ClCreateContextFromTypeTests, GivenNonDefaultPlatformWithInvalidIcdDispat EXPECT_EQ(nullptr, clContext); } -TEST(clCreateContextFromTypeTest, GivenPlatformWithMultipleDevicesWhenCreatingContextFromTypeThenContextContainsOnlyOneDevice) { +TEST(clCreateContextFromTypeTest, GivenPlatformWithMultipleDevicesWhenCreatingContextFromTypeThenContextContainsAllDevices) { DebugManagerStateRestore restorer; debugManager.flags.CreateMultipleRootDevices.set(2); @@ -121,8 +121,9 @@ TEST(clCreateContextFromTypeTest, GivenPlatformWithMultipleDevicesWhenCreatingCo ASSERT_NE(nullptr, context); auto pContext = castToObject(context); - EXPECT_EQ(1u, pContext->getNumDevices()); + 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);