microarchitectures: readable names for AArch64 vendors (#13825)

Vendors for ARM come out of `/proc/cpuinfo` as hex numbers instead of readable strings.

- Add support for associating vendor names with the hex numbers.
- Also move these mappings from Python code to `microarchitectures.json`
- Move darwin feature name mappings to `microarchitectures.json` as well
This commit is contained in:
Massimiliano Culpo 2019-12-17 09:47:50 +01:00 committed by Todd Gamblin
parent a4ff92e42d
commit 5eca4f1470
4 changed files with 103 additions and 30 deletions

View file

@ -13,6 +13,7 @@
import six
from .microarchitecture import generic_microarchitecture, targets
from .schema import targets_json
#: Mapping from operating systems to chain of commands
#: to obtain a dictionary of raw info on the current cpu
@ -108,23 +109,39 @@ def sysctl(*args):
'model': sysctl('-n', 'machdep.cpu.model'),
'model name': sysctl('-n', 'machdep.cpu.brand_string')
}
# Super hacky way to deal with slight representation differences
# Would be better to somehow consider these "identical"
if 'sse4.1' in info['flags']:
info['flags'] += ' sse4_1'
if 'sse4.2' in info['flags']:
info['flags'] += ' sse4_2'
if 'avx1.0' in info['flags']:
info['flags'] += ' avx'
if 'clfsopt' in info['flags']:
info['flags'] += ' clflushopt'
if 'xsave' in info['flags']:
info['flags'] += ' xsavec xsaveopt'
return info
def adjust_raw_flags(info):
"""Adjust the flags detected on the system to homogenize
slightly different representations.
"""
# Flags detected on Darwin turned to their linux counterpart
flags = info.get('flags', [])
d2l = targets_json['conversions']['darwin_flags']
for darwin_flag, linux_flag in d2l.items():
if darwin_flag in flags:
info['flags'] += ' ' + linux_flag
def adjust_raw_vendor(info):
"""Adjust the vendor field to make it human readable"""
if 'CPU implementer' not in info:
return
# Mapping numeric codes to vendor (ARM). This list is a merge from
# different sources:
#
# https://github.com/karelzak/util-linux/blob/master/sys-utils/lscpu-arm.c
# https://developer.arm.com/docs/ddi0487/latest/arm-architecture-reference-manual-armv8-for-armv8-a-architecture-profile
# https://github.com/gcc-mirror/gcc/blob/master/gcc/config/aarch64/aarch64-cores.def
# https://patchwork.kernel.org/patch/10524949/
arm_vendors = targets_json['conversions']['arm_vendors']
arm_code = info['CPU implementer']
if arm_code in arm_vendors:
info['CPU implementer'] = arm_vendors[arm_code]
def raw_info_dictionary():
"""Returns a dictionary with information on the cpu of the current host.
@ -139,6 +156,8 @@ def raw_info_dictionary():
warnings.warn(str(e))
if info:
adjust_raw_flags(info)
adjust_raw_vendor(info)
break
return info

View file

@ -1134,14 +1134,13 @@
},
"clang": {
"versions": ":",
"family": "aarch64",
"flags": "-march={family} -mcpu=generic"
"flags": "-march=armv8-a -mtune=generic"
}
}
},
"thunderx2": {
"from": "aarch64",
"vendor": "0x43",
"vendor": "Cavium",
"features": [
"fp",
"asimd",
@ -1174,15 +1173,21 @@
"flags": "-mcpu=thunderx2t99"
}
],
"clang": {
"versions": ":",
"flags": "-march=armv8-a -mcpu=generic"
"clang": [
{
"versions": "3.9:4.9",
"flags": "-march=armv8.1-a+crc+crypto"
},
{
"versions": "5:",
"flags": "-mcpu=thunderx2t99"
}
]
}
},
"a64fx": {
"from": "aarch64",
"vendor": "0x46",
"vendor": "Fujitsu",
"features": [
"fp",
"asimd",
@ -1217,17 +1222,23 @@
},
{
"versions": "7:7.9",
"flags": "-arch=armv8.2a+crc+crypt+fp16"
"flags": "-march=armv8.2a+crc+crypto+fp16"
},
{
"versions": "8:",
"flags": "-arch=armv8.2a+crc+aes+sh2+fp16+sve -msve-vector-bits=512"
"flags": "-march=armv8.2a+crc+aes+sha2+fp16+sve -msve-vector-bits=512"
}
],
"clang": {
"versions": ":",
"flags": "-march=armv8-a -mcpu=generic"
"clang": [
{
"versions": "3.9:4.9",
"flags": "-march=armv8.2-a+crc+crypto+fp16"
},
{
"versions": "5:",
"flags": "-march=armv8.2-a+crc+crypto+fp16+sve"
}
]
}
},
"arm": {
@ -1313,5 +1324,34 @@
"aarch64"
]
}
},
"conversions": {
"description": "Conversions that map some platform specific values to canonical values",
"arm_vendors": {
"0x41": "ARM",
"0x42": "Broadcom",
"0x43": "Cavium",
"0x44": "DEC",
"0x46": "Fujitsu",
"0x48": "HiSilicon",
"0x49": "Infineon Technologies AG",
"0x4d": "Motorola",
"0x4e": "Nvidia",
"0x50": "APM",
"0x51": "Qualcomm",
"0x53": "Samsung",
"0x56": "Marvell",
"0x61": "Apple",
"0x66": "Faraday",
"0x68": "HXT",
"0x69": "Intel"
},
"darwin_flags": {
"sse4.1": "sse4_1",
"sse4.2": "sse4_2",
"avx1.0": "avx",
"clfsopt": "clflushopt",
"xsave": "xsavec xsaveopt"
}
}
}

View file

@ -72,7 +72,21 @@
'additionalProperties': False
}
},
},
'conversions': {
'type': 'object',
'properties': {
'description': {
'type': 'string'
},
'arm_vendors': {
'type': 'object',
},
'darwin_flags': {
'type': 'object'
}
},
'additionalProperties': False
}
}

View file

@ -219,7 +219,7 @@ def test_target_json_schema():
'-march=icelake-client -mtune=icelake-client'),
('zen2', 'clang', '9.0.0', '-march=znver2 -mtune=znver2'),
('power9le', 'clang', '8.0.0', '-march=ppc64le -mcpu=pwr9'),
('thunderx2', 'clang', '6.0.0', '-march=armv8-a -mcpu=generic'),
('thunderx2', 'clang', '6.0.0', '-mcpu=thunderx2t99'),
# Test Intel on Intel CPUs
('sandybridge', 'intel', '17.0.2', '-march=corei7-avx -mtune=corei7-avx'),
('sandybridge', 'intel', '18.0.5',