1 | namespace dnnl { |
2 | namespace impl { |
3 | namespace gpu { |
4 | namespace ocl { |
5 | const char *xe_lp_conv_bwd_data_x8s8x8_kernel = R"==(/******************************************************************************* )==" "\n" |
6 | R"==(* Copyright 2021 Intel Corporation )==" "\n" |
7 | R"==(* )==" "\n" |
8 | R"==(* Licensed under the Apache License, Version 2.0 (the "License"); )==" "\n" |
9 | R"==(* you may not use this file except in compliance with the License. )==" "\n" |
10 | R"==(* You may obtain a copy of the License at )==" "\n" |
11 | R"==(* )==" "\n" |
12 | R"==(* http: )==" "\n" |
13 | R"==(* )==" "\n" |
14 | R"==(* Unless required by applicable law or agreed to in writing, software )==" "\n" |
15 | R"==(* distributed under the License is distributed on an "AS IS" BASIS, )==" "\n" |
16 | R"==(* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. )==" "\n" |
17 | R"==(* See the License for the specific language governing permissions and )==" "\n" |
18 | R"==(* limitations under the License. )==" "\n" |
19 | R"==(*******************************************************************************/ )==" "\n" |
20 | R"==(#include "gpu/ocl/ocl_math_utils.h" )==" "\n" |
21 | R"==(#include "gpu/ocl/ocl_post_ops.h" )==" "\n" |
22 | R"==(#include "gpu/ocl/ocl_types.h" )==" "\n" |
23 | R"==(#if OC % OC_BLOCK != 0 )==" "\n" |
24 | R"==(#define OC_NBLOCKS_TAIL ((OC - (OC & ~(OC_BLOCK - 1)) + 3) / 4) )==" "\n" |
25 | R"==(#else )==" "\n" |
26 | R"==(#define OC_NBLOCKS_TAIL 8 )==" "\n" |
27 | R"==(#endif )==" "\n" |
28 | R"==(#if IW_BLOCK == 4 )==" "\n" |
29 | R"==(#define BLOCK 4 )==" "\n" |
30 | R"==(#define ACC_DATA_BLOCK int4 )==" "\n" |
31 | R"==(#define A_DATA_BLOCK_T MMAD_DATA4_T )==" "\n" |
32 | R"==(#define WRITE_LOCAL block_write4 )==" "\n" |
33 | R"==(#define READ_BLOCK intel_sub_group_block_read4 )==" "\n" |
34 | R"==(DECLARE_MMAD_EMU(mmad_tail, idot4, OC_NBLOCKS_TAIL, 4, A_DATA_BLOCK_T, int8, )==" "\n" |
35 | R"==(ACC_DATA_BLOCK) )==" "\n" |
36 | R"==(#define MMAD_FULL mmad8x4 )==" "\n" |
37 | R"==(#define MMAD_TAIL mmad_tail )==" "\n" |
38 | R"==(#elif IW_BLOCK == 8 )==" "\n" |
39 | R"==(#define BLOCK 8 )==" "\n" |
40 | R"==(#define ACC_DATA_BLOCK int8 )==" "\n" |
41 | R"==(#define A_DATA_BLOCK_T MMAD_DATA8_T )==" "\n" |
42 | R"==(#define WRITE_LOCAL block_write8 )==" "\n" |
43 | R"==(#define READ_BLOCK intel_sub_group_block_read8 )==" "\n" |
44 | R"==(DECLARE_MMAD_EMU(mmad_tail, idot4, OC_NBLOCKS_TAIL, 8, A_DATA_BLOCK_T, int8, )==" "\n" |
45 | R"==(ACC_DATA_BLOCK) )==" "\n" |
46 | R"==(#define MMAD_FULL mmad8x8 )==" "\n" |
47 | R"==(#define MMAD_TAIL mmad_tail )==" "\n" |
48 | R"==(#else )==" "\n" |
49 | R"==(#error "Wrong IW_BLOCK" )==" "\n" |
50 | R"==(#endif )==" "\n" |
51 | R"==(#define BLOCK_READ_WHT_1x32(data, idx) \ )==" "\n" |
52 | R"==(data = as_int(intel_sub_group_block_read((__global uint *)&wei[idx])); )==" "\n" |
53 | R"==(#define BLOCK_READ_WHT_8x32(data, idx) \ )==" "\n" |
54 | R"==(data = as_int8(intel_sub_group_block_read8((__global uint *)&wei[idx])); )==" "\n" |
55 | R"==(#if IC % IC_BLOCK == 0 )==" "\n" |
56 | R"==(#define BLOCK_READ_BIA(data, idx) \ )==" "\n" |
57 | R"==(data = as_float4(intel_sub_group_block_read4((__global uint *)&bias[idx])); )==" "\n" |
58 | R"==(#else )==" "\n" |
59 | R"==(#define BLOCK_READ_BIA(data, idx) \ )==" "\n" |
60 | R"==(data = (float4)0; \ )==" "\n" |
61 | R"==(int i; \ )==" "\n" |
62 | R"==(for (i = idx; i < idx + IC_BLOCK && i < IC - (IC % SUB_GROUP_SIZE); \ )==" "\n" |
63 | R"==(i += SUB_GROUP_SIZE) { \ )==" "\n" |
64 | R"==(data[(i - idx) / SUB_GROUP_SIZE] = as_float( \ )==" "\n" |
65 | R"==(intel_sub_group_block_read((__global uint *)&bias[i])); \ )==" "\n" |
66 | R"==(} \ )==" "\n" |
67 | R"==(if ((get_sub_group_local_id() < IC % SUB_GROUP_SIZE) \ )==" "\n" |
68 | R"==(&& (i == IC - IC % SUB_GROUP_SIZE)) { \ )==" "\n" |
69 | R"==(data[(i - idx) / SUB_GROUP_SIZE] \ )==" "\n" |
70 | R"==(= as_float(bias[i + get_sub_group_local_id()]); \ )==" "\n" |
71 | R"==(} )==" "\n" |
72 | R"==(#endif )==" "\n" |
73 | R"==(#define HAS_PAD_W (PW > 0 || OW * SW - PW + (KW - 1) * (1 + DW) >= IW) )==" "\n" |
74 | R"==(#if IS_NHWC )==" "\n" |
75 | R"==(inline void write_ic_block4(__global SRC_DATA_T *src, int off, uchar4 value) { )==" "\n" |
76 | R"==(const int local_id = get_sub_group_local_id(); )==" "\n" |
77 | R"==(#if IC % IC_BLOCK != 0 )==" "\n" |
78 | R"==(int tail = IC - off; )==" "\n" |
79 | R"==(if (tail < IC_BLOCK) { )==" "\n" |
80 | R"==(if (local_id < tail) src[8 * 0 + local_id] = value.s0; )==" "\n" |
81 | R"==(if (local_id < tail - 8 * 1) src[1 * 8 + local_id] = value.s1; )==" "\n" |
82 | R"==(if (local_id < tail - 8 * 2) src[2 * 8 + local_id] = value.s2; )==" "\n" |
83 | R"==(if (local_id < tail - 8 * 3) src[3 * 8 + local_id] = value.s3; )==" "\n" |
84 | R"==(return; )==" "\n" |
85 | R"==(} )==" "\n" |
86 | R"==(#endif )==" "\n" |
87 | R"==(#if IC % 4 != 0 )==" "\n" |
88 | R"==(src[0 * 8 + local_id] = value.s0; )==" "\n" |
89 | R"==(src[1 * 8 + local_id] = value.s1; )==" "\n" |
90 | R"==(src[2 * 8 + local_id] = value.s2; )==" "\n" |
91 | R"==(src[3 * 8 + local_id] = value.s3; )==" "\n" |
92 | R"==(return; )==" "\n" |
93 | R"==(#else )==" "\n" |
94 | R"==(intel_sub_group_block_write_uc4((__global uchar *)src, value); )==" "\n" |
95 | R"==(return; )==" "\n" |
96 | R"==(#endif )==" "\n" |
97 | R"==(} )==" "\n" |
98 | R"==(inline void write_local(__local uint *dst_iw_slm_copy, int oc_nchunk, )==" "\n" |
99 | R"==(__global DATA_T *dst_copy) { )==" "\n" |
100 | R"==(const int local_id = get_sub_group_local_id(); )==" "\n" |
101 | R"==(#if OC % OC_BLOCK != 0 )==" "\n" |
102 | R"==(int oc_block_tail = OC % OC_BLOCK; )==" "\n" |
103 | R"==(int oc_bound_tail = oc_block_tail % 4; )==" "\n" |
104 | R"==(int max_i = (local_id * 4 < (oc_block_tail - oc_bound_tail) )==" "\n" |
105 | R"==(|| oc_nchunk < (OC_NCHUNK - 1)) )==" "\n" |
106 | R"==(? 4 )==" "\n" |
107 | R"==(: (local_id * 4 == (oc_block_tail - oc_bound_tail) ? oc_bound_tail )==" "\n" |
108 | R"==(: 0); )==" "\n" |
109 | R"==(uchar4 tmp = 0; )==" "\n" |
110 | R"==(for (int i = 0; i < max_i; ++i) { )==" "\n" |
111 | R"==(tmp[i] = dst_copy[local_id * 4 + i]; )==" "\n" |
112 | R"==(} )==" "\n" |
113 | R"==(dst_iw_slm_copy[local_id] = as_uint(tmp); )==" "\n" |
114 | R"==(return; )==" "\n" |
115 | R"==(#endif )==" "\n" |
116 | R"==(block_write(dst_iw_slm_copy, )==" "\n" |
117 | R"==(intel_sub_group_block_read((const __global uint *)(dst_copy))); )==" "\n" |
118 | R"==(return; )==" "\n" |
119 | R"==(} )==" "\n" |
120 | R"==(#endif )==" "\n" |
121 | R"==(__attribute__((intel_reqd_sub_group_size(SUB_GROUP_SIZE))) )==" "\n" |
122 | R"==(__attribute__((reqd_work_group_size(LWS_0, LWS_1, LWS_2))) )==" "\n" |
123 | R"==(__kernel void )==" "\n" |
124 | R"==(conv_bwd_data_x8s8x8(const __global SRC_DATA_T *src, const __global char *wei, )==" "\n" |
125 | R"==(const __global float *bias, __global DATA_T *dst) { )==" "\n" |
126 | R"==(const int group_ic = get_group_id(0) * IC_GROUP; )==" "\n" |
127 | R"==(const int group_sp = get_group_id(1) * SP_GROUP; )==" "\n" |
128 | R"==(const int group_mb = get_group_id(2) * MB_GROUP; )==" "\n" |
129 | R"==(const int sub_group_id = get_sub_group_id(); )==" "\n" |
130 | R"==(const int sub_group_lid = get_sub_group_local_id(); )==" "\n" |
131 | R"==(const int ic = (sub_group_id % IC_GROUP); )==" "\n" |
132 | R"==(const int sp = (sub_group_id / IC_GROUP); )==" "\n" |
133 | R"==(const int g = (group_ic + ic) / IC_NCHUNK; )==" "\n" |
134 | R"==(const int group_oc = OC_NCHUNK * g; )==" "\n" |
135 | R"==(const int gid = group_sp / (IW_NCHUNK * IH); )==" "\n" |
136 | R"==(const int gihw = group_sp % (IW_NCHUNK * IH); )==" "\n" |
137 | R"==(const int gih = gihw / IW_NCHUNK; )==" "\n" |
138 | R"==(const int giw = IW_BLOCK * (gihw % IW_NCHUNK); )==" "\n" |
139 | R"==(const int id = gid; )==" "\n" |
140 | R"==(const int iw = giw + IW_BLOCK * sp; )==" "\n" |
141 | R"==(const int ih = gih; )==" "\n" |
142 | R"==(#if IS_NHWC )==" "\n" |
143 | R"==(dst += group_mb * MB_BLOCK * OD * OH * OW * G * OC; )==" "\n" |
144 | R"==(dst += OC_BLOCK * group_oc; )==" "\n" |
145 | R"==(src += group_mb * MB_BLOCK * ID * IH * IW * G * IC; )==" "\n" |
146 | R"==(src += (IW * IH * id + IW * ih + iw) * G * IC; )==" "\n" |
147 | R"==(src += (group_ic + ic) * IC_BLOCK; )==" "\n" |
148 | R"==(#else )==" "\n" |
149 | R"==(src += IC_BLOCK * ID * IH * IW * IC_NCHUNK * G * MB_BLOCK * group_mb; )==" "\n" |
150 | R"==(src += IC_BLOCK * ID * IH * IW * MB_BLOCK * (group_ic + ic); )==" "\n" |
151 | R"==(src += IC_BLOCK * MB_BLOCK * (IW * IH * id + IW * ih + iw); )==" "\n" |
152 | R"==(dst += OC_BLOCK * OD * OH * OW * OC_NCHUNK * G * MB_BLOCK * group_mb; )==" "\n" |
153 | R"==(dst += OC_BLOCK * OD * OH * OW * MB_BLOCK * group_oc; )==" "\n" |
154 | R"==(#endif )==" "\n" |
155 | R"==(wei += OC_BLOCK * KD * KH * KW * IC_BLOCK * (group_ic + ic) * OC_NCHUNK; )==" "\n" |
156 | R"==(ACC_DATA_BLOCK C00 = 0, C01 = 0, C02 = 0, C03 = 0; )==" "\n" |
157 | R"==(__local uint dst_slm[DST_SLM_SIZE]; )==" "\n" |
158 | R"==(__local uint *dst_iw_slm = dst_slm + (OC_BLOCK / 4) * sp * IW_BLOCK; )==" "\n" |
159 | R"==(__global DATA_T *dst_tmp = dst; )==" "\n" |
160 | R"==(for (int oc_chunk = 0; oc_chunk < OC_NCHUNK; oc_chunk++) { )==" "\n" |
161 | R"==(A_DATA_BLOCK_T D0; )==" "\n" |
162 | R"==(for (int kd = 0; kd < KD; kd++) { )==" "\n" |
163 | R"==(int od = id - kd * (1 + DD) + PD; )==" "\n" |
164 | R"==(if (od < 0 || od % SD != 0) { )==" "\n" |
165 | R"==(wei += IC_BLOCK * OC_BLOCK * KH * KW; )==" "\n" |
166 | R"==(continue; )==" "\n" |
167 | R"==(} )==" "\n" |
168 | R"==(od /= SD; )==" "\n" |
169 | R"==(if (od >= OD) { )==" "\n" |
170 | R"==(wei += IC_BLOCK * OC_BLOCK * KH * KW; )==" "\n" |
171 | R"==(continue; )==" "\n" |
172 | R"==(} )==" "\n" |
173 | R"==(for (int kh = 0; kh < KH; kh++) { )==" "\n" |
174 | R"==(int oh = (ih - kh * (1 + DH) + PH); )==" "\n" |
175 | R"==(if (oh < 0 || oh % SH != 0) { )==" "\n" |
176 | R"==(wei += IC_BLOCK * OC_BLOCK * KW; )==" "\n" |
177 | R"==(continue; )==" "\n" |
178 | R"==(} )==" "\n" |
179 | R"==(oh /= SH; )==" "\n" |
180 | R"==(if (oh >= OH) { )==" "\n" |
181 | R"==(wei += IC_BLOCK * OC_BLOCK * KW; )==" "\n" |
182 | R"==(continue; )==" "\n" |
183 | R"==(} )==" "\n" |
184 | R"==(#if IS_NHWC )==" "\n" |
185 | R"==(__global DATA_T *dst_cur )==" "\n" |
186 | R"==(= dst + (G * OC * (OW * OH * od + OW * oh)); )==" "\n" |
187 | R"==(#else )==" "\n" |
188 | R"==(__global DATA_T *dst_cur = dst )==" "\n" |
189 | R"==(+ (OC_BLOCK * MB_BLOCK * (OW * OH * od + OW * oh)); )==" "\n" |
190 | R"==(#endif )==" "\n" |
191 | R"==(barrier(CLK_LOCAL_MEM_FENCE); )==" "\n" |
192 | R"==(#if !HAS_PAD_W && SW == 1 && KW == 1 && !IS_NHWC && IW % IW_BLOCK == 0 )==" "\n" |
193 | R"==(int ow_min = (iw - (KW - 1) * (1 + DW)); )==" "\n" |
194 | R"==(int ow_max = (iw + IW_BLOCK - 1); )==" "\n" |
195 | R"==(__attribute__((opencl_unroll_hint)) for (int i = ow_min; )==" "\n" |
196 | R"==(i <= ow_max; )==" "\n" |
197 | R"==(i += IW_BLOCK) { )==" "\n" |
198 | R"==(if (i < 0 || i >= OW) { )==" "\n" |
199 | R"==(block_write(dst_iw_slm + (i - ow_min) * 8, 0); )==" "\n" |
200 | R"==(continue; )==" "\n" |
201 | R"==(} )==" "\n" |
202 | R"==(WRITE_LOCAL(dst_iw_slm + (i - ow_min) * 8, )==" "\n" |
203 | R"==(READ_BLOCK((const __global uint )==" "\n" |
204 | R"==(*)(&dst_cur[i * OC_BLOCK]))); )==" "\n" |
205 | R"==(} )==" "\n" |
206 | R"==(#else )==" "\n" |
207 | R"==(int ow_min = (iw - (KW - 1) * (1 + DW) + PW); )==" "\n" |
208 | R"==(int ow_max = (iw + IW_BLOCK - 1 + PW); )==" "\n" |
209 | R"==(__attribute__((opencl_unroll_hint)) for (int i = ow_min; )==" "\n" |
210 | R"==(i <= ow_max; i++) { )==" "\n" |
211 | R"==(if (i < 0 || i % SW != 0) { )==" "\n" |
212 | R"==(block_write(dst_iw_slm + (i - ow_min) * 8, 0); )==" "\n" |
213 | R"==(continue; )==" "\n" |
214 | R"==(} )==" "\n" |
215 | R"==(int index = i / SW; )==" "\n" |
216 | R"==(if (index >= OW) { )==" "\n" |
217 | R"==(block_write(dst_iw_slm + (i - ow_min) * 8, 0); )==" "\n" |
218 | R"==(continue; )==" "\n" |
219 | R"==(} )==" "\n" |
220 | R"==(#if IS_NHWC )==" "\n" |
221 | R"==(write_local(dst_iw_slm + (i - ow_min) * 8, oc_chunk, )==" "\n" |
222 | R"==(dst_cur + (index * G * OC)); )==" "\n" |
223 | R"==(#else )==" "\n" |
224 | R"==(block_write(dst_iw_slm + (i - ow_min) * 8, )==" "\n" |
225 | R"==(block_read((const __global uint )==" "\n" |
226 | R"==(*)(&dst_cur[index * OC_BLOCK]))); )==" "\n" |
227 | R"==(#endif )==" "\n" |
228 | R"==(} )==" "\n" |
229 | R"==(#endif )==" "\n" |
230 | R"==(barrier(CLK_LOCAL_MEM_FENCE); )==" "\n" |
231 | R"==(for (int kw = 0; kw < KW; kw++) { )==" "\n" |
232 | R"==(unroll_for(int i = 0; i < IW_BLOCK; i++) { )==" "\n" |
233 | R"==(int ow_index = (iw + i - kw * (1 + DW) + PW) - ow_min; )==" "\n" |
234 | R"==(D0[i] = block_read(dst_iw_slm + (ow_index * 8)); )==" "\n" |
235 | R"==(} )==" "\n" |
236 | R"==(int8 W0 = 0, W1 = 0, W2 = 0, W3 = 0; )==" "\n" |
237 | R"==(#if OC % OC_BLOCK != 0 )==" "\n" |
238 | R"==(if (oc_chunk == OC_NCHUNK - 1) { )==" "\n" |
239 | R"==(unroll_for(int i = 0; i < OC_NBLOCKS_TAIL; ++i) )==" "\n" |
240 | R"==(BLOCK_READ_WHT_1x32(W0[i], (i + 0) * OC_BLOCK); )==" "\n" |
241 | R"==(if (IC > 8) )==" "\n" |
242 | R"==(unroll_for(int i = 0; i < OC_NBLOCKS_TAIL; ++i) )==" "\n" |
243 | R"==(BLOCK_READ_WHT_1x32( )==" "\n" |
244 | R"==(W1[i], (i + 8) * OC_BLOCK); )==" "\n" |
245 | R"==(if (IC > 16) )==" "\n" |
246 | R"==(unroll_for(int i = 0; i < OC_NBLOCKS_TAIL; ++i) )==" "\n" |
247 | R"==(BLOCK_READ_WHT_1x32( )==" "\n" |
248 | R"==(W2[i], (i + 16) * OC_BLOCK); )==" "\n" |
249 | R"==(if (IC > 24) )==" "\n" |
250 | R"==(unroll_for(int i = 0; i < OC_NBLOCKS_TAIL; ++i) )==" "\n" |
251 | R"==(BLOCK_READ_WHT_1x32( )==" "\n" |
252 | R"==(W3[i], (i + 24) * OC_BLOCK); )==" "\n" |
253 | R"==(C00 = MMAD_TAIL(D0, W0, C00); )==" "\n" |
254 | R"==(if (IC > 8) C01 = MMAD_TAIL(D0, W1, C01); )==" "\n" |
255 | R"==(if (IC > 16) C02 = MMAD_TAIL(D0, W2, C02); )==" "\n" |
256 | R"==(if (IC > 24) C03 = MMAD_TAIL(D0, W3, C03); )==" "\n" |
257 | R"==(} else )==" "\n" |
258 | R"==(#endif )==" "\n" |
259 | R"==({ )==" "\n" |
260 | R"==(BLOCK_READ_WHT_8x32(W0, 0); )==" "\n" |
261 | R"==(if (IC > 8) BLOCK_READ_WHT_8x32(W1, 8 * OC_BLOCK); )==" "\n" |
262 | R"==(if (IC > 16) BLOCK_READ_WHT_8x32(W2, 16 * OC_BLOCK); )==" "\n" |
263 | R"==(if (IC > 24) BLOCK_READ_WHT_8x32(W3, 24 * OC_BLOCK); )==" "\n" |
264 | R"==(C00 = MMAD_FULL(D0, W0, C00); )==" "\n" |
265 | R"==(if (IC > 8) C01 = MMAD_FULL(D0, W1, C01); )==" "\n" |
266 | R"==(if (IC > 16) C02 = MMAD_FULL(D0, W2, C02); )==" "\n" |
267 | R"==(if (IC > 24) C03 = MMAD_FULL(D0, W3, C03); )==" "\n" |
268 | R"==(} )==" "\n" |
269 | R"==(wei += IC_BLOCK * OC_BLOCK; )==" "\n" |
270 | R"==(} )==" "\n" |
271 | R"==(} )==" "\n" |
272 | R"==(} )==" "\n" |
273 | R"==(#if IS_NHWC )==" "\n" |
274 | R"==(dst += OC_BLOCK; )==" "\n" |
275 | R"==(#else )==" "\n" |
276 | R"==(dst += OC_BLOCK * MB_BLOCK * OH * OW * OD; )==" "\n" |
277 | R"==(#endif )==" "\n" |
278 | R"==(} )==" "\n" |
279 | R"==(#define PACK(idx) \ )==" "\n" |
280 | R"==(BIAS_SUM_RELU(D00[0], tmp[0], C00[idx], bia[0]); \ )==" "\n" |
281 | R"==(BIAS_SUM_RELU(D00[1], tmp[1], C01[idx], bia[1]); \ )==" "\n" |
282 | R"==(BIAS_SUM_RELU(D00[2], tmp[2], C02[idx], bia[2]); \ )==" "\n" |
283 | R"==(BIAS_SUM_RELU(D00[3], tmp[3], C03[idx], bia[3]); \ )==" "\n" |
284 | R"==(src_pack[idx] = as_uint(D00); )==" "\n" |
285 | R"==(#if WITH_BIAS )==" "\n" |
286 | R"==(#define BIAS_SUM_RELU(RES, TMP, ACC, BIA) \ )==" "\n" |
287 | R"==(TMP = (float)ACC + BIA; \ )==" "\n" |
288 | R"==(RES = TO_SRC(TMP); )==" "\n" |
289 | R"==(#else )==" "\n" |
290 | R"==(#define BIAS_SUM_RELU(RES, TMP, ACC, BIA) RES = TO_SRC((float)ACC); )==" "\n" |
291 | R"==(#endif )==" "\n" |
292 | R"==(uchar4 D00; )==" "\n" |
293 | R"==(uint8 src_pack; )==" "\n" |
294 | R"==(float4 bia, tmp; )==" "\n" |
295 | R"==(BLOCK_READ_BIA(bia, (group_ic + ic) * IC_BLOCK); )==" "\n" |
296 | R"==(#if IS_NHWC )==" "\n" |
297 | R"==(#if IW_TAIL )==" "\n" |
298 | R"==(if (iw + IW_BLOCK > IW) { )==" "\n" |
299 | R"==(for (int i = 0; i < IW_TAIL; ++i) { )==" "\n" |
300 | R"==(PACK(i); )==" "\n" |
301 | R"==(} )==" "\n" |
302 | R"==(__attribute__((opencl_unroll_hint(IW_TAIL))) for (int i = 0; )==" "\n" |
303 | R"==(i < IW_TAIL; i++) { )==" "\n" |
304 | R"==(write_ic_block4(src + i * G * IC, (group_ic + ic) * IC_BLOCK, )==" "\n" |
305 | R"==(as_uchar4(src_pack[i])); )==" "\n" |
306 | R"==(} )==" "\n" |
307 | R"==(} else { )==" "\n" |
308 | R"==(#endif )==" "\n" |
309 | R"==(#if IW_BLOCK == 4 || IW_BLOCK == 8 )==" "\n" |
310 | R"==(for (int i = 0; i < IW_BLOCK; ++i) { )==" "\n" |
311 | R"==(PACK(i); )==" "\n" |
312 | R"==(} )==" "\n" |
313 | R"==(write_ic_block4(src + G * IC * 0, (group_ic + ic) * IC_BLOCK, )==" "\n" |
314 | R"==(as_uchar4(src_pack[0])); )==" "\n" |
315 | R"==(write_ic_block4(src + G * IC * 1, (group_ic + ic) * IC_BLOCK, )==" "\n" |
316 | R"==(as_uchar4(src_pack[1])); )==" "\n" |
317 | R"==(write_ic_block4(src + G * IC * 2, (group_ic + ic) * IC_BLOCK, )==" "\n" |
318 | R"==(as_uchar4(src_pack[2])); )==" "\n" |
319 | R"==(write_ic_block4(src + G * IC * 3, (group_ic + ic) * IC_BLOCK, )==" "\n" |
320 | R"==(as_uchar4(src_pack[3])); )==" "\n" |
321 | R"==(#endif )==" "\n" |
322 | R"==(#if IW_BLOCK == 8 )==" "\n" |
323 | R"==(write_ic_block4(src + G * IC * 4, (group_ic + ic) * IC_BLOCK, )==" "\n" |
324 | R"==(as_uchar4(src_pack[4])); )==" "\n" |
325 | R"==(write_ic_block4(src + G * IC * 5, (group_ic + ic) * IC_BLOCK, )==" "\n" |
326 | R"==(as_uchar4(src_pack[5])); )==" "\n" |
327 | R"==(write_ic_block4(src + G * IC * 6, (group_ic + ic) * IC_BLOCK, )==" "\n" |
328 | R"==(as_uchar4(src_pack[6])); )==" "\n" |
329 | R"==(write_ic_block4(src + G * IC * 7, (group_ic + ic) * IC_BLOCK, )==" "\n" |
330 | R"==(as_uchar4(src_pack[7])); )==" "\n" |
331 | R"==(#endif )==" "\n" |
332 | R"==(#if IW_TAIL )==" "\n" |
333 | R"==(} )==" "\n" |
334 | R"==(#endif )==" "\n" |
335 | R"==(#else )==" "\n" |
336 | R"==(#if IW_TAIL )==" "\n" |
337 | R"==(if (iw + IW_BLOCK > IW) { )==" "\n" |
338 | R"==(for (int i = 0; i < IW_TAIL; ++i) { )==" "\n" |
339 | R"==(PACK(i); )==" "\n" |
340 | R"==(} )==" "\n" |
341 | R"==(__attribute__((opencl_unroll_hint(IW_TAIL))) for (int i = 0; )==" "\n" |
342 | R"==(i < IW_TAIL; i++) { )==" "\n" |
343 | R"==(intel_sub_group_block_write_uc4( )==" "\n" |
344 | R"==((__global uchar *)&src[i * IC_BLOCK], )==" "\n" |
345 | R"==(as_uchar4(src_pack[i])); )==" "\n" |
346 | R"==(} )==" "\n" |
347 | R"==(} else { )==" "\n" |
348 | R"==(#endif )==" "\n" |
349 | R"==(#if IW_BLOCK == 4 || IW_BLOCK == 8 )==" "\n" |
350 | R"==(for (int i = 0; i < IW_BLOCK; ++i) { )==" "\n" |
351 | R"==(PACK(i); )==" "\n" |
352 | R"==(} )==" "\n" |
353 | R"==(intel_sub_group_block_write_uc16((__global uchar *)&src[0 * IC_BLOCK], )==" "\n" |
354 | R"==(as_uchar16(src_pack.s0123)); )==" "\n" |
355 | R"==(#endif )==" "\n" |
356 | R"==(#if IW_BLOCK == 8 )==" "\n" |
357 | R"==(intel_sub_group_block_write_uc16((__global uchar *)&src[4 * IC_BLOCK], )==" "\n" |
358 | R"==(as_uchar16(src_pack.s4567)); )==" "\n" |
359 | R"==(#endif )==" "\n" |
360 | R"==(#if IW_TAIL )==" "\n" |
361 | R"==(} )==" "\n" |
362 | R"==(#endif )==" "\n" |
363 | R"==(#endif )==" "\n" |
364 | R"==(} )==" "\n" |
365 | R"==()==" ; |
366 | } |
367 | } |
368 | } |
369 | } |