Last active
August 29, 2015 14:20
-
-
Save BenjiWiebe/52a01924009d3534a5d6 to your computer and use it in GitHub Desktop.
This file contains 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 <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