blob: 17c2c4c85799538b0088a27675a36dec590734e8 [file] [log] [blame]
Tom Stellard51441f82013-06-26 18:22:11 +00001#include <clc/clc.h>
2
3#pragma OPENCL EXTENSION cl_khr_byte_addressable_store : enable
4
5#define VSTORE_VECTORIZE(PRIM_TYPE, ADDR_SPACE) \
6 _CLC_OVERLOAD _CLC_DEF void vstore2(PRIM_TYPE##2 vec, size_t offset, ADDR_SPACE PRIM_TYPE *mem) { \
7 mem[offset] = vec.s0; \
8 mem[offset+1] = vec.s1; \
9 } \
10\
11 _CLC_OVERLOAD _CLC_DEF void vstore3(PRIM_TYPE##3 vec, size_t offset, ADDR_SPACE PRIM_TYPE *mem) { \
12 mem[offset] = vec.s0; \
13 mem[offset+1] = vec.s1; \
14 mem[offset+2] = vec.s2; \
15 } \
16\
17 _CLC_OVERLOAD _CLC_DEF void vstore4(PRIM_TYPE##4 vec, size_t offset, ADDR_SPACE PRIM_TYPE *mem) { \
Tom Stellard64b3bba2013-06-26 18:22:20 +000018 vstore2(vec.lo, offset, mem); \
19 vstore2(vec.hi, offset+2, mem); \
Tom Stellard51441f82013-06-26 18:22:11 +000020 } \
21\
22 _CLC_OVERLOAD _CLC_DEF void vstore8(PRIM_TYPE##8 vec, size_t offset, ADDR_SPACE PRIM_TYPE *mem) { \
23 vstore4(vec.lo, offset, mem); \
24 vstore4(vec.hi, offset+4, mem); \
25 } \
26\
27 _CLC_OVERLOAD _CLC_DEF void vstore16(PRIM_TYPE##16 vec, size_t offset, ADDR_SPACE PRIM_TYPE *mem) { \
28 vstore8(vec.lo, offset, mem); \
29 vstore8(vec.hi, offset+8, mem); \
30 } \
31
Tom Stellardd768ac02013-07-08 17:27:02 +000032#define VSTORE_ADDR_SPACES(__CLC_SCALAR___CLC_GENTYPE) \
33 VSTORE_VECTORIZE(__CLC_SCALAR___CLC_GENTYPE, __private) \
34 VSTORE_VECTORIZE(__CLC_SCALAR___CLC_GENTYPE, __local) \
35 VSTORE_VECTORIZE(__CLC_SCALAR___CLC_GENTYPE, __global) \
Tom Stellard51441f82013-06-26 18:22:11 +000036
Tom Stellard64b3bba2013-06-26 18:22:20 +000037//int/uint are special... see below
Tom Stellard51441f82013-06-26 18:22:11 +000038#define VSTORE_TYPES() \
39 VSTORE_ADDR_SPACES(char) \
40 VSTORE_ADDR_SPACES(uchar) \
41 VSTORE_ADDR_SPACES(short) \
42 VSTORE_ADDR_SPACES(ushort) \
Tom Stellard51441f82013-06-26 18:22:11 +000043 VSTORE_ADDR_SPACES(long) \
44 VSTORE_ADDR_SPACES(ulong) \
45 VSTORE_ADDR_SPACES(float) \
46
47VSTORE_TYPES()
48
49#ifdef cl_khr_fp64
50#pragma OPENCL EXTENSION cl_khr_fp64 : enable
51 VSTORE_ADDR_SPACES(double)
52#endif
53
Tom Stellard64b3bba2013-06-26 18:22:20 +000054VSTORE_VECTORIZE(int, __private)
55VSTORE_VECTORIZE(int, __local)
56VSTORE_VECTORIZE(uint, __private)
57VSTORE_VECTORIZE(uint, __local)
58
59_CLC_OVERLOAD _CLC_DEF void vstore2(int2 vec, size_t offset, global int *mem) {
60 mem[offset] = vec.s0;
61 mem[offset+1] = vec.s1;
62}
63_CLC_OVERLOAD _CLC_DEF void vstore3(int3 vec, size_t offset, global int *mem) {
64 mem[offset] = vec.s0;
65 mem[offset+1] = vec.s1;
66 mem[offset+2] = vec.s2;
67}
68_CLC_OVERLOAD _CLC_DEF void vstore2(uint2 vec, size_t offset, global uint *mem) {
69 mem[offset] = vec.s0;
70 mem[offset+1] = vec.s1;
71}
72_CLC_OVERLOAD _CLC_DEF void vstore3(uint3 vec, size_t offset, global uint *mem) {
73 mem[offset] = vec.s0;
74 mem[offset+1] = vec.s1;
75 mem[offset+2] = vec.s2;
76}
77
78/*Note: R600 probably doesn't support store <2 x ?> and <3 x ?>... so
79 * they aren't actually overridden here... lowest-common-denominator
80 */
81_CLC_DECL void __clc_vstore4_int__global(int4 vec, size_t offset, __global int *);
82_CLC_DECL void __clc_vstore8_int__global(int8 vec, size_t offset, __global int *);
83_CLC_DECL void __clc_vstore16_int__global(int16 vec, size_t offset, __global int *);
84
85_CLC_OVERLOAD _CLC_DEF void vstore4(int4 vec, size_t offset, global int *x) {
86 __clc_vstore4_int__global(vec, offset, x);
87}
88_CLC_OVERLOAD _CLC_DEF void vstore8(int8 vec, size_t offset, global int *x) {
89 __clc_vstore8_int__global(vec, offset, x);
90}
91_CLC_OVERLOAD _CLC_DEF void vstore16(int16 vec, size_t offset, global int *x) {
92 __clc_vstore16_int__global(vec, offset, x);
93}
94
95_CLC_DECL void __clc_vstore4_uint__global(uint4 vec, size_t offset, __global uint *);
96_CLC_DECL void __clc_vstore8_uint__global(uint8 vec, size_t offset, __global uint *);
97_CLC_DECL void __clc_vstore16_uint__global(uint16 vec, size_t offset, __global uint *);
98
99_CLC_OVERLOAD _CLC_DEF void vstore4(uint4 vec, size_t offset, global uint *x) {
100 __clc_vstore4_uint__global(vec, offset, x);
101}
102_CLC_OVERLOAD _CLC_DEF void vstore8(uint8 vec, size_t offset, global uint *x) {
103 __clc_vstore8_uint__global(vec, offset, x);
104}
105_CLC_OVERLOAD _CLC_DEF void vstore16(uint16 vec, size_t offset, global uint *x) {
106 __clc_vstore16_uint__global(vec, offset, x);
107}