CLGETDEVICEIDS(3clc)

πŸ“¦
version 1.0~svn33624 Β· 3 versions
, in ubuntu jammy, ubuntu noble

πŸ’– 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 that clGetPlatformIDs(3clc) handed you earlier, OR you can just pass NULL. Heads up though: if platform is NULL, 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 for device_type are:
    • 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 a CL_DEVICE_TYPE_CUSTOM device. periodt.
    • CL_DEVICE_TYPE_ALL β€” all OpenCL devices available in the system, except CL_DEVICE_TYPE_CUSTOM devices. πŸ¦‹
  • num_entries β€” how many cl_device_id entries can be added to devices. If devices is not NULL, then num_entries must be greater than zero, no exceptions bestie.
  • devices β€” the list of OpenCL devices that got found. The cl_device_id values returned in devices can be used to identify a specific OpenCL device. If the devices argument is NULL, this argument is ignored. The number of OpenCL devices returned is the minimum of the value specified by num_entries or the number of OpenCL devices whose type matches device_type. 🫢
  • num_devices β€” the number of OpenCL devices available that match device_type. If num_devices is NULL, 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_PLATFORM if platform is not a valid platform.
  • CL_INVALID_DEVICE_TYPE if device_type is not a valid value.
  • CL_INVALID_VALUE if num_entries is equal to zero and devices is not NULL or if both num_devices and devices are NULL.
  • CL_DEVICE_NOT_FOUND if no OpenCL devices that matched device_type were found. 😭
  • CL_OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.
  • CL_OUT_OF_HOST_MEMORY if 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 Β© 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 ⭐

  1. 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