Based on these code, OpenCL report 2046 devices on AMD platform. What happen?
int ctr = 0;
cl_uint selectedPlatform = 0;
char param[50];
for(ctr; ctr < num_platforms; ctr++)
{
clGetPlatformInfo(platforms[ctr], CL_PLATFORM_VENDOR, sizeof(param), ¶m, NULL);
printf("%s\n", param);
if(strncmp(param, "NVIDIA", 6) == 0)
{
printf("nVidia\n");
selectedPlatform = ctr;
}
else if (strncmp(param, "Advanced", 😎 == 0)
{
printf("Advanced Micro Devices\n");
clGetDeviceIDs(platforms[ctr], CL_DEVICE_TYPE_ALL, 5, NULL, &num_devices);
printf("Consist of %d OpenCL devices\n", num_devices);
}
else if (strncmp(param, "Intel", 5) == 0)
{
printf("Intel\n");
}
}
Solved! Go to Solution.
What is happening is that in
clGetDeviceIDs(platforms[ctr], CL_DEVICE_TYPE_ALL, 5, NULL, &num_devices);
you are asking at the same time for the name of 5 devices (not to be stored anywhere) and for the number of devices, and this probably confuses the OpenCL implementation, so that num_devices is not properly initialized or getting a bogus value. Try using 0 instead of 5 as third parameter.
The specification is not explicit on this, but I see no reason why num_devices should not be correctly initialized even when num_entries is present, which is why I think this is a bug in the implementation.
What is happening is that in
clGetDeviceIDs(platforms[ctr], CL_DEVICE_TYPE_ALL, 5, NULL, &num_devices);
you are asking at the same time for the name of 5 devices (not to be stored anywhere) and for the number of devices, and this probably confuses the OpenCL implementation, so that num_devices is not properly initialized or getting a bogus value. Try using 0 instead of 5 as third parameter.
The specification is not explicit on this, but I see no reason why num_devices should not be correctly initialized even when num_entries is present, which is why I think this is a bug in the implementation.
Yea, that fixed it.