]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
metal : avoid `threadgroup` matrix array instantiation in kernel_lightning_indexer...
authorJamePeng <redacted>
Fri, 7 Aug 2026 04:49:14 +0000 (12:49 +0800)
committerGitHub <redacted>
Fri, 7 Aug 2026 04:49:14 +0000 (07:49 +0300)
- In MSL, declaring an array of matrix types like `threadgroup half4x4` causes
a 'no matching constructor' compilation error because MSL matrix types do not
have zero-argument default constructors and threadgroup variables cannot have
initializers.

- Fix this by declaring a POD `threadgroup half` array instead and casting
to `threadgroup half4x4 *` for matrix indexing.

Signed-off-by: JamePeng <redacted>
ggml/src/ggml-metal/ggml-metal.metal

index 7d12cb0fe39ba5707df08677feb5e2978c8bbd68..92258b73749823ff5942cee12286dbb12349df08 100644 (file)
@@ -11328,8 +11328,8 @@ kernel void kernel_lightning_indexer(
     const int i_kv_0   = tgpig.x*NK;            // first key of this threadgroup
     const int i_kv     = i_kv_0 + sgitg*NKPSG;  // first key of this simdgroup
 
-    threadgroup half4x4   sk4x4[NK*DK16];
-    threadgroup half    * sk = (threadgroup half *) sk4x4;
+    threadgroup half sk[NK * DK16 * 16];
+    threadgroup half4x4 * sk4x4 = (threadgroup half4x4 *) sk;
 
     for (short i = tiitg; i < NK*DK16; i += NTG) {
         const short ik  = i/DK16;