[libclc] r335279 - atom: Consolidate cl_khr_{local, global}_int32_{base, extended}_atomics implementation
Jan Vesely via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 21 12:27:33 PDT 2018
Author: jvesely
Date: Thu Jun 21 12:27:33 2018
New Revision: 335279
URL: http://llvm.org/viewvc/llvm-project?rev=335279&view=rev
Log:
atom: Consolidate cl_khr_{local,global}_int32_{base,extended}_atomics implementation
These are just atomic_* wrappers.
Switch inc, dec to use atomic_* wrappers as well.
Reviewed-By: Aaron Watry <awatry at gmail.com>
Tested-By: Aaron Watry <awatry at gmail.com>
Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
Added:
libclc/trunk/generic/lib/atom_int32_binary.inc
Modified:
libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_add.cl
libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_dec.cl
libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_inc.cl
libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_sub.cl
libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_xchg.cl
libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_and.cl
libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_max.cl
libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_min.cl
libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_or.cl
libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_xor.cl
libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_add.cl
libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_dec.cl
libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_inc.cl
libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_sub.cl
libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_xchg.cl
libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_and.cl
libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_max.cl
libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_min.cl
libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_or.cl
libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_xor.cl
Added: libclc/trunk/generic/lib/atom_int32_binary.inc
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/atom_int32_binary.inc?rev=335279&view=auto
==============================================================================
--- libclc/trunk/generic/lib/atom_int32_binary.inc (added)
+++ libclc/trunk/generic/lib/atom_int32_binary.inc Thu Jun 21 12:27:33 2018
@@ -0,0 +1,14 @@
+#include <clc/clc.h>
+#include "utils.h"
+
+#define __CLC_ATOM_IMPL(AS, TYPE) \
+_CLC_OVERLOAD _CLC_DEF TYPE __CLC_XCONCAT(atom_, __CLC_ATOMIC_OP) (AS TYPE *p, TYPE val) { \
+ return __CLC_XCONCAT(atomic_, __CLC_ATOMIC_OP) (p, val); \
+}
+
+__CLC_ATOM_IMPL(__CLC_ATOMIC_ADDRESS_SPACE, int)
+__CLC_ATOM_IMPL(__CLC_ATOMIC_ADDRESS_SPACE, uint)
+
+#undef __CLC_ATOM_IMPL
+#undef __CLC_ATOMIC_OP
+#undef __CLC_ATOMIC_ADDRESS_SPACE
Modified: libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_add.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_add.cl?rev=335279&r1=335278&r2=335279&view=diff
==============================================================================
--- libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_add.cl (original)
+++ libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_add.cl Thu Jun 21 12:27:33 2018
@@ -1,9 +1,3 @@
-#include <clc/clc.h>
-
-#define IMPL(TYPE) \
-_CLC_OVERLOAD _CLC_DEF TYPE atom_add(global TYPE *p, TYPE val) { \
- return atomic_add(p, val); \
-}
-
-IMPL(int)
-IMPL(unsigned int)
+#define __CLC_ATOMIC_OP add
+#define __CLC_ATOMIC_ADDRESS_SPACE global
+#include "../atom_int32_binary.inc"
Modified: libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_dec.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_dec.cl?rev=335279&r1=335278&r2=335279&view=diff
==============================================================================
--- libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_dec.cl (original)
+++ libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_dec.cl Thu Jun 21 12:27:33 2018
@@ -2,7 +2,7 @@
#define IMPL(TYPE) \
_CLC_OVERLOAD _CLC_DEF TYPE atom_dec(global TYPE *p) { \
- return atom_sub(p, (TYPE)1); \
+ return atomic_dec(p); \
}
IMPL(int)
Modified: libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_inc.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_inc.cl?rev=335279&r1=335278&r2=335279&view=diff
==============================================================================
--- libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_inc.cl (original)
+++ libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_inc.cl Thu Jun 21 12:27:33 2018
@@ -2,7 +2,7 @@
#define IMPL(TYPE) \
_CLC_OVERLOAD _CLC_DEF TYPE atom_inc(global TYPE *p) { \
- return atom_add(p, (TYPE)1); \
+ return atomic_inc(p); \
}
IMPL(int)
Modified: libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_sub.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_sub.cl?rev=335279&r1=335278&r2=335279&view=diff
==============================================================================
--- libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_sub.cl (original)
+++ libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_sub.cl Thu Jun 21 12:27:33 2018
@@ -1,9 +1,3 @@
-#include <clc/clc.h>
-
-#define IMPL(TYPE) \
-_CLC_OVERLOAD _CLC_DEF TYPE atom_sub(global TYPE *p, TYPE val) { \
- return atomic_sub(p, val); \
-}
-
-IMPL(int)
-IMPL(unsigned int)
+#define __CLC_ATOMIC_OP sub
+#define __CLC_ATOMIC_ADDRESS_SPACE global
+#include "../atom_int32_binary.inc"
Modified: libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_xchg.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_xchg.cl?rev=335279&r1=335278&r2=335279&view=diff
==============================================================================
--- libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_xchg.cl (original)
+++ libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_xchg.cl Thu Jun 21 12:27:33 2018
@@ -1,9 +1,3 @@
-#include <clc/clc.h>
-
-#define IMPL(TYPE) \
-_CLC_OVERLOAD _CLC_DEF TYPE atom_xchg(global TYPE *p, TYPE val) { \
- return atomic_xchg(p, val); \
-}
-
-IMPL(int)
-IMPL(unsigned int)
+#define __CLC_ATOMIC_OP xchg
+#define __CLC_ATOMIC_ADDRESS_SPACE global
+#include "../atom_int32_binary.inc"
Modified: libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_and.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_and.cl?rev=335279&r1=335278&r2=335279&view=diff
==============================================================================
--- libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_and.cl (original)
+++ libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_and.cl Thu Jun 21 12:27:33 2018
@@ -1,9 +1,3 @@
-#include <clc/clc.h>
-
-#define IMPL(TYPE) \
-_CLC_OVERLOAD _CLC_DEF TYPE atom_and(global TYPE *p, TYPE val) { \
- return atomic_and(p, val); \
-}
-
-IMPL(int)
-IMPL(unsigned int)
\ No newline at end of file
+#define __CLC_ATOMIC_OP and
+#define __CLC_ATOMIC_ADDRESS_SPACE global
+#include "../atom_int32_binary.inc"
Modified: libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_max.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_max.cl?rev=335279&r1=335278&r2=335279&view=diff
==============================================================================
--- libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_max.cl (original)
+++ libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_max.cl Thu Jun 21 12:27:33 2018
@@ -1,9 +1,3 @@
-#include <clc/clc.h>
-
-#define IMPL(TYPE) \
-_CLC_OVERLOAD _CLC_DEF TYPE atom_max(global TYPE *p, TYPE val) { \
- return atomic_max(p, val); \
-}
-
-IMPL(int)
-IMPL(unsigned int)
+#define __CLC_ATOMIC_OP max
+#define __CLC_ATOMIC_ADDRESS_SPACE global
+#include "../atom_int32_binary.inc"
Modified: libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_min.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_min.cl?rev=335279&r1=335278&r2=335279&view=diff
==============================================================================
--- libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_min.cl (original)
+++ libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_min.cl Thu Jun 21 12:27:33 2018
@@ -1,9 +1,3 @@
-#include <clc/clc.h>
-
-#define IMPL(TYPE) \
-_CLC_OVERLOAD _CLC_DEF TYPE atom_min(global TYPE *p, TYPE val) { \
- return atomic_min(p, val); \
-}
-
-IMPL(int)
-IMPL(unsigned int)
+#define __CLC_ATOMIC_OP min
+#define __CLC_ATOMIC_ADDRESS_SPACE global
+#include "../atom_int32_binary.inc"
Modified: libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_or.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_or.cl?rev=335279&r1=335278&r2=335279&view=diff
==============================================================================
--- libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_or.cl (original)
+++ libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_or.cl Thu Jun 21 12:27:33 2018
@@ -1,9 +1,3 @@
-#include <clc/clc.h>
-
-#define IMPL(TYPE) \
-_CLC_OVERLOAD _CLC_DEF TYPE atom_or(global TYPE *p, TYPE val) { \
- return atomic_or(p, val); \
-}
-
-IMPL(int)
-IMPL(unsigned int)
+#define __CLC_ATOMIC_OP or
+#define __CLC_ATOMIC_ADDRESS_SPACE global
+#include "../atom_int32_binary.inc"
Modified: libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_xor.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_xor.cl?rev=335279&r1=335278&r2=335279&view=diff
==============================================================================
--- libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_xor.cl (original)
+++ libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_xor.cl Thu Jun 21 12:27:33 2018
@@ -1,9 +1,3 @@
-#include <clc/clc.h>
-
-#define IMPL(TYPE) \
-_CLC_OVERLOAD _CLC_DEF TYPE atom_xor(global TYPE *p, TYPE val) { \
- return atomic_xor(p, val); \
-}
-
-IMPL(int)
-IMPL(unsigned int)
+#define __CLC_ATOMIC_OP xor
+#define __CLC_ATOMIC_ADDRESS_SPACE global
+#include "../atom_int32_binary.inc"
Modified: libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_add.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_add.cl?rev=335279&r1=335278&r2=335279&view=diff
==============================================================================
--- libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_add.cl (original)
+++ libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_add.cl Thu Jun 21 12:27:33 2018
@@ -1,9 +1,3 @@
-#include <clc/clc.h>
-
-#define IMPL(TYPE) \
-_CLC_OVERLOAD _CLC_DEF TYPE atom_add(local TYPE *p, TYPE val) { \
- return atomic_add(p, val); \
-}
-
-IMPL(int)
-IMPL(unsigned int)
+#define __CLC_ATOMIC_OP add
+#define __CLC_ATOMIC_ADDRESS_SPACE local
+#include "../atom_int32_binary.inc"
Modified: libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_dec.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_dec.cl?rev=335279&r1=335278&r2=335279&view=diff
==============================================================================
--- libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_dec.cl (original)
+++ libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_dec.cl Thu Jun 21 12:27:33 2018
@@ -2,7 +2,7 @@
#define IMPL(TYPE) \
_CLC_OVERLOAD _CLC_DEF TYPE atom_dec(local TYPE *p) { \
- return atom_sub(p, (TYPE)1); \
+ return atomic_dec(p); \
}
IMPL(int)
Modified: libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_inc.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_inc.cl?rev=335279&r1=335278&r2=335279&view=diff
==============================================================================
--- libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_inc.cl (original)
+++ libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_inc.cl Thu Jun 21 12:27:33 2018
@@ -2,7 +2,7 @@
#define IMPL(TYPE) \
_CLC_OVERLOAD _CLC_DEF TYPE atom_inc(local TYPE *p) { \
- return atom_add(p, (TYPE)1); \
+ return atomic_inc(p); \
}
IMPL(int)
Modified: libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_sub.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_sub.cl?rev=335279&r1=335278&r2=335279&view=diff
==============================================================================
--- libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_sub.cl (original)
+++ libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_sub.cl Thu Jun 21 12:27:33 2018
@@ -1,9 +1,3 @@
-#include <clc/clc.h>
-
-#define IMPL(TYPE) \
-_CLC_OVERLOAD _CLC_DEF TYPE atom_sub(local TYPE *p, TYPE val) { \
- return atomic_sub(p, val); \
-}
-
-IMPL(int)
-IMPL(unsigned int)
+#define __CLC_ATOMIC_OP sub
+#define __CLC_ATOMIC_ADDRESS_SPACE local
+#include "../atom_int32_binary.inc"
Modified: libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_xchg.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_xchg.cl?rev=335279&r1=335278&r2=335279&view=diff
==============================================================================
--- libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_xchg.cl (original)
+++ libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_xchg.cl Thu Jun 21 12:27:33 2018
@@ -1,9 +1,3 @@
-#include <clc/clc.h>
-
-#define IMPL(TYPE) \
-_CLC_OVERLOAD _CLC_DEF TYPE atom_xchg(local TYPE *p, TYPE val) { \
- return atomic_xchg(p, val); \
-}
-
-IMPL(int)
-IMPL(unsigned int)
+#define __CLC_ATOMIC_OP xchg
+#define __CLC_ATOMIC_ADDRESS_SPACE local
+#include "../atom_int32_binary.inc"
Modified: libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_and.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_and.cl?rev=335279&r1=335278&r2=335279&view=diff
==============================================================================
--- libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_and.cl (original)
+++ libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_and.cl Thu Jun 21 12:27:33 2018
@@ -1,9 +1,3 @@
-#include <clc/clc.h>
-
-#define IMPL(TYPE) \
-_CLC_OVERLOAD _CLC_DEF TYPE atom_and(local TYPE *p, TYPE val) { \
- return atomic_and(p, val); \
-}
-
-IMPL(int)
-IMPL(unsigned int)
\ No newline at end of file
+#define __CLC_ATOMIC_OP and
+#define __CLC_ATOMIC_ADDRESS_SPACE local
+#include "../atom_int32_binary.inc"
Modified: libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_max.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_max.cl?rev=335279&r1=335278&r2=335279&view=diff
==============================================================================
--- libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_max.cl (original)
+++ libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_max.cl Thu Jun 21 12:27:33 2018
@@ -1,9 +1,3 @@
-#include <clc/clc.h>
-
-#define IMPL(TYPE) \
-_CLC_OVERLOAD _CLC_DEF TYPE atom_max(local TYPE *p, TYPE val) { \
- return atomic_max(p, val); \
-}
-
-IMPL(int)
-IMPL(unsigned int)
+#define __CLC_ATOMIC_OP max
+#define __CLC_ATOMIC_ADDRESS_SPACE local
+#include "../atom_int32_binary.inc"
Modified: libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_min.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_min.cl?rev=335279&r1=335278&r2=335279&view=diff
==============================================================================
--- libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_min.cl (original)
+++ libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_min.cl Thu Jun 21 12:27:33 2018
@@ -1,9 +1,3 @@
-#include <clc/clc.h>
-
-#define IMPL(TYPE) \
-_CLC_OVERLOAD _CLC_DEF TYPE atom_min(local TYPE *p, TYPE val) { \
- return atomic_min(p, val); \
-}
-
-IMPL(int)
-IMPL(unsigned int)
+#define __CLC_ATOMIC_OP min
+#define __CLC_ATOMIC_ADDRESS_SPACE local
+#include "../atom_int32_binary.inc"
Modified: libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_or.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_or.cl?rev=335279&r1=335278&r2=335279&view=diff
==============================================================================
--- libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_or.cl (original)
+++ libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_or.cl Thu Jun 21 12:27:33 2018
@@ -1,9 +1,3 @@
-#include <clc/clc.h>
-
-#define IMPL(TYPE) \
-_CLC_OVERLOAD _CLC_DEF TYPE atom_or(local TYPE *p, TYPE val) { \
- return atomic_or(p, val); \
-}
-
-IMPL(int)
-IMPL(unsigned int)
+#define __CLC_ATOMIC_OP or
+#define __CLC_ATOMIC_ADDRESS_SPACE local
+#include "../atom_int32_binary.inc"
Modified: libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_xor.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_xor.cl?rev=335279&r1=335278&r2=335279&view=diff
==============================================================================
--- libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_xor.cl (original)
+++ libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_xor.cl Thu Jun 21 12:27:33 2018
@@ -1,9 +1,3 @@
-#include <clc/clc.h>
-
-#define IMPL(TYPE) \
-_CLC_OVERLOAD _CLC_DEF TYPE atom_xor(local TYPE *p, TYPE val) { \
- return atomic_xor(p, val); \
-}
-
-IMPL(int)
-IMPL(unsigned int)
+#define __CLC_ATOMIC_OP xor
+#define __CLC_ATOMIC_ADDRESS_SPACE local
+#include "../atom_int32_binary.inc"
More information about the cfe-commits
mailing list