Skip to content

Instantly share code, notes, and snippets.

@y-fedorov
Created August 19, 2016 07:58
Show Gist options
  • Save y-fedorov/f56f5acd82144713738163aa8228c918 to your computer and use it in GitHub Desktop.
Save y-fedorov/f56f5acd82144713738163aa8228c918 to your computer and use it in GitHub Desktop.
Testing for OpenCL compatibility (MacOS)
//
// James @ http://stackoverflow.com/questions/7892955/how-can-i-test-for-opencl-compability
//
// clang -framework OpenCL dumpcl.c -o dumpcl && ./dumpcl
#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);
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);
}
// Output - Mac mini (Late 2012):
Device Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz supports OpenCL 1.2
Device HD Graphics 4000 supports OpenCL 1.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment