Created
December 31, 2011 04:35
-
-
Save kayru/1542891 to your computer and use it in GitHub Desktop.
Dump basic information about OpenCL devices in the system
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
// On MacOS X compile with g++ -framework OpenCL <filename> | |
#include <stdio.h> | |
#include <OpenCL/opencl.h> | |
#define P(x) x,#x | |
void printClDeviceInfoString(cl_device_id device_id, cl_device_info param_name, const char* printable_name) | |
{ | |
char val[1024]; | |
clGetDeviceInfo(device_id, param_name, sizeof(val), &val, NULL); | |
printf("%s: %s\n", printable_name, val); | |
} | |
void printClDeviceInfoBool(cl_device_id device_id, cl_device_info param_name, const char* printable_name) | |
{ | |
cl_bool val; | |
clGetDeviceInfo(device_id, param_name, sizeof(val), &val, NULL); | |
printf("%s: %d\n", printable_name, val); | |
} | |
void printClDeviceInfoUint(cl_device_id device_id, cl_device_info param_name, const char* printable_name) | |
{ | |
cl_uint val; | |
clGetDeviceInfo(device_id, param_name, sizeof(val), &val, NULL); | |
printf("%s: %d\n", printable_name, val); | |
} | |
void printClDeviceInfoUlong(cl_device_id device_id, cl_device_info param_name, const char* printable_name) | |
{ | |
cl_ulong val; | |
clGetDeviceInfo(device_id, param_name, sizeof(val), &val, NULL); | |
printf("%s: %llu\n", printable_name, val); | |
} | |
int main() | |
{ | |
cl_uint max_device_ids = 32; | |
cl_uint num_device_ids=0; | |
cl_device_id device_ids[max_device_ids]; | |
clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, max_device_ids, device_ids, &num_device_ids); | |
printf("clGetDeviceIDs returned %d devices\n\n", num_device_ids); | |
for(cl_uint idx=0; idx<num_device_ids; ++idx) | |
{ | |
printf("Device %d\n\n", idx); | |
printClDeviceInfoString (device_ids[idx], P(CL_DEVICE_NAME)); | |
printClDeviceInfoString (device_ids[idx], P(CL_DEVICE_VENDOR)); | |
printClDeviceInfoString (device_ids[idx], P(CL_DEVICE_VERSION)); | |
printClDeviceInfoString (device_ids[idx], P(CL_DRIVER_VERSION)); | |
printClDeviceInfoString (device_ids[idx], P(CL_DEVICE_PROFILE)); | |
printClDeviceInfoBool (device_ids[idx], P(CL_DEVICE_AVAILABLE)); | |
printClDeviceInfoBool (device_ids[idx], P(CL_DEVICE_COMPILER_AVAILABLE)); | |
printClDeviceInfoUlong (device_ids[idx], P(CL_DEVICE_GLOBAL_MEM_SIZE)); | |
printClDeviceInfoUlong (device_ids[idx], P(CL_DEVICE_LOCAL_MEM_SIZE)); | |
printClDeviceInfoBool (device_ids[idx], P(CL_DEVICE_IMAGE_SUPPORT)); | |
printf("\n"); | |
} | |
printf("Finished\n\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment