clGetDeviceInfo not properly updating param_value_size_ret

My hardware and drivers are as follows:

  • Ubuntu 16.04
  • GeForce GT 1030
  • OpenCL 1.2
  • CUDA 10.2.95

I am having troubles with clGetDeviceInfo.

When I call clGetDeviceInfo with an array for param_value as follows, the proper value is returned by param_value_size_ret, which is 373.

/* Extension data */
char ext_data[4096];
size_t ext_size;

/* Access device extensions */
result = clGetDeviceInfo(dev, CL_DEVICE_EXTENSIONS, 4096, ext_data, ext_size);	

According to what I’ve read online, the param_value_size_ret should still be updated when NULL is passed for param_value. However, when I run the follow code, param_value_size_ret is not updated, and the call to clGetDeviceInfo returns -30, which is CL_INVALID_VALUE.

result = clGetDeviceInfo(dev, CL_DEVICE_EXTENSIONS,	4096, NULL, &ext_size);

What am I missing?