[libclc] r313810 - Implement cl_khr_int64_base_atomics builtins
Jan Vesely via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 20 13:42:14 PDT 2017
Author: jvesely
Date: Wed Sep 20 13:42:14 2017
New Revision: 313810
URL: http://llvm.org/viewvc/llvm-project?rev=313810&view=rev
Log:
Implement cl_khr_int64_base_atomics builtins
Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
Reviewed-by: Aaron Watry <awatry at gmail.com>
Tested-by: Aaron Watry <awatry at gmail.com>
Added:
libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/
libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_add.h
libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_cmpxchg.h
libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_dec.h
libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_inc.h
libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_sub.h
libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_xchg.h
libclc/trunk/generic/lib/cl_khr_int64_base_atomics/
libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_add.cl
libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_cmpxchg.cl
libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_dec.cl
libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_inc.cl
libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_sub.cl
libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_xchg.cl
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES
Added: libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_add.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_add.h?rev=313810&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_add.h (added)
+++ libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_add.h Wed Sep 20 13:42:14 2017
@@ -0,0 +1,4 @@
+_CLC_OVERLOAD _CLC_DECL long atom_add(volatile global long *p, long val);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_add(volatile global unsigned long *p, unsigned long val);
+_CLC_OVERLOAD _CLC_DECL long atom_add(volatile local long *p, long val);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_add(volatile local unsigned long *p, unsigned long val);
Added: libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_cmpxchg.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_cmpxchg.h?rev=313810&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_cmpxchg.h (added)
+++ libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_cmpxchg.h Wed Sep 20 13:42:14 2017
@@ -0,0 +1,4 @@
+_CLC_OVERLOAD _CLC_DECL long atom_cmpxchg(volatile global long *p, long cmp, long val);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_cmpxchg(volatile global unsigned long *p, unsigned long cmp, unsigned long val);
+_CLC_OVERLOAD _CLC_DECL long atom_cmpxchg(volatile local long *p, long cmp, long val);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_cmpxchg(volatile local unsigned long *p, unsigned long cmp, unsigned long val);
Added: libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_dec.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_dec.h?rev=313810&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_dec.h (added)
+++ libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_dec.h Wed Sep 20 13:42:14 2017
@@ -0,0 +1,4 @@
+_CLC_OVERLOAD _CLC_DECL long atom_dec(volatile global long *p);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_dec(volatile global unsigned long *p);
+_CLC_OVERLOAD _CLC_DECL long atom_dec(volatile local long *p);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_dec(volatile local unsigned long *p);
Added: libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_inc.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_inc.h?rev=313810&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_inc.h (added)
+++ libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_inc.h Wed Sep 20 13:42:14 2017
@@ -0,0 +1,4 @@
+_CLC_OVERLOAD _CLC_DECL long atom_inc(volatile global long *p);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_inc(volatile global unsigned long *p);
+_CLC_OVERLOAD _CLC_DECL long atom_inc(volatile local long *p);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_inc(volatile local unsigned long *p);
Added: libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_sub.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_sub.h?rev=313810&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_sub.h (added)
+++ libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_sub.h Wed Sep 20 13:42:14 2017
@@ -0,0 +1,4 @@
+_CLC_OVERLOAD _CLC_DECL long atom_sub(volatile global long *p, long val);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_sub(volatile global unsigned long *p, unsigned long val);
+_CLC_OVERLOAD _CLC_DECL long atom_sub(volatile local long *p, long val);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_sub(volatile local unsigned long *p, unsigned long val);
Added: libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_xchg.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_xchg.h?rev=313810&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_xchg.h (added)
+++ libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_xchg.h Wed Sep 20 13:42:14 2017
@@ -0,0 +1,4 @@
+_CLC_OVERLOAD _CLC_DECL long atom_xchg(volatile global long *p, long val);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_xchg(volatile global unsigned long *p, unsigned long val);
+_CLC_OVERLOAD _CLC_DECL long atom_xchg(volatile local long *p, long val);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_xchg(volatile local unsigned long *p, unsigned long val);
Modified: libclc/trunk/generic/include/clc/clc.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=313810&r1=313809&r2=313810&view=diff
==============================================================================
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Wed Sep 20 13:42:14 2017
@@ -237,6 +237,16 @@
#include <clc/cl_khr_local_int32_extended_atomics/atom_or.h>
#include <clc/cl_khr_local_int32_extended_atomics/atom_xor.h>
+/* cl_khr_int64_base_atomics Extension Functions */
+#ifdef cl_khr_int64_base_atomics
+#include <clc/cl_khr_int64_base_atomics/atom_add.h>
+#include <clc/cl_khr_int64_base_atomics/atom_cmpxchg.h>
+#include <clc/cl_khr_int64_base_atomics/atom_dec.h>
+#include <clc/cl_khr_int64_base_atomics/atom_inc.h>
+#include <clc/cl_khr_int64_base_atomics/atom_sub.h>
+#include <clc/cl_khr_int64_base_atomics/atom_xchg.h>
+#endif
+
/* 6.12.12 Miscellaneous Vector Functions */
#include <clc/misc/shuffle.h>
#include <clc/misc/shuffle2.h>
Modified: libclc/trunk/generic/lib/SOURCES
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=313810&r1=313809&r2=313810&view=diff
==============================================================================
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Wed Sep 20 13:42:14 2017
@@ -28,6 +28,12 @@ cl_khr_local_int32_extended_atomics/atom
cl_khr_local_int32_extended_atomics/atom_min.cl
cl_khr_local_int32_extended_atomics/atom_or.cl
cl_khr_local_int32_extended_atomics/atom_xor.cl
+cl_khr_int64_base_atomics/atom_add.cl
+cl_khr_int64_base_atomics/atom_cmpxchg.cl
+cl_khr_int64_base_atomics/atom_dec.cl
+cl_khr_int64_base_atomics/atom_inc.cl
+cl_khr_int64_base_atomics/atom_sub.cl
+cl_khr_int64_base_atomics/atom_xchg.cl
convert.cl
common/degrees.cl
common/mix.cl
Added: libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_add.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_add.cl?rev=313810&view=auto
==============================================================================
--- libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_add.cl (added)
+++ libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_add.cl Wed Sep 20 13:42:14 2017
@@ -0,0 +1,16 @@
+#include <clc/clc.h>
+
+#ifdef cl_khr_int64_base_atomics
+
+#define IMPL(AS, TYPE) \
+_CLC_OVERLOAD _CLC_DEF TYPE atom_add(volatile AS TYPE *p, TYPE val) { \
+ return __sync_fetch_and_add_8(p, val); \
+}
+
+IMPL(global, long)
+IMPL(global, unsigned long)
+IMPL(local, long)
+IMPL(local, unsigned long)
+#undef IMPL
+
+#endif
Added: libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_cmpxchg.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_cmpxchg.cl?rev=313810&view=auto
==============================================================================
--- libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_cmpxchg.cl (added)
+++ libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_cmpxchg.cl Wed Sep 20 13:42:14 2017
@@ -0,0 +1,16 @@
+#include <clc/clc.h>
+
+#ifdef cl_khr_int64_base_atomics
+
+#define IMPL(AS, TYPE) \
+_CLC_OVERLOAD _CLC_DEF TYPE atom_cmpxchg(volatile AS TYPE *p, TYPE cmp, TYPE val) { \
+ return __sync_val_compare_and_swap_8(p, cmp, val); \
+}
+
+IMPL(global, long)
+IMPL(global, unsigned long)
+IMPL(local, long)
+IMPL(local, unsigned long)
+#undef IMPL
+
+#endif
Added: libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_dec.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_dec.cl?rev=313810&view=auto
==============================================================================
--- libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_dec.cl (added)
+++ libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_dec.cl Wed Sep 20 13:42:14 2017
@@ -0,0 +1,16 @@
+#include <clc/clc.h>
+
+#ifdef cl_khr_int64_base_atomics
+
+#define IMPL(AS, TYPE) \
+_CLC_OVERLOAD _CLC_DEF TYPE atom_dec(volatile AS TYPE *p) { \
+ return atom_sub(p, (TYPE)1); \
+}
+
+IMPL(global, long)
+IMPL(global, unsigned long)
+IMPL(local, long)
+IMPL(local, unsigned long)
+#undef IMPL
+
+#endif
Added: libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_inc.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_inc.cl?rev=313810&view=auto
==============================================================================
--- libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_inc.cl (added)
+++ libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_inc.cl Wed Sep 20 13:42:14 2017
@@ -0,0 +1,16 @@
+#include <clc/clc.h>
+
+#ifdef cl_khr_int64_base_atomics
+
+#define IMPL(AS, TYPE) \
+_CLC_OVERLOAD _CLC_DEF TYPE atom_inc(volatile AS TYPE *p) { \
+ return atom_add(p, (TYPE)1); \
+}
+
+IMPL(global, long)
+IMPL(global, unsigned long)
+IMPL(local, long)
+IMPL(local, unsigned long)
+#undef IMPL
+
+#endif
Added: libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_sub.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_sub.cl?rev=313810&view=auto
==============================================================================
--- libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_sub.cl (added)
+++ libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_sub.cl Wed Sep 20 13:42:14 2017
@@ -0,0 +1,16 @@
+#include <clc/clc.h>
+
+#ifdef cl_khr_int64_base_atomics
+
+#define IMPL(AS, TYPE) \
+_CLC_OVERLOAD _CLC_DEF TYPE atom_sub(volatile AS TYPE *p, TYPE val) { \
+ return __sync_fetch_and_sub_8(p, val); \
+}
+
+IMPL(global, long)
+IMPL(global, unsigned long)
+IMPL(local, long)
+IMPL(local, unsigned long)
+#undef IMPL
+
+#endif
Added: libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_xchg.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_xchg.cl?rev=313810&view=auto
==============================================================================
--- libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_xchg.cl (added)
+++ libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_xchg.cl Wed Sep 20 13:42:14 2017
@@ -0,0 +1,16 @@
+#include <clc/clc.h>
+
+#ifdef cl_khr_int64_base_atomics
+
+#define IMPL(AS, TYPE) \
+_CLC_OVERLOAD _CLC_DEF TYPE atom_xchg(volatile AS TYPE *p, TYPE val) { \
+ return __sync_swap_8(p, val); \
+}
+
+IMPL(global, long)
+IMPL(global, unsigned long)
+IMPL(local, long)
+IMPL(local, unsigned long)
+#undef IMPL
+
+#endif
More information about the cfe-commits
mailing list