OpenCL 3.0 : Program Scope Global Variables
Using OpenCL-3.0, Program Scope Global Variables may not be supported anymore.
As released, the NVIDIA driver R465 is OpenCL-3.0 conforming. This version is not fully backward compatible with previous OpenCL1.x and OpenCL2.x.
- https://developer.nvidia.com/blog/nvidia-is-now-opencl-3-0-conformant/
- https://www.khronos.org/registry/OpenCL/specs/3.0-unified/pdf/OpenCL_API.pdf#page=317
- https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_C.html#_usage_for_declaration_scopes_and_variable_types
This would be mostly problematic in HySoP for constant variables describing the meshes.
See attached a modified version of the PyOpenCL ElementwiseKernel documentation example : test_pyopenl_elkernel.py Expected result would be "True True 0.0". On OpenCL-3.0 driver the result is 'inf' in 'res_g'.
Possible Workarounds
-
adding a 'static' qualifier so that the compiler is replacing variables, even from structs fields' by values on building. -
implement a pre-processsing of the generated OpenCL code replacing all these constants structs fields by values in codeThis is already done if accessed from the variable in the code generator.
This issue seems not impacting the autotuned kernels ...
Edited by Jean-Baptiste Keck