Skip to content

Commit c61fe91

Browse files
authored
update apple soc info (#290)
* [WIP] update apple soc info Summary: Added support for A16, A17, A18, A18 pro. Reg values are found from ncnn and needs validation. Additional source Constants are taken from https://github.com/apple-oss-distributions/xnu/blob/e3723e1f17661b24996789d8afc084c0c3303b26/osfmk/mach/machine.h#L449 Test Plan: Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned] * Update on "[WIP] update apple soc info" Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned] * Update on "[WIP] update apple soc info" Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned] * Update on "[WIP] update apple soc info" Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned] * Update on "update apple soc info" Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
1 parent de0ce7c commit c61fe91

File tree

3 files changed

+88
-0
lines changed

3 files changed

+88
-0
lines changed

include/cpuinfo.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,22 @@ enum cpuinfo_uarch {
581581
cpuinfo_uarch_avalanche = 0x0070010D,
582582
/** Apple A15 / M2 processor (little cores). */
583583
cpuinfo_uarch_blizzard = 0x0070010E,
584+
/** Apple A16 processor (big cores). */
585+
cpuinfo_uarch_everest = 0x00700200,
586+
/** Apple A16 processor (little cores). */
587+
cpuinfo_uarch_sawtooth = 0x00700201,
588+
/** Apple A17 processor (big cores). */
589+
cpuinfo_uarch_coll_everest = 0x00700202,
590+
/** Apple A17 processor (little cores). */
591+
cpuinfo_uarch_coll_sawtooth = 0x00700203,
592+
/** Apple A18 processor (big cores). */
593+
cpuinfo_uarch_tupai_everest = 0x00700204,
594+
/** Apple A18 processor (little cores). */
595+
cpuinfo_uarch_tupai_sawtooth = 0x00700205,
596+
/** Apple A18 pro processor (big cores). */
597+
cpuinfo_uarch_tahiti_everest = 0x00700206,
598+
/** Apple A18 pro processor (little cores). */
599+
cpuinfo_uarch_tahiti_sawtooth = 0x00700207,
584600

585601
/** Cavium ThunderX. */
586602
cpuinfo_uarch_thunderx = 0x00800100,

src/arm/mach/init.c

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,45 @@
2727
#ifndef CPUFAMILY_ARM_AVALANCHE_BLIZZARD
2828
#define CPUFAMILY_ARM_AVALANCHE_BLIZZARD 0xDA33D83D
2929
#endif
30+
// Following are copied over from ncnn/src/cpu.cpp
31+
// A16
32+
#ifndef CPUFAMILY_ARM_EVEREST_SAWTOOTH
33+
#define CPUFAMILY_ARM_EVEREST_SAWTOOTH 0x8765edea
34+
#endif
35+
// A17
36+
#ifndef CPUFAMILY_ARM_COLL
37+
#define CPUFAMILY_ARM_COLL 0x2876f5b5
38+
#endif
39+
// A18
40+
#ifndef CPUFAMILY_ARM_TUPAI
41+
#define CPUFAMILY_ARM_TUPAI 0x204526d0
42+
#endif
43+
// A18 Pro
44+
#ifndef CPUFAMILY_ARM_TAHITI
45+
#define CPUFAMILY_ARM_TAHITI 0x75d4acb9
46+
#endif
47+
// For M3/M4 we need to populate more information about
48+
// efficiency and perf cores.
49+
// M3
50+
#ifndef CPUFAMILY_ARM_IBIZA
51+
#define CPUFAMILY_ARM_IBIZA 0xfa33415e
52+
#endif
53+
// M3 Pro
54+
#ifndef CPUFAMILY_ARM_LOBOS
55+
#define CPUFAMILY_ARM_LOBOS 0x5f4dea93
56+
#endif
57+
// M3 Max
58+
#ifndef CPUFAMILY_ARM_PALMA
59+
#define CPUFAMILY_ARM_PALMA 0x72015832
60+
#endif
61+
// M4
62+
#ifndef CPUFAMILY_ARM_DONAN
63+
#define CPUFAMILY_ARM_DONAN 0x6f5129ac
64+
#endif
65+
// M4 Pro / M4 Max
66+
#ifndef CPUFAMILY_ARM_BRAVA
67+
#define CPUFAMILY_ARM_BRAVA 0x17d5b93a
68+
#endif
3069

3170
struct cpuinfo_arm_isa cpuinfo_isa = {
3271
.aes = true,
@@ -93,6 +132,23 @@ static enum cpuinfo_uarch decode_uarch(uint32_t cpu_family, uint32_t core_index,
93132
case CPUFAMILY_ARM_AVALANCHE_BLIZZARD:
94133
/* Hexa-core: 2x Avalanche + 4x Blizzard */
95134
return core_index + 4 < core_count ? cpuinfo_uarch_avalanche : cpuinfo_uarch_blizzard;
135+
case CPUFAMILY_ARM_EVEREST_SAWTOOTH:
136+
/* Hexa-core: 2x Avalanche + 4x Blizzard */
137+
return core_index + 4 < core_count ? cpuinfo_uarch_everest : cpuinfo_uarch_sawtooth;
138+
return core_index + 4 < core_count ? cpuinfo_uarch_avalanche : cpuinfo_uarch_blizzard;
139+
case CPUFAMILY_ARM_COLL:
140+
/* Hexa-core: 2x Avalanche + 4x Blizzard */
141+
return core_index + 4 < core_count ? cpuinfo_uarch_coll_everest : cpuinfo_uarch_coll_sawtooth;
142+
143+
case CPUFAMILY_ARM_TUPAI:
144+
/* Hexa-core: 2x Avalanche + 4x Blizzard */
145+
return core_index + 4 < core_count ? cpuinfo_uarch_tupai_everest : cpuinfo_uarch_tupai_sawtooth;
146+
147+
case CPUFAMILY_ARM_TAHITI:
148+
/* Hexa-core: 2x Avalanche + 4x Blizzard */
149+
return core_index + 4 < core_count ? cpuinfo_uarch_tahiti_everest
150+
: cpuinfo_uarch_tahiti_sawtooth;
151+
96152
default:
97153
/* Use hw.cpusubtype for detection */
98154
break;

tools/cpu-info.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,22 @@ static const char* uarch_to_string(enum cpuinfo_uarch uarch) {
270270
return "Avalanche";
271271
case cpuinfo_uarch_blizzard:
272272
return "Blizzard";
273+
case cpuinfo_uarch_everest:
274+
return "Everest";
275+
case cpuinfo_uarch_sawtooth:
276+
return "Sawtooth";
277+
case cpuinfo_uarch_coll_everest:
278+
return "Coll_Everest";
279+
case cpuinfo_uarch_coll_sawtooth:
280+
return "Coll_Sawtooth";
281+
case cpuinfo_uarch_tupai_everest:
282+
return "Tupai_Everest";
283+
case cpuinfo_uarch_tupai_sawtooth:
284+
return "Tupai_Sawtooth";
285+
case cpuinfo_uarch_tahiti_everest:
286+
return "Tahiti_Everest";
287+
case cpuinfo_uarch_tahiti_sawtooth:
288+
return "Tahiti_Sawtooth";
273289
case cpuinfo_uarch_thunderx:
274290
return "ThunderX";
275291
case cpuinfo_uarch_thunderx2:

0 commit comments

Comments
 (0)