Reputation: 857
I've been messing around with OpenCL, and it seems it's not detecting that I have a device to use in my computer (which I do).
Here's the result of dxdiag:
Here is the first part of my code, where the error is being raised, checking for the number of devices available on my machine.
cl_platform_id platform;
cl_uint num_devices;
cl_int err;
//get first platform
err = clGetPlatformIDs(1, &platform, NULL);
if (err < 0){
perror("Couldn't find any platforms");
exit(1);
}
//determine number of devices: ERROR RAISED AS RESULT OF THIS
err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_ALL, 1, NULL, &num_devices);
if (err < 0){
perror("Couldn't find any devices");
exit(1);
}
This is the output from this code:
And when I print the number of devices it is finding, with
printf("Found %d devices", num_devices);
It gives the same number every time:
Please let me know what other information may help in figuring this out.
Upvotes: 0
Views: 2367
Reputation: 398
make sure that both 32bit and 64bit opencl drivers are installed. If your app is 64 bit, but only a 32bit driver is installed, the device will not be found.
you can check installed devices using my app: https://github.com/zbendefy/opencl-z/blob/master/opencl_z_1_1b.jar
Upvotes: 1
Reputation: 20889
You can't be certain that it's not finding the devices because you haven't properly checked the return value. There are 5 values (more, depending on your OpenCL version) that clGetDeviceIDs
can return:
CL_SUCCESS
if the function is executed successfully.CL_INVALID_PLATFORM
if platform is not a valid platform.CL_INVALID_DEVICE_TYPE
if device_type is not a valid value.CL_INVALID_VALUE
if num_entries is equal to zero and device_type is not NULL or if both num_devices and device_type are NULL.CL_DEVICE_NOT_FOUND
if no OpenCL devices that matched device_type were found.You should check your err
value against those to be sure that CL_DEVICE_NOT_FOUND
is actually the case.
Similarly, you should use supply the num_platforms
value for clGetPlatformIDs
. It's possible that the platform you've selected doesn't have valid devices, but another platform does.
Upvotes: 1