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)platform-
Refers to the platform ID returned by
clGetPlatformIDsor can be NULL. Ifplatformis NULL, the behavior is implementation-defined. device_type-
A bitfield that identifies the type of OpenCL device. The
device_typecan be used to query specific OpenCL devices or all OpenCL devices available. The valid values fordevice_typeare specified in the following table. num_entries-
The number of
cl_device_identries that can be added todevices. Ifdevicesis not NULL, thenum_entriesmust be greater than zero. devices-
A list of OpenCL devices found. The
cl_device_idvalues returned indevicescan be used to identify a specific OpenCL device. Ifdevicesargument is NULL, this argument is ignored. The number of OpenCL devices returned is the mininum of the value specified bynum_entriesor the number of OpenCL devices whose type matchesdevice_type. num_devices-
The number of OpenCL devices available that match
device_type. Ifnum_devicesis NULL, this argument is ignored.
clGetDeviceIDs may return all or a subset of the actual physical devices present in the platform and that match device_type.
clGetDeviceIDs returns CL_SUCCESS if the function is executed successfully.
Otherwise it returns one of the following errors:
-
CL_INVALID_PLATFORMifplatformis not a valid platform. -
CL_INVALID_DEVICE_TYPEifdevice_typeis not a valid value. -
CL_INVALID_VALUEifnum_entriesis equal to zero anddevicesis not NULL or if bothnum_devicesanddevicesare NULL. -
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.