I've written a small program which determines my platform and shows device info. Here is my platform and device info
number of platforms: 1
name: ATI Stream
vendor: Advanced Micro Devices, Inc.
version: OpenCL 1.0 ATI-Stream-v2.0.0
Found 1 device
Intel(R) Atom(TM) CPU Z530 @ 1.60GHz
Because the sizes for memory are defined in 'bytes' I've added the 'B'. However 32 is not much, I have a system with 1GB (and not all memory is in use), so shouldn't this value be a little bit more ?
I guess with a global mem size of 32 bytes you can't do very much Any suggestions how to fix this ?
you're right, CLInfo gives the right size. I've rewritten my program a little bit
cl_platform_id clSelectedPlatformID = NULL;
cl_uint num_platforms ;
cl_int ciErrNum = clGetPlatformIDs (1,&clSelectedPlatformID, &num_platforms);
cl_device_id device_id; // compute device id
cl_int err ;
err = clGetDeviceIDs(clSelectedPlatformID, CL_DEVICE_TYPE_CPU, 1, &device_id, &ciDeviceCount);
if ( err != CL_SUCCESS)
printf("Error: Failed to create a device group %d!\n", err);
printf("number of devices %d\n", ciDeviceCount) ;
size_t local ;
clGetDeviceInfo(device_id, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(size_t), &local, NULL);
printf("\tCL_DEVICE_GLOBAL_MEM_SIZE:\t\t\t%luB\n", local) ;
return EXIT_SUCCESS ;
But now it prints a size of 0. Any comments on the program ? Furthermore, if I leave the platformID NULL in clGetDeviceIDs I get an error. The documentation says you can, any thought on this ?
yes you can. but "If platform is NULL, the behavior is implementation-defined."
second you get only one device with that code. you must first get count of device with this
clGetDeviceIDs(clSelectedPlatformID, CL_DEVICE_TYPE_ALL, 0, NULL, &ciDeviceCount);
then in ciDeviceCount you get how many devices is in system. every GetInfo call can return size if set 0 in param_value_size and NULL in param_value. then functions return count of item or size in bytes.
what does 'implementation-defined' mean ?
I've fixed the code
if ((devices = (cl_device_id*)malloc(sizeof(cl_device_id) * ciDeviceCount)) == NULL)
printf("Failed to allocate memory for devices !!!\n\n") ;
err = clGetDeviceIDs (clSelectedPlatformID, CL_DEVICE_TYPE_ALL, ciDeviceCount, devices, &ciDeviceCount);