[libclc] [libclc] Add generic implementation of some atomic functions in OpenCL spec section 6.15.12.7 (PR #146814)

Fraser Cormack via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 10 03:01:52 PDT 2025


================
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_COMPARE_EXCHANGE_STRONG_H__
+#define __CLC_OPENCL_ATOMIC_ATOMIC_COMPARE_EXCHANGE_STRONG_H__
+
+#define FUNCTION atomic_compare_exchange_strong
----------------
frasercrmck wrote:

We should probably be only declaring/defining these OpenCL builtins according to the appropriate language features. For instance, for `atomic_compare_exchange_strong` we have:

``` c
// Requires OpenCL C 3.0 or newer and both the __opencl_c_atomic_order_seq_cst
// and __opencl_c_atomic_scope_device features.
```

The CLC functions are probably fine and we can unconditionally include them, for simplicity. But I feel we should be adhering to the spec for OpenCL builtins.

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


More information about the cfe-commits mailing list