From: Masashi Yoshimura Date: Thu, 8 Jan 2026 16:36:42 +0000 (+0900) Subject: ggml-webgpu: Fix GGML_MEM_ALIGN to 8 for emscripten. (#18628) X-Git-Tag: upstream/0.0.7721~42 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=480160d47297df43b43746294963476fc0a6e10f;p=pkg%2Fggml%2Fsources%2Fllama.cpp ggml-webgpu: Fix GGML_MEM_ALIGN to 8 for emscripten. (#18628) * Fix GGML_MEM_ALIGN to 8 for emscripten. * Add a comment explaining the need for GGML_MEM_ALIGN == 8 in 64-bit wasm with emscripten --- diff --git a/ggml/include/ggml.h b/ggml/include/ggml.h index 20c912d0..b69583dd 100644 --- a/ggml/include/ggml.h +++ b/ggml/include/ggml.h @@ -234,6 +234,11 @@ #if UINTPTR_MAX == 0xFFFFFFFF #define GGML_MEM_ALIGN 4 +#elif defined(__EMSCRIPTEN__) +// emscripten uses max_align_t == 8, so we need GGML_MEM_ALIGN == 8 for 64-bit wasm. +// (for 32-bit wasm, the first conditional is true and GGML_MEM_ALIGN stays 4.) +// ref: https://github.com/ggml-org/llama.cpp/pull/18628 + #define GGML_MEM_ALIGN 8 #else #define GGML_MEM_ALIGN 16 #endif