[Libclc-dev] [PATCH] Add atomic_sub and atomic_dec builtin functions

Tom Stellard tom at stellard.net
Thu Sep 5 08:56:01 PDT 2013


On Wed, Sep 04, 2013 at 05:24:15PM -0500, Aaron Watry wrote:

Reviewed-by: Tom Stellard <thomas.stellard at amd.com>

> ---
>  generic/include/clc/atomic/atomic_dec.h |  1 +
>  generic/include/clc/atomic/atomic_sub.h |  3 +++
>  generic/include/clc/clc.h               |  2 ++
>  generic/lib/atomic/atomic_impl.ll       | 12 ++++++++++++
>  r600/lib/atomic/atomic.cl               |  1 +
>  5 files changed, 19 insertions(+)
>  create mode 100644 generic/include/clc/atomic/atomic_dec.h
>  create mode 100644 generic/include/clc/atomic/atomic_sub.h
> 
> diff --git a/generic/include/clc/atomic/atomic_dec.h b/generic/include/clc/atomic/atomic_dec.h
> new file mode 100644
> index 0000000..621905f
> --- /dev/null
> +++ b/generic/include/clc/atomic/atomic_dec.h
> @@ -0,0 +1 @@
> +#define atomic_dec(p) atomic_sub(p, 1);
> diff --git a/generic/include/clc/atomic/atomic_sub.h b/generic/include/clc/atomic/atomic_sub.h
> new file mode 100644
> index 0000000..576a3ab
> --- /dev/null
> +++ b/generic/include/clc/atomic/atomic_sub.h
> @@ -0,0 +1,3 @@
> +#define __CLC_FUNCTION atomic_sub
> +#include <clc/atomic/atomic_decl.inc>
> +#undef __CLC_FUNCTION
> diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
> index 105180e..aeb3949 100644
> --- a/generic/include/clc/clc.h
> +++ b/generic/include/clc/clc.h
> @@ -101,6 +101,8 @@
>  
>  /* 6.11.11 Atomic Functins */
>  #include <clc/atomic/atomic_add.h>
> +#include <clc/atomic/atomic_dec.h>
>  #include <clc/atomic/atomic_inc.h>
> +#include <clc/atomic/atomic_sub.h>
>  
>  #pragma OPENCL EXTENSION all : disable
> diff --git a/generic/lib/atomic/atomic_impl.ll b/generic/lib/atomic/atomic_impl.ll
> index c11383b..9df5b9f 100644
> --- a/generic/lib/atomic/atomic_impl.ll
> +++ b/generic/lib/atomic/atomic_impl.ll
> @@ -9,3 +9,15 @@ entry:
>    %0 = atomicrmw volatile add 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
> +  ret i32 %0
> +}
> +
> +define i32 @__clc_atomic_sub_addr3(i32 addrspace(3)* nocapture %ptr, i32 %value) nounwind alwaysinline {
> +entry:
> +  %0 = atomicrmw volatile sub i32 addrspace(3)* %ptr, i32 %value seq_cst
> +  ret i32 %0
> +}
> diff --git a/r600/lib/atomic/atomic.cl b/r600/lib/atomic/atomic.cl
> index e80180c..bd5ee64 100644
> --- a/r600/lib/atomic/atomic.cl
> +++ b/r600/lib/atomic/atomic.cl
> @@ -18,3 +18,4 @@ _CLC_OVERLOAD _CLC_DEF SIGN TYPE FUNCTION (volatile CL_ADDRSPACE SIGN TYPE *p, S
>  	ATOMIC_FUNC_ADDRSPACE(int, FUNCTION)
>  
>  ATOMIC_FUNC(atomic_add)
> +ATOMIC_FUNC(atomic_sub)
> -- 
> 1.8.1.2
> 
> 
> _______________________________________________
> Libclc-dev mailing list
> Libclc-dev at pcc.me.uk
> http://www.pcc.me.uk/cgi-bin/mailman/listinfo/libclc-dev




More information about the Libclc-dev mailing list