interplane.Get Omega
Read in your language

ggml

[Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685)

Brought by drakestapleton

branch master Branches Tags History

ggml / src / ggml-opencl / kernels / gemm_noshuffle_q4_k_f32.cl

490 lines · 19198 bytes Raw Blame History
1#pragma OPENCL EXTENSION cl_khr_fp16 : enable
2
3#ifdef cl_qcom_reqd_sub_group_size
4#pragma OPENCL EXTENSION cl_qcom_reqd_sub_group_size : enable
5#define ADRENO_GPU 1
6#define REQD_SUBGROUP_SIZE_128 __attribute__((qcom_reqd_sub_group_size("full")))
7#define REQD_SUBGROUP_SIZE_64 __attribute__((qcom_reqd_sub_group_size("half")))
8#endif
9#define QK_K 256
10#define K_SCALE_SIZE 12
11
12// scales are transposed: consecutive codes of a row are `stride` apart
13inline void get_scale_min_k4(
14 int j,
15 global const uchar * q,
16 int stride,
17 uchar * d,
18 uchar * m,
19 uchar mask_d6,
20 uchar mask_d4,
21 uchar mask_hi2
22) {
23 if (j < 4) {
24 *d = q[j*stride] & mask_d6;
25 *m = q[(j+4)*stride] & mask_d6;
26 } else {
27 *d = (q[(j+4)*stride] & mask_d4) | ((q[(j-4)*stride] & mask_hi2) >> 2);
28 *m = ((q[(j+4)*stride] >> 4) & mask_d4) | ((q[j*stride] & mask_hi2) >> 2);
29 }
30}
31
32#ifdef ADRENO_GPU
33REQD_SUBGROUP_SIZE_128
34#endif
35kernel void kernel_gemm_noshuffle_q4_k_f32(
36 global const ushort * src0_q,
37 global const uchar * src0_s,
38 global const half * src0_d,
39 global const half * src0_dm,
40 read_only image1d_buffer_t src1,
41 global float * dst,
42 ulong offsetd,
43 int m,
44 int n,
45 int k,
46 int n_no_padding,
47 uchar mask_d6,
48 uchar mask_d4,
49 uchar mask_hi2
50) {
51 dst = (global float *)((global char *)dst + offsetd);
52 int n_4 = n >> 2;
53 int gy = get_global_id(0);
54 int gx = get_global_id(1);
55 int gx_2 = gx << 2;
56
57 half8 c0 = 0, c1 = 0, c2 = 0, c3 = 0;
58 half8 B;
59 half4 dequantized_weights;
60
61
62 global const ushort * weight_ptr = src0_q + gx_2;
63 global const half * d_ptr = src0_d + gx_2;
64 global const half * dm_ptr = src0_dm + gx_2;
65
66 for (int i = 0; i < k; i += 32) {
67 int sb_idx = i / QK_K;
68 int sub_idx = (i / 32) % 8;
69
70 half4 d = vload4(0, d_ptr + sb_idx * m);
71 half4 dm = vload4(0, dm_ptr + sb_idx * m);
72
73 global const uchar * sc0 = src0_s + sb_idx * K_SCALE_SIZE * m + (gx_2+0);
74 global const uchar * sc1 = sc0 + 1;
75 global const uchar * sc2 = sc0 + 2;
76 global const uchar * sc3 = sc0 + 3;
77
78 uchar sv0, mn0, sv1, mn1, sv2, mn2, sv3, mn3;
79 get_scale_min_k4(sub_idx, sc0, m, &sv0, &mn0, mask_d6, mask_d4, mask_hi2);
80 get_scale_min_k4(sub_idx, sc1, m, &sv1, &mn1, mask_d6, mask_d4, mask_hi2);
81 get_scale_min_k4(sub_idx, sc2, m, &sv2, &mn2, mask_d6, mask_d4, mask_hi2);
82 get_scale_min_k4(sub_idx, sc3, m, &sv3, &mn3, mask_d6, mask_d4, mask_hi2);
83
84 half4 scale = convert_half4(convert_float4(d) * convert_float4((uchar4)(sv0, sv1, sv2, sv3)));
85 half4 mval = convert_half4(convert_float4(dm) * convert_float4((uchar4)(mn0, mn1, mn2, mn3)));
86
87 for (int l = 0; l < 32; l += 4) {
88 int ki = i + l;
89 ushort4 bits4 = vload4(0, weight_ptr + (ki/4) * m);
90
91 // j=0
92 B.s0123 = read_imageh(src1, gy*2 + (ki+0) * n_4);
93 B.s4567 = read_imageh(src1, gy*2+1 + (ki+0) * n_4);
94 dequantized_weights.s0 = (bits4.s0 & 0x000F) * scale.s0 - mval.s0;
95 dequantized_weights.s1 = (bits4.s1 & 0x000F) * scale.s1 - mval.s1;
96 dequantized_weights.s2 = (bits4.s2 & 0x000F) * scale.s2 - mval.s2;
97 dequantized_weights.s3 = (bits4.s3 & 0x000F) * scale.s3 - mval.s3;
98 c0 += B * dequantized_weights.s0;
99 c1 += B * dequantized_weights.s1;
100 c2 += B * dequantized_weights.s2;
101 c3 += B * dequantized_weights.s3;
102
103 // j=1
104 B.s0123 = read_imageh(src1, gy*2 + (ki+1) * n_4);
105 B.s4567 = read_imageh(src1, gy*2+1 + (ki+1) * n_4);
106 dequantized_weights.s0 = ((bits4.s0 & 0x00F0) >> 4) * scale.s0 - mval.s0;
107 dequantized_weights.s1 = ((bits4.s1 & 0x00F0) >> 4) * scale.s1 - mval.s1;
108 dequantized_weights.s2 = ((bits4.s2 & 0x00F0) >> 4) * scale.s2 - mval.s2;
109 dequantized_weights.s3 = ((bits4.s3 & 0x00F0) >> 4) * scale.s3 - mval.s3;
110 c0 += B * dequantized_weights.s0;
111 c1 += B * dequantized_weights.s1;
112 c2 += B * dequantized_weights.s2;
113 c3 += B * dequantized_weights.s3;
114
115 // j=2
116 B.s0123 = read_imageh(src1, gy*2 + (ki+2) * n_4);
117 B.s4567 = read_imageh(src1, gy*2+1 + (ki+2) * n_4);
118 dequantized_weights.s0 = ((bits4.s0 & 0x0F00) >> 8) * scale.s0 - mval.s0;
119 dequantized_weights.s1 = ((bits4.s1 & 0x0F00) >> 8) * scale.s1 - mval.s1;
120 dequantized_weights.s2 = ((bits4.s2 & 0x0F00) >> 8) * scale.s2 - mval.s2;
121 dequantized_weights.s3 = ((bits4.s3 & 0x0F00) >> 8) * scale.s3 - mval.s3;
122 c0 += B * dequantized_weights.s0;
123 c1 += B * dequantized_weights.s1;
124 c2 += B * dequantized_weights.s2;
125 c3 += B * dequantized_weights.s3;
126
127 // j=3
128 B.s0123 = read_imageh(src1, gy*2 + (ki+3) * n_4);
129 B.s4567 = read_imageh(src1, gy*2+1 + (ki+3) * n_4);
130 dequantized_weights.s0 = ((bits4.s0 & 0xF000) >> 12) * scale.s0 - mval.s0;
131 dequantized_weights.s1 = ((bits4.s1 & 0xF000) >> 12) * scale.s1 - mval.s1;
132 dequantized_weights.s2 = ((bits4.s2 & 0xF000) >> 12) * scale.s2 - mval.s2;
133 dequantized_weights.s3 = ((bits4.s3 & 0xF000) >> 12) * scale.s3 - mval.s3;
134 c0 += B * dequantized_weights.s0;
135 c1 += B * dequantized_weights.s1;
136 c2 += B * dequantized_weights.s2;
137 c3 += B * dequantized_weights.s3;
138 }
139 }
140
141 int idx = (gy<<3)*m + (gx<<2);
142
143 if (idx+3 < m*n_no_padding) {
144 vstore4((float4)(c0.s0, c1.s0, c2.s0, c3.s0), 0, dst + idx);
145 idx += m;
146 }
147 if (idx+3 < m*n_no_padding) {
148 vstore4((float4)(c0.s1, c1.s1, c2.s1, c3.s1), 0, dst + idx);
149 idx += m;
150 }
151 if (idx+3 < m*n_no_padding) {
152 vstore4((float4)(c0.s2, c1.s2, c2.s2, c3.s2), 0, dst + idx);
153 idx += m;
154 }
155 if (idx+3 < m*n_no_padding) {
156 vstore4((float4)(c0.s3, c1.s3, c2.s3, c3.s3), 0, dst + idx);
157 idx += m;
158 }
159 if (idx+3 < m*n_no_padding) {
160 vstore4((float4)(c0.s4, c1.s4, c2.s4, c3.s4), 0, dst + idx);
161 idx += m;
162 }
163 if (idx+3 < m*n_no_padding) {
164 vstore4((float4)(c0.s5, c1.s5, c2.s5, c3.s5), 0, dst + idx);
165 idx += m;
166 }
167 if (idx+3 < m*n_no_padding) {
168 vstore4((float4)(c0.s6, c1.s6, c2.s6, c3.s6), 0, dst + idx);
169 idx += m;
170 }
171 if (idx+3 < m*n_no_padding) {
172 vstore4((float4)(c0.s7, c1.s7, c2.s7, c3.s7), 0, dst + idx);
173 }
174}
175
176// 1x8 per-WI tile (1 output row x 8 output cols). For the small-batch
177// (medium n_q, e.g. MTP/spec verify) path where the 2x8 kernel is starved:
178// at ne1<=8 the grid is (1, ceil(M/2)) -> only ~M/256 workgroups, leaving
179// the SP under-occupied. 1 row per WI doubles the M-axis workgroup count
180// (ceil(M/1)/128 vs ceil(M/2)/128) AND collapses the accumulators to a
181// single half8 (16 regs, no spill), so more waves co-reside. Same weight
182// traffic as 2x8 (rows never share weights); the win is pure occupancy.
183#ifdef ADRENO_GPU
184REQD_SUBGROUP_SIZE_128
185#endif
186kernel void kernel_gemm_noshuffle_q4_k_f32_r1(
187 global const ushort * src0_q,
188 global const uchar * src0_s,
189 global const half * src0_d,
190 global const half * src0_dm,
191 read_only image1d_buffer_t src1,
192 global float * dst,
193 ulong offsetd,
194 int m,
195 int n,
196 int k,
197 int n_no_padding,
198 uchar mask_d6,
199 uchar mask_d4,
200 uchar mask_hi2
201) {
202 dst = (global float *)((global char *)dst + offsetd);
203 int n_4 = n >> 2;
204 int gy = get_global_id(0);
205 int gx = get_global_id(1); // 1 row per WI
206
207 half8 c0 = 0;
208 half8 B;
209 half dq;
210
211 int num_blocks_K = k / QK_K;
212
213 global const ushort * weight_ptr = src0_q + gx;
214 global const half * d_ptr = src0_d + gx;
215 global const half * dm_ptr = src0_dm + gx;
216
217 for (int i = 0; i < k; i += 32) {
218 int sb_idx = i / QK_K;
219 int sub_idx = (i / 32) % 8;
220
221 half dd = d_ptr [sb_idx * m];
222 half dmm = dm_ptr[sb_idx * m];
223
224 global const uchar * sc0 = src0_s + sb_idx * K_SCALE_SIZE * m + gx;
225
226 uchar sv0, mn0;
227 get_scale_min_k4(sub_idx, sc0, m, &sv0, &mn0, mask_d6, mask_d4, mask_hi2);
228
229 half scale = convert_half(convert_float(dd) * (float)sv0);
230 half mval = convert_half(convert_float(dmm) * (float)mn0);
231
232 for (int l = 0; l < 32; l += 4) {
233 int ki = i + l;
234 ushort bits = weight_ptr[(ki/4) * m];
235
236 B.s0123 = read_imageh(src1, gy*2 + (ki+0) * n_4);
237 B.s4567 = read_imageh(src1, gy*2+1 + (ki+0) * n_4);
238 dq = (bits & 0x000F) * scale - mval;
239 c0 += B * dq;
240
241 B.s0123 = read_imageh(src1, gy*2 + (ki+1) * n_4);
242 B.s4567 = read_imageh(src1, gy*2+1 + (ki+1) * n_4);
243 dq = ((bits & 0x00F0) >> 4) * scale - mval;
244 c0 += B * dq;
245
246 B.s0123 = read_imageh(src1, gy*2 + (ki+2) * n_4);
247 B.s4567 = read_imageh(src1, gy*2+1 + (ki+2) * n_4);
248 dq = ((bits & 0x0F00) >> 8) * scale - mval;
249 c0 += B * dq;
250
251 B.s0123 = read_imageh(src1, gy*2 + (ki+3) * n_4);
252 B.s4567 = read_imageh(src1, gy*2+1 + (ki+3) * n_4);
253 dq = ((bits & 0xF000) >> 12) * scale - mval;
254 c0 += B * dq;
255 }
256 }
257
258 // Output: 8 cols, 1 row per col-step. Scalar store, coalesced across
259 // neighbouring WIs (consecutive gx -> consecutive dst addresses).
260 int idx = (gy<<3)*m + gx;
261 if (idx < m*n_no_padding) { dst[idx] = c0.s0; idx += m; }
262 if (idx < m*n_no_padding) { dst[idx] = c0.s1; idx += m; }
263 if (idx < m*n_no_padding) { dst[idx] = c0.s2; idx += m; }
264 if (idx < m*n_no_padding) { dst[idx] = c0.s3; idx += m; }
265 if (idx < m*n_no_padding) { dst[idx] = c0.s4; idx += m; }
266 if (idx < m*n_no_padding) { dst[idx] = c0.s5; idx += m; }
267 if (idx < m*n_no_padding) { dst[idx] = c0.s6; idx += m; }
268 if (idx < m*n_no_padding) { dst[idx] = c0.s7; }
269}
270
271// 2x8 tile, but weights read through an image1d_buffer (CL_R/UINT32 over the
272// same packed-q buffer) instead of a plain global buffer. The ne1==1 GEMV
273// already does this and is much faster per weight byte than this GEMM at
274// small n_q; the structural difference is the image path hits the dedicated
275// TPL1 weight cache (L1) while the global path only reaches L2. At small n_q
276// the forward is weight-read-bound, so L1-cached weights is the lever.
277// The 2 adjacent rows the 2x8 tile reads as a ushort2 are exactly one uint32,
278// so the vload2 becomes a single read_imageui at index gx + (ki/4)*(m/2).
279#ifdef ADRENO_GPU
280REQD_SUBGROUP_SIZE_128
281#endif
282kernel void kernel_gemm_noshuffle_q4_k_f32_kimg(
283 read_only image1d_buffer_t src0_q_img,
284 global const uchar * src0_s,
285 global const half * src0_d,
286 global const half * src0_dm,
287 read_only image1d_buffer_t src1,
288 global float * dst,
289 ulong offsetd,
290 int m,
291 int n,
292 int k,
293 int n_no_padding,
294 uchar mask_d6,
295 uchar mask_d4,
296 uchar mask_hi2
297) {
298 dst = (global float *)((global char *)dst + offsetd);
299 int n_4 = n >> 2;
300 int m_2 = m >> 1;
301 int gy = get_global_id(0);
302 int gx = get_global_id(1);
303 int gx_2 = gx << 1;
304
305 half8 c0 = 0, c1 = 0;
306 half8 B;
307 half2 dequantized_weights;
308
309 int num_blocks_K = k / QK_K;
310
311 global const half * d_ptr = src0_d + gx_2;
312 global const half * dm_ptr = src0_dm + gx_2;
313
314 for (int i = 0; i < k; i += 32) {
315 int sb_idx = i / QK_K;
316 int sub_idx = (i / 32) % 8;
317
318 half2 d = vload2(0, d_ptr + sb_idx * m);
319 half2 dm = vload2(0, dm_ptr + sb_idx * m);
320
321 global const uchar * sc0 = src0_s + sb_idx * K_SCALE_SIZE * m + (gx_2+0);
322 global const uchar * sc1 = sc0 + 1;
323
324 uchar sv0, mn0, sv1, mn1;
325 get_scale_min_k4(sub_idx, sc0, m, &sv0, &mn0, mask_d6, mask_d4, mask_hi2);
326 get_scale_min_k4(sub_idx, sc1, m, &sv1, &mn1, mask_d6, mask_d4, mask_hi2);
327
328 half2 scale = convert_half2(convert_float2(d) * convert_float2((uchar2)(sv0, sv1)));
329 half2 mval = convert_half2(convert_float2(dm) * convert_float2((uchar2)(mn0, mn1)));
330
331 for (int l = 0; l < 32; l += 4) {
332 int ki = i + l;
333 uint wpacked = read_imageui(src0_q_img, gx + (ki/4) * m_2).x;
334 ushort2 bits2 = (ushort2)((ushort)(wpacked & 0xFFFFu), (ushort)(wpacked >> 16));
335
336 // j=0
337 B.s0123 = read_imageh(src1, gy*2 + (ki+0) * n_4);
338 B.s4567 = read_imageh(src1, gy*2+1 + (ki+0) * n_4);
339 dequantized_weights.s0 = (bits2.s0 & 0x000F) * scale.s0 - mval.s0;
340 dequantized_weights.s1 = (bits2.s1 & 0x000F) * scale.s1 - mval.s1;
341 c0 += B * dequantized_weights.s0;
342 c1 += B * dequantized_weights.s1;
343
344 // j=1
345 B.s0123 = read_imageh(src1, gy*2 + (ki+1) * n_4);
346 B.s4567 = read_imageh(src1, gy*2+1 + (ki+1) * n_4);
347 dequantized_weights.s0 = ((bits2.s0 & 0x00F0) >> 4) * scale.s0 - mval.s0;
348 dequantized_weights.s1 = ((bits2.s1 & 0x00F0) >> 4) * scale.s1 - mval.s1;
349 c0 += B * dequantized_weights.s0;
350 c1 += B * dequantized_weights.s1;
351
352 // j=2
353 B.s0123 = read_imageh(src1, gy*2 + (ki+2) * n_4);
354 B.s4567 = read_imageh(src1, gy*2+1 + (ki+2) * n_4);
355 dequantized_weights.s0 = ((bits2.s0 & 0x0F00) >> 8) * scale.s0 - mval.s0;
356 dequantized_weights.s1 = ((bits2.s1 & 0x0F00) >> 8) * scale.s1 - mval.s1;
357 c0 += B * dequantized_weights.s0;
358 c1 += B * dequantized_weights.s1;
359
360 // j=3
361 B.s0123 = read_imageh(src1, gy*2 + (ki+3) * n_4);
362 B.s4567 = read_imageh(src1, gy*2+1 + (ki+3) * n_4);
363 dequantized_weights.s0 = ((bits2.s0 & 0xF000) >> 12) * scale.s0 - mval.s0;
364 dequantized_weights.s1 = ((bits2.s1 & 0xF000) >> 12) * scale.s1 - mval.s1;
365 c0 += B * dequantized_weights.s0;
366 c1 += B * dequantized_weights.s1;
367 }
368 }
369
370 int idx = (gy<<3)*m + (gx<<1);
371 if (idx+1 < m*n_no_padding) { vstore2((float2)(c0.s0, c1.s0), 0, dst + idx); idx += m; }
372 if (idx+1 < m*n_no_padding) { vstore2((float2)(c0.s1, c1.s1), 0, dst + idx); idx += m; }
373 if (idx+1 < m*n_no_padding) { vstore2((float2)(c0.s2, c1.s2), 0, dst + idx); idx += m; }
374 if (idx+1 < m*n_no_padding) { vstore2((float2)(c0.s3, c1.s3), 0, dst + idx); idx += m; }
375 if (idx+1 < m*n_no_padding) { vstore2((float2)(c0.s4, c1.s4), 0, dst + idx); idx += m; }
376 if (idx+1 < m*n_no_padding) { vstore2((float2)(c0.s5, c1.s5), 0, dst + idx); idx += m; }
377 if (idx+1 < m*n_no_padding) { vstore2((float2)(c0.s6, c1.s6), 0, dst + idx); idx += m; }
378 if (idx+1 < m*n_no_padding) { vstore2((float2)(c0.s7, c1.s7), 0, dst + idx); }
379}
380
381// Cooperative-K GEMM for the small-batch (n_q in [2..8]) path. Mirrors the
382// ne1==1 GEMV's structure: a WG is (COK_SG lanes x COK_NSG subgroups); each
383// lane owns ONE output row and computes its 8 (padded) columns, and the
384// COK_NSG subgroups SPLIT the K reduction round-robin, combining via a
385// __local reduction. This is the thing the per-WI GEMM lacked — at small n_q
386// the old kernel had ~M/256 workgroups each walking all of K serially; this
387// has M/64 workgroups AND COK_NSG-way K parallelism. Uses REQD_SUBGROUP_SIZE_64
388// + barrier (same safe reduction pattern as the GEMV; never sub_group_reduce
389// at full width on X2 per the GDN miscompile note).
390#define COK_NSG 8
391#define COK_SG 64
392#ifdef ADRENO_GPU
393REQD_SUBGROUP_SIZE_64
394#endif
395kernel void kernel_gemm_noshuffle_q4_k_f32_cok(
396 global const ushort * src0_q,
397 global const uchar * src0_s,
398 global const half * src0_d,
399 global const half * src0_dm,
400 read_only image1d_buffer_t src1,
401 global float * dst,
402 ulong offsetd,
403 int m,
404 int n,
405 int k,
406 int n_no_padding,
407 uchar mask_d6,
408 uchar mask_d4,
409 uchar mask_hi2
410) {
411 dst = (global float *)((global char *)dst + offsetd);
412 int n_4 = n >> 2;
413 int gx = get_global_id(0); // output row
414 int sg = get_local_id(1); // subgroup index (K-split lane)
415 int lane = get_local_id(0); // lane within subgroup (0..COK_SG-1)
416
417 int num_blocks_K = k / QK_K;
418 int num_32blk = k / 32;
419
420 global const ushort * weight_ptr = src0_q + gx;
421 global const half * d_ptr = src0_d + gx;
422 global const half * dm_ptr = src0_dm + gx;
423
424 half8 acc = 0;
425 half8 B;
426 half dq;
427
428 for (int blk = sg; blk < num_32blk; blk += COK_NSG) {
429 int i = blk << 5; // blk * 32
430 int sb_idx = blk >> 3; // (blk*32) / QK_K (QK_K = 256 = 32*8)
431 int sub_idx = blk & 7; // (i/32) % 8
432
433 half dd = d_ptr [sb_idx * m];
434 half dmm = dm_ptr[sb_idx * m];
435
436 global const uchar * sc0 = src0_s + sb_idx * K_SCALE_SIZE * m + gx;
437 uchar sv0, mn0;
438 get_scale_min_k4(sub_idx, sc0, m, &sv0, &mn0, mask_d6, mask_d4, mask_hi2);
439 half scale = convert_half(convert_float(dd) * (float)sv0);
440 half mval = convert_half(convert_float(dmm) * (float)mn0);
441
442 for (int l = 0; l < 32; l += 4) {
443 int ki = i + l;
444 ushort bits = weight_ptr[(ki>>2) * m];
445
446 B.s0123 = read_imageh(src1, (ki+0) * n_4);
447 B.s4567 = read_imageh(src1, 1 + (ki+0) * n_4);
448 dq = (bits & 0x000F) * scale - mval;
449 acc += B * dq;
450
451 B.s0123 = read_imageh(src1, (ki+1) * n_4);
452 B.s4567 = read_imageh(src1, 1 + (ki+1) * n_4);
453 dq = ((bits & 0x00F0) >> 4) * scale - mval;
454 acc += B * dq;
455
456 B.s0123 = read_imageh(src1, (ki+2) * n_4);
457 B.s4567 = read_imageh(src1, 1 + (ki+2) * n_4);
458 dq = ((bits & 0x0F00) >> 8) * scale - mval;
459 acc += B * dq;
460
461 B.s0123 = read_imageh(src1, (ki+3) * n_4);
462 B.s4567 = read_imageh(src1, 1 + (ki+3) * n_4);
463 dq = ((bits & 0xF000) >> 12) * scale - mval;
464 acc += B * dq;
465 }
466 }
467
468 // cross-subgroup reduction over the K-split (float for accuracy)
469 local float8 reduceLM[COK_SG * (COK_NSG - 1)];
470 if (sg > 0) {
471 reduceLM[(sg - 1) * COK_SG + lane] = convert_float8(acc);
472 }
473 barrier(CLK_LOCAL_MEM_FENCE);
474
475 if (sg == 0) {
476 float8 sum = convert_float8(acc);
477 for (int s = 0; s < COK_NSG - 1; s++) {
478 sum += reduceLM[s * COK_SG + lane];
479 }
480 int idx = gx;
481 if (idx < m*n_no_padding) { dst[idx] = sum.s0; idx += m; }
482 if (idx < m*n_no_padding) { dst[idx] = sum.s1; idx += m; }
483 if (idx < m*n_no_padding) { dst[idx] = sum.s2; idx += m; }
484 if (idx < m*n_no_padding) { dst[idx] = sum.s3; idx += m; }
485 if (idx < m*n_no_padding) { dst[idx] = sum.s4; idx += m; }
486 if (idx < m*n_no_padding) { dst[idx] = sum.s5; idx += m; }
487 if (idx < m*n_no_padding) { dst[idx] = sum.s6; idx += m; }
488 if (idx < m*n_no_padding) { dst[idx] = sum.s7; }
489 }
490}