[Libclc-dev] [PATCH 1/1] Implement vstore_half{,n}

Tom Stellard via Libclc-dev libclc-dev at lists.llvm.org
Wed Aug 17 12:31:22 PDT 2016


On Wed, Aug 17, 2016 at 12:31:57AM -0400, Jan Vesely via Libclc-dev wrote:
> On Sat, 2016-07-30 at 15:37 -0400, Jan Vesely wrote:
> > Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
> 
> ping. Even if the llvm patch needs more work, this one should be safe.

> 
LGTM.
> Jan
> 
> > ---
> > 
> > vstore_half(float) version passes newly posted piglit on Kaveri.
> > vstore_half(double) fails, but the generated llvm IR appears good
> > 
> >  generic/include/clc/shared/vstore.h | 45 +++++++++++++++++++++----
> > ------------
> >  generic/lib/shared/vstore.cl        | 32 ++++++++++++++++++++++++++
> >  generic/lib/shared/vstore_half.inc  | 10 +++++++++
> >  3 files changed, 68 insertions(+), 19 deletions(-)
> >  create mode 100644 generic/lib/shared/vstore_half.inc
> > 
> > diff --git a/generic/include/clc/shared/vstore.h
> > b/generic/include/clc/shared/vstore.h
> > index 1f784f8..ea8d4cf 100644
> > --- a/generic/include/clc/shared/vstore.h
> > +++ b/generic/include/clc/shared/vstore.h
> > @@ -1,17 +1,20 @@
> > -#define _CLC_VSTORE_DECL(PRIM_TYPE, VEC_TYPE, WIDTH, ADDR_SPACE) \
> > -  _CLC_OVERLOAD _CLC_DECL void vstore##WIDTH(VEC_TYPE vec, size_t
> > offset, ADDR_SPACE PRIM_TYPE *out);
> > +#define _CLC_VSTORE_DECL(SUFFIX, PRIM_TYPE, VEC_TYPE, WIDTH,
> > ADDR_SPACE) \
> > +  _CLC_OVERLOAD _CLC_DECL void vstore##SUFFIX##WIDTH(VEC_TYPE vec,
> > size_t offset, ADDR_SPACE PRIM_TYPE *out);
> >  
> > -#define _CLC_VECTOR_VSTORE_DECL(PRIM_TYPE, ADDR_SPACE) \
> > -  _CLC_VSTORE_DECL(PRIM_TYPE, PRIM_TYPE##2, 2, ADDR_SPACE) \
> > -  _CLC_VSTORE_DECL(PRIM_TYPE, PRIM_TYPE##3, 3, ADDR_SPACE) \
> > -  _CLC_VSTORE_DECL(PRIM_TYPE, PRIM_TYPE##4, 4, ADDR_SPACE) \
> > -  _CLC_VSTORE_DECL(PRIM_TYPE, PRIM_TYPE##8, 8, ADDR_SPACE) \
> > -  _CLC_VSTORE_DECL(PRIM_TYPE, PRIM_TYPE##16, 16, ADDR_SPACE)
> > +#define _CLC_VECTOR_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE,
> > ADDR_SPACE) \
> > +  _CLC_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##2, 2, ADDR_SPACE) \
> > +  _CLC_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##3, 3, ADDR_SPACE) \
> > +  _CLC_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##4, 4, ADDR_SPACE) \
> > +  _CLC_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##8, 8, ADDR_SPACE) \
> > +  _CLC_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##16, 16, ADDR_SPACE)
> > +
> > +#define _CLC_VECTOR_VSTORE_PRIM3(SUFFIX, MEM_TYPE, PRIM_TYPE) \
> > +  _CLC_VECTOR_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __private) \
> > +  _CLC_VECTOR_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __local) \
> > +  _CLC_VECTOR_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __global) \
> >  
> >  #define _CLC_VECTOR_VSTORE_PRIM1(PRIM_TYPE) \
> > -  _CLC_VECTOR_VSTORE_DECL(PRIM_TYPE, __private) \
> > -  _CLC_VECTOR_VSTORE_DECL(PRIM_TYPE, __local) \
> > -  _CLC_VECTOR_VSTORE_DECL(PRIM_TYPE, __global) \
> > +  _CLC_VECTOR_VSTORE_PRIM3(,PRIM_TYPE, PRIM_TYPE) \
> >  
> >  #define _CLC_VECTOR_VSTORE_PRIM() \
> >      _CLC_VECTOR_VSTORE_PRIM1(char) \
> > @@ -23,14 +26,18 @@
> >      _CLC_VECTOR_VSTORE_PRIM1(long) \
> >      _CLC_VECTOR_VSTORE_PRIM1(ulong) \
> >      _CLC_VECTOR_VSTORE_PRIM1(float) \
> > -        
> > +    _CLC_VECTOR_VSTORE_PRIM3(_half, half, float)
> > +
> >  #ifdef cl_khr_fp64
> > -#define _CLC_VECTOR_VSTORE() \
> > -  _CLC_VECTOR_VSTORE_PRIM1(double) \
> > -  _CLC_VECTOR_VSTORE_PRIM()
> > -#else
> > -#define _CLC_VECTOR_VSTORE() \
> > -  _CLC_VECTOR_VSTORE_PRIM()
> > +#pragma cl_khr_fp64: enable
> > +  _CLC_VECTOR_VSTORE_PRIM1(double)
> > +  _CLC_VECTOR_VSTORE_PRIM3(_half, half, double)
> > +  _CLC_VSTORE_DECL(_half, half, double, , __private)
> > +  _CLC_VSTORE_DECL(_half, half, double, , __local)
> > +  _CLC_VSTORE_DECL(_half, half, double, , __global)
> >  #endif
> >  
> > -_CLC_VECTOR_VSTORE()
> > +_CLC_VECTOR_VSTORE_PRIM()
> > +_CLC_VSTORE_DECL(_half, half, float, , __private)
> > +_CLC_VSTORE_DECL(_half, half, float, , __local)
> > +_CLC_VSTORE_DECL(_half, half, float, , __global)
> > diff --git a/generic/lib/shared/vstore.cl
> > b/generic/lib/shared/vstore.cl
> > index 4777b7e..ebc9446 100644
> > --- a/generic/lib/shared/vstore.cl
> > +++ b/generic/lib/shared/vstore.cl
> > @@ -50,3 +50,35 @@ VSTORE_TYPES()
> >  #pragma OPENCL EXTENSION cl_khr_fp64 : enable
> >      VSTORE_ADDR_SPACES(double)
> >  #endif
> > +
> > +/* vstore_half are legal even without cl_khr_fp16 */
> > +
> > +#define VEC_STORE1(val) mem[offset++] = val;
> > +#define VEC_STORE2(val) \
> > +	VEC_STORE1(val.lo) \
> > +	VEC_STORE1(val.hi)
> > +#define VEC_STORE3(val) \
> > +	VEC_STORE1(val.s0) \
> > +	VEC_STORE1(val.s1) \
> > +	VEC_STORE1(val.s2)
> > +#define VEC_STORE4(val) \
> > +	VEC_STORE2(val.lo) \
> > +	VEC_STORE2(val.hi)
> > +#define VEC_STORE8(val) \
> > +	VEC_STORE4(val.lo) \
> > +	VEC_STORE4(val.hi)
> > +#define VEC_STORE16(val) \
> > +	VEC_STORE8(val.lo) \
> > +	VEC_STORE8(val.hi)
> > +
> > +#define __FUNC(SUFFIX, VEC_SIZE, TYPE, AS) \
> > +  _CLC_OVERLOAD _CLC_DEF void vstore_half##SUFFIX(TYPE vec, size_t
> > offset, AS half *mem) { \
> > +    offset *= VEC_SIZE; \
> > +    VEC_STORE##VEC_SIZE(vec) \
> > +  }
> > +
> > +#define FUNC(SUFFIX, VEC_SIZE, TYPE, AS) __FUNC(SUFFIX, VEC_SIZE,
> > TYPE, AS)
> > +
> > +#define __CLC_BODY "vstore_half.inc"
> > +#include <clc/math/gentype.inc>
> > +
> > diff --git a/generic/lib/shared/vstore_half.inc
> > b/generic/lib/shared/vstore_half.inc
> > new file mode 100644
> > index 0000000..8ed03a0
> > --- /dev/null
> > +++ b/generic/lib/shared/vstore_half.inc
> > @@ -0,0 +1,10 @@
> > +
> > +#ifdef __CLC_VECSIZE
> > +  FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_GENTYPE, __private);
> > +  FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_GENTYPE, __local);
> > +  FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_GENTYPE, __global);
> > +#else
> > +  FUNC(, 1, __CLC_GENTYPE, __private);
> > +  FUNC(, 1, __CLC_GENTYPE, __local);
> > +  FUNC(, 1, __CLC_GENTYPE, __global);
> > +#endif



> _______________________________________________
> Libclc-dev mailing list
> Libclc-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/libclc-dev



More information about the Libclc-dev mailing list