From 7bbb7a17a6248e5c23286567fee793d0a3c99bcd Mon Sep 17 00:00:00 2001 From: Piotr Wilkin Date: Sat, 16 May 2026 15:47:06 +0200 Subject: [PATCH] Add missing unrolls --- ggml/src/ggml-vulkan/vulkan-shaders/types.glsl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ggml/src/ggml-vulkan/vulkan-shaders/types.glsl b/ggml/src/ggml-vulkan/vulkan-shaders/types.glsl index adb1bb8b32..1943cfc999 100644 --- a/ggml/src/ggml-vulkan/vulkan-shaders/types.glsl +++ b/ggml/src/ggml-vulkan/vulkan-shaders/types.glsl @@ -6,6 +6,7 @@ #extension GL_EXT_shader_explicit_arithmetic_types_int16 : require #extension GL_EXT_shader_explicit_arithmetic_types_int8 : require #extension GL_EXT_shader_16bit_storage : require +#extension GL_EXT_control_flow_attributes : require #ifdef USE_OCP_FP4 #extension GL_EXT_float_e2m1 : require @@ -1816,7 +1817,9 @@ shared FLOAT_TYPE kvalues_iq4nl[16]; void init_iq_shmem(uvec3 wgsize) { // copy the table into shared memory and sync - for (uint i = gl_LocalInvocationIndex.x; i < kvalues_iq4nl.length(); i += wgsize.x) { + // Use gl_LocalInvocationIndex (uint scalar) directly - each thread loads its portion + // with stride equal to workgroup size for coalesced shared memory writes + [[unroll]] for (uint i = gl_LocalInvocationIndex; i < kvalues_iq4nl.length(); i += wgsize.x) { kvalues_iq4nl[i] = FLOAT_TYPE(kvalues_iq4nl_const[i]); } barrier(); @@ -1856,11 +1859,12 @@ float ue4m3_to_fp32_build(uint u) { void init_iq_shmem(uvec3 wgsize) { // copy the table into shared memory and sync - for (uint i = gl_LocalInvocationIndex.x; i < kvalues_mxfp4.length(); i += wgsize.x) { + // Use gl_LocalInvocationIndex (uint scalar) directly for thread-strided initialization + [[unroll]] for (uint i = gl_LocalInvocationIndex; i < kvalues_mxfp4.length(); i += wgsize.x) { kvalues_mxfp4[i] = kvalues_mxfp4_const[i]; } #if defined(DATA_A_NVFP4) - for (uint i = gl_LocalInvocationIndex.x; i < 128u; i += wgsize.x) { + [[unroll]] for (uint i = gl_LocalInvocationIndex; i < 128u; i += wgsize.x) { ue4m3_fp32_lut[i] = ue4m3_to_fp32_build(i); } #endif