forked from OSchip/llvm-project
Implement vstore_half{,n}
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu> llvm-svn: 278962
This commit is contained in:
parent
8b58bdfe6f
commit
ad8672727c
|
@ -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)
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue