xref: /aosp_15_r20/external/ComputeLibrary/cl_kernels/helpers.hembed (revision c217d954acce2dbc11938adb493fc0abd69584f3)
1*c217d954SCole FaustR"(
2*c217d954SCole Faust#ifndef ARM_COMPUTE_HELPER_H
3*c217d954SCole Faust#define ARM_COMPUTE_HELPER_H
4*c217d954SCole Faust
5*c217d954SCole Faust
6*c217d954SCole Faust
7*c217d954SCole Faust
8*c217d954SCole Faust#define STORE_ROW_1(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
9*c217d954SCole Faust    VSTORE(N0)                                                 \
10*c217d954SCole Faust    (BASENAME##0, 0, (__global DATA_TYPE *)(PTR + 0 * STRIDE_Y + Z##0));
11*c217d954SCole Faust
12*c217d954SCole Faust#define STORE_ROW_2(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
13*c217d954SCole Faust    STORE_ROW_1(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
14*c217d954SCole Faust    VSTORE(N0)                                                 \
15*c217d954SCole Faust    (BASENAME##1, 0, (__global DATA_TYPE *)(PTR + 1 * STRIDE_Y + Z##1));
16*c217d954SCole Faust
17*c217d954SCole Faust#define STORE_ROW_3(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
18*c217d954SCole Faust    STORE_ROW_2(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
19*c217d954SCole Faust    VSTORE(N0)                                                 \
20*c217d954SCole Faust    (BASENAME##2, 0, (__global DATA_TYPE *)(PTR + 2 * STRIDE_Y + Z##2));
21*c217d954SCole Faust
22*c217d954SCole Faust#define STORE_ROW_4(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
23*c217d954SCole Faust    STORE_ROW_3(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
24*c217d954SCole Faust    VSTORE(N0)                                                 \
25*c217d954SCole Faust    (BASENAME##3, 0, (__global DATA_TYPE *)(PTR + 3 * STRIDE_Y + Z##3));
26*c217d954SCole Faust
27*c217d954SCole Faust#define STORE_ROW_5(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
28*c217d954SCole Faust    STORE_ROW_4(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
29*c217d954SCole Faust    VSTORE(N0)                                                 \
30*c217d954SCole Faust    (BASENAME##4, 0, (__global DATA_TYPE *)(PTR + 4 * STRIDE_Y + Z##4));
31*c217d954SCole Faust
32*c217d954SCole Faust#define STORE_ROW_6(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
33*c217d954SCole Faust    STORE_ROW_5(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
34*c217d954SCole Faust    VSTORE(N0)                                                 \
35*c217d954SCole Faust    (BASENAME##5, 0, (__global DATA_TYPE *)(PTR + 5 * STRIDE_Y + Z##5));
36*c217d954SCole Faust
37*c217d954SCole Faust#define STORE_ROW_7(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
38*c217d954SCole Faust    STORE_ROW_6(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
39*c217d954SCole Faust    VSTORE(N0)                                                 \
40*c217d954SCole Faust    (BASENAME##6, 0, (__global DATA_TYPE *)(PTR + 6 * STRIDE_Y + Z##6));
41*c217d954SCole Faust
42*c217d954SCole Faust#define STORE_ROW_8(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
43*c217d954SCole Faust    STORE_ROW_7(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
44*c217d954SCole Faust    VSTORE(N0)                                                 \
45*c217d954SCole Faust    (BASENAME##7, 0, (__global DATA_TYPE *)(PTR + 7 * STRIDE_Y + Z##7));
46*c217d954SCole Faust
47*c217d954SCole Faust#define STORE_ROW_9(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
48*c217d954SCole Faust    STORE_ROW_8(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
49*c217d954SCole Faust    VSTORE(N0)                                                 \
50*c217d954SCole Faust    (BASENAME##8, 0, (__global DATA_TYPE *)(PTR + 8 * STRIDE_Y + Z##8));
51*c217d954SCole Faust
52*c217d954SCole Faust#define STORE_ROW_10(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
53*c217d954SCole Faust    STORE_ROW_9(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)      \
54*c217d954SCole Faust    VSTORE(N0)                                                  \
55*c217d954SCole Faust    (BASENAME##9, 0, (__global DATA_TYPE *)(PTR + 9 * STRIDE_Y + Z##9));
56*c217d954SCole Faust
57*c217d954SCole Faust#define STORE_ROW_11(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
58*c217d954SCole Faust    STORE_ROW_10(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
59*c217d954SCole Faust    VSTORE(N0)                                                  \
60*c217d954SCole Faust    (BASENAME##A, 0, (__global DATA_TYPE *)(PTR + 10 * STRIDE_Y + Z##A));
61*c217d954SCole Faust
62*c217d954SCole Faust#define STORE_ROW_12(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
63*c217d954SCole Faust    STORE_ROW_11(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
64*c217d954SCole Faust    VSTORE(N0)                                                  \
65*c217d954SCole Faust    (BASENAME##B, 0, (__global DATA_TYPE *)(PTR + 11 * STRIDE_Y + Z##B));
66*c217d954SCole Faust
67*c217d954SCole Faust#define STORE_ROW_13(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
68*c217d954SCole Faust    STORE_ROW_12(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
69*c217d954SCole Faust    VSTORE(N0)                                                  \
70*c217d954SCole Faust    (BASENAME##C, 0, (__global DATA_TYPE *)(PTR + 12 * STRIDE_Y + Z##C));
71*c217d954SCole Faust
72*c217d954SCole Faust#define STORE_ROW_14(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
73*c217d954SCole Faust    STORE_ROW_13(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
74*c217d954SCole Faust    VSTORE(N0)                                                  \
75*c217d954SCole Faust    (BASENAME##D, 0, (__global DATA_TYPE *)(PTR + 13 * STRIDE_Y + Z##D));
76*c217d954SCole Faust
77*c217d954SCole Faust#define STORE_ROW_15(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
78*c217d954SCole Faust    STORE_ROW_14(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
79*c217d954SCole Faust    VSTORE(N0)                                                  \
80*c217d954SCole Faust    (BASENAME##E, 0, (__global DATA_TYPE *)(PTR + 14 * STRIDE_Y + Z##E));
81*c217d954SCole Faust
82*c217d954SCole Faust#define STORE_ROW_16(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
83*c217d954SCole Faust    STORE_ROW_15(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
84*c217d954SCole Faust    VSTORE(N0)                                                  \
85*c217d954SCole Faust    (BASENAME##F, 0, (__global DATA_TYPE *)(PTR + 15 * STRIDE_Y + Z##F));
86*c217d954SCole Faust
87*c217d954SCole Faust
88*c217d954SCole Faust
89*c217d954SCole Faust#define CONVERT_STORE_ROW_1(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
90*c217d954SCole Faust    VSTORE(N0)                                                         \
91*c217d954SCole Faust    (CONVERT_SAT((BASENAME##0), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 0 * STRIDE_Y + Z##0));
92*c217d954SCole Faust
93*c217d954SCole Faust#define CONVERT_STORE_ROW_2(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
94*c217d954SCole Faust    CONVERT_STORE_ROW_1(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
95*c217d954SCole Faust    VSTORE(N0)                                                         \
96*c217d954SCole Faust    (CONVERT_SAT((BASENAME##1), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 1 * STRIDE_Y + Z##1));
97*c217d954SCole Faust
98*c217d954SCole Faust#define CONVERT_STORE_ROW_3(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
99*c217d954SCole Faust    CONVERT_STORE_ROW_2(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
100*c217d954SCole Faust    VSTORE(N0)                                                         \
101*c217d954SCole Faust    (CONVERT_SAT((BASENAME##2), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 2 * STRIDE_Y + Z##2));
102*c217d954SCole Faust
103*c217d954SCole Faust#define CONVERT_STORE_ROW_4(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
104*c217d954SCole Faust    CONVERT_STORE_ROW_3(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
105*c217d954SCole Faust    VSTORE(N0)                                                         \
106*c217d954SCole Faust    (CONVERT_SAT((BASENAME##3), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 3 * STRIDE_Y + Z##3));
107*c217d954SCole Faust
108*c217d954SCole Faust#define CONVERT_STORE_ROW_5(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
109*c217d954SCole Faust    CONVERT_STORE_ROW_4(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
110*c217d954SCole Faust    VSTORE(N0)                                                         \
111*c217d954SCole Faust    (CONVERT_SAT((BASENAME##4), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 4 * STRIDE_Y + Z##4));
112*c217d954SCole Faust
113*c217d954SCole Faust#define CONVERT_STORE_ROW_6(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
114*c217d954SCole Faust    CONVERT_STORE_ROW_5(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
115*c217d954SCole Faust    VSTORE(N0)                                                         \
116*c217d954SCole Faust    (CONVERT_SAT((BASENAME##5), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 5 * STRIDE_Y + Z##5));
117*c217d954SCole Faust
118*c217d954SCole Faust#define CONVERT_STORE_ROW_7(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
119*c217d954SCole Faust    CONVERT_STORE_ROW_6(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
120*c217d954SCole Faust    VSTORE(N0)                                                         \
121*c217d954SCole Faust    (CONVERT_SAT((BASENAME##6), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 6 * STRIDE_Y + Z##6));
122*c217d954SCole Faust
123*c217d954SCole Faust#define CONVERT_STORE_ROW_8(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
124*c217d954SCole Faust    CONVERT_STORE_ROW_7(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
125*c217d954SCole Faust    VSTORE(N0)                                                         \
126*c217d954SCole Faust    (CONVERT_SAT((BASENAME##7), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 7 * STRIDE_Y + Z##7));
127*c217d954SCole Faust
128*c217d954SCole Faust#define CONVERT_STORE_ROW_9(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
129*c217d954SCole Faust    CONVERT_STORE_ROW_8(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
130*c217d954SCole Faust    VSTORE(N0)                                                         \
131*c217d954SCole Faust    (CONVERT_SAT((BASENAME##8), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 8 * STRIDE_Y + Z##8));
132*c217d954SCole Faust
133*c217d954SCole Faust#define CONVERT_STORE_ROW_10(N0, DATA, BASENAME, PTR, STRIDE_Y, Z) \
134*c217d954SCole Faust    CONVERT_STORE_ROW_9(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
135*c217d954SCole Faust    VSTORE(N0)                                                     \
136*c217d954SCole Faust    (CONVERT_SAT((BASENAME##9), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 9 * STRIDE_Y + Z##9));
137*c217d954SCole Faust
138*c217d954SCole Faust#define CONVERT_STORE_ROW_11(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
139*c217d954SCole Faust    CONVERT_STORE_ROW_10(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
140*c217d954SCole Faust    VSTORE(N0)                                                          \
141*c217d954SCole Faust    (CONVERT_SAT((BASENAME##A), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 10 * STRIDE_Y + Z##A));
142*c217d954SCole Faust
143*c217d954SCole Faust#define CONVERT_STORE_ROW_12(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
144*c217d954SCole Faust    CONVERT_STORE_ROW_11(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
145*c217d954SCole Faust    VSTORE(N0)                                                          \
146*c217d954SCole Faust    (CONVERT_SAT((BASENAME##B), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 11 * STRIDE_Y + Z##B));
147*c217d954SCole Faust
148*c217d954SCole Faust#define CONVERT_STORE_ROW_13(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
149*c217d954SCole Faust    CONVERT_STORE_ROW_12(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
150*c217d954SCole Faust    VSTORE(N0)                                                          \
151*c217d954SCole Faust    (CONVERT_SAT((BASENAME##C), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 12 * STRIDE_Y + Z##C));
152*c217d954SCole Faust
153*c217d954SCole Faust#define CONVERT_STORE_ROW_14(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
154*c217d954SCole Faust    CONVERT_STORE_ROW_13(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
155*c217d954SCole Faust    VSTORE(N0)                                                          \
156*c217d954SCole Faust    (CONVERT_SAT((BASENAME##D), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 13 * STRIDE_Y + Z##D));
157*c217d954SCole Faust
158*c217d954SCole Faust#define CONVERT_STORE_ROW_15(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
159*c217d954SCole Faust    CONVERT_STORE_ROW_14(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
160*c217d954SCole Faust    VSTORE(N0)                                                          \
161*c217d954SCole Faust    (CONVERT_SAT((BASENAME##E), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 14 * STRIDE_Y + Z##E));
162*c217d954SCole Faust
163*c217d954SCole Faust#define CONVERT_STORE_ROW_16(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
164*c217d954SCole Faust    CONVERT_STORE_ROW_15(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
165*c217d954SCole Faust    VSTORE(N0)                                                          \
166*c217d954SCole Faust    (CONVERT_SAT((BASENAME##F), VEC_DATA_TYPE(DATA_TYPE, N0)), 0, (__global DATA_TYPE *)(PTR + 15 * STRIDE_Y + Z##F));
167*c217d954SCole Faust
168*c217d954SCole Faust
169*c217d954SCole Faust
170*c217d954SCole Faust
171*c217d954SCole Faust#define STORE_BLOCK_STR(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) STORE_ROW_##M0(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)
172*c217d954SCole Faust#define STORE_BLOCK(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) STORE_BLOCK_STR(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)
173*c217d954SCole Faust
174*c217d954SCole Faust
175*c217d954SCole Faust
176*c217d954SCole Faust#define CONVERT_STORE_BLOCK_STR(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) CONVERT_STORE_ROW_##M0(N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)
177*c217d954SCole Faust#define CONVERT_STORE_BLOCK(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) CONVERT_STORE_BLOCK_STR(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)
178*c217d954SCole Faust
179*c217d954SCole Faust
180*c217d954SCole Faust
181*c217d954SCole Faust#define STORE_ROW_PARTIAL_1(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
182*c217d954SCole Faust    VSTORE_PARTIAL(N0, STORE_N0)                                                 \
183*c217d954SCole Faust    (BASENAME##0, 0, (__global DATA_TYPE *)(PTR + 0 * STRIDE_Y + Z##0));
184*c217d954SCole Faust
185*c217d954SCole Faust#define STORE_ROW_PARTIAL_2(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
186*c217d954SCole Faust    STORE_ROW_PARTIAL_1(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
187*c217d954SCole Faust    VSTORE_PARTIAL(N0, STORE_N0)                                                 \
188*c217d954SCole Faust    (BASENAME##1, 0, (__global DATA_TYPE *)(PTR + 1 * STRIDE_Y + Z##1));
189*c217d954SCole Faust
190*c217d954SCole Faust#define STORE_ROW_PARTIAL_3(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
191*c217d954SCole Faust    STORE_ROW_PARTIAL_2(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
192*c217d954SCole Faust    VSTORE_PARTIAL(N0, STORE_N0)                                                 \
193*c217d954SCole Faust    (BASENAME##2, 0, (__global DATA_TYPE *)(PTR + 2 * STRIDE_Y + Z##2));
194*c217d954SCole Faust
195*c217d954SCole Faust#define STORE_ROW_PARTIAL_4(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
196*c217d954SCole Faust    STORE_ROW_PARTIAL_3(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
197*c217d954SCole Faust    VSTORE_PARTIAL(N0, STORE_N0)                                                 \
198*c217d954SCole Faust    (BASENAME##3, 0, (__global DATA_TYPE *)(PTR + 3 * STRIDE_Y + Z##3));
199*c217d954SCole Faust
200*c217d954SCole Faust#define STORE_ROW_PARTIAL_5(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
201*c217d954SCole Faust    STORE_ROW_PARTIAL_4(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
202*c217d954SCole Faust    VSTORE_PARTIAL(N0, STORE_N0)                                                 \
203*c217d954SCole Faust    (BASENAME##4, 0, (__global DATA_TYPE *)(PTR + 4 * STRIDE_Y + Z##4));
204*c217d954SCole Faust
205*c217d954SCole Faust#define STORE_ROW_PARTIAL_6(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
206*c217d954SCole Faust    STORE_ROW_PARTIAL_5(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
207*c217d954SCole Faust    VSTORE_PARTIAL(N0, STORE_N0)                                                 \
208*c217d954SCole Faust    (BASENAME##5, 0, (__global DATA_TYPE *)(PTR + 5 * STRIDE_Y + Z##5));
209*c217d954SCole Faust
210*c217d954SCole Faust#define STORE_ROW_PARTIAL_7(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
211*c217d954SCole Faust    STORE_ROW_PARTIAL_6(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
212*c217d954SCole Faust    VSTORE_PARTIAL(N0, STORE_N0)                                                 \
213*c217d954SCole Faust    (BASENAME##6, 0, (__global DATA_TYPE *)(PTR + 6 * STRIDE_Y + Z##6));
214*c217d954SCole Faust
215*c217d954SCole Faust#define STORE_ROW_PARTIAL_8(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
216*c217d954SCole Faust    STORE_ROW_PARTIAL_7(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
217*c217d954SCole Faust    VSTORE_PARTIAL(N0, STORE_N0)                                                 \
218*c217d954SCole Faust    (BASENAME##7, 0, (__global DATA_TYPE *)(PTR + 7 * STRIDE_Y + Z##7));
219*c217d954SCole Faust
220*c217d954SCole Faust#define STORE_ROW_PARTIAL_9(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
221*c217d954SCole Faust    STORE_ROW_PARTIAL_8(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
222*c217d954SCole Faust    VSTORE_PARTIAL(N0, STORE_N0)                                                 \
223*c217d954SCole Faust    (BASENAME##8, 0, (__global DATA_TYPE *)(PTR + 8 * STRIDE_Y + Z##8));
224*c217d954SCole Faust
225*c217d954SCole Faust#define STORE_ROW_PARTIAL_10(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
226*c217d954SCole Faust    STORE_ROW_PARTIAL_9(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)      \
227*c217d954SCole Faust    VSTORE_PARTIAL(N0, STORE_N0)                                                  \
228*c217d954SCole Faust    (BASENAME##9, 0, (__global DATA_TYPE *)(PTR + 9 * STRIDE_Y + Z##9));
229*c217d954SCole Faust
230*c217d954SCole Faust#define STORE_ROW_PARTIAL_11(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
231*c217d954SCole Faust    STORE_ROW_PARTIAL_10(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
232*c217d954SCole Faust    VSTORE_PARTIAL(N0, STORE_N0)                                                  \
233*c217d954SCole Faust    (BASENAME##A, 0, (__global DATA_TYPE *)(PTR + 10 * STRIDE_Y + Z##A));
234*c217d954SCole Faust
235*c217d954SCole Faust#define STORE_ROW_PARTIAL_12(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
236*c217d954SCole Faust    STORE_ROW_PARTIAL_11(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
237*c217d954SCole Faust    VSTORE_PARTIAL(N0, STORE_N0)                                                  \
238*c217d954SCole Faust    (BASENAME##B, 0, (__global DATA_TYPE *)(PTR + 11 * STRIDE_Y + Z##B));
239*c217d954SCole Faust
240*c217d954SCole Faust#define STORE_ROW_PARTIAL_13(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
241*c217d954SCole Faust    STORE_ROW_PARTIAL_12(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
242*c217d954SCole Faust    VSTORE_PARTIAL(N0, STORE_N0)                                                  \
243*c217d954SCole Faust    (BASENAME##C, 0, (__global DATA_TYPE *)(PTR + 12 * STRIDE_Y + Z##C));
244*c217d954SCole Faust
245*c217d954SCole Faust#define STORE_ROW_PARTIAL_14(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
246*c217d954SCole Faust    STORE_ROW_PARTIAL_13(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
247*c217d954SCole Faust    VSTORE_PARTIAL(N0, STORE_N0)                                                  \
248*c217d954SCole Faust    (BASENAME##D, 0, (__global DATA_TYPE *)(PTR + 13 * STRIDE_Y + Z##D));
249*c217d954SCole Faust
250*c217d954SCole Faust#define STORE_ROW_PARTIAL_15(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
251*c217d954SCole Faust    STORE_ROW_PARTIAL_14(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
252*c217d954SCole Faust    VSTORE_PARTIAL(N0, STORE_N0)                                                  \
253*c217d954SCole Faust    (BASENAME##E, 0, (__global DATA_TYPE *)(PTR + 14 * STRIDE_Y + Z##E));
254*c217d954SCole Faust
255*c217d954SCole Faust#define STORE_ROW_PARTIAL_16(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) \
256*c217d954SCole Faust    STORE_ROW_PARTIAL_15(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)     \
257*c217d954SCole Faust    VSTORE_PARTIAL(N0, STORE_N0)                                                  \
258*c217d954SCole Faust    (BASENAME##F, 0, (__global DATA_TYPE *)(PTR + 15 * STRIDE_Y + Z##F));
259*c217d954SCole Faust
260*c217d954SCole Faust
261*c217d954SCole Faust
262*c217d954SCole Faust#define STORE_BLOCK_PARTIAL_STR(STORE_M0, STORE_N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) STORE_ROW_PARTIAL_##STORE_M0(N0, STORE_N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)
263*c217d954SCole Faust#define STORE_BLOCK_PARTIAL(STORE_M0, STORE_N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z) STORE_BLOCK_PARTIAL_STR(STORE_M0, STORE_N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)
264*c217d954SCole Faust
265*c217d954SCole Faust#define STORE_BLOCK_PARTIAL_IN_X_AND_Y(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_STORE_N0, PARTIAL_COND_Y, PARTIAL_COND_X) \
266*c217d954SCole Faust    if(!(PARTIAL_COND_X) && !(PARTIAL_COND_Y))                                                                                                            \
267*c217d954SCole Faust    {                                                                                                                                                     \
268*c217d954SCole Faust        STORE_BLOCK_PARTIAL(M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z);                                                                           \
269*c217d954SCole Faust    }                                                                                                                                                     \
270*c217d954SCole Faust    else if((PARTIAL_COND_Y) && !(PARTIAL_COND_X))                                                                                                        \
271*c217d954SCole Faust    {                                                                                                                                                     \
272*c217d954SCole Faust        STORE_BLOCK_PARTIAL(PARTIAL_STORE_M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z);                                                             \
273*c217d954SCole Faust    }                                                                                                                                                     \
274*c217d954SCole Faust    else if(!(PARTIAL_COND_Y) && (PARTIAL_COND_X))                                                                                                        \
275*c217d954SCole Faust    {                                                                                                                                                     \
276*c217d954SCole Faust        STORE_BLOCK_PARTIAL(M0, PARTIAL_STORE_N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z);                                                             \
277*c217d954SCole Faust    }                                                                                                                                                     \
278*c217d954SCole Faust    else                                                                                                                                                  \
279*c217d954SCole Faust    {                                                                                                                                                     \
280*c217d954SCole Faust        STORE_BLOCK_PARTIAL(PARTIAL_STORE_M0, PARTIAL_STORE_N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z);                                               \
281*c217d954SCole Faust    }
282*c217d954SCole Faust
283*c217d954SCole Faust#define STORE_BLOCK_PARTIAL_IN_X(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_N0, PARTIAL_COND_X) \
284*c217d954SCole Faust    if(!(PARTIAL_COND_X))                                                                                         \
285*c217d954SCole Faust    {                                                                                                             \
286*c217d954SCole Faust        STORE_BLOCK_PARTIAL(M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z);                                   \
287*c217d954SCole Faust    }                                                                                                             \
288*c217d954SCole Faust    else                                                                                                          \
289*c217d954SCole Faust    {                                                                                                             \
290*c217d954SCole Faust        STORE_BLOCK_PARTIAL(M0, PARTIAL_STORE_N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z);                     \
291*c217d954SCole Faust    }
292*c217d954SCole Faust
293*c217d954SCole Faust#define STORE_BLOCK_PARTIAL_IN_Y(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_COND_Y) \
294*c217d954SCole Faust    if(!(PARTIAL_COND_Y))                                                                                         \
295*c217d954SCole Faust    {                                                                                                             \
296*c217d954SCole Faust        STORE_BLOCK_PARTIAL(M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z);                                   \
297*c217d954SCole Faust    }                                                                                                             \
298*c217d954SCole Faust    else                                                                                                          \
299*c217d954SCole Faust    {                                                                                                             \
300*c217d954SCole Faust        STORE_BLOCK_PARTIAL(PARTIAL_STORE_M0, N0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z);                     \
301*c217d954SCole Faust    }
302*c217d954SCole Faust
303*c217d954SCole Faust
304*c217d954SCole Faust#if defined(PARTIAL_STORE_M0) && defined(PARTIAL_STORE_N0)
305*c217d954SCole Faust
306*c217d954SCole Faust
307*c217d954SCole Faust#if PARTIAL_STORE_M0 == 0 && PARTIAL_STORE_N0 == 0
308*c217d954SCole Faust
309*c217d954SCole Faust#define STORE_BLOCK_BOUNDARY_AWARE(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_STORE_N0, PARTIAL_COND_Y, PARTIAL_COND_X) \
310*c217d954SCole Faust    STORE_BLOCK(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z)
311*c217d954SCole Faust
312*c217d954SCole Faust#elif PARTIAL_STORE_M0 > 0 && PARTIAL_STORE_N0 == 0
313*c217d954SCole Faust
314*c217d954SCole Faust#define STORE_BLOCK_BOUNDARY_AWARE(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_STORE_N0, PARTIAL_COND_Y, PARTIAL_COND_X) \
315*c217d954SCole Faust    STORE_BLOCK_PARTIAL_IN_Y(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_COND_Y)
316*c217d954SCole Faust
317*c217d954SCole Faust#elif PARTIAL_STORE_M0 == 0 && PARTIAL_STORE_N0 > 0
318*c217d954SCole Faust
319*c217d954SCole Faust#define STORE_BLOCK_BOUNDARY_AWARE(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_STORE_N0, PARTIAL_COND_Y, PARTIAL_COND_X) \
320*c217d954SCole Faust    STORE_BLOCK_PARTIAL_IN_X(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_N0, PARTIAL_COND_X)
321*c217d954SCole Faust
322*c217d954SCole Faust#else
323*c217d954SCole Faust
324*c217d954SCole Faust#define STORE_BLOCK_BOUNDARY_AWARE(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_STORE_N0, PARTIAL_COND_Y, PARTIAL_COND_X) \
325*c217d954SCole Faust    STORE_BLOCK_PARTIAL_IN_X_AND_Y(M0, N0, DATA_TYPE, BASENAME, PTR, STRIDE_Y, Z, PARTIAL_STORE_M0, PARTIAL_STORE_N0, PARTIAL_COND_Y, PARTIAL_COND_X)
326*c217d954SCole Faust
327*c217d954SCole Faust#endif
328*c217d954SCole Faust
329*c217d954SCole Faust#endif
330*c217d954SCole Faust
331*c217d954SCole Faust
332*c217d954SCole Faust#if defined(PARTIAL_STORE_M0)
333*c217d954SCole Faust
334*c217d954SCole Faust#define COMPUTE_M0_START_ROW(y, M0, PARTIAL_STORE_M0) \
335*c217d954SCole Faust    ((uint)(max(0, (int)(y * M0) - (int)((M0 - PARTIAL_STORE_M0) % M0))))
336*c217d954SCole Faust#else
337*c217d954SCole Faust#define COMPUTE_M0_START_ROW(y, M0, PARTIAL_STORE_M0) \
338*c217d954SCole Faust    ((uint)(y * M0))
339*c217d954SCole Faust#endif
340*c217d954SCole Faust
341*c217d954SCole Faust
342*c217d954SCole Faust
343*c217d954SCole Faust#define STORE_VECTOR_SELECT(basename, data_type, ptr, vec_size, leftover, cond) \
344*c217d954SCole Faust    STORE_BLOCK_PARTIAL_IN_X(1, vec_size, data_type, basename, ptr, 0, 0, leftover, cond)
345*c217d954SCole Faust
346*c217d954SCole Faust
347*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_FP16_ENABLED) && defined(cl_khr_fp16)
348*c217d954SCole Faust#pragma OPENCL EXTENSION cl_khr_fp16 : enable
349*c217d954SCole Faust#endif
350*c217d954SCole Faust
351*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_DOT8_ENABLED) && defined(cl_arm_integer_dot_product_int8)
352*c217d954SCole Faust#pragma OPENCL EXTENSION cl_arm_integer_dot_product_int8 : enable
353*c217d954SCole Faust#endif
354*c217d954SCole Faust
355*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_DOT8_ACC_ENABLED) && defined(cl_arm_integer_dot_product_accumulate_int8)
356*c217d954SCole Faust#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int8 : enable
357*c217d954SCole Faust#endif
358*c217d954SCole Faust
359*c217d954SCole Faust#if defined(ARM_COMPUTE_DEBUG_ENABLED) && defined(cl_arm_printf)
360*c217d954SCole Faust#pragma OPENCL EXTENSION cl_arm_printf : enable
361*c217d954SCole Faust#endif
362*c217d954SCole Faust
363*c217d954SCole Faust#define GPU_ARCH_MIDGARD 0x100
364*c217d954SCole Faust#define GPU_ARCH_BIFROST 0x200
365*c217d954SCole Faust#define GPU_ARCH_VALHALL 0x300
366*c217d954SCole Faust
367*c217d954SCole Faust
368*c217d954SCole Faust#define CONCAT(a, b) a##b
369*c217d954SCole Faust
370*c217d954SCole Faust
371*c217d954SCole Faust#define EXPAND(x) x
372*c217d954SCole Faust
373*c217d954SCole Faust
374*c217d954SCole Faust#define CLAMP(x, min_val, max_val) min(max(x, min_val), max_val)
375*c217d954SCole Faust
376*c217d954SCole Faust
377*c217d954SCole Faust#define REV1(x) ((x))
378*c217d954SCole Faust#define REV2(x) ((x).s10)
379*c217d954SCole Faust#define REV3(x) ((x).s210)
380*c217d954SCole Faust#define REV4(x) ((x).s3210)
381*c217d954SCole Faust#define REV8(x) ((x).s76543210)
382*c217d954SCole Faust#define REV16(x) ((x).sFEDCBA9876543210)
383*c217d954SCole Faust
384*c217d954SCole Faust
385*c217d954SCole Faust
386*c217d954SCole Faust#define REVERSE_STR(x, s) REV##s((x))
387*c217d954SCole Faust#define REVERSE(x, s) REVERSE_STR(x, s)
388*c217d954SCole Faust
389*c217d954SCole Faust
390*c217d954SCole Faust
391*c217d954SCole Faust#define ROT1_0(x) ((x))
392*c217d954SCole Faust#define ROT1_1(x) ((x))
393*c217d954SCole Faust
394*c217d954SCole Faust#define ROT2_0(x) ((x))
395*c217d954SCole Faust#define ROT2_1(x) ((x).s10)
396*c217d954SCole Faust#define ROT2_2(x) ((x))
397*c217d954SCole Faust
398*c217d954SCole Faust#define ROT3_0(x) ((x))
399*c217d954SCole Faust#define ROT3_1(x) ((x).s201)
400*c217d954SCole Faust#define ROT3_2(x) ((x).s120)
401*c217d954SCole Faust#define ROT3_3(x) ((x))
402*c217d954SCole Faust
403*c217d954SCole Faust#define ROT4_0(x) ((x))
404*c217d954SCole Faust#define ROT4_1(x) ((x).s3012)
405*c217d954SCole Faust#define ROT4_2(x) ((x).s2301)
406*c217d954SCole Faust#define ROT4_3(x) ((x).s1230)
407*c217d954SCole Faust#define ROT4_4(x) ((x))
408*c217d954SCole Faust
409*c217d954SCole Faust#define ROT8_0(x) ((x))
410*c217d954SCole Faust#define ROT8_1(x) ((x).s70123456)
411*c217d954SCole Faust#define ROT8_2(x) ((x).s67012345)
412*c217d954SCole Faust#define ROT8_3(x) ((x).s56701234)
413*c217d954SCole Faust#define ROT8_4(x) ((x).s45670123)
414*c217d954SCole Faust#define ROT8_5(x) ((x).s34567012)
415*c217d954SCole Faust#define ROT8_6(x) ((x).s23456701)
416*c217d954SCole Faust#define ROT8_7(x) ((x).s12345670)
417*c217d954SCole Faust#define ROT8_8(x) ((x))
418*c217d954SCole Faust
419*c217d954SCole Faust#define ROT16_0(x) ((x))
420*c217d954SCole Faust#define ROT16_1(x) ((x).sF0123456789ABCDE)
421*c217d954SCole Faust#define ROT16_2(x) ((x).sEF0123456789ABCD)
422*c217d954SCole Faust#define ROT16_3(x) ((x).sDEF0123456789ABC)
423*c217d954SCole Faust#define ROT16_4(x) ((x).sCDEF0123456789AB)
424*c217d954SCole Faust#define ROT16_5(x) ((x).sBCDEF0123456789A)
425*c217d954SCole Faust#define ROT16_6(x) ((x).sABCDEF0123456789)
426*c217d954SCole Faust#define ROT16_7(x) ((x).s9ABCDEF012345678)
427*c217d954SCole Faust#define ROT16_8(x) ((x).s89ABCDEF01234567)
428*c217d954SCole Faust#define ROT16_9(x) ((x).s789ABCDEF0123456)
429*c217d954SCole Faust#define ROT16_10(x) ((x).s6789ABCDEF012345)
430*c217d954SCole Faust#define ROT16_11(x) ((x).s56789ABCDEF01234)
431*c217d954SCole Faust#define ROT16_12(x) ((x).s456789ABCDEF0123)
432*c217d954SCole Faust#define ROT16_13(x) ((x).s3456789ABCDEF012)
433*c217d954SCole Faust#define ROT16_14(x) ((x).s23456789ABCDEF01)
434*c217d954SCole Faust#define ROT16_15(x) ((x).s123456789ABCDEF0)
435*c217d954SCole Faust#define ROT16_16(x) ((x))
436*c217d954SCole Faust
437*c217d954SCole Faust
438*c217d954SCole Faust
439*c217d954SCole Faust#define ROTATE_STR(x, s, n) ROT##s##_##n(x)
440*c217d954SCole Faust#define ROTATE(x, s, n) ROTATE_STR(x, s, n)
441*c217d954SCole Faust
442*c217d954SCole Faust
443*c217d954SCole Faust
444*c217d954SCole Faust#define V_OFFS1(dt) (dt##1)(0)
445*c217d954SCole Faust#define V_OFFS2(dt) (dt##2)(0, 1)
446*c217d954SCole Faust#define V_OFFS3(dt) (dt##3)(0, 1, 2)
447*c217d954SCole Faust#define V_OFFS4(dt) (dt##4)(0, 1, 2, 3)
448*c217d954SCole Faust#define V_OFFS8(dt) (dt##8)(0, 1, 2, 3, 4, 5, 6, 7)
449*c217d954SCole Faust#define V_OFFS16(dt) (dt##16)(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
450*c217d954SCole Faust
451*c217d954SCole Faust
452*c217d954SCole Faust
453*c217d954SCole Faust#define VEC_OFFS_STR(dt, s) V_OFFS##s(dt)
454*c217d954SCole Faust#define VEC_OFFS(dt, s) VEC_OFFS_STR(dt, s)
455*c217d954SCole Faust
456*c217d954SCole Faust
457*c217d954SCole Faust#define VLOAD_STR(size) vload##size
458*c217d954SCole Faust#define VLOAD(size) VLOAD_STR(size)
459*c217d954SCole Faust
460*c217d954SCole Faust
461*c217d954SCole Faust#define VLOAD_PARTIAL_STR(size, load_size) vload_partial_##size##_##load_size
462*c217d954SCole Faust#define VLOAD_PARTIAL(size, load_size) VLOAD_PARTIAL_STR(size, load_size)
463*c217d954SCole Faust
464*c217d954SCole Faust#define NO_LOAD(data, offs, ptr) \
465*c217d954SCole Faust    {                            \
466*c217d954SCole Faust    }
467*c217d954SCole Faust
468*c217d954SCole Faust
469*c217d954SCole Faust#define vload_partial_1_0 NO_LOAD
470*c217d954SCole Faust#define vload_partial_1_1 vload1
471*c217d954SCole Faust#define vload_partial_1_2 NO_LOAD
472*c217d954SCole Faust#define vload_partial_1_3 NO_LOAD
473*c217d954SCole Faust#define vload_partial_1_4 NO_LOAD
474*c217d954SCole Faust#define vload_partial_1_5 NO_LOAD
475*c217d954SCole Faust#define vload_partial_1_6 NO_LOAD
476*c217d954SCole Faust#define vload_partial_1_7 NO_LOAD
477*c217d954SCole Faust#define vload_partial_1_8 NO_LOAD
478*c217d954SCole Faust#define vload_partial_1_9 NO_LOAD
479*c217d954SCole Faust#define vload_partial_1_10 NO_LOAD
480*c217d954SCole Faust#define vload_partial_1_11 NO_LOAD
481*c217d954SCole Faust#define vload_partial_1_12 NO_LOAD
482*c217d954SCole Faust#define vload_partial_1_13 NO_LOAD
483*c217d954SCole Faust#define vload_partial_1_14 NO_LOAD
484*c217d954SCole Faust#define vload_partial_1_15 NO_LOAD
485*c217d954SCole Faust#define vload_partial_1_16 NO_LOAD
486*c217d954SCole Faust
487*c217d954SCole Faust#define vload_partial_2_0 NO_LOAD
488*c217d954SCole Faust#define vload_partial_2_1 vload_partial_1
489*c217d954SCole Faust#define vload_partial_2_2 vload_partial_2
490*c217d954SCole Faust#define vload_partial_2_3 NO_LOAD
491*c217d954SCole Faust#define vload_partial_2_4 NO_LOAD
492*c217d954SCole Faust#define vload_partial_2_5 NO_LOAD
493*c217d954SCole Faust#define vload_partial_2_6 NO_LOAD
494*c217d954SCole Faust#define vload_partial_2_7 NO_LOAD
495*c217d954SCole Faust#define vload_partial_2_8 NO_LOAD
496*c217d954SCole Faust#define vload_partial_2_9 NO_LOAD
497*c217d954SCole Faust#define vload_partial_2_10 NO_LOAD
498*c217d954SCole Faust#define vload_partial_2_11 NO_LOAD
499*c217d954SCole Faust#define vload_partial_2_12 NO_LOAD
500*c217d954SCole Faust#define vload_partial_2_13 NO_LOAD
501*c217d954SCole Faust#define vload_partial_2_14 NO_LOAD
502*c217d954SCole Faust#define vload_partial_2_15 NO_LOAD
503*c217d954SCole Faust#define vload_partial_2_16 NO_LOAD
504*c217d954SCole Faust
505*c217d954SCole Faust#define vload_partial_3_0 NO_LOAD
506*c217d954SCole Faust#define vload_partial_3_1 vload_partial_1
507*c217d954SCole Faust#define vload_partial_3_2 vload_partial_2
508*c217d954SCole Faust#define vload_partial_3_3 vload_partial_3
509*c217d954SCole Faust#define vload_partial_3_4 NO_LOAD
510*c217d954SCole Faust#define vload_partial_3_5 NO_LOAD
511*c217d954SCole Faust#define vload_partial_3_6 NO_LOAD
512*c217d954SCole Faust#define vload_partial_3_7 NO_LOAD
513*c217d954SCole Faust#define vload_partial_3_8 NO_LOAD
514*c217d954SCole Faust#define vload_partial_3_9 NO_LOAD
515*c217d954SCole Faust#define vload_partial_3_10 NO_LOAD
516*c217d954SCole Faust#define vload_partial_3_11 NO_LOAD
517*c217d954SCole Faust#define vload_partial_3_12 NO_LOAD
518*c217d954SCole Faust#define vload_partial_3_13 NO_LOAD
519*c217d954SCole Faust#define vload_partial_3_14 NO_LOAD
520*c217d954SCole Faust#define vload_partial_3_15 NO_LOAD
521*c217d954SCole Faust#define vload_partial_3_16 NO_LOAD
522*c217d954SCole Faust
523*c217d954SCole Faust#define vload_partial_4_0 NO_LOAD
524*c217d954SCole Faust#define vload_partial_4_1 vload_partial_1
525*c217d954SCole Faust#define vload_partial_4_2 vload_partial_2
526*c217d954SCole Faust#define vload_partial_4_3 vload_partial_3
527*c217d954SCole Faust#define vload_partial_4_4 vload_partial_4
528*c217d954SCole Faust#define vload_partial_4_5 NO_LOAD
529*c217d954SCole Faust#define vload_partial_4_6 NO_LOAD
530*c217d954SCole Faust#define vload_partial_4_7 NO_LOAD
531*c217d954SCole Faust#define vload_partial_4_8 NO_LOAD
532*c217d954SCole Faust#define vload_partial_4_9 NO_LOAD
533*c217d954SCole Faust#define vload_partial_4_10 NO_LOAD
534*c217d954SCole Faust#define vload_partial_4_11 NO_LOAD
535*c217d954SCole Faust#define vload_partial_4_12 NO_LOAD
536*c217d954SCole Faust#define vload_partial_4_13 NO_LOAD
537*c217d954SCole Faust#define vload_partial_4_14 NO_LOAD
538*c217d954SCole Faust#define vload_partial_4_15 NO_LOAD
539*c217d954SCole Faust#define vload_partial_4_16 NO_LOAD
540*c217d954SCole Faust
541*c217d954SCole Faust#define vload_partial_8_0 NO_LOAD
542*c217d954SCole Faust#define vload_partial_8_1 vload_partial_1
543*c217d954SCole Faust#define vload_partial_8_2 vload_partial_2
544*c217d954SCole Faust#define vload_partial_8_3 vload_partial_3
545*c217d954SCole Faust#define vload_partial_8_4 vload_partial_4
546*c217d954SCole Faust#define vload_partial_8_5 vload_partial_5
547*c217d954SCole Faust#define vload_partial_8_6 vload_partial_6
548*c217d954SCole Faust#define vload_partial_8_7 vload_partial_7
549*c217d954SCole Faust#define vload_partial_8_8 vload_partial_8
550*c217d954SCole Faust#define vload_partial_8_9 NO_LOAD
551*c217d954SCole Faust#define vload_partial_8_10 NO_LOAD
552*c217d954SCole Faust#define vload_partial_8_11 NO_LOAD
553*c217d954SCole Faust#define vload_partial_8_12 NO_LOAD
554*c217d954SCole Faust#define vload_partial_8_13 NO_LOAD
555*c217d954SCole Faust#define vload_partial_8_14 NO_LOAD
556*c217d954SCole Faust#define vload_partial_8_15 NO_LOAD
557*c217d954SCole Faust#define vload_partial_8_16 NO_LOAD
558*c217d954SCole Faust
559*c217d954SCole Faust#define vload_partial_16_0 NO_LOAD
560*c217d954SCole Faust#define vload_partial_16_1 vload_partial_1
561*c217d954SCole Faust#define vload_partial_16_2 vload_partial_2
562*c217d954SCole Faust#define vload_partial_16_3 vload_partial_3
563*c217d954SCole Faust#define vload_partial_16_4 vload_partial_4
564*c217d954SCole Faust#define vload_partial_16_5 vload_partial_5
565*c217d954SCole Faust#define vload_partial_16_6 vload_partial_6
566*c217d954SCole Faust#define vload_partial_16_7 vload_partial_7
567*c217d954SCole Faust#define vload_partial_16_8 vload_partial_8
568*c217d954SCole Faust#define vload_partial_16_9 vload_partial_9
569*c217d954SCole Faust#define vload_partial_16_10 vload_partial_10
570*c217d954SCole Faust#define vload_partial_16_11 vload_partial_11
571*c217d954SCole Faust#define vload_partial_16_12 vload_partial_12
572*c217d954SCole Faust#define vload_partial_16_13 vload_partial_13
573*c217d954SCole Faust#define vload_partial_16_14 vload_partial_14
574*c217d954SCole Faust#define vload_partial_16_15 vload_partial_15
575*c217d954SCole Faust#define vload_partial_16_16 vload_partial_16
576*c217d954SCole Faust
577*c217d954SCole Faust
578*c217d954SCole Faust#define vload_partial_1(DATA, OFFSET, PTR) \
579*c217d954SCole Faust    DATA.s0 = vload1(OFFSET, PTR);
580*c217d954SCole Faust
581*c217d954SCole Faust#define vload_partial_2(DATA, OFFSET, PTR) \
582*c217d954SCole Faust    DATA.s01 = vload2(OFFSET, PTR);
583*c217d954SCole Faust
584*c217d954SCole Faust#define vload_partial_3(DATA, OFFSET, PTR) \
585*c217d954SCole Faust    DATA.s012 = vload3(OFFSET, PTR);
586*c217d954SCole Faust
587*c217d954SCole Faust#define vload_partial_4(DATA, OFFSET, PTR) \
588*c217d954SCole Faust    DATA.s0123 = vload4(OFFSET, PTR);
589*c217d954SCole Faust
590*c217d954SCole Faust#define vload_partial_5(DATA, OFFSET, PTR)    \
591*c217d954SCole Faust    vload_partial_4(DATA.s0123, OFFSET, PTR); \
592*c217d954SCole Faust    DATA.s4 = vload1(OFFSET, PTR + 4);
593*c217d954SCole Faust
594*c217d954SCole Faust#define vload_partial_6(DATA, OFFSET, PTR)    \
595*c217d954SCole Faust    vload_partial_4(DATA.s0123, OFFSET, PTR); \
596*c217d954SCole Faust    vload_partial_2(DATA.s45, OFFSET, PTR + 4);
597*c217d954SCole Faust
598*c217d954SCole Faust#define vload_partial_7(DATA, OFFSET, PTR)    \
599*c217d954SCole Faust    vload_partial_4(DATA.s0123, OFFSET, PTR); \
600*c217d954SCole Faust    vload_partial_3(DATA.s456, OFFSET, PTR + 4);
601*c217d954SCole Faust
602*c217d954SCole Faust#define vload_partial_8(DATA, OFFSET, PTR) \
603*c217d954SCole Faust    DATA.s01234567 = vload8(OFFSET, PTR);
604*c217d954SCole Faust
605*c217d954SCole Faust#define vload_partial_9(DATA, OFFSET, PTR)        \
606*c217d954SCole Faust    vload_partial_8(DATA.s01234567, OFFSET, PTR); \
607*c217d954SCole Faust    DATA.s8 = vload1(OFFSET, PTR + 8);
608*c217d954SCole Faust
609*c217d954SCole Faust#define vload_partial_10(DATA, OFFSET, PTR)       \
610*c217d954SCole Faust    vload_partial_8(DATA.s01234567, OFFSET, PTR); \
611*c217d954SCole Faust    vload_partial_2(DATA.s89, OFFSET, PTR + 8);
612*c217d954SCole Faust
613*c217d954SCole Faust#define vload_partial_11(DATA, OFFSET, PTR)       \
614*c217d954SCole Faust    vload_partial_8(DATA.s01234567, OFFSET, PTR); \
615*c217d954SCole Faust    vload_partial_3(DATA.s89A, OFFSET, PTR + 8);
616*c217d954SCole Faust
617*c217d954SCole Faust#define vload_partial_12(DATA, OFFSET, PTR)       \
618*c217d954SCole Faust    vload_partial_8(DATA.s01234567, OFFSET, PTR); \
619*c217d954SCole Faust    vload_partial_4(DATA.s89AB, OFFSET, PTR + 8);
620*c217d954SCole Faust
621*c217d954SCole Faust#define vload_partial_13(DATA, OFFSET, PTR)       \
622*c217d954SCole Faust    vload_partial_8(DATA.s01234567, OFFSET, PTR); \
623*c217d954SCole Faust    vload_partial_5(DATA.s89ABCDEF, OFFSET, PTR + 8);
624*c217d954SCole Faust
625*c217d954SCole Faust#define vload_partial_14(DATA, OFFSET, PTR)       \
626*c217d954SCole Faust    vload_partial_8(DATA.s01234567, OFFSET, PTR); \
627*c217d954SCole Faust    vload_partial_6(DATA.s89ABCDEF, OFFSET, PTR + 8);
628*c217d954SCole Faust
629*c217d954SCole Faust#define vload_partial_15(DATA, OFFSET, PTR)       \
630*c217d954SCole Faust    vload_partial_8(DATA.s01234567, OFFSET, PTR); \
631*c217d954SCole Faust    vload_partial_7(DATA.s89ABCDEF, OFFSET, PTR + 8);
632*c217d954SCole Faust
633*c217d954SCole Faust#define vload_partial_16(DATA, OFFSET, PTR) \
634*c217d954SCole Faust    DATA = vload16(OFFSET, PTR);
635*c217d954SCole Faust
636*c217d954SCole Faust
637*c217d954SCole Faust
638*c217d954SCole Faust#define PIXEL_UNIT4 1
639*c217d954SCole Faust#define PIXEL_UNIT8 2
640*c217d954SCole Faust#define PIXEL_UNIT16 4
641*c217d954SCole Faust
642*c217d954SCole Faust
643*c217d954SCole Faust#define CONVERT_VECTOR_SIZE_TO_PIXEL_UNIT_STR(vec_size) PIXEL_UNIT##vec_size
644*c217d954SCole Faust#define CONVERT_VECTOR_SIZE_TO_PIXEL_UNIT(vec_size) CONVERT_VECTOR_SIZE_TO_PIXEL_UNIT_STR(vec_size)
645*c217d954SCole Faust
646*c217d954SCole Faust
647*c217d954SCole Faust#define read_image2d_floatx1(img, x_coord, y_coord) (float4)(read_imagef(img, (int2)(x_coord, y_coord)));
648*c217d954SCole Faust#define read_image2d_floatx2(img, x_coord, y_coord) (float8)(read_imagef(img, (int2)(x_coord, y_coord)), read_imagef(img, (int2)(x_coord + 1, y_coord)));
649*c217d954SCole Faust#define read_image2d_floatx4(img, x_coord, y_coord) (float16)(read_imagef(img, (int2)(x_coord, y_coord)), read_imagef(img, (int2)(x_coord + 1, y_coord)), read_imagef(img, (int2)(x_coord + 2, y_coord)), read_imagef(img, (int2)(x_coord + 3, y_coord)));
650*c217d954SCole Faust
651*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_FP16_ENABLED) && defined(cl_khr_fp16)
652*c217d954SCole Faust#define read_image2d_halfx1(img, x_coord, y_coord) (half4)(read_imageh(img, (int2)(x_coord, y_coord)));
653*c217d954SCole Faust#define read_image2d_halfx2(img, x_coord, y_coord) (half8)(read_imageh(img, (int2)(x_coord, y_coord)), read_imageh(img, (int2)(x_coord + 1, y_coord)));
654*c217d954SCole Faust#define read_image2d_halfx4(img, x_coord, y_coord) (half16)(read_imageh(img, (int2)(x_coord, y_coord)), read_imageh(img, (int2)(x_coord + 1, y_coord)), read_imageh(img, (int2)(x_coord + 2, y_coord)), read_imageh(img, (int2)(x_coord + 3, y_coord)));
655*c217d954SCole Faust#endif
656*c217d954SCole Faust
657*c217d954SCole Faust#define write_image2d_floatx1(img, x_coord, y_coord, values) (write_imagef(img, (int2)(x_coord, y_coord), values));
658*c217d954SCole Faust#define write_image2d_floatx2(img, x_coord, y_coord, values) (write_imagef(img, (int2)(x_coord, y_coord), values.s0123), write_imagef(img, (int2)(x_coord + 1, y_coord), values.s4567));
659*c217d954SCole Faust#define write_image2d_floatx4(img, x_coord, y_coord, values) (write_imagef(img, (int2)(x_coord, y_coord), values.s0123), write_imagef(img, (int2)(x_coord + 1, y_coord), values.s4567), write_imagef(img, (int2)(x_coord + 2, y_coord), values.s89AB), write_imagef(img, (int2)(x_coord + 3, y_coord), values.sCDEF));
660*c217d954SCole Faust
661*c217d954SCole Faust#if defined(ARM_COMPUTE_OPENCL_FP16_ENABLED) && defined(cl_khr_fp16)
662*c217d954SCole Faust#define write_image2d_halfx1(img, x_coord, y_coord, values) (write_imageh(img, (int2)(x_coord, y_coord), values));
663*c217d954SCole Faust#define write_image2d_halfx2(img, x_coord, y_coord, values) (write_imageh(img, (int2)(x_coord, y_coord), values.s0123), write_imageh(img, (int2)(x_coord + 1, y_coord), values.s4567));
664*c217d954SCole Faust#define write_image2d_halfx4(img, x_coord, y_coord, values) (write_imageh(img, (int2)(x_coord, y_coord), values.s0123), write_imageh(img, (int2)(x_coord + 1, y_coord), values.s4567), write_imageh(img, (int2)(x_coord + 2, y_coord), values.s89AB), write_imageh(img, (int2)(x_coord + 3, y_coord), values.sCDEF));
665*c217d954SCole Faust#endif
666*c217d954SCole Faust
667*c217d954SCole Faust
668*c217d954SCole Faust#define READ_IMAGE2D_STR(data_type, n0, img, x_coord, y_coord) read_image2d_##data_type##x##n0(img, x_coord, y_coord)
669*c217d954SCole Faust#define READ_IMAGE2D(data_type, n0, img, x_coord, y_coord) READ_IMAGE2D_STR(data_type, n0, img, x_coord, y_coord)
670*c217d954SCole Faust
671*c217d954SCole Faust
672*c217d954SCole Faust#define WRITE_IMAGE2D_STR(data_type, n0, img, x_coord, y_coord, values) write_image2d_##data_type##x##n0(img, x_coord, y_coord, values)
673*c217d954SCole Faust#define WRITE_IMAGE2D(data_type, n0, img, x_coord, y_coord, values) WRITE_IMAGE2D_STR(data_type, n0, img, x_coord, y_coord, values)
674*c217d954SCole Faust
675*c217d954SCole Faust#define VSTORE_STR(size) vstore##size
676*c217d954SCole Faust#define VSTORE(size) VSTORE_STR(size)
677*c217d954SCole Faust
678*c217d954SCole Faust#define float1 float
679*c217d954SCole Faust#define half1 half
680*c217d954SCole Faust#define char1 char
681*c217d954SCole Faust#define uchar1 uchar
682*c217d954SCole Faust#define short1 short
683*c217d954SCole Faust#define ushort1 ushort
684*c217d954SCole Faust#define int1 int
685*c217d954SCole Faust#define uint1 uint
686*c217d954SCole Faust#define long1 long
687*c217d954SCole Faust#define ulong1 ulong
688*c217d954SCole Faust#define double1 double
689*c217d954SCole Faust
690*c217d954SCole Faust#define vload1(OFFSET, PTR) *(OFFSET + PTR)
691*c217d954SCole Faust#define vstore1(DATA, OFFSET, PTR) *(OFFSET + PTR) = DATA
692*c217d954SCole Faust
693*c217d954SCole Faust
694*c217d954SCole Faust#define VSTORE_PARTIAL_STR(size, store_size) vstore_partial_##size##_##store_size
695*c217d954SCole Faust#define VSTORE_PARTIAL(size, store_size) VSTORE_PARTIAL_STR(size, store_size)
696*c217d954SCole Faust
697*c217d954SCole Faust#define NO_STORE(data, offs, ptr) \
698*c217d954SCole Faust    {                             \
699*c217d954SCole Faust    }
700*c217d954SCole Faust
701*c217d954SCole Faust
702*c217d954SCole Faust#define vstore_partial_1_0 NO_STORE
703*c217d954SCole Faust#define vstore_partial_1_1 vstore1
704*c217d954SCole Faust#define vstore_partial_1_2 NO_STORE
705*c217d954SCole Faust#define vstore_partial_1_3 NO_STORE
706*c217d954SCole Faust#define vstore_partial_1_4 NO_STORE
707*c217d954SCole Faust#define vstore_partial_1_5 NO_STORE
708*c217d954SCole Faust#define vstore_partial_1_6 NO_STORE
709*c217d954SCole Faust#define vstore_partial_1_7 NO_STORE
710*c217d954SCole Faust#define vstore_partial_1_8 NO_STORE
711*c217d954SCole Faust#define vstore_partial_1_9 NO_STORE
712*c217d954SCole Faust#define vstore_partial_1_10 NO_STORE
713*c217d954SCole Faust#define vstore_partial_1_11 NO_STORE
714*c217d954SCole Faust#define vstore_partial_1_12 NO_STORE
715*c217d954SCole Faust#define vstore_partial_1_13 NO_STORE
716*c217d954SCole Faust#define vstore_partial_1_14 NO_STORE
717*c217d954SCole Faust#define vstore_partial_1_15 NO_STORE
718*c217d954SCole Faust#define vstore_partial_1_16 NO_STORE
719*c217d954SCole Faust
720*c217d954SCole Faust#define vstore_partial_2_0 NO_STORE
721*c217d954SCole Faust#define vstore_partial_2_1 vstore_partial_1
722*c217d954SCole Faust#define vstore_partial_2_2 vstore_partial_2
723*c217d954SCole Faust#define vstore_partial_2_3 NO_STORE
724*c217d954SCole Faust#define vstore_partial_2_4 NO_STORE
725*c217d954SCole Faust#define vstore_partial_2_5 NO_STORE
726*c217d954SCole Faust#define vstore_partial_2_6 NO_STORE
727*c217d954SCole Faust#define vstore_partial_2_7 NO_STORE
728*c217d954SCole Faust#define vstore_partial_2_8 NO_STORE
729*c217d954SCole Faust#define vstore_partial_2_9 NO_STORE
730*c217d954SCole Faust#define vstore_partial_2_10 NO_STORE
731*c217d954SCole Faust#define vstore_partial_2_11 NO_STORE
732*c217d954SCole Faust#define vstore_partial_2_12 NO_STORE
733*c217d954SCole Faust#define vstore_partial_2_13 NO_STORE
734*c217d954SCole Faust#define vstore_partial_2_14 NO_STORE
735*c217d954SCole Faust#define vstore_partial_2_15 NO_STORE
736*c217d954SCole Faust#define vstore_partial_2_16 NO_STORE
737*c217d954SCole Faust
738*c217d954SCole Faust#define vstore_partial_3_0 NO_STORE
739*c217d954SCole Faust#define vstore_partial_3_1 vstore_partial_1
740*c217d954SCole Faust#define vstore_partial_3_2 vstore_partial_2
741*c217d954SCole Faust#define vstore_partial_3_3 vstore_partial_3
742*c217d954SCole Faust#define vstore_partial_3_4 NO_STORE
743*c217d954SCole Faust#define vstore_partial_3_5 NO_STORE
744*c217d954SCole Faust#define vstore_partial_3_6 NO_STORE
745*c217d954SCole Faust#define vstore_partial_3_7 NO_STORE
746*c217d954SCole Faust#define vstore_partial_3_8 NO_STORE
747*c217d954SCole Faust#define vstore_partial_3_9 NO_STORE
748*c217d954SCole Faust#define vstore_partial_3_10 NO_STORE
749*c217d954SCole Faust#define vstore_partial_3_11 NO_STORE
750*c217d954SCole Faust#define vstore_partial_3_12 NO_STORE
751*c217d954SCole Faust#define vstore_partial_3_13 NO_STORE
752*c217d954SCole Faust#define vstore_partial_3_14 NO_STORE
753*c217d954SCole Faust#define vstore_partial_3_15 NO_STORE
754*c217d954SCole Faust#define vstore_partial_3_16 NO_STORE
755*c217d954SCole Faust
756*c217d954SCole Faust#define vstore_partial_4_0 NO_STORE
757*c217d954SCole Faust#define vstore_partial_4_1 vstore_partial_1
758*c217d954SCole Faust#define vstore_partial_4_2 vstore_partial_2
759*c217d954SCole Faust#define vstore_partial_4_3 vstore_partial_3
760*c217d954SCole Faust#define vstore_partial_4_4 vstore_partial_4
761*c217d954SCole Faust#define vstore_partial_4_5 NO_STORE
762*c217d954SCole Faust#define vstore_partial_4_6 NO_STORE
763*c217d954SCole Faust#define vstore_partial_4_7 NO_STORE
764*c217d954SCole Faust#define vstore_partial_4_8 NO_STORE
765*c217d954SCole Faust#define vstore_partial_4_9 NO_STORE
766*c217d954SCole Faust#define vstore_partial_4_10 NO_STORE
767*c217d954SCole Faust#define vstore_partial_4_11 NO_STORE
768*c217d954SCole Faust#define vstore_partial_4_12 NO_STORE
769*c217d954SCole Faust#define vstore_partial_4_13 NO_STORE
770*c217d954SCole Faust#define vstore_partial_4_14 NO_STORE
771*c217d954SCole Faust#define vstore_partial_4_15 NO_STORE
772*c217d954SCole Faust#define vstore_partial_4_16 NO_STORE
773*c217d954SCole Faust
774*c217d954SCole Faust#define vstore_partial_8_0 NO_STORE
775*c217d954SCole Faust#define vstore_partial_8_1 vstore_partial_1
776*c217d954SCole Faust#define vstore_partial_8_2 vstore_partial_2
777*c217d954SCole Faust#define vstore_partial_8_3 vstore_partial_3
778*c217d954SCole Faust#define vstore_partial_8_4 vstore_partial_4
779*c217d954SCole Faust#define vstore_partial_8_5 vstore_partial_5
780*c217d954SCole Faust#define vstore_partial_8_6 vstore_partial_6
781*c217d954SCole Faust#define vstore_partial_8_7 vstore_partial_7
782*c217d954SCole Faust#define vstore_partial_8_8 vstore_partial_8
783*c217d954SCole Faust#define vstore_partial_8_9 NO_STORE
784*c217d954SCole Faust#define vstore_partial_8_10 NO_STORE
785*c217d954SCole Faust#define vstore_partial_8_11 NO_STORE
786*c217d954SCole Faust#define vstore_partial_8_12 NO_STORE
787*c217d954SCole Faust#define vstore_partial_8_13 NO_STORE
788*c217d954SCole Faust#define vstore_partial_8_14 NO_STORE
789*c217d954SCole Faust#define vstore_partial_8_15 NO_STORE
790*c217d954SCole Faust#define vstore_partial_8_16 NO_STORE
791*c217d954SCole Faust
792*c217d954SCole Faust#define vstore_partial_16_0 NO_STORE
793*c217d954SCole Faust#define vstore_partial_16_1 vstore_partial_1
794*c217d954SCole Faust#define vstore_partial_16_2 vstore_partial_2
795*c217d954SCole Faust#define vstore_partial_16_3 vstore_partial_3
796*c217d954SCole Faust#define vstore_partial_16_4 vstore_partial_4
797*c217d954SCole Faust#define vstore_partial_16_5 vstore_partial_5
798*c217d954SCole Faust#define vstore_partial_16_6 vstore_partial_6
799*c217d954SCole Faust#define vstore_partial_16_7 vstore_partial_7
800*c217d954SCole Faust#define vstore_partial_16_8 vstore_partial_8
801*c217d954SCole Faust#define vstore_partial_16_9 vstore_partial_9
802*c217d954SCole Faust#define vstore_partial_16_10 vstore_partial_10
803*c217d954SCole Faust#define vstore_partial_16_11 vstore_partial_11
804*c217d954SCole Faust#define vstore_partial_16_12 vstore_partial_12
805*c217d954SCole Faust#define vstore_partial_16_13 vstore_partial_13
806*c217d954SCole Faust#define vstore_partial_16_14 vstore_partial_14
807*c217d954SCole Faust#define vstore_partial_16_15 vstore_partial_15
808*c217d954SCole Faust#define vstore_partial_16_16 vstore_partial_16
809*c217d954SCole Faust
810*c217d954SCole Faust
811*c217d954SCole Faust#define vstore_partial_1(DATA, OFFSET, PTR) \
812*c217d954SCole Faust    vstore1(DATA.s0, OFFSET, PTR);
813*c217d954SCole Faust
814*c217d954SCole Faust#define vstore_partial_2(DATA, OFFSET, PTR) \
815*c217d954SCole Faust    vstore2(DATA.s01, OFFSET, PTR);
816*c217d954SCole Faust
817*c217d954SCole Faust#define vstore_partial_3(DATA, OFFSET, PTR) \
818*c217d954SCole Faust    vstore3(DATA.s012, OFFSET, PTR);
819*c217d954SCole Faust
820*c217d954SCole Faust#define vstore_partial_4(DATA, OFFSET, PTR) \
821*c217d954SCole Faust    vstore4(DATA.s0123, OFFSET, PTR);
822*c217d954SCole Faust
823*c217d954SCole Faust#define vstore_partial_5(DATA, OFFSET, PTR)    \
824*c217d954SCole Faust    vstore_partial_4(DATA.s0123, OFFSET, PTR); \
825*c217d954SCole Faust    vstore1(DATA.s4, OFFSET, PTR + 4);
826*c217d954SCole Faust
827*c217d954SCole Faust#define vstore_partial_6(DATA, OFFSET, PTR)    \
828*c217d954SCole Faust    vstore_partial_4(DATA.s0123, OFFSET, PTR); \
829*c217d954SCole Faust    vstore_partial_2(DATA.s45, OFFSET, PTR + 4);
830*c217d954SCole Faust
831*c217d954SCole Faust#define vstore_partial_7(DATA, OFFSET, PTR)    \
832*c217d954SCole Faust    vstore_partial_4(DATA.s0123, OFFSET, PTR); \
833*c217d954SCole Faust    vstore_partial_3(DATA.s456, OFFSET, PTR + 4);
834*c217d954SCole Faust
835*c217d954SCole Faust#define vstore_partial_8(DATA, OFFSET, PTR) \
836*c217d954SCole Faust    vstore8(DATA.s01234567, OFFSET, PTR);
837*c217d954SCole Faust
838*c217d954SCole Faust#define vstore_partial_9(DATA, OFFSET, PTR)        \
839*c217d954SCole Faust    vstore_partial_8(DATA.s01234567, OFFSET, PTR); \
840*c217d954SCole Faust    vstore1(DATA.s8, OFFSET, PTR + 8);
841*c217d954SCole Faust
842*c217d954SCole Faust#define vstore_partial_10(DATA, OFFSET, PTR)       \
843*c217d954SCole Faust    vstore_partial_8(DATA.s01234567, OFFSET, PTR); \
844*c217d954SCole Faust    vstore_partial_2(DATA.s89, OFFSET, PTR + 8);
845*c217d954SCole Faust
846*c217d954SCole Faust#define vstore_partial_11(DATA, OFFSET, PTR)       \
847*c217d954SCole Faust    vstore_partial_8(DATA.s01234567, OFFSET, PTR); \
848*c217d954SCole Faust    vstore_partial_3(DATA.s89a, OFFSET, PTR + 8);
849*c217d954SCole Faust
850*c217d954SCole Faust#define vstore_partial_12(DATA, OFFSET, PTR)       \
851*c217d954SCole Faust    vstore_partial_8(DATA.s01234567, OFFSET, PTR); \
852*c217d954SCole Faust    vstore_partial_4(DATA.s89ab, OFFSET, PTR + 8);
853*c217d954SCole Faust
854*c217d954SCole Faust#define vstore_partial_13(DATA, OFFSET, PTR)       \
855*c217d954SCole Faust    vstore_partial_8(DATA.s01234567, OFFSET, PTR); \
856*c217d954SCole Faust    vstore_partial_5(DATA.s89abcdef, OFFSET, PTR + 8);
857*c217d954SCole Faust
858*c217d954SCole Faust#define vstore_partial_14(DATA, OFFSET, PTR)       \
859*c217d954SCole Faust    vstore_partial_8(DATA.s01234567, OFFSET, PTR); \
860*c217d954SCole Faust    vstore_partial_6(DATA.s89abcdef, OFFSET, PTR + 8);
861*c217d954SCole Faust
862*c217d954SCole Faust#define vstore_partial_15(DATA, OFFSET, PTR)       \
863*c217d954SCole Faust    vstore_partial_8(DATA.s01234567, OFFSET, PTR); \
864*c217d954SCole Faust    vstore_partial_7(DATA.s89abcdef, OFFSET, PTR + 8);
865*c217d954SCole Faust
866*c217d954SCole Faust#define vstore_partial_16(DATA, OFFSET, PTR) \
867*c217d954SCole Faust    vstore16(DATA, OFFSET, PTR);
868*c217d954SCole Faust
869*c217d954SCole Faust
870*c217d954SCole Faust
871*c217d954SCole Faust
872*c217d954SCole Faust
873*c217d954SCole Faust#define convert_float_sat convert_float
874*c217d954SCole Faust#define convert_float1_sat convert_float
875*c217d954SCole Faust#define convert_float2_sat convert_float2
876*c217d954SCole Faust#define convert_float3_sat convert_float3
877*c217d954SCole Faust#define convert_float4_sat convert_float4
878*c217d954SCole Faust#define convert_float8_sat convert_float8
879*c217d954SCole Faust#define convert_float16_sat convert_float16
880*c217d954SCole Faust#define convert_half_sat convert_float
881*c217d954SCole Faust#define convert_half1_sat convert_half
882*c217d954SCole Faust#define convert_half2_sat convert_half2
883*c217d954SCole Faust#define convert_half3_sat convert_half3
884*c217d954SCole Faust#define convert_half4_sat convert_half4
885*c217d954SCole Faust#define convert_half8_sat convert_half8
886*c217d954SCole Faust#define convert_half16_sat convert_half16
887*c217d954SCole Faust
888*c217d954SCole Faust#define convert_float1 convert_float
889*c217d954SCole Faust#define convert_half1 convert_half
890*c217d954SCole Faust#define convert_char1 convert_char
891*c217d954SCole Faust#define convert_uchar1 convert_uchar
892*c217d954SCole Faust#define convert_short1 convert_short
893*c217d954SCole Faust#define convert_ushort1 convert_ushort
894*c217d954SCole Faust#define convert_int1 convert_int
895*c217d954SCole Faust#define convert_uint1 convert_uint
896*c217d954SCole Faust#define convert_long1 convert_long
897*c217d954SCole Faust#define convert_ulong1 convert_ulong
898*c217d954SCole Faust#define convert_double1 convert_double
899*c217d954SCole Faust
900*c217d954SCole Faust#define convert_char1_sat convert_char_sat
901*c217d954SCole Faust#define convert_uchar1_sat convert_uchar_sat
902*c217d954SCole Faust#define convert_uchar2_sat convert_uchar2_sat
903*c217d954SCole Faust#define convert_uchar3_sat convert_uchar3_sat
904*c217d954SCole Faust#define convert_uchar4_sat convert_uchar4_sat
905*c217d954SCole Faust#define convert_uchar8_sat convert_uchar8_sat
906*c217d954SCole Faust#define convert_uchar16_sat convert_uchar16_sat
907*c217d954SCole Faust#define convert_short1_sat convert_short_sat
908*c217d954SCole Faust#define convert_ushort1_sat convert_ushort_sat
909*c217d954SCole Faust#define convert_int1_sat convert_int_sat
910*c217d954SCole Faust#define convert_uint1_sat convert_uint_sat
911*c217d954SCole Faust#define convert_long1_sat convert_long_sat
912*c217d954SCole Faust#define convert_ulong1_sat convert_ulong_sat
913*c217d954SCole Faust#define convert_double1_sat convert_double_sat
914*c217d954SCole Faust
915*c217d954SCole Faust#define VEC_DATA_TYPE_STR(type, size) type##size
916*c217d954SCole Faust#define VEC_DATA_TYPE(type, size) VEC_DATA_TYPE_STR(type, size)
917*c217d954SCole Faust
918*c217d954SCole Faust#define CONVERT_STR(x, type) (convert_##type((x)))
919*c217d954SCole Faust#define CONVERT(x, type) CONVERT_STR(x, type)
920*c217d954SCole Faust
921*c217d954SCole Faust#define CONVERT_SAT_STR(x, type) (convert_##type##_sat((x)))
922*c217d954SCole Faust#define CONVERT_SAT(x, type) CONVERT_SAT_STR(x, type)
923*c217d954SCole Faust
924*c217d954SCole Faust#define CONVERT_SAT_ROUND_STR(x, type, round) (convert_##type##_sat_##round((x)))
925*c217d954SCole Faust#define CONVERT_SAT_ROUND(x, type, round) CONVERT_SAT_ROUND_STR(x, type, round)
926*c217d954SCole Faust
927*c217d954SCole Faust#define select_vec_dt_uchar(size) uchar##size
928*c217d954SCole Faust#define select_vec_dt_char(size) char##size
929*c217d954SCole Faust#define select_vec_dt_ushort(size) ushort##size
930*c217d954SCole Faust#define select_vec_dt_short(size) short##size
931*c217d954SCole Faust#define select_vec_dt_half(size) short##size
932*c217d954SCole Faust#define select_vec_dt_uint(size) uint##size
933*c217d954SCole Faust#define select_vec_dt_int(size) int##size
934*c217d954SCole Faust#define select_vec_dt_float(size) int##size
935*c217d954SCole Faust#define select_vec_dt_ulong(size) ulong##size
936*c217d954SCole Faust#define select_vec_dt_long(size) long##size
937*c217d954SCole Faust
938*c217d954SCole Faust#define SELECT_VEC_DATA_TYPE_STR(type, size) select_vec_dt_##type(size)
939*c217d954SCole Faust#define SELECT_VEC_DATA_TYPE(type, size) SELECT_VEC_DATA_TYPE_STR(type, size)
940*c217d954SCole Faust#define SELECT_DATA_TYPE(type) SELECT_VEC_DATA_TYPE_STR(type, 1)
941*c217d954SCole Faust
942*c217d954SCole Faust#define signed_int_vec_dt_uchar(size) char##size
943*c217d954SCole Faust#define signed_int_vec_dt_char(size) char##size
944*c217d954SCole Faust#define signed_int_vec_dt_ushort(size) short##size
945*c217d954SCole Faust#define signed_int_vec_dt_short(size) short##size
946*c217d954SCole Faust#define signed_int_vec_dt_half(size) short##size
947*c217d954SCole Faust#define signed_int_vec_dt_uint(size) int##size
948*c217d954SCole Faust#define signed_int_vec_dt_int(size) int##size
949*c217d954SCole Faust#define signed_int_vec_dt_float(size) int##size
950*c217d954SCole Faust#define signed_int_vec_dt_ulong(size) long##size
951*c217d954SCole Faust#define signed_int_vec_dt_long(size) long##size
952*c217d954SCole Faust
953*c217d954SCole Faust#define SIGNED_INT_VEC_DATA_TYPE_STR(type, size) signed_int_vec_dt_##type(size)
954*c217d954SCole Faust#define SIGNED_INT_VEC_DATA_TYPE(type, size) SIGNED_INT_VEC_DATA_TYPE_STR(type, size)
955*c217d954SCole Faust#define SIGNED_INT_DATA_TYPE(type) SIGNED_INT_VEC_DATA_TYPE_STR(type, 1)
956*c217d954SCole Faust
957*c217d954SCole Faust#define sum_reduce_1(x) (x)
958*c217d954SCole Faust#define sum_reduce_2(x) ((x).s0) + ((x).s1)
959*c217d954SCole Faust#define sum_reduce_3(x) sum_reduce_2((x).s01) + ((x).s2)
960*c217d954SCole Faust#define sum_reduce_4(x) sum_reduce_2((x).s01) + sum_reduce_2((x).s23)
961*c217d954SCole Faust#define sum_reduce_8(x) sum_reduce_4((x).s0123) + sum_reduce_4((x).s4567)
962*c217d954SCole Faust#define sum_reduce_16(x) sum_reduce_8((x).s01234567) + sum_reduce_8((x).s89ABCDEF)
963*c217d954SCole Faust
964*c217d954SCole Faust#define SUM_REDUCE_STR(x, size) sum_reduce_##size(x)
965*c217d954SCole Faust#define SUM_REDUCE(x, size) SUM_REDUCE_STR(x, size)
966*c217d954SCole Faust
967*c217d954SCole Faust#define prod_reduce_1(x) (x)
968*c217d954SCole Faust#define prod_reduce_2(x) ((x).s0) * ((x).s1)
969*c217d954SCole Faust#define prod_reduce_3(x) prod_reduce_2((x).s01) * ((x).s2)
970*c217d954SCole Faust#define prod_reduce_4(x) prod_reduce_2((x).s01) * prod_reduce_2((x).s23)
971*c217d954SCole Faust#define prod_reduce_8(x) prod_reduce_4((x).s0123) * prod_reduce_4((x).s4567)
972*c217d954SCole Faust#define prod_reduce_16(x) prod_reduce_8((x).s01234567) * prod_reduce_8((x).s89ABCDEF)
973*c217d954SCole Faust
974*c217d954SCole Faust#define PROD_REDUCE_STR(x, size) prod_reduce_##size(x)
975*c217d954SCole Faust#define PROD_REDUCE(x, size) PROD_REDUCE_STR(x, size)
976*c217d954SCole Faust
977*c217d954SCole Faust#define max_reduce_1(x) (x)
978*c217d954SCole Faust#define max_reduce_2(x) max(((x).s0), ((x).s1))
979*c217d954SCole Faust#define max_reduce_3(x) max(max_reduce_2((x).s01), ((x).s2))
980*c217d954SCole Faust#define max_reduce_4(x) max(max_reduce_2((x).s01), max_reduce_2((x).s23))
981*c217d954SCole Faust#define max_reduce_8(x) max(max_reduce_4((x).s0123), max_reduce_4((x).s4567))
982*c217d954SCole Faust#define max_reduce_16(x) max(max_reduce_8((x).s01234567), max_reduce_8((x).s89ABCDEF))
983*c217d954SCole Faust
984*c217d954SCole Faust#define MAX_REDUCE_STR(x, size) max_reduce_##size(x)
985*c217d954SCole Faust#define MAX_REDUCE(x, size) MAX_REDUCE_STR(x, size)
986*c217d954SCole Faust
987*c217d954SCole Faust#define VECTOR_DECLARATION(name)     \
988*c217d954SCole Faust    __global uchar *name##_ptr,      \
989*c217d954SCole Faust    uint        name##_stride_x, \
990*c217d954SCole Faust    uint        name##_step_x,   \
991*c217d954SCole Faust    uint        name##_offset_first_element_in_bytes
992*c217d954SCole Faust
993*c217d954SCole Faust#define IMAGE_DECLARATION(name)      \
994*c217d954SCole Faust    __global uchar *name##_ptr,      \
995*c217d954SCole Faust    uint        name##_stride_x, \
996*c217d954SCole Faust    uint        name##_step_x,   \
997*c217d954SCole Faust    uint        name##_stride_y, \
998*c217d954SCole Faust    uint        name##_step_y,   \
999*c217d954SCole Faust    uint        name##_offset_first_element_in_bytes
1000*c217d954SCole Faust
1001*c217d954SCole Faust#define TENSOR3D_DECLARATION(name)   \
1002*c217d954SCole Faust    __global uchar *name##_ptr,      \
1003*c217d954SCole Faust    uint        name##_stride_x, \
1004*c217d954SCole Faust    uint        name##_step_x,   \
1005*c217d954SCole Faust    uint        name##_stride_y, \
1006*c217d954SCole Faust    uint        name##_step_y,   \
1007*c217d954SCole Faust    uint        name##_stride_z, \
1008*c217d954SCole Faust    uint        name##_step_z,   \
1009*c217d954SCole Faust    uint        name##_offset_first_element_in_bytes
1010*c217d954SCole Faust
1011*c217d954SCole Faust#define TENSOR4D_DECLARATION(name)   \
1012*c217d954SCole Faust    __global uchar *name##_ptr,      \
1013*c217d954SCole Faust    uint        name##_stride_x, \
1014*c217d954SCole Faust    uint        name##_step_x,   \
1015*c217d954SCole Faust    uint        name##_stride_y, \
1016*c217d954SCole Faust    uint        name##_step_y,   \
1017*c217d954SCole Faust    uint        name##_stride_z, \
1018*c217d954SCole Faust    uint        name##_step_z,   \
1019*c217d954SCole Faust    uint        name##_stride_w, \
1020*c217d954SCole Faust    uint        name##_step_w,   \
1021*c217d954SCole Faust    uint        name##_offset_first_element_in_bytes
1022*c217d954SCole Faust
1023*c217d954SCole Faust#define TENSOR5D_DECLARATION(name)   \
1024*c217d954SCole Faust    __global uchar *name##_ptr,      \
1025*c217d954SCole Faust    uint        name##_stride_x, \
1026*c217d954SCole Faust    uint        name##_step_x,   \
1027*c217d954SCole Faust    uint        name##_stride_y, \
1028*c217d954SCole Faust    uint        name##_step_y,   \
1029*c217d954SCole Faust    uint        name##_stride_z, \
1030*c217d954SCole Faust    uint        name##_step_z,   \
1031*c217d954SCole Faust    uint        name##_stride_w, \
1032*c217d954SCole Faust    uint        name##_step_w,   \
1033*c217d954SCole Faust    uint        name##_stride_v, \
1034*c217d954SCole Faust    uint        name##_step_v,   \
1035*c217d954SCole Faust    uint        name##_offset_first_element_in_bytes
1036*c217d954SCole Faust
1037*c217d954SCole Faust#define CONVERT_TO_VECTOR_STRUCT(name) \
1038*c217d954SCole Faust    update_vector_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, name##_step_x)
1039*c217d954SCole Faust
1040*c217d954SCole Faust#define CONVERT_TO_VECTOR_STRUCT_NO_STEP(name) \
1041*c217d954SCole Faust    update_vector_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, 0)
1042*c217d954SCole Faust
1043*c217d954SCole Faust#define CONVERT_TO_IMAGE_STRUCT(name) \
1044*c217d954SCole Faust    update_image_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, name##_step_x, name##_stride_y, name##_step_y)
1045*c217d954SCole Faust
1046*c217d954SCole Faust#define CONVERT_TO_IMAGE_STRUCT_NO_STEP(name) \
1047*c217d954SCole Faust    update_image_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, 0, name##_stride_y, 0)
1048*c217d954SCole Faust
1049*c217d954SCole Faust#define CONVERT_TENSOR3D_TO_IMAGE_STRUCT(name) \
1050*c217d954SCole Faust    update_image_from_tensor3D_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, name##_step_x, name##_stride_y, name##_step_y, name##_stride_z, name##_step_z)
1051*c217d954SCole Faust
1052*c217d954SCole Faust#define CONVERT_TENSOR3D_TO_IMAGE_STRUCT_NO_STEP(name) \
1053*c217d954SCole Faust    update_image_from_tensor3D_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, 0, name##_stride_y, 0, name##_stride_z, name##_step_z)
1054*c217d954SCole Faust
1055*c217d954SCole Faust#define CONVERT_TENSOR3D_TO_IMAGE_STRUCT(name) \
1056*c217d954SCole Faust    update_image_from_tensor3D_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, name##_step_x, name##_stride_y, name##_step_y, name##_stride_z, name##_step_z)
1057*c217d954SCole Faust
1058*c217d954SCole Faust#define CONVERT_TO_TENSOR3D_STRUCT(name)                                                                                                           \
1059*c217d954SCole Faust    update_tensor3D_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, name##_step_x, name##_stride_y, name##_step_y, \
1060*c217d954SCole Faust                                 name##_stride_z, name##_step_z)
1061*c217d954SCole Faust
1062*c217d954SCole Faust#define CONVERT_TO_TENSOR3D_STRUCT_NO_STEP(name) \
1063*c217d954SCole Faust    update_tensor3D_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, 0, name##_stride_y, 0, name##_stride_z, 0)
1064*c217d954SCole Faust
1065*c217d954SCole Faust#define CONVERT_TO_TENSOR4D_STRUCT(name, mod_size)                                                                                                 \
1066*c217d954SCole Faust    update_tensor4D_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, name##_step_x, name##_stride_y, name##_step_y, \
1067*c217d954SCole Faust                                 name##_stride_z, name##_step_z, name##_stride_w, name##_step_w, mod_size)
1068*c217d954SCole Faust
1069*c217d954SCole Faust#define CONVERT_TO_TENSOR4D_STRUCT_NO_STEP(name, mod_size) \
1070*c217d954SCole Faust    update_tensor4D_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, 0, name##_stride_y, 0, name##_stride_z, 0, name##_stride_w, 0, mod_size)
1071*c217d954SCole Faust
1072*c217d954SCole Faust#define CONVERT_TO_TENSOR3D_STRUCT_NO_UPDATE_PTR(name)                                                                                       \
1073*c217d954SCole Faust    tensor3D_ptr_no_update(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, name##_step_x, name##_stride_y, name##_step_y, \
1074*c217d954SCole Faust                           name##_stride_z, name##_step_z)
1075*c217d954SCole Faust
1076*c217d954SCole Faust
1077*c217d954SCole Fausttypedef struct Vector
1078*c217d954SCole Faust{
1079*c217d954SCole Faust    __global uchar *ptr;
1080*c217d954SCole Faust    int             offset_first_element_in_bytes;
1081*c217d954SCole Faust    int             stride_x;
1082*c217d954SCole Faust} Vector;
1083*c217d954SCole Faust
1084*c217d954SCole Faust
1085*c217d954SCole Fausttypedef struct Image
1086*c217d954SCole Faust{
1087*c217d954SCole Faust    __global uchar *ptr;
1088*c217d954SCole Faust    int             offset_first_element_in_bytes;
1089*c217d954SCole Faust    int             stride_x;
1090*c217d954SCole Faust    int             stride_y;
1091*c217d954SCole Faust} Image;
1092*c217d954SCole Faust
1093*c217d954SCole Faust
1094*c217d954SCole Fausttypedef struct Tensor3D
1095*c217d954SCole Faust{
1096*c217d954SCole Faust    __global uchar *ptr;
1097*c217d954SCole Faust    int             offset_first_element_in_bytes;
1098*c217d954SCole Faust    int             stride_x;
1099*c217d954SCole Faust    int             stride_y;
1100*c217d954SCole Faust    int             stride_z;
1101*c217d954SCole Faust} Tensor3D;
1102*c217d954SCole Faust
1103*c217d954SCole Faust
1104*c217d954SCole Fausttypedef struct Tensor4D
1105*c217d954SCole Faust{
1106*c217d954SCole Faust    __global uchar *ptr;
1107*c217d954SCole Faust    int             offset_first_element_in_bytes;
1108*c217d954SCole Faust    int             stride_x;
1109*c217d954SCole Faust    int             stride_y;
1110*c217d954SCole Faust    int             stride_z;
1111*c217d954SCole Faust    int             stride_w;
1112*c217d954SCole Faust} Tensor4D;
1113*c217d954SCole Faust
1114*c217d954SCole Faust
1115*c217d954SCole Faustinline Vector update_vector_workitem_ptr(__global uchar *ptr, uint offset_first_element_in_bytes, uint stride_x, uint step_x)
1116*c217d954SCole Faust{
1117*c217d954SCole Faust    Vector vector =
1118*c217d954SCole Faust    {
1119*c217d954SCole Faust        .ptr                           = ptr,
1120*c217d954SCole Faust        .offset_first_element_in_bytes = offset_first_element_in_bytes,
1121*c217d954SCole Faust        .stride_x                      = stride_x,
1122*c217d954SCole Faust    };
1123*c217d954SCole Faust    vector.ptr += vector.offset_first_element_in_bytes + get_global_id(0) * step_x;
1124*c217d954SCole Faust    return vector;
1125*c217d954SCole Faust}
1126*c217d954SCole Faust
1127*c217d954SCole Faust
1128*c217d954SCole Faustinline Image update_image_workitem_ptr(__global uchar *ptr, uint offset_first_element_in_bytes, uint stride_x, uint step_x, uint stride_y, uint step_y)
1129*c217d954SCole Faust{
1130*c217d954SCole Faust    Image img =
1131*c217d954SCole Faust    {
1132*c217d954SCole Faust        .ptr                           = ptr,
1133*c217d954SCole Faust        .offset_first_element_in_bytes = offset_first_element_in_bytes,
1134*c217d954SCole Faust        .stride_x                      = stride_x,
1135*c217d954SCole Faust        .stride_y                      = stride_y
1136*c217d954SCole Faust    };
1137*c217d954SCole Faust    img.ptr += img.offset_first_element_in_bytes + get_global_id(0) * step_x + get_global_id(1) * step_y;
1138*c217d954SCole Faust    return img;
1139*c217d954SCole Faust}
1140*c217d954SCole Faust
1141*c217d954SCole Faust
1142*c217d954SCole Faustinline Image update_image_from_tensor3D_workitem_ptr(__global uchar *ptr, uint offset_first_element_in_bytes, uint stride_x, uint step_x, uint stride_y, uint step_y, uint stride_z, uint step_z)
1143*c217d954SCole Faust{
1144*c217d954SCole Faust    Image img =
1145*c217d954SCole Faust    {
1146*c217d954SCole Faust        .ptr                           = ptr,
1147*c217d954SCole Faust        .offset_first_element_in_bytes = offset_first_element_in_bytes,
1148*c217d954SCole Faust        .stride_x                      = stride_x,
1149*c217d954SCole Faust        .stride_y                      = stride_y
1150*c217d954SCole Faust    };
1151*c217d954SCole Faust    img.ptr += img.offset_first_element_in_bytes + get_global_id(0) * step_x + get_global_id(1) * step_y + get_global_id(2) * step_z;
1152*c217d954SCole Faust    return img;
1153*c217d954SCole Faust}
1154*c217d954SCole Faust
1155*c217d954SCole Faust
1156*c217d954SCole Faustinline Tensor3D update_tensor3D_workitem_ptr(__global uchar *ptr, uint offset_first_element_in_bytes, uint stride_x, uint step_x, uint stride_y, uint step_y, uint stride_z, uint step_z)
1157*c217d954SCole Faust{
1158*c217d954SCole Faust    Tensor3D tensor =
1159*c217d954SCole Faust    {
1160*c217d954SCole Faust        .ptr                           = ptr,
1161*c217d954SCole Faust        .offset_first_element_in_bytes = offset_first_element_in_bytes,
1162*c217d954SCole Faust        .stride_x                      = stride_x,
1163*c217d954SCole Faust        .stride_y                      = stride_y,
1164*c217d954SCole Faust        .stride_z                      = stride_z
1165*c217d954SCole Faust    };
1166*c217d954SCole Faust    tensor.ptr += tensor.offset_first_element_in_bytes + get_global_id(0) * step_x + get_global_id(1) * step_y + get_global_id(2) * step_z;
1167*c217d954SCole Faust    return tensor;
1168*c217d954SCole Faust}
1169*c217d954SCole Faust
1170*c217d954SCole Faust
1171*c217d954SCole Faustinline Tensor3D tensor3D_ptr_no_update(__global uchar *ptr, uint offset_first_element_in_bytes, uint stride_x, uint step_x, uint stride_y, uint step_y, uint stride_z, uint step_z)
1172*c217d954SCole Faust{
1173*c217d954SCole Faust    Tensor3D tensor =
1174*c217d954SCole Faust    {
1175*c217d954SCole Faust        .ptr                           = ptr,
1176*c217d954SCole Faust        .offset_first_element_in_bytes = offset_first_element_in_bytes,
1177*c217d954SCole Faust        .stride_x                      = stride_x,
1178*c217d954SCole Faust        .stride_y                      = stride_y,
1179*c217d954SCole Faust        .stride_z                      = stride_z
1180*c217d954SCole Faust    };
1181*c217d954SCole Faust    return tensor;
1182*c217d954SCole Faust}
1183*c217d954SCole Faust
1184*c217d954SCole Faustinline Tensor4D update_tensor4D_workitem_ptr(__global uchar *ptr, uint offset_first_element_in_bytes, uint stride_x, uint step_x, uint stride_y, uint step_y, uint stride_z, uint step_z, uint stride_w,
1185*c217d954SCole Faust                                             uint step_w,
1186*c217d954SCole Faust                                             uint mod_size)
1187*c217d954SCole Faust{
1188*c217d954SCole Faust    Tensor4D tensor =
1189*c217d954SCole Faust    {
1190*c217d954SCole Faust        .ptr                           = ptr,
1191*c217d954SCole Faust        .offset_first_element_in_bytes = offset_first_element_in_bytes,
1192*c217d954SCole Faust        .stride_x                      = stride_x,
1193*c217d954SCole Faust        .stride_y                      = stride_y,
1194*c217d954SCole Faust        .stride_z                      = stride_z,
1195*c217d954SCole Faust        .stride_w                      = stride_w
1196*c217d954SCole Faust    };
1197*c217d954SCole Faust
1198*c217d954SCole Faust    tensor.ptr += tensor.offset_first_element_in_bytes + get_global_id(0) * step_x + get_global_id(1) * step_y + (get_global_id(2) % mod_size) * step_z + (get_global_id(2) / mod_size) * step_w;
1199*c217d954SCole Faust    return tensor;
1200*c217d954SCole Faust}
1201*c217d954SCole Faust
1202*c217d954SCole Faust
1203*c217d954SCole Faustinline __global const uchar *vector_offset(const Vector *vec, int x)
1204*c217d954SCole Faust{
1205*c217d954SCole Faust    return vec->ptr + x * vec->stride_x;
1206*c217d954SCole Faust}
1207*c217d954SCole Faust
1208*c217d954SCole Faust
1209*c217d954SCole Faustinline __global uchar *offset(const Image *img, int x, int y)
1210*c217d954SCole Faust{
1211*c217d954SCole Faust    return img->ptr + x * img->stride_x + y * img->stride_y;
1212*c217d954SCole Faust}
1213*c217d954SCole Faust
1214*c217d954SCole Faust
1215*c217d954SCole Faustinline __global const uchar *tensor3D_offset(const Tensor3D *tensor, int x, int y, int z)
1216*c217d954SCole Faust{
1217*c217d954SCole Faust    return tensor->ptr + x * tensor->stride_x + y * tensor->stride_y + z * tensor->stride_z;
1218*c217d954SCole Faust}
1219*c217d954SCole Faust
1220*c217d954SCole Faust
1221*c217d954SCole Faustinline __global const uchar *tensor4D_offset(const Tensor4D *tensor, int x, int y, int z, int w)
1222*c217d954SCole Faust{
1223*c217d954SCole Faust    return tensor->ptr + x * tensor->stride_x + y * tensor->stride_y + z * tensor->stride_z + w * tensor->stride_w;
1224*c217d954SCole Faust}
1225*c217d954SCole Faust
1226*c217d954SCole Faust
1227*c217d954SCole Faustinline __global const uchar *tensor3D_index2ptr(const Tensor3D *tensor, uint width, uint height, uint depth, uint index)
1228*c217d954SCole Faust{
1229*c217d954SCole Faust    uint num_elements = width * height;
1230*c217d954SCole Faust
1231*c217d954SCole Faust    const uint z = index / num_elements;
1232*c217d954SCole Faust
1233*c217d954SCole Faust    index %= num_elements;
1234*c217d954SCole Faust
1235*c217d954SCole Faust    const uint y = index / width;
1236*c217d954SCole Faust
1237*c217d954SCole Faust    index %= width;
1238*c217d954SCole Faust
1239*c217d954SCole Faust    const uint x = index;
1240*c217d954SCole Faust
1241*c217d954SCole Faust    return tensor->ptr + x * tensor->stride_x + y * tensor->stride_y + z * tensor->stride_z + tensor->offset_first_element_in_bytes;
1242*c217d954SCole Faust}
1243*c217d954SCole Faust
1244*c217d954SCole Faust#endif  )"