---
name: "clGetDeviceIDs"
section: "3clc"
platform: "linux"
package: "opencl-1.2-man-doc"
version: "1.0~svn33624-5.1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/clGetDeviceIDs"
---

# clGetDeviceIDs(3clc)

Obtain the list of devices available on a platform.

## 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*

Refers to the platform ID returned by [**clGetPlatformIDs**(3clc)](/clGetPlatformIDs/3clc.md) or can be NULL. If *platform* is NULL, the behavior is implementation-defined.

*device\_type*

A bitfield that identifies the type of OpenCL device. The *device\_type* can be used to query specific OpenCL devices or all OpenCL devices available. The valid values for *device\_type* are specified in the following table.

| | |
| --- | --- |
| **cl\_device\_type** | **Description** |
| **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. By this we mean that 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. The default device cannot be a **CL\_DEVICE\_TYPE\_CUSTOM** device. |
| **CL\_DEVICE\_TYPE\_ALL** | All OpenCL devices available in the system except **CL\_DEVICE\_TYPE\_CUSTOM** devices. |

*num\_entries*

The number of **cl\_device\_id** entries that can be added to *devices*. If *devices* is not NULL, the *num\_entries* must be greater than zero.

*devices*

A list of OpenCL devices found. The **cl\_device\_id** values returned in *devices* can be used to identify a specific OpenCL device. If *devices* argument is NULL, this argument is ignored. The number of OpenCL devices returned is the mininum 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 and that match *device\_type*.

## 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)](/clGetDeviceInfo/3clc.md), [**clGetPlatformIDs**(3clc)](/clGetPlatformIDs/3clc.md), [**clCreateContext**(3clc)](/clCreateContext/3clc.md), [**classDiagram**(3clc)](/classDiagram/3clc.md)

## 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

- 1\.

  OpenCL Specification

  page 35, section 4.2 - Querying Devices
