]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commit
vulkan: Optimize argsort (#15354)
authorJeff Bolz <redacted>
Sun, 17 Aug 2025 08:41:45 +0000 (03:41 -0500)
committerGitHub <redacted>
Sun, 17 Aug 2025 08:41:45 +0000 (10:41 +0200)
commitde5627910df74298c998e6bb36ee3217375a5719
tree6b3562027711f565826e5b01ce1e7ebbb5c81dd9
parent65349f26f2299e06477ec8e85e46243046801358
vulkan: Optimize argsort (#15354)

- Launch an appropriate number of invocations (next larger power of two).
32 invocations is common and the barrier is much cheaper there.
- Specialize for "needs bounds checking" vs not.
- Make the code less branchy and [[unroll]] the loops. In the final code,
I see no branches inside the main loop (only predicated stores) when
needs_bounds_check is false.
- Always sort ascending, then apply the ascending vs descending option when
doing the final stores to memory.
- Copy the values into shared memory, makes them slightly cheaper to access.
ggml/src/ggml-vulkan/ggml-vulkan.cpp
ggml/src/ggml-vulkan/vulkan-shaders/argsort.comp
tests/test-backend-ops.cpp