CLGETDEVICEIDS(3clc)
π CLGETDEVICEIDS π
okay bestie, gather round, because this one is the glow-up moment of your OpenCL journey. This is clGetDeviceIDs, a lil function from the OpenCL Manual (section 3clc), and it's literally how you find out what hardware you've got to work with. It's giving "let me introduce you to your own computer." π
β¨ NAME β¨
clGetDeviceIDs β obtain the list of devices available on a platform.
cl_int clGetDeviceIDs(cl_platform_id platform,
cl_device_type device_type, cl_uint num_entries,
cl_device_id *devices, cl_uint *num_devices);
πΈ PARAMETERS πΈ
platformβ this is the platform ID thatclGetPlatformIDs(3clc)handed you earlier, OR you can just passNULL. Heads up though: ifplatformisNULL, the behavior is implementation-defined, which is fancy speak for "whatever your vendor felt like doing that day, no promises." πdevice_typeβ a bitfield that says what kind of OpenCL device you're looking for. You can use it to hunt down one specific type of device or just vibe-check everything that's available. The valid values fordevice_typeare:CL_DEVICE_TYPE_CPUβ an OpenCL device that is the host processor. The host processor runs the OpenCL implementations and is a single or multi-core CPU. πCL_DEVICE_TYPE_GPUβ an OpenCL device that is a GPU. And by "GPU" we mean the device can also be used to accelerate a 3D API such as OpenGL or DirectX. β¨CL_DEVICE_TYPE_ACCELERATORβ dedicated OpenCL accelerators (for example the IBM CELL Blade). These devices communicate with the host processor using a peripheral interconnect such as PCIe. π₯CL_DEVICE_TYPE_CUSTOMβ dedicated accelerators that do not support programs written in OpenCL C. πCL_DEVICE_TYPE_DEFAULTβ the default OpenCL device in the system. And no, the default device cannot be aCL_DEVICE_TYPE_CUSTOMdevice. periodt.CL_DEVICE_TYPE_ALLβ all OpenCL devices available in the system, exceptCL_DEVICE_TYPE_CUSTOMdevices. π¦
num_entriesβ how manycl_device_identries can be added todevices. Ifdevicesis notNULL, thennum_entriesmust be greater than zero, no exceptions bestie.devicesβ the list of OpenCL devices that got found. Thecl_device_idvalues returned indevicescan be used to identify a specific OpenCL device. If thedevicesargument isNULL, this argument is ignored. The number of OpenCL devices returned is the minimum of the value specified bynum_entriesor the number of OpenCL devices whose type matchesdevice_type. π«Άnum_devicesβ the number of OpenCL devices available that matchdevice_type. Ifnum_devicesisNULL, this argument is ignored.
π NOTES π
clGetDeviceIDs may return all or a subset of the actual physical devices present in the platform that match device_type. So like... don't be shocked if the list is shorter than your hardware's potential. π
π ERRORS π
clGetDeviceIDs returns CL_SUCCESS if the function is executed successfully. Otherwise it returns one of the following:
CL_INVALID_PLATFORMifplatformis not a valid platform.CL_INVALID_DEVICE_TYPEifdevice_typeis not a valid value.CL_INVALID_VALUEifnum_entriesis equal to zero anddevicesis notNULLor if bothnum_devicesanddevicesareNULL.CL_DEVICE_NOT_FOUNDif no OpenCL devices that matcheddevice_typewere found. πCL_OUT_OF_RESOURCESif there is a failure to allocate resources required by the OpenCL implementation on the device.CL_OUT_OF_HOST_MEMORYif there is a failure to allocate resources required by the OpenCL implementation on the host.
π SPECIFICATION π
OpenCL Specification[1]
π SEE ALSO π
clGetDeviceInfo(3clc), clGetPlatformIDs(3clc), clCreateContext(3clc), classDiagram(3clc)
π§ AUTHORS π§
The Khronos Group
π COPYRIGHT π
Copyright Β© 2007-2011 The Khronos Group Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials.
β NOTES β
- OpenCL Specification β page 35, section 4.2 - Querying Devices
and that's the whole page bestie, you ate that π
This gorgeous lil number is brought to you by The Khronos Group, dated 01/14/2021, living its best life as CLGETDEVICEIDS(3clc). iykyk π¦β¨
π¦ where this page comes from
- ubuntu jammy: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- ubuntu noble: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms