[clang] [AMDGPU] Support the OpenCL generic addrspace feature by default (PR #137636)

Fraser Cormack via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 28 09:33:15 PDT 2025


================
@@ -155,3 +155,11 @@
 #endif
 #pragma OPENCL EXTENSION cl_amd_media_ops2: enable
 
+#if (__OPENCL_C_VERSION__ >= 300)
----------------
frasercrmck wrote:

My reading of the specification is that OpenCL 2.0 has the "generic address space" capability available by default, but not the `__opencl_c_generic_address_space` _feature_ (it's just automatically on). OpenCL 3.0 has the optional `__opencl_c_generic_address_space` feature which is not on by default.

See https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_C.html#the-generic-address-space. All of the wording surrounding the generic address space is, e.g., `If the generic address space is supported i.e. for OpenCL C 2.0 or OpenCL C 3.0 with __opencl_c_generic_address_space feature [...]`.

Looking at `opencl-c-base.h`, my guess is that we are defining the `__opencl_c_generic_address_space` feature on by default for OpenCL 2.0. That's non-standard, but it means there's a simpler internal way of checking for the feature's availability. Regardless, that header isn't available to this particular test - this is just using internal compiler defines, and there's no `__opencl_c_generic_address_space` defined by clang for OpenCL 2.0. I think that's the correct behaviour.

https://github.com/llvm/llvm-project/pull/137636


More information about the cfe-commits mailing list