mirror of
https://github.com/pithings/unkernel.git
synced 2026-12-06 06:09:51 +08:00
19 lines
556 B
Plaintext
19 lines
556 B
Plaintext
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
// Copyright (C) 2026 Pooya Parsa <pooya@pi0.io>
|
|
#version 450
|
|
// 512 invocations reducing through shared memory (ggml's norm family): on a
|
|
// device allowing 256 the workgroup cannot be split, so no pipeline.
|
|
layout(local_size_x = 512) in;
|
|
layout(set = 0, binding = 0) buffer B { float v[]; } b;
|
|
shared float s[512];
|
|
void main() {
|
|
uint i = gl_LocalInvocationID.x;
|
|
s[i] = b.v[i];
|
|
barrier();
|
|
for (uint k = 256u; k > 0u; k >>= 1) {
|
|
if (i < k) s[i] += s[i + k];
|
|
barrier();
|
|
}
|
|
if (i == 0u) b.v[0] = s[0];
|
|
}
|