forked from FEX-Emu/FEX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aarch64_fit_native.py
102 lines (93 loc) · 3.31 KB
/
aarch64_fit_native.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/python3
import re
import sys
import subprocess
from pkg_resources import parse_version
# Order this list from oldest to newest
# try not to list something newer than our minimum compiler supported version
BigCoreIDs = {
# ARM
tuple([0x41, 0xd07]): "cortex-a57",
tuple([0x41, 0xd08]): "cortex-a72",
tuple([0x41, 0xd09]): "cortex-a73",
tuple([0x41, 0xd0a]): "cortex-a75",
tuple([0x41, 0xd0b]): "cortex-a76",
tuple([0x41, 0xd0d]): "cortex-a77",
tuple([0x41, 0xd41]): "cortex-a78",
tuple([0x41, 0xd41]):
[ ["cortex-a78", "0.0"],
["cortex-x1c", "14.0"], # Claim to be x1c as an alternative if available.
["cortex-a78c", "9999.0"], # Doesn't exist in clang as of version 15.0
],
tuple([0x41, 0xd44]): "cortex-x1",
tuple([0x41, 0xd4c]):
[ ["cortex-x1", "0.0"],
["cortex-x1c", "14.0"],
],
tuple([0x41, 0xd47]):
[ ["cortex-a78", "0.0"],
["cortex-a710", "14.0"],
],
tuple([0x41, 0xd48]):
[ ["cortex-x1", "0.0"],
["cortex-x2", "14.0"],
],
tuple([0x41, 0xd0c]): "neoverse-n1",
tuple([0x41, 0xd49]): "neoverse-n2",
## Nvidia
tuple([0x4e, 0x004]): "carmel", # Carmel
# Qualcomm
tuple([0x51, 0x800]): "cortex-a73", # Kryo 2xx Gold
tuple([0x51, 0x802]): "cortex-a75", # Kryo 3xx Gold
tuple([0x51, 0x804]): "cortex-a76", # Kryo 4xx Gold
# Apple M1 Parallels hypervisor
tuple([0x41, 0x0]):
[ ["apple-a13", "0.0"], # If we aren't on 12.0+
["apple-a14", "12.0"], # Only exists in 12.0+
],
}
LittleCoreIDs = {
# ARM
tuple([0x41, 0xd04]): "cortex-a35",
tuple([0x41, 0xd03]): "cortex-a53",
tuple([0x41, 0xd05]): "cortex-a55",
tuple([0x41, 0xd46]):
[ ["cortex-a55", "0.0"],
["cortex-a510", "14.0"],
],
# Qualcomm
tuple([0x51, 0x801]): "cortex-a53", # Kryo 2xx Silver
tuple([0x51, 0x803]): "cortex-a55", # Kryo 3xx Silver
tuple([0x51, 0x805]): "cortex-a55", # Kryo 4xx/5xx Silver
}
# Args: </proc/cpuinfo file> <clang version>
if (len(sys.argv) < 3):
sys.exit()
clang_version = sys.argv[2]
cpuinfo = []
with open(sys.argv[1]) as cpuinfo_file:
current_implementer = 0
current_part = 0
for line in cpuinfo_file:
line = line.strip()
if "CPU implementer" in line:
current_implementer = int(re.findall(r'0x[0-9A-F]+', line, re.I)[0], 16)
if "CPU part" in line:
current_part = int(re.findall(r'0x[0-9A-F]+', line, re.I)[0], 16)
cpuinfo += {tuple([current_implementer, current_part])}
largest_big = "cortex-a57"
largest_little = "cortex-a53"
for core in cpuinfo:
if BigCoreIDs.get(core):
IDList = BigCoreIDs.get(core)
if type(IDList) is list:
for ID in IDList:
if parse_version(clang_version) >= parse_version(ID[1]):
largest_big = ID[0]
else:
largest_big = BigCoreIDs.get(core)
if LittleCoreIDs.get(core):
largest_little = LittleCoreIDs.get(core)
# We only want the big core output
print(largest_big)
# print(largest_little)