Skip to content

Commit b2a9099

Browse files
committed
Merge remote-tracking branch 'origin/ggml-use-svcntb-for-sve-vector-length-detection' into installama
2 parents 142fd71 + 502cc78 commit b2a9099

File tree

1 file changed

+5
-31
lines changed

1 file changed

+5
-31
lines changed

ggml/src/ggml-cpu/ggml-cpu.c

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646
#undef GGML_USE_LLAMAFILE
4747
#endif
4848

49+
#if defined(__ARM_FEATURE_SVE)
50+
#include <arm_sve.h>
51+
#endif
52+
4953
#ifdef GGML_USE_LLAMAFILE
5054
#include "llamafile/sgemm.h"
5155
#endif
@@ -75,13 +79,6 @@
7579
// precomputed f32 table for f16 (256 KB) (simd-mappings.h)
7680
float ggml_table_f32_f16[1 << 16];
7781

78-
#if defined(__ARM_ARCH)
79-
struct ggml_arm_arch_features_type {
80-
int sve_cnt;
81-
} ggml_arm_arch_features = { 0 };
82-
#endif
83-
84-
8582
#if defined(_WIN32)
8683

8784
#define WIN32_LEAN_AND_MEAN
@@ -682,25 +679,6 @@ bool ggml_is_numa(void) {
682679
return g_state.numa.n_nodes > 1;
683680
}
684681

685-
#if defined(__ARM_ARCH)
686-
687-
#if defined(__linux__) && defined(__aarch64__)
688-
#include <sys/auxv.h>
689-
#endif
690-
691-
static void ggml_init_arm_arch_features(void) {
692-
#if defined(__aarch64__) && defined(__ARM_FEATURE_SVE)
693-
#if defined(__linux__)
694-
ggml_arm_arch_features.sve_cnt = PR_SVE_VL_LEN_MASK & prctl(PR_SVE_GET_VL);
695-
#else
696-
// TODO: add support of SVE for non-linux systems
697-
#error "TODO: SVE is not supported on this platform. To use SVE, sve_cnt needs to be initialized here."
698-
#endif
699-
#endif
700-
}
701-
702-
#endif // __ARM_ARCH
703-
704682
struct ggml_tensor * ggml_new_i32(struct ggml_context * ctx, int32_t value) {
705683
GGML_ASSERT(!ggml_get_no_alloc(ctx));
706684

@@ -3556,7 +3534,7 @@ int ggml_cpu_has_matmul_int8(void) {
35563534

35573535
int ggml_cpu_get_sve_cnt(void) {
35583536
#if defined(__ARM_ARCH) && defined(__ARM_FEATURE_SVE)
3559-
return ggml_arm_arch_features.sve_cnt;
3537+
return svcntb();
35603538
#else
35613539
return 0;
35623540
#endif
@@ -3620,10 +3598,6 @@ void ggml_cpu_init(void) {
36203598
#endif
36213599
}
36223600

3623-
#if defined(__ARM_ARCH)
3624-
ggml_init_arm_arch_features();
3625-
#endif
3626-
36273601
is_first_call = false;
36283602
}
36293603

0 commit comments

Comments
 (0)