]> git.djapps.eu Git - pkg/ggml/sources/ggml/commitdiff
ggml : use svcntb() for SVE vector length detection (llama/17474)
authorAdrien Gallouët <redacted>
Tue, 2 Dec 2025 16:21:11 +0000 (17:21 +0100)
committerGeorgi Gerganov <redacted>
Thu, 11 Dec 2025 13:32:52 +0000 (15:32 +0200)
Signed-off-by: Adrien Gallouët <redacted>
src/ggml-cpu/ggml-cpu.c

index 3247af8bb039ccdfe0ca0cd7afe9a862ab1858e7..e19e82ac9ce1add5fd6cbed1b16dd0a90c01ab3f 100644 (file)
@@ -683,22 +683,14 @@ bool ggml_is_numa(void) {
 }
 
 #if defined(__ARM_ARCH)
-
-#if defined(__linux__) && defined(__aarch64__)
-#include <sys/auxv.h>
-#endif
-
-static void ggml_init_arm_arch_features(void) {
 #if defined(__aarch64__) && defined(__ARM_FEATURE_SVE)
-#if defined(__linux__)
-    ggml_arm_arch_features.sve_cnt = PR_SVE_VL_LEN_MASK & prctl(PR_SVE_GET_VL);
+#include <arm_sve.h>
+static void ggml_init_arm_arch_features(void) {
+    ggml_arm_arch_features.sve_cnt = svcntb();
+}
 #else
-    // TODO: add support of SVE for non-linux systems
-#error "TODO: SVE is not supported on this platform. To use SVE, sve_cnt needs to be initialized here."
-#endif
+static void ggml_init_arm_arch_features(void) {}
 #endif
-}
-
 #endif // __ARM_ARCH
 
 struct ggml_tensor * ggml_new_i32(struct ggml_context * ctx, int32_t value) {