[libclc] r185007 - libclc: Initial vstore implementation
Tom Stellard
thomas.stellard at amd.com
Wed Jun 26 11:22:11 PDT 2013
Author: tstellar
Date: Wed Jun 26 13:22:11 2013
New Revision: 185007
URL: http://llvm.org/viewvc/llvm-project?rev=185007&view=rev
Log:
libclc: Initial vstore implementation
Assumes that the target supports byte-addressable stores.
Completely unoptimized.
Patch by: Aaron Watry
Added:
libclc/trunk/generic/include/clc/shared/vstore.h
libclc/trunk/generic/lib/shared/vstore.cl
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES
Modified: libclc/trunk/generic/include/clc/clc.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=185007&r1=185006&r2=185007&view=diff
==============================================================================
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Wed Jun 26 13:22:11 2013
@@ -72,6 +72,7 @@
#include <clc/shared/max.h>
#include <clc/shared/min.h>
#include <clc/shared/vload.h>
+#include <clc/shared/vstore.h>
/* 6.11.5 Geometric Functions */
#include <clc/geometric/cross.h>
Added: libclc/trunk/generic/include/clc/shared/vstore.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/shared/vstore.h?rev=185007&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/shared/vstore.h (added)
+++ libclc/trunk/generic/include/clc/shared/vstore.h Wed Jun 26 13:22:11 2013
@@ -0,0 +1,36 @@
+#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_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_PRIM1(PRIM_TYPE) \
+ _CLC_VECTOR_VSTORE_DECL(PRIM_TYPE, __private) \
+ _CLC_VECTOR_VSTORE_DECL(PRIM_TYPE, __local) \
+ _CLC_VECTOR_VSTORE_DECL(PRIM_TYPE, __global) \
+
+#define _CLC_VECTOR_VSTORE_PRIM() \
+ _CLC_VECTOR_VSTORE_PRIM1(char) \
+ _CLC_VECTOR_VSTORE_PRIM1(uchar) \
+ _CLC_VECTOR_VSTORE_PRIM1(short) \
+ _CLC_VECTOR_VSTORE_PRIM1(ushort) \
+ _CLC_VECTOR_VSTORE_PRIM1(int) \
+ _CLC_VECTOR_VSTORE_PRIM1(uint) \
+ _CLC_VECTOR_VSTORE_PRIM1(long) \
+ _CLC_VECTOR_VSTORE_PRIM1(ulong) \
+ _CLC_VECTOR_VSTORE_PRIM1(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()
+#endif
+
+_CLC_VECTOR_VSTORE()
Modified: libclc/trunk/generic/lib/SOURCES
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=185007&r1=185006&r2=185007&view=diff
==============================================================================
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Wed Jun 26 13:22:11 2013
@@ -24,5 +24,6 @@ shared/clamp.cl
shared/max.cl
shared/min.cl
shared/vload.cl
+shared/vstore.cl
workitem/get_global_id.cl
workitem/get_global_size.cl
Added: libclc/trunk/generic/lib/shared/vstore.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/shared/vstore.cl?rev=185007&view=auto
==============================================================================
--- libclc/trunk/generic/lib/shared/vstore.cl (added)
+++ libclc/trunk/generic/lib/shared/vstore.cl Wed Jun 26 13:22:11 2013
@@ -0,0 +1,56 @@
+#include <clc/clc.h>
+
+#pragma OPENCL EXTENSION cl_khr_byte_addressable_store : enable
+
+#define VSTORE_VECTORIZE(PRIM_TYPE, ADDR_SPACE) \
+ _CLC_OVERLOAD _CLC_DEF void vstore2(PRIM_TYPE##2 vec, size_t offset, ADDR_SPACE PRIM_TYPE *mem) { \
+ mem[offset] = vec.s0; \
+ mem[offset+1] = vec.s1; \
+ } \
+\
+ _CLC_OVERLOAD _CLC_DEF void vstore3(PRIM_TYPE##3 vec, size_t offset, ADDR_SPACE PRIM_TYPE *mem) { \
+ mem[offset] = vec.s0; \
+ mem[offset+1] = vec.s1; \
+ mem[offset+2] = vec.s2; \
+ } \
+\
+ _CLC_OVERLOAD _CLC_DEF void vstore4(PRIM_TYPE##4 vec, size_t offset, ADDR_SPACE PRIM_TYPE *mem) { \
+ mem[offset] = vec.s0; \
+ mem[offset+1] = vec.s1; \
+ mem[offset+2] = vec.s2; \
+ mem[offset+3] = vec.s3; \
+ } \
+\
+ _CLC_OVERLOAD _CLC_DEF void vstore8(PRIM_TYPE##8 vec, size_t offset, ADDR_SPACE PRIM_TYPE *mem) { \
+ vstore4(vec.lo, offset, mem); \
+ vstore4(vec.hi, offset+4, mem); \
+ } \
+\
+ _CLC_OVERLOAD _CLC_DEF void vstore16(PRIM_TYPE##16 vec, size_t offset, ADDR_SPACE PRIM_TYPE *mem) { \
+ vstore8(vec.lo, offset, mem); \
+ vstore8(vec.hi, offset+8, mem); \
+ } \
+
+#define VSTORE_ADDR_SPACES(SCALAR_GENTYPE) \
+ VSTORE_VECTORIZE(SCALAR_GENTYPE, __private) \
+ VSTORE_VECTORIZE(SCALAR_GENTYPE, __local) \
+ VSTORE_VECTORIZE(SCALAR_GENTYPE, __global) \
+
+#define VSTORE_TYPES() \
+ VSTORE_ADDR_SPACES(char) \
+ VSTORE_ADDR_SPACES(uchar) \
+ VSTORE_ADDR_SPACES(short) \
+ VSTORE_ADDR_SPACES(ushort) \
+ VSTORE_ADDR_SPACES(int) \
+ VSTORE_ADDR_SPACES(uint) \
+ VSTORE_ADDR_SPACES(long) \
+ VSTORE_ADDR_SPACES(ulong) \
+ VSTORE_ADDR_SPACES(float) \
+
+VSTORE_TYPES()
+
+#ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+ VSTORE_ADDR_SPACES(double)
+#endif
+
More information about the cfe-commits
mailing list