File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed
ggml/src/ggml-vulkan/vulkan-shaders Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -49,16 +49,14 @@ float warp_reduce_sum(float val) {
4949 warp_sdata[warp_offset + lane] = val;
5050 barrier();
5151
52- if (lane < 16) warp_sdata[warp_offset + lane] += warp_sdata[warp_offset + lane + 16];
53- barrier();
54- if (lane < 8) warp_sdata[warp_offset + lane] += warp_sdata[warp_offset + lane + 8];
55- barrier();
56- if (lane < 4) warp_sdata[warp_offset + lane] += warp_sdata[warp_offset + lane + 4];
57- barrier();
58- if (lane < 2) warp_sdata[warp_offset + lane] += warp_sdata[warp_offset + lane + 2];
59- barrier();
60- if (lane < 1) warp_sdata[warp_offset + lane] += warp_sdata[warp_offset + lane + 1];
61- barrier();
52+ int offset = WARP_SIZE / 2;
53+ while (offset > 0) {
54+ if (lane < offset) {
55+ warp_sdata[warp_offset + lane] += warp_sdata[warp_offset + lane + offset];
56+ }
57+ barrier();
58+ offset >>= 1;
59+ }
6260
6361 return warp_sdata[warp_offset];
6462}
You can’t perform that action at this time.
0 commit comments