Created
May 15, 2015 08:42
-
-
Save pvinis/f93b2e1c04664e78c493 to your computer and use it in GitHub Desktop.
opencl-device-detect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <OpenCL/opencl.h> | |
| int main(int argc, char* const argv[]) { | |
| cl_uint num_devices, i; | |
| clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, 0, NULL, &num_devices); | |
| cl_device_id* devices = calloc(sizeof(cl_device_id), num_devices); | |
| clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, num_devices, devices, NULL); | |
| fprintf(stdout, "Devices found: %d\n", num_devices); | |
| char buf[128]; | |
| for (i = 0; i < num_devices; i++) { | |
| clGetDeviceInfo(devices[i], CL_DEVICE_NAME, 128, buf, NULL); | |
| fprintf(stdout, "Device %s supports ", buf); | |
| clGetDeviceInfo(devices[i], CL_DEVICE_VERSION, 128, buf, NULL); | |
| fprintf(stdout, "%s\n", buf); | |
| } | |
| free(devices); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment