File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
ggml/src/ggml-cpu/arch/arm Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 4
4
5
5
#if defined(__linux__)
6
6
#include < sys/auxv.h>
7
+
8
+ #include < fstream>
9
+ #include < string>
7
10
#elif defined(__APPLE__)
8
11
#include < sys/sysctl.h>
9
12
#endif
17
20
#endif
18
21
19
22
struct aarch64_features {
23
+ int cpu_part = -1 ;
20
24
// has_neon not needed, aarch64 has NEON guaranteed
21
25
bool has_dotprod = false ;
22
26
bool has_fp16_va = false ;
@@ -36,6 +40,17 @@ struct aarch64_features {
36
40
has_sve2 = !!(hwcap2 & HWCAP2_SVE2);
37
41
has_i8mm = !!(hwcap2 & HWCAP2_I8MM);
38
42
has_sme = !!(hwcap2 & HWCAP2_SME);
43
+
44
+ std::ifstream cpuinfo (" /proc/cpuinfo" );
45
+ std::string line;
46
+ while (std::getline (cpuinfo, line)) {
47
+ if (line.find (" CPU part" ) == 0 ) {
48
+ // Parse the hex number after the colon
49
+ cpu_part = std::stoi (line.substr (line.find (' :' ) + 1 ), nullptr , 16 );
50
+ break ;
51
+ }
52
+ }
53
+ cpuinfo.close ();
39
54
#elif defined(__APPLE__)
40
55
int oldp = 0 ;
41
56
size_t size = sizeof (oldp);
@@ -63,6 +78,11 @@ static int ggml_backend_cpu_aarch64_score() {
63
78
64
79
// Bits 2-8 are used to rank backends by architecture or core when they
65
80
// otherwise have identical features.
81
+ #if defined(GGML_ARM_MCPU) && GGML_ARM_MCPU == NEOVERSE_V2
82
+ if (af.cpu_part == 0xd4f ) {
83
+ score += 1 <<5 ;
84
+ }
85
+ #endif
66
86
67
87
// Bits 9+: Features always trump architecture or core.
68
88
#ifdef GGML_USE_DOTPROD
You can’t perform that action at this time.
0 commit comments