From 71a764e5f869b866da377a0823f7d301664a4893 Mon Sep 17 00:00:00 2001 From: Aaron Teo Date: Wed, 9 Apr 2025 18:24:37 +0800 Subject: [PATCH 1/4] ggml: fixes #12846 compilation error Signed-off-by: Aaron Teo Co-authored-by: Aleksei Nikiforov --- ggml/src/ggml-cpu/simd-mappings.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ggml/src/ggml-cpu/simd-mappings.h b/ggml/src/ggml-cpu/simd-mappings.h index e0b5fc38dd49e..b452dac0ba873 100644 --- a/ggml/src/ggml-cpu/simd-mappings.h +++ b/ggml/src/ggml-cpu/simd-mappings.h @@ -851,13 +851,13 @@ static inline __vector float __lzs_f16cx4_load(const ggml_fp16_t * x) { tmp[i] = GGML_FP16_TO_FP32(x[i]); } - return vec_xl(0, tmp); + return vec_xl(0, &(tmp[0])); } static inline void __lzs_f16cx4_store(ggml_fp16_t * x, __vector float y) { float arr[4]; - vec_xst(y, 0, arr); + vec_xst(y, 0, &(arr[0])); for (int i = 0; i < 4; i++) { x[i] = GGML_FP32_TO_FP16(arr[i]); From c2b19c81b0dc48ca27e48dbb0ad225b16c4ab0f6 Mon Sep 17 00:00:00 2001 From: Aaron Teo Date: Wed, 9 Apr 2025 18:43:20 +0800 Subject: [PATCH 2/4] ggml: add documentation for code change Signed-off-by: Aaron Teo Co-authored-by: Aleksei Nikiforov --- ggml/src/ggml-cpu/simd-mappings.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ggml/src/ggml-cpu/simd-mappings.h b/ggml/src/ggml-cpu/simd-mappings.h index b452dac0ba873..ab15f8cf0934c 100644 --- a/ggml/src/ggml-cpu/simd-mappings.h +++ b/ggml/src/ggml-cpu/simd-mappings.h @@ -851,12 +851,16 @@ static inline __vector float __lzs_f16cx4_load(const ggml_fp16_t * x) { tmp[i] = GGML_FP16_TO_FP32(x[i]); } + // TODO: change to const pointer instead (see #12846) + // this is only a workaround to the compile error but its unreadable return vec_xl(0, &(tmp[0])); } static inline void __lzs_f16cx4_store(ggml_fp16_t * x, __vector float y) { float arr[4]; + // TODO: change to const pointer instead (see #12846) + // this is only a workaround to the compile error but its unreadable vec_xst(y, 0, &(arr[0])); for (int i = 0; i < 4; i++) { From f83470e931f237f16ede70ee68e4784f3ffb10af Mon Sep 17 00:00:00 2001 From: Aaron Teo Date: Wed, 9 Apr 2025 21:53:11 +0800 Subject: [PATCH 3/4] ggml: refactor to type-cast and update documentation Signed-off-by: Aaron Teo Co-authored-by: Aleksei Nikiforov --- ggml/src/ggml-cpu/simd-mappings.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ggml/src/ggml-cpu/simd-mappings.h b/ggml/src/ggml-cpu/simd-mappings.h index ab15f8cf0934c..0618684605cab 100644 --- a/ggml/src/ggml-cpu/simd-mappings.h +++ b/ggml/src/ggml-cpu/simd-mappings.h @@ -851,17 +851,15 @@ static inline __vector float __lzs_f16cx4_load(const ggml_fp16_t * x) { tmp[i] = GGML_FP16_TO_FP32(x[i]); } - // TODO: change to const pointer instead (see #12846) - // this is only a workaround to the compile error but its unreadable - return vec_xl(0, &(tmp[0])); + // note: keep type-cast here to prevent compiler bugs (see #12846) + return vec_xl(0, (const float *)(tmp)); } static inline void __lzs_f16cx4_store(ggml_fp16_t * x, __vector float y) { float arr[4]; - // TODO: change to const pointer instead (see #12846) - // this is only a workaround to the compile error but its unreadable - vec_xst(y, 0, &(arr[0])); + // note: keep type-cast here to prevent compiler bugs (see #12846) + vec_xst(y, 0, (float *)(arr)); for (int i = 0; i < 4; i++) { x[i] = GGML_FP32_TO_FP16(arr[i]); From e181fdc60730be45ff4cd6712593044b4fde4ca1 Mon Sep 17 00:00:00 2001 From: Aaron Teo Date: Thu, 10 Apr 2025 12:57:22 +0800 Subject: [PATCH 4/4] ggml: update documentation to provide full issue link Signed-off-by: Aaron Teo Co-authored-by: Aleksei Nikiforov --- ggml/src/ggml-cpu/simd-mappings.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ggml/src/ggml-cpu/simd-mappings.h b/ggml/src/ggml-cpu/simd-mappings.h index 0618684605cab..de9ec41ea2ad5 100644 --- a/ggml/src/ggml-cpu/simd-mappings.h +++ b/ggml/src/ggml-cpu/simd-mappings.h @@ -851,14 +851,16 @@ static inline __vector float __lzs_f16cx4_load(const ggml_fp16_t * x) { tmp[i] = GGML_FP16_TO_FP32(x[i]); } - // note: keep type-cast here to prevent compiler bugs (see #12846) + // note: keep type-cast here to prevent compiler bugs + // see: https://github.com/ggml-org/llama.cpp/issues/12846 return vec_xl(0, (const float *)(tmp)); } static inline void __lzs_f16cx4_store(ggml_fp16_t * x, __vector float y) { float arr[4]; - // note: keep type-cast here to prevent compiler bugs (see #12846) + // note: keep type-cast here to prevent compiler bugs + // see: https://github.com/ggml-org/llama.cpp/issues/12846 vec_xst(y, 0, (float *)(arr)); for (int i = 0; i < 4; i++) {