Skip to content

Instantly share code, notes, and snippets.

@BenjiWiebe
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenjiWiebe/52a01924009d3534a5d6 to your computer and use it in GitHub Desktop.
Save BenjiWiebe/52a01924009d3534a5d6 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <CL/cl.h>
int main()
{
cl_int err;
cl_platform_id platform_ids[10];
cl_uint number;
err = clGetPlatformIDs(10, (cl_platform_id*) platform_ids, &number);
if(err != CL_SUCCESS)
{
printf("clGetPlatformIDs() failed!\n");
return 1;
}
printf("%d OpenCL platforms found!\n", number);
cl_device_id device_ids[10];
cl_uint numdevs;
err = clGetDeviceIDs(platform_ids[0], CL_DEVICE_TYPE_GPU, 10, (cl_device_id*) device_ids, &numdevs);
if(err != CL_SUCCESS)
{
printf("clGetDeviceIDs() for type GPU failed!\n");
return 1;
}
printf("%d OpenCL devices found!\n", numdevs);
char vendor[100];
err = clGetDeviceInfo(device_ids[0], CL_DEVICE_VENDOR, sizeof(vendor), (char*)vendor, NULL);
if(err != CL_SUCCESS)
{
printf("clGetDeviceInfo() failed!\n");
return 1;
}
printf("Vendor: %s\n", vendor);
cl_uint compute_units;
err = clGetDeviceInfo(device_ids[0], CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(compute_units), &compute_units, NULL);
if(err != CL_SUCCESS)
{
printf("clGetDeviceInfo() failed!\n");
return 1;
}
printf("Max compute units: %d\n", compute_units);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment