chapter 11 string search fails on nvidia platform ( gpu is gtx 1650)
Opened this issue · 0 comments
andreish commented
This is because of mismatched type for variable global_size , quick fix is to initialize global_size=0 may fix , but the actual issue is with its type because calling clGetDeviceInfo will only change 4 bytes from the 8 bytes of global_size variable:
size_t sz =0;
clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS,
sizeof(global_size), &global_size, &sz);
printf("global_size=%lu sz=%lu, %lu\n",global_size, sz, sizeof(global_size));
will print :
global_size=14 sz=4, 8
one can see in the specs : https://www.khronos.org/registry/OpenCL/sdk/2.2/docs/man/html/clGetDeviceInfo.html
clGetDeviceInfo with CL_DEVICE_MAX_COMPUTE_UNITS returns a cl_uint while global_info is a size_t
more correct code and more readable will be to have a separate variable for num_max_compute_units and compute global_size with it.
Tested on fedora 34.