ggml : use svcntb() for SVE vector length detection (#17474)

Signed-off-by: Adrien Gallouët <angt@huggingface.co>
This commit is contained in:
Adrien Gallouët 2025-12-02 17:21:11 +01:00 committed by GitHub
parent a2b0fe8d37
commit e148380c7c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 14 deletions

View File

@ -683,22 +683,14 @@ bool ggml_is_numa(void) {
} }
#if defined(__ARM_ARCH) #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(__aarch64__) && defined(__ARM_FEATURE_SVE)
#if defined(__linux__) #include <arm_sve.h>
ggml_arm_arch_features.sve_cnt = PR_SVE_VL_LEN_MASK & prctl(PR_SVE_GET_VL); static void ggml_init_arm_arch_features(void) {
#else ggml_arm_arch_features.sve_cnt = svcntb();
// 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
#endif
} }
#else
static void ggml_init_arm_arch_features(void) {}
#endif
#endif // __ARM_ARCH #endif // __ARM_ARCH
struct ggml_tensor * ggml_new_i32(struct ggml_context * ctx, int32_t value) { struct ggml_tensor * ggml_new_i32(struct ggml_context * ctx, int32_t value) {