This is an archive of the discontinued LLVM Phabricator instance.

[OpenCL] Add OpenCL 3.0 atomics to -fdeclare-opencl-builtins
ClosedPublic

Authored by svenvh on Feb 10 2022, 2:22 AM.

Details

Summary

Add the atomic overloads for the global and local address spaces,
which are new in OpenCL 3.0. Ensure the preexisting generic
overloads are guarded by the generic address space feature macro.

Ensure a subset of the atomic builtins are guarded by the
__opencl_c_atomic_order_seq_cst and __opencl_c_atomic_scope_device
feature macros, and enable those macros for SPIR/SPIR-V targets in
opencl-c-base.h.

Also guard the cl_ext_float_atomics builtins with the atomic order
and scope feature macros.

Diff Detail

Event Timeline

svenvh created this revision.Feb 10 2022, 2:22 AM
svenvh requested review of this revision.Feb 10 2022, 2:22 AM
Anastasia added inline comments.Feb 10 2022, 3:49 AM
clang/lib/Sema/OpenCLBuiltins.td
1151–1159

maybe we can improve the name, so something like extension_fp16?

Same for below: extension_fp16, extension_32, extension_64?

clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
84

Why do we need to set those for __OPENCL_CPP_VERSION__ == 100 since those atomics are for OpenCL 2.0 onwards?

Anastasia accepted this revision.Feb 10 2022, 4:58 AM

LGTM! The rename can be made on commit.

clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
84

Sorry C++ for OpenCL is aligned with OpenCL 2, so this check makes sense.

This revision is now accepted and ready to land.Feb 10 2022, 4:58 AM