Add OpenCL 3.1 (-cl-std=CL3.1) support#752
Conversation
Clang gained OpenCL 3.1 language version support (16d22173dbb1d) and,
separately, promotes 6 extensions to OpenCL 3.1 core (f4aa82f80e00):
cl_khr_extended_bit_ops, cl_khr_integer_dot_product,
cl_khr_subgroup_extended_types, cl_khr_subgroup_rotate,
cl_khr_subgroup_shuffle, cl_khr_subgroup_shuffle_relative. Their
builtins in opencl-c.h are gated on __OPENCL_C_VERSION__ >=
CL_VERSION_3_1, which is only set correctly if the PCM used for CL3.1
was itself built with -cl-std=CL3.1.
Wire -cl-std=CL3.1 through the opencl-clang wrapper with its own set
of precompiled headers (opencl-c-31-{spir,spir64}[-fp64].pcm) instead
of reusing the CL3.0 PCMs, so the promoted builtins are visible under
CL3.1 without requiring users to pass -cl-ext=+<extension> explicitly.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
| create_pcm(opencl-c-12-spir.pcm cl12spir opencl-c-base.h "${SPIR_TRIPLE};${CL12};${OPTS}" "${DEPS}") | ||
| create_pcm(opencl-c-20-spir.pcm cl20spir opencl-c-base.h "${SPIR_TRIPLE};${CL20};${OPTS}" "${DEPS}") | ||
| create_pcm(opencl-c-30-spir.pcm cl30spir opencl-c-base.h "${SPIR_TRIPLE};${CL30};${OPTS};${OPTS30}" "${DEPS}") | ||
| create_pcm(opencl-c-31-spir.pcm cl31spir opencl-c-base.h "${SPIR_TRIPLE};${CL31};${OPTS};${OPTS30}" "${DEPS}") |
There was a problem hiding this comment.
I think we need to add an OPTS31 to include new optional features. Please refer to table in https://registry.khronos.org/OpenCL/specs/unified/html/OpenCL_C.html#features. Section 6.2.1 table 1.
new features are appended in the table after "__opencl_c_work_group_collective_functions"
There was a problem hiding this comment.
should they be added to OPTS30 instead? where is doc link that they are added for OpenCL 3.1?
There was a problem hiding this comment.
According to table name "Optional features in OpenCL C 3.0 or newer and their predefined macros". I agree that they be added to OPTS30.
The OpenCL C spec is updated incrementally. I believe that when OpenCL 3.0 spec was published several years ago. These new feature macros were not included.
There was a problem hiding this comment.
Will add to OPTS30 in separate PR, since OpenCL 3.1 doesn't explicit adds them.
These extension checks apply to 3.1 as well. This fix kernel build fails when OpenCL 3.1 is enabled in intel/opencl-clang#752 Assisted-by: Claude
These extension checks apply to 3.1 as well. This fix kernel build fails when OpenCL 3.1 is enabled in intel/opencl-clang#752 Assisted-by: Claude
These extension checks apply to 3.1 as well. This fix kernel build fails when OpenCL 3.1 is enabled in intel/opencl-clang#752 Assisted-by: Claude
These extension checks apply to 3.1 as well. This fix kernel build fails when OpenCL 3.1 is enabled in intel/opencl-clang#752 Assisted-by: Claude
Clang gained OpenCL 3.1 language version support (16d22173dbb1d) and, separately, promotes 6 extensions to OpenCL 3.1 core (f4aa82f80e00): cl_khr_extended_bit_ops, cl_khr_integer_dot_product, cl_khr_subgroup_extended_types, cl_khr_subgroup_rotate, cl_khr_subgroup_shuffle, cl_khr_subgroup_shuffle_relative. Their builtins in opencl-c.h are gated on OPENCL_C_VERSION >= CL_VERSION_3_1, which is only set correctly if the PCM used for CL3.1 was itself built with -cl-std=CL3.1.
Wire -cl-std=CL3.1 through the opencl-clang wrapper with its own set of precompiled headers (opencl-c-31-{spir,spir64}[-fp64].pcm) instead of reusing the CL3.0 PCMs, so the promoted builtins are visible under CL3.1 without requiring users to pass -cl-ext=+ explicitly.