Author: jvesely Date: Wed Sep 20 13:42:19 2017 New Revision: 313811 URL: http://llvm.org/viewvc/llvm-project?rev=313811&view=rev Log: Implement cl_khr_int64_extended_atomics builtins
Signed-off-by: Jan Vesely <jan.ves...@rutgers.edu> Reviewed-by: Aaron Watry <awa...@gmail.com> Tested-by: Aaron Watry <awa...@gmail.com> Added: libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/ libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/ libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_and.h libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_max.h libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_min.h libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_or.h libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_xor.h libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/ libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_and.cl libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_max.cl libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_min.cl libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_or.cl libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_xor.cl Modified: libclc/trunk/amdgcn/lib/SOURCES libclc/trunk/generic/include/clc/clc.h libclc/trunk/generic/lib/SOURCES Modified: libclc/trunk/amdgcn/lib/SOURCES URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/SOURCES?rev=313811&r1=313810&r2=313811&view=diff ============================================================================== --- libclc/trunk/amdgcn/lib/SOURCES (original) +++ libclc/trunk/amdgcn/lib/SOURCES Wed Sep 20 13:42:19 2017 @@ -1,3 +1,4 @@ +cl_khr_int64_extended_atomics/minmax_helpers.ll math/ldexp.cl mem_fence/fence.cl mem_fence/waitcnt.ll Added: libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll?rev=313811&view=auto ============================================================================== --- libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll (added) +++ libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll Wed Sep 20 13:42:19 2017 @@ -0,0 +1,47 @@ +define i64 @__clc__sync_fetch_and_min_global_8(i64 addrspace(1)* nocapture %ptr, i64 %value) nounwind alwaysinline { +entry: + %0 = atomicrmw volatile min i64 addrspace(1)* %ptr, i64 %value seq_cst + ret i64 %0 +} + +define i64 @__clc__sync_fetch_and_umin_global_8(i64 addrspace(1)* nocapture %ptr, i64 %value) nounwind alwaysinline { +entry: + %0 = atomicrmw volatile umin i64 addrspace(1)* %ptr, i64 %value seq_cst + ret i64 %0 +} + +define i64 @__clc__sync_fetch_and_min_local_8(i64 addrspace(3)* nocapture %ptr, i64 %value) nounwind alwaysinline { +entry: + %0 = atomicrmw volatile min i64 addrspace(3)* %ptr, i64 %value seq_cst + ret i64 %0 +} + +define i64 @__clc__sync_fetch_and_umin_local_8(i64 addrspace(3)* nocapture %ptr, i64 %value) nounwind alwaysinline { +entry: + %0 = atomicrmw volatile umin i64 addrspace(3)* %ptr, i64 %value seq_cst + ret i64 %0 +} + +define i64 @__clc__sync_fetch_and_max_global_8(i64 addrspace(1)* nocapture %ptr, i64 %value) nounwind alwaysinline { +entry: + %0 = atomicrmw volatile max i64 addrspace(1)* %ptr, i64 %value seq_cst + ret i64 %0 +} + +define i64 @__clc__sync_fetch_and_umax_global_8(i64 addrspace(1)* nocapture %ptr, i64 %value) nounwind alwaysinline { +entry: + %0 = atomicrmw volatile umax i64 addrspace(1)* %ptr, i64 %value seq_cst + ret i64 %0 +} + +define i64 @__clc__sync_fetch_and_max_local_8(i64 addrspace(3)* nocapture %ptr, i64 %value) nounwind alwaysinline { +entry: + %0 = atomicrmw volatile max i64 addrspace(3)* %ptr, i64 %value seq_cst + ret i64 %0 +} + +define i64 @__clc__sync_fetch_and_umax_local_8(i64 addrspace(3)* nocapture %ptr, i64 %value) nounwind alwaysinline { +entry: + %0 = atomicrmw volatile umax i64 addrspace(3)* %ptr, i64 %value seq_cst + ret i64 %0 +} Added: libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_and.h URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_and.h?rev=313811&view=auto ============================================================================== --- libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_and.h (added) +++ libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_and.h Wed Sep 20 13:42:19 2017 @@ -0,0 +1,4 @@ +_CLC_OVERLOAD _CLC_DECL long atom_and(volatile global long *p, long val); +_CLC_OVERLOAD _CLC_DECL unsigned long atom_and(volatile global unsigned long *p, unsigned long val); +_CLC_OVERLOAD _CLC_DECL long atom_and(volatile local long *p, long val); +_CLC_OVERLOAD _CLC_DECL unsigned long atom_and(volatile local unsigned long *p, unsigned long val); Added: libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_max.h URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_max.h?rev=313811&view=auto ============================================================================== --- libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_max.h (added) +++ libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_max.h Wed Sep 20 13:42:19 2017 @@ -0,0 +1,4 @@ +_CLC_OVERLOAD _CLC_DECL long atom_max(volatile global long *p, long val); +_CLC_OVERLOAD _CLC_DECL unsigned long atom_max(volatile global unsigned long *p, unsigned long val); +_CLC_OVERLOAD _CLC_DECL long atom_max(volatile local long *p, long val); +_CLC_OVERLOAD _CLC_DECL unsigned long atom_max(volatile local unsigned long *p, unsigned long val); Added: libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_min.h URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_min.h?rev=313811&view=auto ============================================================================== --- libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_min.h (added) +++ libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_min.h Wed Sep 20 13:42:19 2017 @@ -0,0 +1,4 @@ +_CLC_OVERLOAD _CLC_DECL long atom_min(volatile global long *p, long val); +_CLC_OVERLOAD _CLC_DECL unsigned long atom_min(volatile global unsigned long *p, unsigned long val); +_CLC_OVERLOAD _CLC_DECL long atom_min(volatile local long *p, long val); +_CLC_OVERLOAD _CLC_DECL unsigned long atom_min(volatile local unsigned long *p, unsigned long val); Added: libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_or.h URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_or.h?rev=313811&view=auto ============================================================================== --- libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_or.h (added) +++ libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_or.h Wed Sep 20 13:42:19 2017 @@ -0,0 +1,4 @@ +_CLC_OVERLOAD _CLC_DECL long atom_or(volatile global long *p, long val); +_CLC_OVERLOAD _CLC_DECL unsigned long atom_or(volatile global unsigned long *p, unsigned long val); +_CLC_OVERLOAD _CLC_DECL long atom_or(volatile local long *p, long val); +_CLC_OVERLOAD _CLC_DECL unsigned long atom_or(volatile local unsigned long *p, unsigned long val); Added: libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_xor.h URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_xor.h?rev=313811&view=auto ============================================================================== --- libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_xor.h (added) +++ libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_xor.h Wed Sep 20 13:42:19 2017 @@ -0,0 +1,4 @@ +_CLC_OVERLOAD _CLC_DECL long atom_xor(volatile global long *p, long val); +_CLC_OVERLOAD _CLC_DECL unsigned long atom_xor(volatile global unsigned long *p, unsigned long val); +_CLC_OVERLOAD _CLC_DECL long atom_xor(volatile local long *p, long val); +_CLC_OVERLOAD _CLC_DECL unsigned long atom_xor(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=313811&r1=313810&r2=313811&view=diff ============================================================================== --- libclc/trunk/generic/include/clc/clc.h (original) +++ libclc/trunk/generic/include/clc/clc.h Wed Sep 20 13:42:19 2017 @@ -247,6 +247,15 @@ #include <clc/cl_khr_int64_base_atomics/atom_xchg.h> #endif +/* cl_khr_int64_extended_atomics Extension Functions */ +#ifdef cl_khr_int64_base_atomics +#include <clc/cl_khr_int64_extended_atomics/atom_and.h> +#include <clc/cl_khr_int64_extended_atomics/atom_max.h> +#include <clc/cl_khr_int64_extended_atomics/atom_min.h> +#include <clc/cl_khr_int64_extended_atomics/atom_or.h> +#include <clc/cl_khr_int64_extended_atomics/atom_xor.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=313811&r1=313810&r2=313811&view=diff ============================================================================== --- libclc/trunk/generic/lib/SOURCES (original) +++ libclc/trunk/generic/lib/SOURCES Wed Sep 20 13:42:19 2017 @@ -34,6 +34,11 @@ 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 +cl_khr_int64_extended_atomics/atom_and.cl +cl_khr_int64_extended_atomics/atom_max.cl +cl_khr_int64_extended_atomics/atom_min.cl +cl_khr_int64_extended_atomics/atom_or.cl +cl_khr_int64_extended_atomics/atom_xor.cl convert.cl common/degrees.cl common/mix.cl Added: libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_and.cl URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_and.cl?rev=313811&view=auto ============================================================================== --- libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_and.cl (added) +++ libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_and.cl Wed Sep 20 13:42:19 2017 @@ -0,0 +1,16 @@ +#include <clc/clc.h> + +#ifdef cl_khr_int64_extended_atomics + +#define IMPL(AS, TYPE) \ +_CLC_OVERLOAD _CLC_DEF TYPE atom_and(volatile AS TYPE *p, TYPE val) { \ + return __sync_fetch_and_and_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_extended_atomics/atom_max.cl URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_max.cl?rev=313811&view=auto ============================================================================== --- libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_max.cl (added) +++ libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_max.cl Wed Sep 20 13:42:19 2017 @@ -0,0 +1,21 @@ +#include <clc/clc.h> + +#ifdef cl_khr_int64_extended_atomics + +unsigned long __clc__sync_fetch_and_max_local_8(volatile local long *, long); +unsigned long __clc__sync_fetch_and_max_global_8(volatile global long *, long); +unsigned long __clc__sync_fetch_and_umax_local_8(volatile local unsigned long *, unsigned long); +unsigned long __clc__sync_fetch_and_umax_global_8(volatile global unsigned long *, unsigned long); + +#define IMPL(AS, TYPE, OP) \ +_CLC_OVERLOAD _CLC_DEF TYPE atom_max(volatile AS TYPE *p, TYPE val) { \ + return __clc__sync_fetch_and_##OP##_##AS##_8(p, val); \ +} + +IMPL(global, long, max) +IMPL(global, unsigned long, umax) +IMPL(local, long, max) +IMPL(local, unsigned long, umax) +#undef IMPL + +#endif Added: libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_min.cl URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_min.cl?rev=313811&view=auto ============================================================================== --- libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_min.cl (added) +++ libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_min.cl Wed Sep 20 13:42:19 2017 @@ -0,0 +1,21 @@ +#include <clc/clc.h> + +#ifdef cl_khr_int64_extended_atomics + +unsigned long __clc__sync_fetch_and_min_local_8(volatile local long *, long); +unsigned long __clc__sync_fetch_and_min_global_8(volatile global long *, long); +unsigned long __clc__sync_fetch_and_umin_local_8(volatile local unsigned long *, unsigned long); +unsigned long __clc__sync_fetch_and_umin_global_8(volatile global unsigned long *, unsigned long); + +#define IMPL(AS, TYPE, OP) \ +_CLC_OVERLOAD _CLC_DEF TYPE atom_min(volatile AS TYPE *p, TYPE val) { \ + return __clc__sync_fetch_and_##OP##_##AS##_8(p, val); \ +} + +IMPL(global, long, min) +IMPL(global, unsigned long, umin) +IMPL(local, long, min) +IMPL(local, unsigned long, umin) +#undef IMPL + +#endif Added: libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_or.cl URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_or.cl?rev=313811&view=auto ============================================================================== --- libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_or.cl (added) +++ libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_or.cl Wed Sep 20 13:42:19 2017 @@ -0,0 +1,16 @@ +#include <clc/clc.h> + +#ifdef cl_khr_int64_extended_atomics + +#define IMPL(AS, TYPE) \ +_CLC_OVERLOAD _CLC_DEF TYPE atom_or(volatile AS TYPE *p, TYPE val) { \ + return __sync_fetch_and_or_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_extended_atomics/atom_xor.cl URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_xor.cl?rev=313811&view=auto ============================================================================== --- libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_xor.cl (added) +++ libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_xor.cl Wed Sep 20 13:42:19 2017 @@ -0,0 +1,16 @@ +#include <clc/clc.h> + +#ifdef cl_khr_int64_extended_atomics + +#define IMPL(AS, TYPE) \ +_CLC_OVERLOAD _CLC_DEF TYPE atom_xor(volatile AS TYPE *p, TYPE val) { \ + return __sync_fetch_and_xor_8(p, val); \ +} + +IMPL(global, long) +IMPL(global, unsigned long) +IMPL(local, long) +IMPL(local, unsigned long) +#undef IMPL + +#endif _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits