https://github.com/wenju-he updated https://github.com/llvm/llvm-project/pull/146814
>From 6429b5538dcfcd9de262f6f0a49d8283db8f5db9 Mon Sep 17 00:00:00 2001 From: Wenju He <wenju...@intel.com> Date: Wed, 2 Jul 2025 17:11:56 -0700 Subject: [PATCH 1/2] [libclc] Add generic implementation of some atomic functions in OpenCL spec section 6.15.12.7 Add corresponding clc functions, which are implemented with clang __scoped_atomic builtins. OpenCL functions are implemented as a wrapper over clc functions. Also change legacy atomic_inc and atomic_dec to re-use the newly added clc_atomic_inc/dec implementations. llvm-diff only no change to atomic_inc and atomic_dec in bitcode. Notes: * Generic OpenCL built-ins functions uses __ATOMIC_SEQ_CST and __MEMORY_SCOPE_SYSTEM for memory order and memory scope parameters. Ideally we should check if __opencl_c_atomic_order_seq_cst, __opencl_c_atomic_scope_all_devices and __opencl_c_atomic_scope_device feature macros should be checked. However, none of them are defined for nvptx64 and amdgcn arch yet. We can add the check when the backends are fixed. * OpenCL atomic_*_explicit, atomic_flag* built-ins are not implemented yet. * OpenCL built-ins of atomic_intptr_t, atomic_uintptr_t, atomic_size_t and atomic_ptrdiff_t types are not implemented yet. * llvm-diff only shows new built-ins are added to nvptx64--nvidiacl.bc and amdgcn--amdhsa.bc. The number of newly added built-ins in amdgcn--amdhsa.bc is higher than in nvptx64--nvidiacl.bc because 64-bit atomics are enabled for amdgcn--amdhsa. --- libclc/clc/include/clc/atomic/atomic_decl.inc | 47 +++++++++++ .../clc/atomic/clc_atomic_compare_exchange.h | 26 ++++++ .../clc/include/clc/atomic/clc_atomic_dec.h | 23 ++++++ .../include/clc/atomic/clc_atomic_exchange.h | 24 ++++++ .../include/clc/atomic/clc_atomic_fetch_add.h | 24 ++++++ .../include/clc/atomic/clc_atomic_fetch_and.h | 21 +++++ .../include/clc/atomic/clc_atomic_fetch_max.h | 24 ++++++ .../include/clc/atomic/clc_atomic_fetch_min.h | 24 ++++++ .../include/clc/atomic/clc_atomic_fetch_or.h | 21 +++++ .../include/clc/atomic/clc_atomic_fetch_sub.h | 24 ++++++ .../include/clc/atomic/clc_atomic_fetch_xor.h | 21 +++++ .../clc/include/clc/atomic/clc_atomic_inc.h | 23 ++++++ .../clc/include/clc/atomic/clc_atomic_load.h | 26 ++++++ .../clc/include/clc/atomic/clc_atomic_store.h | 26 ++++++ libclc/clc/lib/generic/SOURCES | 13 +++ libclc/clc/lib/generic/atomic/atomic_def.inc | 65 +++++++++++++++ .../atomic/clc_atomic_compare_exchange.cl | 15 ++++ .../atomic/clc_atomic_compare_exchange.inc | 50 ++++++++++++ .../clc/lib/generic/atomic/clc_atomic_dec.cl | 16 ++++ .../lib/generic/atomic/clc_atomic_exchange.cl | 23 ++++++ .../generic/atomic/clc_atomic_fetch_add.cl | 18 +++++ .../generic/atomic/clc_atomic_fetch_and.cl | 15 ++++ .../generic/atomic/clc_atomic_fetch_max.cl | 18 +++++ .../generic/atomic/clc_atomic_fetch_min.cl | 18 +++++ .../lib/generic/atomic/clc_atomic_fetch_or.cl | 15 ++++ .../generic/atomic/clc_atomic_fetch_sub.cl | 18 +++++ .../generic/atomic/clc_atomic_fetch_xor.cl | 15 ++++ .../clc/lib/generic/atomic/clc_atomic_inc.cl | 16 ++++ .../clc/lib/generic/atomic/clc_atomic_load.cl | 24 ++++++ .../lib/generic/atomic/clc_atomic_store.cl | 22 +++++ .../include/clc/opencl/atomic/atomic_add.h | 2 +- .../include/clc/opencl/atomic/atomic_and.h | 2 +- .../atomic/atomic_compare_exchange_strong.h | 19 +++++ .../atomic/atomic_compare_exchange_weak.h | 19 +++++ .../include/clc/opencl/atomic/atomic_decl.inc | 60 +++++++++++--- .../clc/opencl/atomic/atomic_decl_legacy.inc | 22 +++++ .../clc/opencl/atomic/atomic_exchange.h | 17 ++++ .../clc/opencl/atomic/atomic_fetch_add.h | 17 ++++ .../clc/opencl/atomic/atomic_fetch_and.h | 14 ++++ .../clc/opencl/atomic/atomic_fetch_max.h | 17 ++++ .../clc/opencl/atomic/atomic_fetch_min.h | 17 ++++ .../clc/opencl/atomic/atomic_fetch_or.h | 14 ++++ .../clc/opencl/atomic/atomic_fetch_sub.h | 17 ++++ .../clc/opencl/atomic/atomic_fetch_xor.h | 14 ++++ .../include/clc/opencl/atomic/atomic_load.h | 19 +++++ .../include/clc/opencl/atomic/atomic_max.h | 2 +- .../include/clc/opencl/atomic/atomic_min.h | 2 +- .../include/clc/opencl/atomic/atomic_or.h | 2 +- .../include/clc/opencl/atomic/atomic_store.h | 19 +++++ .../include/clc/opencl/atomic/atomic_sub.h | 2 +- .../include/clc/opencl/atomic/atomic_xchg.h | 2 +- .../include/clc/opencl/atomic/atomic_xor.h | 2 +- libclc/opencl/include/clc/opencl/clc.h | 12 +++ libclc/opencl/lib/generic/SOURCES | 26 ++++-- .../atomic/atomic_compare_exchange_strong.cl | 19 +++++ .../atomic/atomic_compare_exchange_weak.cl | 19 +++++ .../opencl/lib/generic/atomic/atomic_dec.cl | 14 ++-- .../opencl/lib/generic/atomic/atomic_def.inc | 81 +++++++++++++++++++ .../lib/generic/atomic/atomic_exchange.cl | 19 +++++ .../lib/generic/atomic/atomic_fetch_add.cl | 19 +++++ .../lib/generic/atomic/atomic_fetch_and.cl | 16 ++++ .../lib/generic/atomic/atomic_fetch_max.cl | 19 +++++ .../lib/generic/atomic/atomic_fetch_min.cl | 19 +++++ .../lib/generic/atomic/atomic_fetch_or.cl | 16 ++++ .../lib/generic/atomic/atomic_fetch_sub.cl | 19 +++++ .../lib/generic/atomic/atomic_fetch_xor.cl | 16 ++++ .../opencl/lib/generic/atomic/atomic_inc.cl | 14 ++-- .../lib/generic/atomic/atomic_inc_dec.inc | 26 ++++++ .../opencl/lib/generic/atomic/atomic_load.cl | 20 +++++ .../opencl/lib/generic/atomic/atomic_store.cl | 20 +++++ 70 files changed, 1367 insertions(+), 43 deletions(-) create mode 100644 libclc/clc/include/clc/atomic/atomic_decl.inc create mode 100644 libclc/clc/include/clc/atomic/clc_atomic_compare_exchange.h create mode 100644 libclc/clc/include/clc/atomic/clc_atomic_dec.h create mode 100644 libclc/clc/include/clc/atomic/clc_atomic_exchange.h create mode 100644 libclc/clc/include/clc/atomic/clc_atomic_fetch_add.h create mode 100644 libclc/clc/include/clc/atomic/clc_atomic_fetch_and.h create mode 100644 libclc/clc/include/clc/atomic/clc_atomic_fetch_max.h create mode 100644 libclc/clc/include/clc/atomic/clc_atomic_fetch_min.h create mode 100644 libclc/clc/include/clc/atomic/clc_atomic_fetch_or.h create mode 100644 libclc/clc/include/clc/atomic/clc_atomic_fetch_sub.h create mode 100644 libclc/clc/include/clc/atomic/clc_atomic_fetch_xor.h create mode 100644 libclc/clc/include/clc/atomic/clc_atomic_inc.h create mode 100644 libclc/clc/include/clc/atomic/clc_atomic_load.h create mode 100644 libclc/clc/include/clc/atomic/clc_atomic_store.h create mode 100644 libclc/clc/lib/generic/atomic/atomic_def.inc create mode 100644 libclc/clc/lib/generic/atomic/clc_atomic_compare_exchange.cl create mode 100644 libclc/clc/lib/generic/atomic/clc_atomic_compare_exchange.inc create mode 100644 libclc/clc/lib/generic/atomic/clc_atomic_dec.cl create mode 100644 libclc/clc/lib/generic/atomic/clc_atomic_exchange.cl create mode 100644 libclc/clc/lib/generic/atomic/clc_atomic_fetch_add.cl create mode 100644 libclc/clc/lib/generic/atomic/clc_atomic_fetch_and.cl create mode 100644 libclc/clc/lib/generic/atomic/clc_atomic_fetch_max.cl create mode 100644 libclc/clc/lib/generic/atomic/clc_atomic_fetch_min.cl create mode 100644 libclc/clc/lib/generic/atomic/clc_atomic_fetch_or.cl create mode 100644 libclc/clc/lib/generic/atomic/clc_atomic_fetch_sub.cl create mode 100644 libclc/clc/lib/generic/atomic/clc_atomic_fetch_xor.cl create mode 100644 libclc/clc/lib/generic/atomic/clc_atomic_inc.cl create mode 100644 libclc/clc/lib/generic/atomic/clc_atomic_load.cl create mode 100644 libclc/clc/lib/generic/atomic/clc_atomic_store.cl create mode 100644 libclc/opencl/include/clc/opencl/atomic/atomic_compare_exchange_strong.h create mode 100644 libclc/opencl/include/clc/opencl/atomic/atomic_compare_exchange_weak.h create mode 100644 libclc/opencl/include/clc/opencl/atomic/atomic_decl_legacy.inc create mode 100644 libclc/opencl/include/clc/opencl/atomic/atomic_exchange.h create mode 100644 libclc/opencl/include/clc/opencl/atomic/atomic_fetch_add.h create mode 100644 libclc/opencl/include/clc/opencl/atomic/atomic_fetch_and.h create mode 100644 libclc/opencl/include/clc/opencl/atomic/atomic_fetch_max.h create mode 100644 libclc/opencl/include/clc/opencl/atomic/atomic_fetch_min.h create mode 100644 libclc/opencl/include/clc/opencl/atomic/atomic_fetch_or.h create mode 100644 libclc/opencl/include/clc/opencl/atomic/atomic_fetch_sub.h create mode 100644 libclc/opencl/include/clc/opencl/atomic/atomic_fetch_xor.h create mode 100644 libclc/opencl/include/clc/opencl/atomic/atomic_load.h create mode 100644 libclc/opencl/include/clc/opencl/atomic/atomic_store.h create mode 100644 libclc/opencl/lib/generic/atomic/atomic_compare_exchange_strong.cl create mode 100644 libclc/opencl/lib/generic/atomic/atomic_compare_exchange_weak.cl create mode 100644 libclc/opencl/lib/generic/atomic/atomic_def.inc create mode 100644 libclc/opencl/lib/generic/atomic/atomic_exchange.cl create mode 100644 libclc/opencl/lib/generic/atomic/atomic_fetch_add.cl create mode 100644 libclc/opencl/lib/generic/atomic/atomic_fetch_and.cl create mode 100644 libclc/opencl/lib/generic/atomic/atomic_fetch_max.cl create mode 100644 libclc/opencl/lib/generic/atomic/atomic_fetch_min.cl create mode 100644 libclc/opencl/lib/generic/atomic/atomic_fetch_or.cl create mode 100644 libclc/opencl/lib/generic/atomic/atomic_fetch_sub.cl create mode 100644 libclc/opencl/lib/generic/atomic/atomic_fetch_xor.cl create mode 100644 libclc/opencl/lib/generic/atomic/atomic_inc_dec.inc create mode 100644 libclc/opencl/lib/generic/atomic/atomic_load.cl create mode 100644 libclc/opencl/lib/generic/atomic/atomic_store.cl diff --git a/libclc/clc/include/clc/atomic/atomic_decl.inc b/libclc/clc/include/clc/atomic/atomic_decl.inc new file mode 100644 index 0000000000000..5e0f456e34009 --- /dev/null +++ b/libclc/clc/include/clc/atomic/atomic_decl.inc @@ -0,0 +1,47 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// MemoryOrder is memory order supported by Clang __scoped_atomic* builtins. +// MemoryScope is memory scope supported by Clang __scoped_atomic* builtins. + +#ifdef __CLC_SCALAR +#if defined(__CLC_FPSIZE) || (__CLC_GENSIZE >= 32) + +#ifdef __CLC_NO_VALUE_ARG +#define __CLC_DECLARE_ATOMIC(ADDRSPACE) \ + _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION( \ + volatile ADDRSPACE __CLC_GENTYPE *Ptr, int MemoryOrder, \ + int MemoryScope); +#elif defined(__CLC_RETURN_VOID) +#define __CLC_DECLARE_ATOMIC(ADDRSPACE) \ + _CLC_OVERLOAD _CLC_DECL void __CLC_FUNCTION( \ + volatile ADDRSPACE __CLC_GENTYPE *Ptr, __CLC_GENTYPE Value, \ + int MemoryOrder, int MemoryScope); +#elif defined(__CLC_COMPARE_EXCHANGE) +#define __CLC_DECLARE_ATOMIC(ADDRSPACE) \ + _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION( \ + volatile ADDRSPACE __CLC_GENTYPE *Ptr, __CLC_GENTYPE Comparator, \ + __CLC_GENTYPE Value, int MemoryOrderEqual, int MemoryOrderUnequal, \ + int MemoryScope); +#else +#define __CLC_DECLARE_ATOMIC(ADDRSPACE) \ + _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION( \ + volatile ADDRSPACE __CLC_GENTYPE *Ptr, __CLC_GENTYPE Value, \ + int MemoryOrder, int MemoryScope); +#endif + +__CLC_DECLARE_ATOMIC(global) +__CLC_DECLARE_ATOMIC(local) +#if _CLC_GENERIC_AS_SUPPORTED +__CLC_DECLARE_ATOMIC() +#endif + +#undef __CLC_DECLARE_ATOMIC + +#endif // defined(__CLC_FPSIZE) || (__CLC_GENSIZE >= 32) +#endif // __CLC_SCALAR diff --git a/libclc/clc/include/clc/atomic/clc_atomic_compare_exchange.h b/libclc/clc/include/clc/atomic/clc_atomic_compare_exchange.h new file mode 100644 index 0000000000000..31b8167223502 --- /dev/null +++ b/libclc/clc/include/clc/atomic/clc_atomic_compare_exchange.h @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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_ATOMIC_CLC_ATOMIC_COMPARE_EXCHANGE_H__ +#define __CLC_ATOMIC_CLC_ATOMIC_COMPARE_EXCHANGE_H__ + +#include <clc/internal/clc.h> + +#define __CLC_FUNCTION __clc_atomic_compare_exchange +#define __CLC_COMPARE_EXCHANGE + +#define __CLC_BODY <clc/atomic/atomic_decl.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <clc/atomic/atomic_decl.inc> +#include <clc/math/gentype.inc> + +#undef __CLC_COMPARE_EXCHANGE +#undef __CLC_FUNCTION + +#endif // __CLC_ATOMIC_CLC_ATOMIC_COMPARE_EXCHANGE_H__ diff --git a/libclc/clc/include/clc/atomic/clc_atomic_dec.h b/libclc/clc/include/clc/atomic/clc_atomic_dec.h new file mode 100644 index 0000000000000..66302b6b9ade2 --- /dev/null +++ b/libclc/clc/include/clc/atomic/clc_atomic_dec.h @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// 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_ATOMIC_CLC_ATOMIC_DEC_H__ +#define __CLC_ATOMIC_CLC_ATOMIC_DEC_H__ + +#include <clc/internal/clc.h> + +#define __CLC_FUNCTION __clc_atomic_dec +#define __CLC_NO_VALUE_ARG + +#define __CLC_BODY <clc/atomic/atomic_decl.inc> +#include <clc/integer/gentype.inc> + +#undef __CLC_NO_VALUE_ARG +#undef __CLC_FUNCTION + +#endif // __CLC_ATOMIC_CLC_ATOMIC_DEC_H__ diff --git a/libclc/clc/include/clc/atomic/clc_atomic_exchange.h b/libclc/clc/include/clc/atomic/clc_atomic_exchange.h new file mode 100644 index 0000000000000..321cfb4030851 --- /dev/null +++ b/libclc/clc/include/clc/atomic/clc_atomic_exchange.h @@ -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_ATOMIC_CLC_ATOMIC_EXCHANGE_H__ +#define __CLC_ATOMIC_CLC_ATOMIC_EXCHANGE_H__ + +#include <clc/internal/clc.h> + +#define __CLC_FUNCTION __clc_atomic_exchange + +#define __CLC_BODY <clc/atomic/atomic_decl.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <clc/atomic/atomic_decl.inc> +#include <clc/math/gentype.inc> + +#undef __CLC_FUNCTION + +#endif // __CLC_ATOMIC_CLC_ATOMIC_EXCHANGE_H__ diff --git a/libclc/clc/include/clc/atomic/clc_atomic_fetch_add.h b/libclc/clc/include/clc/atomic/clc_atomic_fetch_add.h new file mode 100644 index 0000000000000..4ef29fce50af8 --- /dev/null +++ b/libclc/clc/include/clc/atomic/clc_atomic_fetch_add.h @@ -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_ATOMIC_CLC_ATOMIC_FETCH_ADD_H__ +#define __CLC_ATOMIC_CLC_ATOMIC_FETCH_ADD_H__ + +#include <clc/internal/clc.h> + +#define __CLC_FUNCTION __clc_atomic_fetch_add + +#define __CLC_BODY <clc/atomic/atomic_decl.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <clc/atomic/atomic_decl.inc> +#include <clc/math/gentype.inc> + +#undef __CLC_FUNCTION + +#endif // __CLC_ATOMIC_CLC_ATOMIC_FETCH_ADD_H__ diff --git a/libclc/clc/include/clc/atomic/clc_atomic_fetch_and.h b/libclc/clc/include/clc/atomic/clc_atomic_fetch_and.h new file mode 100644 index 0000000000000..688c11287db50 --- /dev/null +++ b/libclc/clc/include/clc/atomic/clc_atomic_fetch_and.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// 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_ATOMIC_CLC_ATOMIC_FETCH_AND_H__ +#define __CLC_ATOMIC_CLC_ATOMIC_FETCH_AND_H__ + +#include <clc/internal/clc.h> + +#define __CLC_FUNCTION __clc_atomic_fetch_and + +#define __CLC_BODY <clc/atomic/atomic_decl.inc> +#include <clc/integer/gentype.inc> + +#undef __CLC_FUNCTION + +#endif // __CLC_ATOMIC_CLC_ATOMIC_FETCH_AND_H__ diff --git a/libclc/clc/include/clc/atomic/clc_atomic_fetch_max.h b/libclc/clc/include/clc/atomic/clc_atomic_fetch_max.h new file mode 100644 index 0000000000000..a4e44b88a697f --- /dev/null +++ b/libclc/clc/include/clc/atomic/clc_atomic_fetch_max.h @@ -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_ATOMIC_CLC_ATOMIC_FETCH_MAX_H__ +#define __CLC_ATOMIC_CLC_ATOMIC_FETCH_MAX_H__ + +#include <clc/internal/clc.h> + +#define __CLC_FUNCTION __clc_atomic_fetch_max + +#define __CLC_BODY <clc/atomic/atomic_decl.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <clc/atomic/atomic_decl.inc> +#include <clc/math/gentype.inc> + +#undef __CLC_FUNCTION + +#endif // __CLC_ATOMIC_CLC_ATOMIC_FETCH_MAX_H__ diff --git a/libclc/clc/include/clc/atomic/clc_atomic_fetch_min.h b/libclc/clc/include/clc/atomic/clc_atomic_fetch_min.h new file mode 100644 index 0000000000000..b58b538649e19 --- /dev/null +++ b/libclc/clc/include/clc/atomic/clc_atomic_fetch_min.h @@ -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_ATOMIC_CLC_ATOMIC_FETCH_MIN_H__ +#define __CLC_ATOMIC_CLC_ATOMIC_FETCH_MIN_H__ + +#include <clc/internal/clc.h> + +#define __CLC_FUNCTION __clc_atomic_fetch_min + +#define __CLC_BODY <clc/atomic/atomic_decl.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <clc/atomic/atomic_decl.inc> +#include <clc/math/gentype.inc> + +#undef __CLC_FUNCTION + +#endif // __CLC_ATOMIC_CLC_ATOMIC_FETCH_MIN_H__ diff --git a/libclc/clc/include/clc/atomic/clc_atomic_fetch_or.h b/libclc/clc/include/clc/atomic/clc_atomic_fetch_or.h new file mode 100644 index 0000000000000..ab303cc673ba2 --- /dev/null +++ b/libclc/clc/include/clc/atomic/clc_atomic_fetch_or.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// 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_ATOMIC_CLC_ATOMIC_FETCH_OR_H__ +#define __CLC_ATOMIC_CLC_ATOMIC_FETCH_OR_H__ + +#include <clc/internal/clc.h> + +#define __CLC_FUNCTION __clc_atomic_fetch_or + +#define __CLC_BODY <clc/atomic/atomic_decl.inc> +#include <clc/integer/gentype.inc> + +#undef __CLC_FUNCTION + +#endif // __CLC_ATOMIC_CLC_ATOMIC_FETCH_OR_H__ diff --git a/libclc/clc/include/clc/atomic/clc_atomic_fetch_sub.h b/libclc/clc/include/clc/atomic/clc_atomic_fetch_sub.h new file mode 100644 index 0000000000000..d9deae085a61e --- /dev/null +++ b/libclc/clc/include/clc/atomic/clc_atomic_fetch_sub.h @@ -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_ATOMIC_CLC_ATOMIC_FETCH_SUB_H__ +#define __CLC_ATOMIC_CLC_ATOMIC_FETCH_SUB_H__ + +#include <clc/internal/clc.h> + +#define __CLC_FUNCTION __clc_atomic_fetch_sub + +#define __CLC_BODY <clc/atomic/atomic_decl.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <clc/atomic/atomic_decl.inc> +#include <clc/math/gentype.inc> + +#undef __CLC_FUNCTION + +#endif // __CLC_ATOMIC_CLC_ATOMIC_FETCH_SUB_H__ diff --git a/libclc/clc/include/clc/atomic/clc_atomic_fetch_xor.h b/libclc/clc/include/clc/atomic/clc_atomic_fetch_xor.h new file mode 100644 index 0000000000000..fe13a641fc1cd --- /dev/null +++ b/libclc/clc/include/clc/atomic/clc_atomic_fetch_xor.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// 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_ATOMIC_CLC_ATOMIC_FETCH_XOR_H__ +#define __CLC_ATOMIC_CLC_ATOMIC_FETCH_XOR_H__ + +#include <clc/internal/clc.h> + +#define __CLC_FUNCTION __clc_atomic_fetch_xor + +#define __CLC_BODY <clc/atomic/atomic_decl.inc> +#include <clc/integer/gentype.inc> + +#undef __CLC_FUNCTION + +#endif // __CLC_ATOMIC_CLC_ATOMIC_FETCH_XOR_H__ diff --git a/libclc/clc/include/clc/atomic/clc_atomic_inc.h b/libclc/clc/include/clc/atomic/clc_atomic_inc.h new file mode 100644 index 0000000000000..c6fcdad30949b --- /dev/null +++ b/libclc/clc/include/clc/atomic/clc_atomic_inc.h @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// 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_ATOMIC_CLC_ATOMIC_INC_H__ +#define __CLC_ATOMIC_CLC_ATOMIC_INC_H__ + +#include <clc/internal/clc.h> + +#define __CLC_FUNCTION __clc_atomic_inc +#define __CLC_NO_VALUE_ARG + +#define __CLC_BODY <clc/atomic/atomic_decl.inc> +#include <clc/integer/gentype.inc> + +#undef __CLC_NO_VALUE_ARG +#undef __CLC_FUNCTION + +#endif // __CLC_ATOMIC_CLC_ATOMIC_INC_H__ diff --git a/libclc/clc/include/clc/atomic/clc_atomic_load.h b/libclc/clc/include/clc/atomic/clc_atomic_load.h new file mode 100644 index 0000000000000..3abfce86b1947 --- /dev/null +++ b/libclc/clc/include/clc/atomic/clc_atomic_load.h @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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_ATOMIC_CLC_ATOMIC_LOAD_H__ +#define __CLC_ATOMIC_CLC_ATOMIC_LOAD_H__ + +#include <clc/internal/clc.h> + +#define __CLC_FUNCTION __clc_atomic_load +#define __CLC_NO_VALUE_ARG + +#define __CLC_BODY <clc/atomic/atomic_decl.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <clc/atomic/atomic_decl.inc> +#include <clc/math/gentype.inc> + +#undef __CLC_NO_VALUE_ARG +#undef __CLC_FUNCTION + +#endif // __CLC_ATOMIC_CLC_ATOMIC_LOAD_H__ diff --git a/libclc/clc/include/clc/atomic/clc_atomic_store.h b/libclc/clc/include/clc/atomic/clc_atomic_store.h new file mode 100644 index 0000000000000..94d77621735d0 --- /dev/null +++ b/libclc/clc/include/clc/atomic/clc_atomic_store.h @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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_ATOMIC_CLC_ATOMIC_STORE_H__ +#define __CLC_ATOMIC_CLC_ATOMIC_STORE_H__ + +#include <clc/internal/clc.h> + +#define __CLC_FUNCTION __clc_atomic_store +#define __CLC_RETURN_VOID + +#define __CLC_BODY <clc/atomic/atomic_decl.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <clc/atomic/atomic_decl.inc> +#include <clc/math/gentype.inc> + +#undef __CLC_RETURN_VOID +#undef __CLC_FUNCTION + +#endif // __CLC_ATOMIC_CLC_ATOMIC_STORE_H__ diff --git a/libclc/clc/lib/generic/SOURCES b/libclc/clc/lib/generic/SOURCES index d285bbba3dd26..6264c0f6390af 100644 --- a/libclc/clc/lib/generic/SOURCES +++ b/libclc/clc/lib/generic/SOURCES @@ -1,4 +1,17 @@ async/clc_prefetch.cl +atomic/clc_atomic_compare_exchange.cl +atomic/clc_atomic_dec.cl +atomic/clc_atomic_exchange.cl +atomic/clc_atomic_fetch_add.cl +atomic/clc_atomic_fetch_and.cl +atomic/clc_atomic_fetch_max.cl +atomic/clc_atomic_fetch_min.cl +atomic/clc_atomic_fetch_or.cl +atomic/clc_atomic_fetch_sub.cl +atomic/clc_atomic_fetch_xor.cl +atomic/clc_atomic_inc.cl +atomic/clc_atomic_load.cl +atomic/clc_atomic_store.cl common/clc_degrees.cl common/clc_radians.cl common/clc_sign.cl diff --git a/libclc/clc/lib/generic/atomic/atomic_def.inc b/libclc/clc/lib/generic/atomic/atomic_def.inc new file mode 100644 index 0000000000000..6bdda7fc4548a --- /dev/null +++ b/libclc/clc/lib/generic/atomic/atomic_def.inc @@ -0,0 +1,65 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifdef __CLC_SCALAR +#if defined(__CLC_FPSIZE) || (__CLC_GENSIZE >= 32) + +#ifndef __CLC_PTR_CASTTYPE +#define __CLC_PTR_CASTTYPE __CLC_GENTYPE +#endif + +#ifndef __CLC_AS_RETTYPE +#define __CLC_AS_RETTYPE(x) x +#endif + +#ifdef __CLC_NO_VALUE_ARG +#define __CLC_DEFINE_ATOMIC(ADDRSPACE) \ + _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION( \ + volatile ADDRSPACE __CLC_GENTYPE *Ptr, int MemoryOrder, \ + int MemoryScope) { \ + return __CLC_AS_RETTYPE(__IMPL_FUNCTION( \ + (ADDRSPACE __CLC_PTR_CASTTYPE *)Ptr, MemoryOrder, MemoryScope)); \ + } +#elif defined(__CLC_INC_DEC) +#define __CLC_DEFINE_ATOMIC(ADDRSPACE) \ + _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION( \ + volatile ADDRSPACE __CLC_GENTYPE *Ptr, int MemoryOrder, \ + int MemoryScope) { \ + return __CLC_AS_RETTYPE( \ + __IMPL_FUNCTION((ADDRSPACE __CLC_PTR_CASTTYPE *)Ptr, (__CLC_GENTYPE)1, \ + MemoryOrder, MemoryScope)); \ + } +#elif defined(__CLC_RETURN_VOID) +#define __CLC_DEFINE_ATOMIC(ADDRSPACE) \ + _CLC_OVERLOAD _CLC_DECL void FUNCTION(volatile ADDRSPACE __CLC_GENTYPE *Ptr, \ + __CLC_GENTYPE Value, int MemoryOrder, \ + int MemoryScope) { \ + __IMPL_FUNCTION((ADDRSPACE __CLC_PTR_CASTTYPE *)Ptr, Value, MemoryOrder, \ + MemoryScope); \ + } +#else +#define __CLC_DEFINE_ATOMIC(ADDRSPACE) \ + _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION( \ + volatile ADDRSPACE __CLC_GENTYPE *Ptr, __CLC_GENTYPE Value, \ + int MemoryOrder, int MemoryScope) { \ + return __CLC_AS_RETTYPE( \ + __IMPL_FUNCTION((ADDRSPACE __CLC_PTR_CASTTYPE *)Ptr, Value, \ + MemoryOrder, MemoryScope)); \ + } +#endif + +__CLC_DEFINE_ATOMIC(global) +__CLC_DEFINE_ATOMIC(local) +#if _CLC_GENERIC_AS_SUPPORTED +__CLC_DEFINE_ATOMIC() +#endif + +#undef __CLC_DEFINE_ATOMIC + +#endif // defined(__CLC_FPSIZE) || (__CLC_GENSIZE >= 32) +#endif // __CLC_SCALAR diff --git a/libclc/clc/lib/generic/atomic/clc_atomic_compare_exchange.cl b/libclc/clc/lib/generic/atomic/clc_atomic_compare_exchange.cl new file mode 100644 index 0000000000000..796dedcef3857 --- /dev/null +++ b/libclc/clc/lib/generic/atomic/clc_atomic_compare_exchange.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include <clc/atomic/clc_atomic_compare_exchange.h> + +#define __CLC_BODY <clc_atomic_compare_exchange.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <clc_atomic_compare_exchange.inc> +#include <clc/math/gentype.inc> diff --git a/libclc/clc/lib/generic/atomic/clc_atomic_compare_exchange.inc b/libclc/clc/lib/generic/atomic/clc_atomic_compare_exchange.inc new file mode 100644 index 0000000000000..4bacf2db5389d --- /dev/null +++ b/libclc/clc/lib/generic/atomic/clc_atomic_compare_exchange.inc @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifdef __CLC_SCALAR +#if defined(__CLC_FPSIZE) || (__CLC_GENSIZE >= 32) + +#ifdef __CLC_FPSIZE + +#define __CLC_DEFINE_ATOMIC(ADDRSPACE) \ + _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __clc_atomic_compare_exchange( \ + volatile ADDRSPACE __CLC_GENTYPE *Ptr, __CLC_GENTYPE Comparator, \ + __CLC_GENTYPE Value, int MemoryOrderEqual, int MemoryOrderUnequal, \ + int MemoryScope) { \ + __CLC_U_GENTYPE Comp = __CLC_AS_U_GENTYPE(Comparator); \ + __scoped_atomic_compare_exchange_n( \ + (ADDRSPACE __CLC_U_GENTYPE *)Ptr, &Comp, __CLC_AS_U_GENTYPE(Value), \ + false, MemoryOrderEqual, MemoryOrderUnequal, MemoryScope); \ + return __CLC_AS_GENTYPE(Comp); \ + } + +#else + +#define __CLC_DEFINE_ATOMIC(ADDRSPACE) \ + _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __clc_atomic_compare_exchange( \ + volatile ADDRSPACE __CLC_GENTYPE *Ptr, __CLC_GENTYPE Comparator, \ + __CLC_GENTYPE Value, int MemoryOrderEqual, int MemoryOrderUnequal, \ + int MemoryScope) { \ + __scoped_atomic_compare_exchange_n(Ptr, &Comparator, Value, false, \ + MemoryOrderEqual, MemoryOrderUnequal, \ + MemoryScope); \ + return Comparator; \ + } + +#endif // __CLC_FPSIZE + +__CLC_DEFINE_ATOMIC(global) +__CLC_DEFINE_ATOMIC(local) +#if _CLC_GENERIC_AS_SUPPORTED +__CLC_DEFINE_ATOMIC() +#endif + +#undef __CLC_DEFINE_ATOMIC + +#endif // defined(__CLC_FPSIZE) || (__CLC_GENSIZE >= 32) +#endif // __CLC_SCALAR diff --git a/libclc/clc/lib/generic/atomic/clc_atomic_dec.cl b/libclc/clc/lib/generic/atomic/clc_atomic_dec.cl new file mode 100644 index 0000000000000..d49233dd71f2f --- /dev/null +++ b/libclc/clc/lib/generic/atomic/clc_atomic_dec.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include <clc/atomic/clc_atomic_dec.h> + +#define FUNCTION __clc_atomic_dec +#define __IMPL_FUNCTION __scoped_atomic_fetch_add +#define __CLC_INC_DEC + +#define __CLC_BODY <atomic_def.inc> +#include <clc/integer/gentype.inc> diff --git a/libclc/clc/lib/generic/atomic/clc_atomic_exchange.cl b/libclc/clc/lib/generic/atomic/clc_atomic_exchange.cl new file mode 100644 index 0000000000000..9ece22d1bf892 --- /dev/null +++ b/libclc/clc/lib/generic/atomic/clc_atomic_exchange.cl @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include <clc/atomic/clc_atomic_exchange.h> + +#define FUNCTION __clc_atomic_exchange +#define __IMPL_FUNCTION __scoped_atomic_exchange_n + +#define __CLC_BODY <atomic_def.inc> +#include <clc/integer/gentype.inc> + +#undef __CLC_PTR_CASTTYPE +#undef __CLC_AS_RETTYPE +#define __CLC_PTR_CASTTYPE __CLC_BIT_INTN +#define __CLC_AS_RETTYPE(x) __CLC_AS_GENTYPE(x) + +#define __CLC_BODY <atomic_def.inc> +#include <clc/math/gentype.inc> diff --git a/libclc/clc/lib/generic/atomic/clc_atomic_fetch_add.cl b/libclc/clc/lib/generic/atomic/clc_atomic_fetch_add.cl new file mode 100644 index 0000000000000..82c4ff2ca3be6 --- /dev/null +++ b/libclc/clc/lib/generic/atomic/clc_atomic_fetch_add.cl @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include <clc/atomic/clc_atomic_fetch_add.h> + +#define FUNCTION __clc_atomic_fetch_add +#define __IMPL_FUNCTION __scoped_atomic_fetch_add + +#define __CLC_BODY <atomic_def.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <atomic_def.inc> +#include <clc/math/gentype.inc> diff --git a/libclc/clc/lib/generic/atomic/clc_atomic_fetch_and.cl b/libclc/clc/lib/generic/atomic/clc_atomic_fetch_and.cl new file mode 100644 index 0000000000000..0b9486a8ee7ff --- /dev/null +++ b/libclc/clc/lib/generic/atomic/clc_atomic_fetch_and.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include <clc/atomic/clc_atomic_fetch_and.h> + +#define FUNCTION __clc_atomic_fetch_and +#define __IMPL_FUNCTION __scoped_atomic_fetch_and + +#define __CLC_BODY <atomic_def.inc> +#include <clc/integer/gentype.inc> diff --git a/libclc/clc/lib/generic/atomic/clc_atomic_fetch_max.cl b/libclc/clc/lib/generic/atomic/clc_atomic_fetch_max.cl new file mode 100644 index 0000000000000..3726dbfeab8f5 --- /dev/null +++ b/libclc/clc/lib/generic/atomic/clc_atomic_fetch_max.cl @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include <clc/atomic/clc_atomic_fetch_max.h> + +#define FUNCTION __clc_atomic_fetch_max +#define __IMPL_FUNCTION __scoped_atomic_fetch_max + +#define __CLC_BODY <atomic_def.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <atomic_def.inc> +#include <clc/math/gentype.inc> diff --git a/libclc/clc/lib/generic/atomic/clc_atomic_fetch_min.cl b/libclc/clc/lib/generic/atomic/clc_atomic_fetch_min.cl new file mode 100644 index 0000000000000..763283d8dce35 --- /dev/null +++ b/libclc/clc/lib/generic/atomic/clc_atomic_fetch_min.cl @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include <clc/atomic/clc_atomic_fetch_min.h> + +#define FUNCTION __clc_atomic_fetch_min +#define __IMPL_FUNCTION __scoped_atomic_fetch_min + +#define __CLC_BODY <atomic_def.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <atomic_def.inc> +#include <clc/math/gentype.inc> diff --git a/libclc/clc/lib/generic/atomic/clc_atomic_fetch_or.cl b/libclc/clc/lib/generic/atomic/clc_atomic_fetch_or.cl new file mode 100644 index 0000000000000..2f159c1091953 --- /dev/null +++ b/libclc/clc/lib/generic/atomic/clc_atomic_fetch_or.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include <clc/atomic/clc_atomic_fetch_or.h> + +#define FUNCTION __clc_atomic_fetch_or +#define __IMPL_FUNCTION __scoped_atomic_fetch_or + +#define __CLC_BODY <atomic_def.inc> +#include <clc/integer/gentype.inc> diff --git a/libclc/clc/lib/generic/atomic/clc_atomic_fetch_sub.cl b/libclc/clc/lib/generic/atomic/clc_atomic_fetch_sub.cl new file mode 100644 index 0000000000000..0000cdf10b598 --- /dev/null +++ b/libclc/clc/lib/generic/atomic/clc_atomic_fetch_sub.cl @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include <clc/atomic/clc_atomic_fetch_sub.h> + +#define FUNCTION __clc_atomic_fetch_sub +#define __IMPL_FUNCTION __scoped_atomic_fetch_sub + +#define __CLC_BODY <atomic_def.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <atomic_def.inc> +#include <clc/math/gentype.inc> diff --git a/libclc/clc/lib/generic/atomic/clc_atomic_fetch_xor.cl b/libclc/clc/lib/generic/atomic/clc_atomic_fetch_xor.cl new file mode 100644 index 0000000000000..e21cbc8a3bf2c --- /dev/null +++ b/libclc/clc/lib/generic/atomic/clc_atomic_fetch_xor.cl @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include <clc/atomic/clc_atomic_fetch_xor.h> + +#define FUNCTION __clc_atomic_fetch_xor +#define __IMPL_FUNCTION __scoped_atomic_fetch_xor + +#define __CLC_BODY <atomic_def.inc> +#include <clc/integer/gentype.inc> diff --git a/libclc/clc/lib/generic/atomic/clc_atomic_inc.cl b/libclc/clc/lib/generic/atomic/clc_atomic_inc.cl new file mode 100644 index 0000000000000..e348687acbd76 --- /dev/null +++ b/libclc/clc/lib/generic/atomic/clc_atomic_inc.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include <clc/atomic/clc_atomic_inc.h> + +#define FUNCTION __clc_atomic_inc +#define __IMPL_FUNCTION __scoped_atomic_fetch_sub +#define __CLC_INC_DEC + +#define __CLC_BODY <atomic_def.inc> +#include <clc/integer/gentype.inc> diff --git a/libclc/clc/lib/generic/atomic/clc_atomic_load.cl b/libclc/clc/lib/generic/atomic/clc_atomic_load.cl new file mode 100644 index 0000000000000..9d49fcc609f83 --- /dev/null +++ b/libclc/clc/lib/generic/atomic/clc_atomic_load.cl @@ -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 +// +//===----------------------------------------------------------------------===// + +#include <clc/atomic/clc_atomic_load.h> + +#define FUNCTION __clc_atomic_load +#define __IMPL_FUNCTION __scoped_atomic_load_n +#define __CLC_NO_VALUE_ARG + +#define __CLC_BODY <atomic_def.inc> +#include <clc/integer/gentype.inc> + +#undef __CLC_PTR_CASTTYPE +#undef __CLC_AS_RETTYPE +#define __CLC_PTR_CASTTYPE __CLC_BIT_INTN +#define __CLC_AS_RETTYPE(x) __CLC_AS_GENTYPE(x) + +#define __CLC_BODY <atomic_def.inc> +#include <clc/math/gentype.inc> diff --git a/libclc/clc/lib/generic/atomic/clc_atomic_store.cl b/libclc/clc/lib/generic/atomic/clc_atomic_store.cl new file mode 100644 index 0000000000000..56a229a4a9807 --- /dev/null +++ b/libclc/clc/lib/generic/atomic/clc_atomic_store.cl @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include <clc/atomic/clc_atomic_store.h> + +#define FUNCTION __clc_atomic_store +#define __IMPL_FUNCTION __scoped_atomic_store_n +#define __CLC_RETURN_VOID + +#define __CLC_BODY <atomic_def.inc> +#include <clc/integer/gentype.inc> + +#undef __CLC_PTR_CASTTYPE +#define __CLC_PTR_CASTTYPE __CLC_BIT_INTN + +#define __CLC_BODY <atomic_def.inc> +#include <clc/math/gentype.inc> diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_add.h b/libclc/opencl/include/clc/opencl/atomic/atomic_add.h index 937def3f4a2ae..dc2e09cd7abb9 100644 --- a/libclc/opencl/include/clc/opencl/atomic/atomic_add.h +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_add.h @@ -7,4 +7,4 @@ //===----------------------------------------------------------------------===// #define __CLC_FUNCTION atomic_add -#include <clc/opencl/atomic/atomic_decl.inc> +#include <clc/opencl/atomic/atomic_decl_legacy.inc> diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_and.h b/libclc/opencl/include/clc/opencl/atomic/atomic_and.h index 5f353f40318f6..c16c29ef69d1f 100644 --- a/libclc/opencl/include/clc/opencl/atomic/atomic_and.h +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_and.h @@ -7,4 +7,4 @@ //===----------------------------------------------------------------------===// #define __CLC_FUNCTION atomic_and -#include <clc/opencl/atomic/atomic_decl.inc> +#include <clc/opencl/atomic/atomic_decl_legacy.inc> diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_compare_exchange_strong.h b/libclc/opencl/include/clc/opencl/atomic/atomic_compare_exchange_strong.h new file mode 100644 index 0000000000000..21a9b5d047655 --- /dev/null +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_compare_exchange_strong.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#define FUNCTION atomic_compare_exchange_strong +#define __CLC_COMPARE_EXCHANGE + +#define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc> +#include <clc/math/gentype.inc> + +#undef __CLC_COMPARE_EXCHANGE +#undef FUNCTION diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_compare_exchange_weak.h b/libclc/opencl/include/clc/opencl/atomic/atomic_compare_exchange_weak.h new file mode 100644 index 0000000000000..a0d034270accc --- /dev/null +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_compare_exchange_weak.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#define FUNCTION atomic_compare_exchange_weak +#define __CLC_COMPARE_EXCHANGE + +#define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc> +#include <clc/math/gentype.inc> + +#undef __CLC_COMPARE_EXCHANGE +#undef FUNCTION diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_decl.inc b/libclc/opencl/include/clc/opencl/atomic/atomic_decl.inc index 0cfd4c3eab5f6..638ab5f590eae 100644 --- a/libclc/opencl/include/clc/opencl/atomic/atomic_decl.inc +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_decl.inc @@ -6,17 +6,57 @@ // //===----------------------------------------------------------------------===// -#define __CLC_DECLARE_ATOMIC(ADDRSPACE, TYPE) \ - _CLC_OVERLOAD _CLC_DECL TYPE __CLC_FUNCTION(volatile ADDRSPACE TYPE *, TYPE); +#ifdef __CLC_SCALAR -#define __CLC_DECLARE_ATOMIC_ADDRSPACE(TYPE) \ - __CLC_DECLARE_ATOMIC(global, TYPE) \ - __CLC_DECLARE_ATOMIC(local, TYPE) +#if (defined(cl_khr_int64_base_atomics) && \ + defined(cl_khr_int64_extended_atomics)) +#define HAVE_64_ATOMIC +#endif +#if defined(__CLC_FPSIZE) && (__CLC_FPSIZE < 64 || (defined(HAVE_64_ATOMIC) && \ + defined(__opencl_c_fp64))) +#define HAVE_FP_ATOMIC +#endif +#if defined(__CLC_GENSIZE) && \ + ((__CLC_GENSIZE == 32) || \ + (__CLC_GENSIZE == 64 && \ + (defined(HAVE_64_ATOMIC) && defined(__opencl_c_int64)))) +#define HAVE_INT_ATOMIC +#endif +#if defined(HAVE_FP_ATOMIC) || defined(HAVE_INT_ATOMIC) -__CLC_DECLARE_ATOMIC_ADDRSPACE(int) -__CLC_DECLARE_ATOMIC_ADDRSPACE(uint) +#define __CLC_ATOMIC_GENTYPE __CLC_XCONCAT(atomic_, __CLC_GENTYPE) -#undef __CLC_DECLARE_ATOMIC_ADDRSPACE -#undef __CLC_DECLARE_ATOMIC +#ifdef __CLC_NO_VALUE_ARG +#define __CLC_DEFINE_ATOMIC(ADDRSPACE) \ + _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION( \ + volatile ADDRSPACE __CLC_ATOMIC_GENTYPE *Ptr); +#elif defined(__CLC_RETURN_VOID) +#define __CLC_DEFINE_ATOMIC(ADDRSPACE) \ + _CLC_OVERLOAD _CLC_DECL void FUNCTION( \ + volatile ADDRSPACE __CLC_ATOMIC_GENTYPE *Ptr, __CLC_GENTYPE Value); +#elif defined(__CLC_COMPARE_EXCHANGE) +#define __CLC_DEFINE_ATOMIC(ADDRSPACE) \ + _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION( \ + volatile ADDRSPACE __CLC_ATOMIC_GENTYPE *Ptr, \ + ADDRSPACE __CLC_GENTYPE *Expected, __CLC_GENTYPE Desired); +#else +#define __CLC_DEFINE_ATOMIC(ADDRSPACE) \ + _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION( \ + volatile ADDRSPACE __CLC_ATOMIC_GENTYPE *Ptr, __CLC_GENTYPE Value); +#endif -#undef __CLC_FUNCTION +__CLC_DEFINE_ATOMIC(global) +__CLC_DEFINE_ATOMIC(local) +#if _CLC_GENERIC_AS_SUPPORTED +__CLC_DEFINE_ATOMIC() +#endif + +#undef __CLC_DEFINE_ATOMIC + +#endif // HAVE_FP_ATOMIC || HAVE_INT_ATOMIC + +#undef HAVE_INT_ATOMIC +#undef HAVE_FP_ATOMIC +#undef HAVE_64_ATOMIC + +#endif // __CLC_SCALAR diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_decl_legacy.inc b/libclc/opencl/include/clc/opencl/atomic/atomic_decl_legacy.inc new file mode 100644 index 0000000000000..0cfd4c3eab5f6 --- /dev/null +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_decl_legacy.inc @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#define __CLC_DECLARE_ATOMIC(ADDRSPACE, TYPE) \ + _CLC_OVERLOAD _CLC_DECL TYPE __CLC_FUNCTION(volatile ADDRSPACE TYPE *, TYPE); + +#define __CLC_DECLARE_ATOMIC_ADDRSPACE(TYPE) \ + __CLC_DECLARE_ATOMIC(global, TYPE) \ + __CLC_DECLARE_ATOMIC(local, TYPE) + +__CLC_DECLARE_ATOMIC_ADDRSPACE(int) +__CLC_DECLARE_ATOMIC_ADDRSPACE(uint) + +#undef __CLC_DECLARE_ATOMIC_ADDRSPACE +#undef __CLC_DECLARE_ATOMIC + +#undef __CLC_FUNCTION diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_exchange.h b/libclc/opencl/include/clc/opencl/atomic/atomic_exchange.h new file mode 100644 index 0000000000000..c27a4a3b2c05f --- /dev/null +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_exchange.h @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#define FUNCTION atomic_exchange + +#define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc> +#include <clc/math/gentype.inc> + +#undef FUNCTION diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_add.h b/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_add.h new file mode 100644 index 0000000000000..8e7d852d4b9ca --- /dev/null +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_add.h @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#define FUNCTION atomic_fetch_add + +#define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc> +#include <clc/math/gentype.inc> + +#undef FUNCTION diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_and.h b/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_and.h new file mode 100644 index 0000000000000..2f43a90db8195 --- /dev/null +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_and.h @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#define FUNCTION atomic_fetch_and + +#define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc> +#include <clc/integer/gentype.inc> + +#undef FUNCTION diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_max.h b/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_max.h new file mode 100644 index 0000000000000..064bc0e66cf68 --- /dev/null +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_max.h @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#define FUNCTION atomic_fetch_max + +#define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc> +#include <clc/math/gentype.inc> + +#undef FUNCTION diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_min.h b/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_min.h new file mode 100644 index 0000000000000..802ae6a6e7e32 --- /dev/null +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_min.h @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#define FUNCTION atomic_fetch_min + +#define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc> +#include <clc/math/gentype.inc> + +#undef FUNCTION diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_or.h b/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_or.h new file mode 100644 index 0000000000000..21b0d1a737ced --- /dev/null +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_or.h @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#define FUNCTION atomic_fetch_or + +#define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc> +#include <clc/integer/gentype.inc> + +#undef FUNCTION diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_sub.h b/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_sub.h new file mode 100644 index 0000000000000..bd654fbee2cec --- /dev/null +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_sub.h @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#define FUNCTION atomic_fetch_sub + +#define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc> +#include <clc/math/gentype.inc> + +#undef FUNCTION diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_xor.h b/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_xor.h new file mode 100644 index 0000000000000..7021ddb4b488b --- /dev/null +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_xor.h @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#define FUNCTION atomic_fetch_xor + +#define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc> +#include <clc/integer/gentype.inc> + +#undef FUNCTION diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_load.h b/libclc/opencl/include/clc/opencl/atomic/atomic_load.h new file mode 100644 index 0000000000000..b7030517be2fc --- /dev/null +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_load.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#define FUNCTION atomic_load +#define __CLC_NO_VALUE_ARG + +#define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc> +#include <clc/math/gentype.inc> + +#undef __CLC_NO_VALUE_ARG +#undef FUNCTION diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_max.h b/libclc/opencl/include/clc/opencl/atomic/atomic_max.h index 13832423cfeec..2a20920adaffe 100644 --- a/libclc/opencl/include/clc/opencl/atomic/atomic_max.h +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_max.h @@ -7,4 +7,4 @@ //===----------------------------------------------------------------------===// #define __CLC_FUNCTION atomic_max -#include <clc/opencl/atomic/atomic_decl.inc> +#include <clc/opencl/atomic/atomic_decl_legacy.inc> diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_min.h b/libclc/opencl/include/clc/opencl/atomic/atomic_min.h index 3bd47a3f7837d..ba6c45e63448e 100644 --- a/libclc/opencl/include/clc/opencl/atomic/atomic_min.h +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_min.h @@ -7,4 +7,4 @@ //===----------------------------------------------------------------------===// #define __CLC_FUNCTION atomic_min -#include <clc/opencl/atomic/atomic_decl.inc> +#include <clc/opencl/atomic/atomic_decl_legacy.inc> diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_or.h b/libclc/opencl/include/clc/opencl/atomic/atomic_or.h index 13f84ea49a5ab..9971e0c2c1f76 100644 --- a/libclc/opencl/include/clc/opencl/atomic/atomic_or.h +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_or.h @@ -7,4 +7,4 @@ //===----------------------------------------------------------------------===// #define __CLC_FUNCTION atomic_or -#include <clc/opencl/atomic/atomic_decl.inc> +#include <clc/opencl/atomic/atomic_decl_legacy.inc> diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_store.h b/libclc/opencl/include/clc/opencl/atomic/atomic_store.h new file mode 100644 index 0000000000000..2a423b1f281fa --- /dev/null +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_store.h @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#define FUNCTION atomic_store +#define __CLC_RETURN_VOID + +#define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc> +#include <clc/math/gentype.inc> + +#undef __CLC_RETURN_VOID +#undef FUNCTION diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_sub.h b/libclc/opencl/include/clc/opencl/atomic/atomic_sub.h index eedc9d0e76054..1480992adf162 100644 --- a/libclc/opencl/include/clc/opencl/atomic/atomic_sub.h +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_sub.h @@ -7,4 +7,4 @@ //===----------------------------------------------------------------------===// #define __CLC_FUNCTION atomic_sub -#include <clc/opencl/atomic/atomic_decl.inc> +#include <clc/opencl/atomic/atomic_decl_legacy.inc> diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_xchg.h b/libclc/opencl/include/clc/opencl/atomic/atomic_xchg.h index ec322d56e23d1..20712281082d4 100644 --- a/libclc/opencl/include/clc/opencl/atomic/atomic_xchg.h +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_xchg.h @@ -10,4 +10,4 @@ _CLC_OVERLOAD _CLC_DECL float __CLC_FUNCTION(volatile local float *, float); _CLC_OVERLOAD _CLC_DECL float __CLC_FUNCTION(volatile global float *, float); -#include <clc/opencl/atomic/atomic_decl.inc> +#include <clc/opencl/atomic/atomic_decl_legacy.inc> diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_xor.h b/libclc/opencl/include/clc/opencl/atomic/atomic_xor.h index 6f6b4564fdf3c..c02495f19ce3e 100644 --- a/libclc/opencl/include/clc/opencl/atomic/atomic_xor.h +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_xor.h @@ -7,4 +7,4 @@ //===----------------------------------------------------------------------===// #define __CLC_FUNCTION atomic_xor -#include <clc/opencl/atomic/atomic_decl.inc> +#include <clc/opencl/atomic/atomic_decl_legacy.inc> diff --git a/libclc/opencl/include/clc/opencl/clc.h b/libclc/opencl/include/clc/opencl/clc.h index 5859a00c3158b..58d2f43be22a8 100644 --- a/libclc/opencl/include/clc/opencl/clc.h +++ b/libclc/opencl/include/clc/opencl/clc.h @@ -229,11 +229,23 @@ #include <clc/opencl/atomic/atomic_add.h> #include <clc/opencl/atomic/atomic_and.h> #include <clc/opencl/atomic/atomic_cmpxchg.h> +#include <clc/opencl/atomic/atomic_compare_exchange_strong.h> +#include <clc/opencl/atomic/atomic_compare_exchange_weak.h> #include <clc/opencl/atomic/atomic_dec.h> +#include <clc/opencl/atomic/atomic_exchange.h> +#include <clc/opencl/atomic/atomic_fetch_add.h> +#include <clc/opencl/atomic/atomic_fetch_and.h> +#include <clc/opencl/atomic/atomic_fetch_max.h> +#include <clc/opencl/atomic/atomic_fetch_min.h> +#include <clc/opencl/atomic/atomic_fetch_or.h> +#include <clc/opencl/atomic/atomic_fetch_sub.h> +#include <clc/opencl/atomic/atomic_fetch_xor.h> #include <clc/opencl/atomic/atomic_inc.h> +#include <clc/opencl/atomic/atomic_load.h> #include <clc/opencl/atomic/atomic_max.h> #include <clc/opencl/atomic/atomic_min.h> #include <clc/opencl/atomic/atomic_or.h> +#include <clc/opencl/atomic/atomic_store.h> #include <clc/opencl/atomic/atomic_sub.h> #include <clc/opencl/atomic/atomic_xchg.h> #include <clc/opencl/atomic/atomic_xor.h> diff --git a/libclc/opencl/lib/generic/SOURCES b/libclc/opencl/lib/generic/SOURCES index 46ce6d6e36c24..eeda7c00127a0 100644 --- a/libclc/opencl/lib/generic/SOURCES +++ b/libclc/opencl/lib/generic/SOURCES @@ -8,24 +8,36 @@ atomic/atom_add.cl atomic/atom_and.cl atomic/atom_cmpxchg.cl atomic/atom_dec.cl -atomic/atom_inc.cl -atomic/atom_max.cl -atomic/atom_min.cl -atomic/atom_or.cl -atomic/atom_sub.cl -atomic/atom_xchg.cl -atomic/atom_xor.cl atomic/atomic_add.cl atomic/atomic_and.cl atomic/atomic_cmpxchg.cl +atomic/atomic_compare_exchange_strong.cl +atomic/atomic_compare_exchange_weak.cl atomic/atomic_dec.cl +atomic/atomic_exchange.cl +atomic/atomic_fetch_add.cl +atomic/atomic_fetch_and.cl +atomic/atomic_fetch_max.cl +atomic/atomic_fetch_min.cl +atomic/atomic_fetch_or.cl +atomic/atomic_fetch_sub.cl +atomic/atomic_fetch_xor.cl atomic/atomic_inc.cl +atomic/atomic_load.cl atomic/atomic_max.cl atomic/atomic_min.cl atomic/atomic_or.cl +atomic/atomic_store.cl atomic/atomic_sub.cl atomic/atomic_xchg.cl atomic/atomic_xor.cl +atomic/atom_inc.cl +atomic/atom_max.cl +atomic/atom_min.cl +atomic/atom_or.cl +atomic/atom_sub.cl +atomic/atom_xchg.cl +atomic/atom_xor.cl common/degrees.cl common/mix.cl common/radians.cl diff --git a/libclc/opencl/lib/generic/atomic/atomic_compare_exchange_strong.cl b/libclc/opencl/lib/generic/atomic/atomic_compare_exchange_strong.cl new file mode 100644 index 0000000000000..f364303b8cfe9 --- /dev/null +++ b/libclc/opencl/lib/generic/atomic/atomic_compare_exchange_strong.cl @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include <clc/atomic/clc_atomic_compare_exchange.h> +#include <clc/opencl/clc.h> + +#define FUNCTION atomic_compare_exchange_strong +#define __CLC_COMPARE_EXCHANGE + +#define __CLC_BODY <atomic_def.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <atomic_def.inc> +#include <clc/math/gentype.inc> diff --git a/libclc/opencl/lib/generic/atomic/atomic_compare_exchange_weak.cl b/libclc/opencl/lib/generic/atomic/atomic_compare_exchange_weak.cl new file mode 100644 index 0000000000000..443235128def5 --- /dev/null +++ b/libclc/opencl/lib/generic/atomic/atomic_compare_exchange_weak.cl @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include <clc/atomic/clc_atomic_compare_exchange.h> +#include <clc/opencl/clc.h> + +#define FUNCTION atomic_compare_exchange_weak +#define __CLC_COMPARE_EXCHANGE + +#define __CLC_BODY <atomic_def.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <atomic_def.inc> +#include <clc/math/gentype.inc> diff --git a/libclc/opencl/lib/generic/atomic/atomic_dec.cl b/libclc/opencl/lib/generic/atomic/atomic_dec.cl index d67f6382fd07d..0cbcb95e623a3 100644 --- a/libclc/opencl/lib/generic/atomic/atomic_dec.cl +++ b/libclc/opencl/lib/generic/atomic/atomic_dec.cl @@ -6,15 +6,11 @@ // //===----------------------------------------------------------------------===// +#include <clc/atomic/clc_atomic_dec.h> #include <clc/opencl/clc.h> -#define IMPL(TYPE, AS) \ - _CLC_OVERLOAD _CLC_DEF TYPE atomic_dec(volatile AS TYPE *p) { \ - return __sync_fetch_and_sub(p, (TYPE)1); \ - } +#define FUNCTION atomic_dec +#define __IMPL_FUNCTION __clc_atomic_dec -IMPL(int, global) -IMPL(unsigned int, global) -IMPL(int, local) -IMPL(unsigned int, local) -#undef IMPL +#define __CLC_BODY <atomic_inc_dec.inc> +#include <clc/integer/gentype.inc> diff --git a/libclc/opencl/lib/generic/atomic/atomic_def.inc b/libclc/opencl/lib/generic/atomic/atomic_def.inc new file mode 100644 index 0000000000000..41a074ba8f4da --- /dev/null +++ b/libclc/opencl/lib/generic/atomic/atomic_def.inc @@ -0,0 +1,81 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifdef __CLC_SCALAR + +#if (defined(cl_khr_int64_base_atomics) && \ + defined(cl_khr_int64_extended_atomics)) +#define HAVE_64_ATOMIC +#endif +#if defined(__CLC_FPSIZE) && (__CLC_FPSIZE < 64 || (defined(HAVE_64_ATOMIC) && \ + defined(__opencl_c_fp64))) +#define HAVE_FP_ATOMIC +#endif +#if defined(__CLC_GENSIZE) && \ + ((__CLC_GENSIZE == 32) || \ + (__CLC_GENSIZE == 64 && \ + (defined(HAVE_64_ATOMIC) && defined(__opencl_c_int64)))) +#define HAVE_INT_ATOMIC +#endif +#if defined(HAVE_FP_ATOMIC) || defined(HAVE_INT_ATOMIC) + +#define __CLC_ATOMIC_GENTYPE __CLC_XCONCAT(atomic_, __CLC_GENTYPE) + +#ifdef __CLC_NO_VALUE_ARG +#define __CLC_DEFINE_ATOMIC(ADDRSPACE) \ + _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION( \ + volatile ADDRSPACE __CLC_ATOMIC_GENTYPE *Ptr) { \ + return __IMPL_FUNCTION((volatile ADDRSPACE __CLC_GENTYPE *)Ptr, \ + __ATOMIC_SEQ_CST, __MEMORY_SCOPE_SYSTEM); \ + } +#elif defined(__CLC_RETURN_VOID) +#define __CLC_DEFINE_ATOMIC(ADDRSPACE) \ + _CLC_OVERLOAD _CLC_DEF void FUNCTION( \ + volatile ADDRSPACE __CLC_ATOMIC_GENTYPE *Ptr, __CLC_GENTYPE Value) { \ + __IMPL_FUNCTION((volatile ADDRSPACE __CLC_GENTYPE *)Ptr, Value, \ + __ATOMIC_SEQ_CST, __MEMORY_SCOPE_SYSTEM); \ + } +#elif defined(__CLC_COMPARE_EXCHANGE) +#define __CLC_DEFINE_ATOMIC(ADDRSPACE) \ + _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION( \ + volatile ADDRSPACE __CLC_ATOMIC_GENTYPE *Ptr, \ + ADDRSPACE __CLC_GENTYPE *Expected, __CLC_GENTYPE Desired) { \ + __CLC_GENTYPE Comparator = *Expected; \ + __CLC_GENTYPE RetValue = __clc_atomic_compare_exchange( \ + (volatile ADDRSPACE __CLC_GENTYPE *)Ptr, Comparator, Desired, \ + __ATOMIC_SEQ_CST, __ATOMIC_RELAXED, __MEMORY_SCOPE_SYSTEM); \ + if (Comparator != RetValue) { \ + *Expected = RetValue; \ + return true; \ + } \ + return false; \ + } +#else +#define __CLC_DEFINE_ATOMIC(ADDRSPACE) \ + _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION( \ + volatile ADDRSPACE __CLC_ATOMIC_GENTYPE *Ptr, __CLC_GENTYPE Value) { \ + return __IMPL_FUNCTION((volatile ADDRSPACE __CLC_GENTYPE *)Ptr, Value, \ + __ATOMIC_SEQ_CST, __MEMORY_SCOPE_SYSTEM); \ + } +#endif + +__CLC_DEFINE_ATOMIC(global) +__CLC_DEFINE_ATOMIC(local) +#if _CLC_GENERIC_AS_SUPPORTED +__CLC_DEFINE_ATOMIC() +#endif + +#undef __CLC_DEFINE_ATOMIC + +#endif // HAVE_FP_ATOMIC || HAVE_INT_ATOMIC + +#undef HAVE_INT_ATOMIC +#undef HAVE_FP_ATOMIC +#undef HAVE_64_ATOMIC + +#endif // __CLC_SCALAR diff --git a/libclc/opencl/lib/generic/atomic/atomic_exchange.cl b/libclc/opencl/lib/generic/atomic/atomic_exchange.cl new file mode 100644 index 0000000000000..30fc1cf4b8c8c --- /dev/null +++ b/libclc/opencl/lib/generic/atomic/atomic_exchange.cl @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include <clc/atomic/clc_atomic_exchange.h> +#include <clc/opencl/clc.h> + +#define FUNCTION atomic_exchange +#define __IMPL_FUNCTION __clc_atomic_exchange + +#define __CLC_BODY <atomic_def.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <atomic_def.inc> +#include <clc/math/gentype.inc> diff --git a/libclc/opencl/lib/generic/atomic/atomic_fetch_add.cl b/libclc/opencl/lib/generic/atomic/atomic_fetch_add.cl new file mode 100644 index 0000000000000..74f040af81636 --- /dev/null +++ b/libclc/opencl/lib/generic/atomic/atomic_fetch_add.cl @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include <clc/atomic/clc_atomic_fetch_add.h> +#include <clc/opencl/clc.h> + +#define FUNCTION atomic_fetch_add +#define __IMPL_FUNCTION __clc_atomic_fetch_add + +#define __CLC_BODY <atomic_def.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <atomic_def.inc> +#include <clc/math/gentype.inc> diff --git a/libclc/opencl/lib/generic/atomic/atomic_fetch_and.cl b/libclc/opencl/lib/generic/atomic/atomic_fetch_and.cl new file mode 100644 index 0000000000000..46eb4775a9f5e --- /dev/null +++ b/libclc/opencl/lib/generic/atomic/atomic_fetch_and.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include <clc/atomic/clc_atomic_fetch_and.h> +#include <clc/opencl/clc.h> + +#define FUNCTION atomic_fetch_and +#define __IMPL_FUNCTION __clc_atomic_fetch_and + +#define __CLC_BODY <atomic_def.inc> +#include <clc/integer/gentype.inc> diff --git a/libclc/opencl/lib/generic/atomic/atomic_fetch_max.cl b/libclc/opencl/lib/generic/atomic/atomic_fetch_max.cl new file mode 100644 index 0000000000000..bda6b330e62c8 --- /dev/null +++ b/libclc/opencl/lib/generic/atomic/atomic_fetch_max.cl @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include <clc/atomic/clc_atomic_fetch_max.h> +#include <clc/opencl/clc.h> + +#define FUNCTION atomic_fetch_max +#define __IMPL_FUNCTION __clc_atomic_fetch_max + +#define __CLC_BODY <atomic_def.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <atomic_def.inc> +#include <clc/math/gentype.inc> diff --git a/libclc/opencl/lib/generic/atomic/atomic_fetch_min.cl b/libclc/opencl/lib/generic/atomic/atomic_fetch_min.cl new file mode 100644 index 0000000000000..8cc92ba17b8f0 --- /dev/null +++ b/libclc/opencl/lib/generic/atomic/atomic_fetch_min.cl @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include <clc/atomic/clc_atomic_fetch_min.h> +#include <clc/opencl/clc.h> + +#define FUNCTION atomic_fetch_min +#define __IMPL_FUNCTION __clc_atomic_fetch_min + +#define __CLC_BODY <atomic_def.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <atomic_def.inc> +#include <clc/math/gentype.inc> diff --git a/libclc/opencl/lib/generic/atomic/atomic_fetch_or.cl b/libclc/opencl/lib/generic/atomic/atomic_fetch_or.cl new file mode 100644 index 0000000000000..9cc2eb5363d34 --- /dev/null +++ b/libclc/opencl/lib/generic/atomic/atomic_fetch_or.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include <clc/atomic/clc_atomic_fetch_or.h> +#include <clc/opencl/clc.h> + +#define FUNCTION atomic_fetch_or +#define __IMPL_FUNCTION __clc_atomic_fetch_or + +#define __CLC_BODY <atomic_def.inc> +#include <clc/integer/gentype.inc> diff --git a/libclc/opencl/lib/generic/atomic/atomic_fetch_sub.cl b/libclc/opencl/lib/generic/atomic/atomic_fetch_sub.cl new file mode 100644 index 0000000000000..1d468055db592 --- /dev/null +++ b/libclc/opencl/lib/generic/atomic/atomic_fetch_sub.cl @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include <clc/atomic/clc_atomic_fetch_sub.h> +#include <clc/opencl/clc.h> + +#define FUNCTION atomic_fetch_sub +#define __IMPL_FUNCTION __clc_atomic_fetch_sub + +#define __CLC_BODY <atomic_def.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <atomic_def.inc> +#include <clc/math/gentype.inc> diff --git a/libclc/opencl/lib/generic/atomic/atomic_fetch_xor.cl b/libclc/opencl/lib/generic/atomic/atomic_fetch_xor.cl new file mode 100644 index 0000000000000..e42b321774e36 --- /dev/null +++ b/libclc/opencl/lib/generic/atomic/atomic_fetch_xor.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include <clc/atomic/clc_atomic_fetch_xor.h> +#include <clc/opencl/clc.h> + +#define FUNCTION atomic_fetch_xor +#define __IMPL_FUNCTION __clc_atomic_fetch_xor + +#define __CLC_BODY <atomic_def.inc> +#include <clc/integer/gentype.inc> diff --git a/libclc/opencl/lib/generic/atomic/atomic_inc.cl b/libclc/opencl/lib/generic/atomic/atomic_inc.cl index 989c45c0e5d8a..bbb998db8e1bf 100644 --- a/libclc/opencl/lib/generic/atomic/atomic_inc.cl +++ b/libclc/opencl/lib/generic/atomic/atomic_inc.cl @@ -6,15 +6,11 @@ // //===----------------------------------------------------------------------===// +#include <clc/atomic/clc_atomic_inc.h> #include <clc/opencl/clc.h> -#define IMPL(TYPE, AS) \ - _CLC_OVERLOAD _CLC_DEF TYPE atomic_inc(volatile AS TYPE *p) { \ - return __sync_fetch_and_add(p, (TYPE)1); \ - } +#define FUNCTION atomic_inc +#define __IMPL_FUNCTION __clc_atomic_inc -IMPL(int, global) -IMPL(unsigned int, global) -IMPL(int, local) -IMPL(unsigned int, local) -#undef IMPL +#define __CLC_BODY <atomic_inc_dec.inc> +#include <clc/integer/gentype.inc> diff --git a/libclc/opencl/lib/generic/atomic/atomic_inc_dec.inc b/libclc/opencl/lib/generic/atomic/atomic_inc_dec.inc new file mode 100644 index 0000000000000..913a0e65d5949 --- /dev/null +++ b/libclc/opencl/lib/generic/atomic/atomic_inc_dec.inc @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifdef __CLC_SCALAR + +#if __CLC_GENSIZE == 32 + +#define __CLC_DEFINE_ATOMIC(ADDRSPACE) \ + _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION( \ + volatile ADDRSPACE __CLC_GENTYPE *Ptr) { \ + return __IMPL_FUNCTION(Ptr, __ATOMIC_SEQ_CST, __MEMORY_SCOPE_SYSTEM); \ + } + +__CLC_DEFINE_ATOMIC(global) +__CLC_DEFINE_ATOMIC(local) + +#undef __CLC_DEFINE_ATOMIC + +#endif // __CLC_GENSIZE == 32 + +#endif // __CLC_SCALAR diff --git a/libclc/opencl/lib/generic/atomic/atomic_load.cl b/libclc/opencl/lib/generic/atomic/atomic_load.cl new file mode 100644 index 0000000000000..d4d97186f17d7 --- /dev/null +++ b/libclc/opencl/lib/generic/atomic/atomic_load.cl @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include <clc/atomic/clc_atomic_load.h> +#include <clc/opencl/clc.h> + +#define FUNCTION atomic_load +#define __IMPL_FUNCTION __clc_atomic_load +#define __CLC_NO_VALUE_ARG + +#define __CLC_BODY <atomic_def.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <atomic_def.inc> +#include <clc/math/gentype.inc> diff --git a/libclc/opencl/lib/generic/atomic/atomic_store.cl b/libclc/opencl/lib/generic/atomic/atomic_store.cl new file mode 100644 index 0000000000000..0adee5321ea6e --- /dev/null +++ b/libclc/opencl/lib/generic/atomic/atomic_store.cl @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include <clc/atomic/clc_atomic_store.h> +#include <clc/opencl/clc.h> + +#define FUNCTION atomic_store +#define __IMPL_FUNCTION __clc_atomic_store +#define __CLC_RETURN_VOID + +#define __CLC_BODY <atomic_def.inc> +#include <clc/integer/gentype.inc> + +#define __CLC_BODY <atomic_def.inc> +#include <clc/math/gentype.inc> >From 952100b500e06c534bf5f818ba54dfd05b6a8ffb Mon Sep 17 00:00:00 2001 From: Wenju He <wenju...@intel.com> Date: Thu, 3 Jul 2025 19:45:01 -0700 Subject: [PATCH 2/2] Add include guard to OpenCL headers. Only include needed header in OpenCL files. --- .../clc/opencl/atomic/atomic_compare_exchange_strong.h | 5 +++++ .../include/clc/opencl/atomic/atomic_compare_exchange_weak.h | 5 +++++ libclc/opencl/include/clc/opencl/atomic/atomic_exchange.h | 5 +++++ libclc/opencl/include/clc/opencl/atomic/atomic_fetch_add.h | 5 +++++ libclc/opencl/include/clc/opencl/atomic/atomic_fetch_and.h | 5 +++++ libclc/opencl/include/clc/opencl/atomic/atomic_fetch_max.h | 5 +++++ libclc/opencl/include/clc/opencl/atomic/atomic_fetch_min.h | 5 +++++ libclc/opencl/include/clc/opencl/atomic/atomic_fetch_or.h | 5 +++++ libclc/opencl/include/clc/opencl/atomic/atomic_fetch_sub.h | 5 +++++ libclc/opencl/include/clc/opencl/atomic/atomic_fetch_xor.h | 5 +++++ libclc/opencl/include/clc/opencl/atomic/atomic_load.h | 5 +++++ libclc/opencl/include/clc/opencl/atomic/atomic_store.h | 5 +++++ libclc/opencl/include/clc/opencl/atomic/atomic_sub.h | 5 +++++ .../lib/generic/atomic/atomic_compare_exchange_strong.cl | 2 +- .../lib/generic/atomic/atomic_compare_exchange_weak.cl | 2 +- libclc/opencl/lib/generic/atomic/atomic_exchange.cl | 2 +- libclc/opencl/lib/generic/atomic/atomic_fetch_add.cl | 2 +- libclc/opencl/lib/generic/atomic/atomic_fetch_and.cl | 2 +- libclc/opencl/lib/generic/atomic/atomic_fetch_max.cl | 2 +- libclc/opencl/lib/generic/atomic/atomic_fetch_min.cl | 2 +- libclc/opencl/lib/generic/atomic/atomic_fetch_or.cl | 2 +- libclc/opencl/lib/generic/atomic/atomic_fetch_sub.cl | 2 +- libclc/opencl/lib/generic/atomic/atomic_fetch_xor.cl | 2 +- libclc/opencl/lib/generic/atomic/atomic_load.cl | 2 +- libclc/opencl/lib/generic/atomic/atomic_store.cl | 2 +- 25 files changed, 77 insertions(+), 12 deletions(-) diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_compare_exchange_strong.h b/libclc/opencl/include/clc/opencl/atomic/atomic_compare_exchange_strong.h index 21a9b5d047655..76eeda7ba3469 100644 --- a/libclc/opencl/include/clc/opencl/atomic/atomic_compare_exchange_strong.h +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_compare_exchange_strong.h @@ -6,6 +6,9 @@ // //===----------------------------------------------------------------------===// +#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_COMPARE_EXCHANGE_STRONG_H__ +#define __CLC_OPENCL_ATOMIC_ATOMIC_COMPARE_EXCHANGE_STRONG_H__ + #define FUNCTION atomic_compare_exchange_strong #define __CLC_COMPARE_EXCHANGE @@ -17,3 +20,5 @@ #undef __CLC_COMPARE_EXCHANGE #undef FUNCTION + +#endif // __CLC_OPENCL_ATOMIC_ATOMIC_COMPARE_EXCHANGE_STRONG_H__ diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_compare_exchange_weak.h b/libclc/opencl/include/clc/opencl/atomic/atomic_compare_exchange_weak.h index a0d034270accc..12788ad03a2d1 100644 --- a/libclc/opencl/include/clc/opencl/atomic/atomic_compare_exchange_weak.h +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_compare_exchange_weak.h @@ -6,6 +6,9 @@ // //===----------------------------------------------------------------------===// +#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_COMPARE_EXCHANGE_WEAK_H__ +#define __CLC_OPENCL_ATOMIC_ATOMIC_COMPARE_EXCHANGE_WEAK_H__ + #define FUNCTION atomic_compare_exchange_weak #define __CLC_COMPARE_EXCHANGE @@ -17,3 +20,5 @@ #undef __CLC_COMPARE_EXCHANGE #undef FUNCTION + +#endif // __CLC_OPENCL_ATOMIC_ATOMIC_COMPARE_EXCHANGE_WEAK_H__ diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_exchange.h b/libclc/opencl/include/clc/opencl/atomic/atomic_exchange.h index c27a4a3b2c05f..3949bc13401f2 100644 --- a/libclc/opencl/include/clc/opencl/atomic/atomic_exchange.h +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_exchange.h @@ -6,6 +6,9 @@ // //===----------------------------------------------------------------------===// +#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_EXCHANGE_H__ +#define __CLC_OPENCL_ATOMIC_ATOMIC_EXCHANGE_H__ + #define FUNCTION atomic_exchange #define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc> @@ -15,3 +18,5 @@ #include <clc/math/gentype.inc> #undef FUNCTION + +#endif // __CLC_OPENCL_ATOMIC_ATOMIC_EXCHANGE_H__ diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_add.h b/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_add.h index 8e7d852d4b9ca..972c1fa69fe7b 100644 --- a/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_add.h +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_add.h @@ -6,6 +6,9 @@ // //===----------------------------------------------------------------------===// +#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_ADD_H__ +#define __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_ADD_H__ + #define FUNCTION atomic_fetch_add #define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc> @@ -15,3 +18,5 @@ #include <clc/math/gentype.inc> #undef FUNCTION + +#endif // __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_ADD_H__ diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_and.h b/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_and.h index 2f43a90db8195..fdac049a74d3f 100644 --- a/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_and.h +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_and.h @@ -6,9 +6,14 @@ // //===----------------------------------------------------------------------===// +#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_AND_H__ +#define __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_AND_H__ + #define FUNCTION atomic_fetch_and #define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc> #include <clc/integer/gentype.inc> #undef FUNCTION + +#endif // __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_AND_H__ diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_max.h b/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_max.h index 064bc0e66cf68..513b60fec2727 100644 --- a/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_max.h +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_max.h @@ -6,6 +6,9 @@ // //===----------------------------------------------------------------------===// +#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_MAX_H__ +#define __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_MAX_H__ + #define FUNCTION atomic_fetch_max #define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc> @@ -15,3 +18,5 @@ #include <clc/math/gentype.inc> #undef FUNCTION + +#endif // __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_MAX_H__ diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_min.h b/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_min.h index 802ae6a6e7e32..c961c4a641656 100644 --- a/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_min.h +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_min.h @@ -6,6 +6,9 @@ // //===----------------------------------------------------------------------===// +#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_MIN_H__ +#define __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_MIN_H__ + #define FUNCTION atomic_fetch_min #define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc> @@ -15,3 +18,5 @@ #include <clc/math/gentype.inc> #undef FUNCTION + +#endif // __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_MIN_H__ diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_or.h b/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_or.h index 21b0d1a737ced..25923e3647e36 100644 --- a/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_or.h +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_or.h @@ -6,9 +6,14 @@ // //===----------------------------------------------------------------------===// +#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_OR_H__ +#define __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_OR_H__ + #define FUNCTION atomic_fetch_or #define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc> #include <clc/integer/gentype.inc> #undef FUNCTION + +#endif // __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_OR_H__ diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_sub.h b/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_sub.h index bd654fbee2cec..b307c30a298b3 100644 --- a/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_sub.h +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_sub.h @@ -6,6 +6,9 @@ // //===----------------------------------------------------------------------===// +#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_SUB_H__ +#define __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_SUB_H__ + #define FUNCTION atomic_fetch_sub #define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc> @@ -15,3 +18,5 @@ #include <clc/math/gentype.inc> #undef FUNCTION + +#endif // __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_SUB_H__ diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_xor.h b/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_xor.h index 7021ddb4b488b..52510d018574d 100644 --- a/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_xor.h +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_fetch_xor.h @@ -6,9 +6,14 @@ // //===----------------------------------------------------------------------===// +#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_XOR_H__ +#define __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_XOR_H__ + #define FUNCTION atomic_fetch_xor #define __CLC_BODY <clc/opencl/atomic/atomic_decl.inc> #include <clc/integer/gentype.inc> #undef FUNCTION + +#endif // __CLC_OPENCL_ATOMIC_ATOMIC_FETCH_XOR_H__ diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_load.h b/libclc/opencl/include/clc/opencl/atomic/atomic_load.h index b7030517be2fc..3998a4de9452b 100644 --- a/libclc/opencl/include/clc/opencl/atomic/atomic_load.h +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_load.h @@ -6,6 +6,9 @@ // //===----------------------------------------------------------------------===// +#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_LOAD_H__ +#define __CLC_OPENCL_ATOMIC_ATOMIC_LOAD_H__ + #define FUNCTION atomic_load #define __CLC_NO_VALUE_ARG @@ -17,3 +20,5 @@ #undef __CLC_NO_VALUE_ARG #undef FUNCTION + +#endif // __CLC_OPENCL_ATOMIC_ATOMIC_LOAD_H__ diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_store.h b/libclc/opencl/include/clc/opencl/atomic/atomic_store.h index 2a423b1f281fa..4893a5b88df03 100644 --- a/libclc/opencl/include/clc/opencl/atomic/atomic_store.h +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_store.h @@ -6,6 +6,9 @@ // //===----------------------------------------------------------------------===// +#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_STORE_H__ +#define __CLC_OPENCL_ATOMIC_ATOMIC_STORE_H__ + #define FUNCTION atomic_store #define __CLC_RETURN_VOID @@ -17,3 +20,5 @@ #undef __CLC_RETURN_VOID #undef FUNCTION + +#endif // __CLC_OPENCL_ATOMIC_ATOMIC_STORE_H__ diff --git a/libclc/opencl/include/clc/opencl/atomic/atomic_sub.h b/libclc/opencl/include/clc/opencl/atomic/atomic_sub.h index 1480992adf162..5d712b7b65b62 100644 --- a/libclc/opencl/include/clc/opencl/atomic/atomic_sub.h +++ b/libclc/opencl/include/clc/opencl/atomic/atomic_sub.h @@ -6,5 +6,10 @@ // //===----------------------------------------------------------------------===// +#ifndef __CLC_OPENCL_ATOMIC_ATOMIC_SUB_H__ +#define __CLC_OPENCL_ATOMIC_ATOMIC_SUB_H__ + #define __CLC_FUNCTION atomic_sub #include <clc/opencl/atomic/atomic_decl_legacy.inc> + +#endif // __CLC_OPENCL_ATOMIC_ATOMIC_SUB_H__ diff --git a/libclc/opencl/lib/generic/atomic/atomic_compare_exchange_strong.cl b/libclc/opencl/lib/generic/atomic/atomic_compare_exchange_strong.cl index f364303b8cfe9..12e2ecf8b8677 100644 --- a/libclc/opencl/lib/generic/atomic/atomic_compare_exchange_strong.cl +++ b/libclc/opencl/lib/generic/atomic/atomic_compare_exchange_strong.cl @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include <clc/atomic/clc_atomic_compare_exchange.h> -#include <clc/opencl/clc.h> +#include <clc/opencl/atomic/atomic_compare_exchange_strong.h> #define FUNCTION atomic_compare_exchange_strong #define __CLC_COMPARE_EXCHANGE diff --git a/libclc/opencl/lib/generic/atomic/atomic_compare_exchange_weak.cl b/libclc/opencl/lib/generic/atomic/atomic_compare_exchange_weak.cl index 443235128def5..d9501652222ff 100644 --- a/libclc/opencl/lib/generic/atomic/atomic_compare_exchange_weak.cl +++ b/libclc/opencl/lib/generic/atomic/atomic_compare_exchange_weak.cl @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include <clc/atomic/clc_atomic_compare_exchange.h> -#include <clc/opencl/clc.h> +#include <clc/opencl/atomic/atomic_compare_exchange_weak.h> #define FUNCTION atomic_compare_exchange_weak #define __CLC_COMPARE_EXCHANGE diff --git a/libclc/opencl/lib/generic/atomic/atomic_exchange.cl b/libclc/opencl/lib/generic/atomic/atomic_exchange.cl index 30fc1cf4b8c8c..70f419fe8fe5b 100644 --- a/libclc/opencl/lib/generic/atomic/atomic_exchange.cl +++ b/libclc/opencl/lib/generic/atomic/atomic_exchange.cl @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include <clc/atomic/clc_atomic_exchange.h> -#include <clc/opencl/clc.h> +#include <clc/opencl/atomic/atomic_exchange.h> #define FUNCTION atomic_exchange #define __IMPL_FUNCTION __clc_atomic_exchange diff --git a/libclc/opencl/lib/generic/atomic/atomic_fetch_add.cl b/libclc/opencl/lib/generic/atomic/atomic_fetch_add.cl index 74f040af81636..cc3ac43a23965 100644 --- a/libclc/opencl/lib/generic/atomic/atomic_fetch_add.cl +++ b/libclc/opencl/lib/generic/atomic/atomic_fetch_add.cl @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include <clc/atomic/clc_atomic_fetch_add.h> -#include <clc/opencl/clc.h> +#include <clc/opencl/atomic/atomic_fetch_add.h> #define FUNCTION atomic_fetch_add #define __IMPL_FUNCTION __clc_atomic_fetch_add diff --git a/libclc/opencl/lib/generic/atomic/atomic_fetch_and.cl b/libclc/opencl/lib/generic/atomic/atomic_fetch_and.cl index 46eb4775a9f5e..d3b2bf2aaece9 100644 --- a/libclc/opencl/lib/generic/atomic/atomic_fetch_and.cl +++ b/libclc/opencl/lib/generic/atomic/atomic_fetch_and.cl @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include <clc/atomic/clc_atomic_fetch_and.h> -#include <clc/opencl/clc.h> +#include <clc/opencl/atomic/atomic_fetch_and.h> #define FUNCTION atomic_fetch_and #define __IMPL_FUNCTION __clc_atomic_fetch_and diff --git a/libclc/opencl/lib/generic/atomic/atomic_fetch_max.cl b/libclc/opencl/lib/generic/atomic/atomic_fetch_max.cl index bda6b330e62c8..666051d19d006 100644 --- a/libclc/opencl/lib/generic/atomic/atomic_fetch_max.cl +++ b/libclc/opencl/lib/generic/atomic/atomic_fetch_max.cl @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include <clc/atomic/clc_atomic_fetch_max.h> -#include <clc/opencl/clc.h> +#include <clc/opencl/atomic/atomic_fetch_max.h> #define FUNCTION atomic_fetch_max #define __IMPL_FUNCTION __clc_atomic_fetch_max diff --git a/libclc/opencl/lib/generic/atomic/atomic_fetch_min.cl b/libclc/opencl/lib/generic/atomic/atomic_fetch_min.cl index 8cc92ba17b8f0..c1663f312c24d 100644 --- a/libclc/opencl/lib/generic/atomic/atomic_fetch_min.cl +++ b/libclc/opencl/lib/generic/atomic/atomic_fetch_min.cl @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include <clc/atomic/clc_atomic_fetch_min.h> -#include <clc/opencl/clc.h> +#include <clc/opencl/atomic/atomic_fetch_min.h> #define FUNCTION atomic_fetch_min #define __IMPL_FUNCTION __clc_atomic_fetch_min diff --git a/libclc/opencl/lib/generic/atomic/atomic_fetch_or.cl b/libclc/opencl/lib/generic/atomic/atomic_fetch_or.cl index 9cc2eb5363d34..886cfcecd3909 100644 --- a/libclc/opencl/lib/generic/atomic/atomic_fetch_or.cl +++ b/libclc/opencl/lib/generic/atomic/atomic_fetch_or.cl @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include <clc/atomic/clc_atomic_fetch_or.h> -#include <clc/opencl/clc.h> +#include <clc/opencl/atomic/atomic_fetch_or.h> #define FUNCTION atomic_fetch_or #define __IMPL_FUNCTION __clc_atomic_fetch_or diff --git a/libclc/opencl/lib/generic/atomic/atomic_fetch_sub.cl b/libclc/opencl/lib/generic/atomic/atomic_fetch_sub.cl index 1d468055db592..23fd33daa5e3c 100644 --- a/libclc/opencl/lib/generic/atomic/atomic_fetch_sub.cl +++ b/libclc/opencl/lib/generic/atomic/atomic_fetch_sub.cl @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include <clc/atomic/clc_atomic_fetch_sub.h> -#include <clc/opencl/clc.h> +#include <clc/opencl/atomic/atomic_fetch_sub.h> #define FUNCTION atomic_fetch_sub #define __IMPL_FUNCTION __clc_atomic_fetch_sub diff --git a/libclc/opencl/lib/generic/atomic/atomic_fetch_xor.cl b/libclc/opencl/lib/generic/atomic/atomic_fetch_xor.cl index e42b321774e36..afe3fc624bb1d 100644 --- a/libclc/opencl/lib/generic/atomic/atomic_fetch_xor.cl +++ b/libclc/opencl/lib/generic/atomic/atomic_fetch_xor.cl @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include <clc/atomic/clc_atomic_fetch_xor.h> -#include <clc/opencl/clc.h> +#include <clc/opencl/atomic/atomic_fetch_xor.h> #define FUNCTION atomic_fetch_xor #define __IMPL_FUNCTION __clc_atomic_fetch_xor diff --git a/libclc/opencl/lib/generic/atomic/atomic_load.cl b/libclc/opencl/lib/generic/atomic/atomic_load.cl index d4d97186f17d7..e2c7fb2eb43b3 100644 --- a/libclc/opencl/lib/generic/atomic/atomic_load.cl +++ b/libclc/opencl/lib/generic/atomic/atomic_load.cl @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include <clc/atomic/clc_atomic_load.h> -#include <clc/opencl/clc.h> +#include <clc/opencl/atomic/atomic_load.h> #define FUNCTION atomic_load #define __IMPL_FUNCTION __clc_atomic_load diff --git a/libclc/opencl/lib/generic/atomic/atomic_store.cl b/libclc/opencl/lib/generic/atomic/atomic_store.cl index 0adee5321ea6e..c0a9ba5ea909e 100644 --- a/libclc/opencl/lib/generic/atomic/atomic_store.cl +++ b/libclc/opencl/lib/generic/atomic/atomic_store.cl @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include <clc/atomic/clc_atomic_store.h> -#include <clc/opencl/clc.h> +#include <clc/opencl/atomic/atomic_store.h> #define FUNCTION atomic_store #define __IMPL_FUNCTION __clc_atomic_store _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits