atomic: Add generic atomic_min implementation

Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
llvm-svn: 217916
This commit is contained in:
Aaron Watry 2014-09-16 22:34:41 +00:00
parent 3f0a1a4c27
commit 7cfa12c2a5
8 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,3 @@
#define __CLC_FUNCTION atomic_min
#include <clc/atomic/atomic_decl.inc>
#undef __CLC_FUNCTION

View File

@ -0,0 +1,2 @@
_CLC_OVERLOAD _CLC_DECL int atom_min(global int *p, int val);
_CLC_OVERLOAD _CLC_DECL unsigned int atom_min(global unsigned int *p, unsigned int val);

View File

@ -0,0 +1,2 @@
_CLC_OVERLOAD _CLC_DECL int atom_min(local int *p, int val);
_CLC_OVERLOAD _CLC_DECL unsigned int atom_min(local unsigned int *p, unsigned int val);

View File

@ -145,6 +145,7 @@
#include <clc/atomic/atomic_dec.h>
#include <clc/atomic/atomic_inc.h>
#include <clc/atomic/atomic_max.h>
#include <clc/atomic/atomic_min.h>
#include <clc/atomic/atomic_or.h>
#include <clc/atomic/atomic_sub.h>
#include <clc/atomic/atomic_xor.h>
@ -158,6 +159,7 @@
/* cl_khr_global_int32_extended_atomics Extension Functions */
#include <clc/cl_khr_global_int32_extended_atomics/atom_and.h>
#include <clc/cl_khr_global_int32_extended_atomics/atom_max.h>
#include <clc/cl_khr_global_int32_extended_atomics/atom_min.h>
#include <clc/cl_khr_global_int32_extended_atomics/atom_or.h>
#include <clc/cl_khr_global_int32_extended_atomics/atom_xor.h>
@ -170,6 +172,7 @@
/* cl_khr_local_int32_extended_atomics Extension Functions */
#include <clc/cl_khr_local_int32_extended_atomics/atom_and.h>
#include <clc/cl_khr_local_int32_extended_atomics/atom_max.h>
#include <clc/cl_khr_local_int32_extended_atomics/atom_min.h>
#include <clc/cl_khr_local_int32_extended_atomics/atom_or.h>
#include <clc/cl_khr_local_int32_extended_atomics/atom_xor.h>

View File

@ -6,6 +6,7 @@ cl_khr_global_int32_base_atomics/atom_inc.cl
cl_khr_global_int32_base_atomics/atom_sub.cl
cl_khr_global_int32_extended_atomics/atom_and.cl
cl_khr_global_int32_extended_atomics/atom_max.cl
cl_khr_global_int32_extended_atomics/atom_min.cl
cl_khr_global_int32_extended_atomics/atom_or.cl
cl_khr_global_int32_extended_atomics/atom_xor.cl
cl_khr_local_int32_base_atomics/atom_add.cl
@ -14,6 +15,7 @@ cl_khr_local_int32_base_atomics/atom_inc.cl
cl_khr_local_int32_base_atomics/atom_sub.cl
cl_khr_local_int32_extended_atomics/atom_and.cl
cl_khr_local_int32_extended_atomics/atom_max.cl
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
convert.cl

View File

@ -34,6 +34,18 @@ entry:
ret i32 %0
}
define i32 @__clc_atomic_min_addr1(i32 addrspace(1)* nocapture %ptr, i32 %value) nounwind alwaysinline {
entry:
%0 = atomicrmw volatile min i32 addrspace(1)* %ptr, i32 %value seq_cst
ret i32 %0
}
define i32 @__clc_atomic_min_addr3(i32 addrspace(3)* nocapture %ptr, i32 %value) nounwind alwaysinline {
entry:
%0 = atomicrmw volatile min i32 addrspace(3)* %ptr, i32 %value seq_cst
ret i32 %0
}
define i32 @__clc_atomic_or_addr1(i32 addrspace(1)* nocapture %ptr, i32 %value) nounwind alwaysinline {
entry:
%0 = atomicrmw volatile or i32 addrspace(1)* %ptr, i32 %value seq_cst
@ -58,6 +70,18 @@ entry:
ret i32 %0
}
define i32 @__clc_atomic_umin_addr1(i32 addrspace(1)* nocapture %ptr, i32 %value) nounwind alwaysinline {
entry:
%0 = atomicrmw volatile umin i32 addrspace(1)* %ptr, i32 %value seq_cst
ret i32 %0
}
define i32 @__clc_atomic_umin_addr3(i32 addrspace(3)* nocapture %ptr, i32 %value) nounwind alwaysinline {
entry:
%0 = atomicrmw volatile umin i32 addrspace(3)* %ptr, i32 %value seq_cst
ret i32 %0
}
define i32 @__clc_atomic_sub_addr1(i32 addrspace(1)* nocapture %ptr, i32 %value) nounwind alwaysinline {
entry:
%0 = atomicrmw volatile sub i32 addrspace(1)* %ptr, i32 %value seq_cst

View File

@ -0,0 +1,9 @@
#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)

View File

@ -0,0 +1,9 @@
#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)