Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display human readable text for AArch64 vendors #13825

Merged
merged 14 commits into from Dec 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
45 changes: 32 additions & 13 deletions lib/spack/llnl/util/cpu/detect.py
Expand Up @@ -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
Expand Down Expand Up @@ -108,21 +109,37 @@ def sysctl(*args):
'model': sysctl('-n', 'machdep.cpu.model'),
'model name': sysctl('-n', 'machdep.cpu.brand_string')
}
return info

# 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', [])
tgamblin marked this conversation as resolved.
Show resolved Hide resolved
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():
Expand All @@ -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
Expand Down
68 changes: 54 additions & 14 deletions lib/spack/llnl/util/cpu/microarchitectures.json
Expand Up @@ -1156,14 +1156,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",
Expand Down Expand Up @@ -1196,15 +1195,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",
Expand Down Expand Up @@ -1239,17 +1244,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": {
Expand Down Expand Up @@ -1335,5 +1346,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"
}
}
}
16 changes: 15 additions & 1 deletion lib/spack/llnl/util/cpu/schema.py
Expand Up @@ -72,7 +72,21 @@
'additionalProperties': False
}
},

},
'conversions': {
'type': 'object',
'properties': {
'description': {
'type': 'string'
},
'arm_vendors': {
'type': 'object',
},
'darwin_flags': {
'type': 'object'
}
},
'additionalProperties': False
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/spack/spack/test/llnl/util/cpu.py
Expand Up @@ -218,7 +218,7 @@ def test_target_json_schema():
('icelake', 'clang', '8.0.0', '-march=x86-64 -mcpu=icelake-client'),
('zen2', 'clang', '9.0.0', '-march=x86-64 -mcpu=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',
Expand Down