summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2019-12-17 09:47:50 +0100
committerTodd Gamblin <tgamblin@llnl.gov>2019-12-17 00:47:50 -0800
commit5eca4f14706a9590407f14c9c76e5a8bb663e9df (patch)
tree5219e3ff654bc1c84779ef54e5610b0c769ff93c /lib
parenta4ff92e42dbbb4c6a302da31a4424759ac84c58b (diff)
downloadspack-5eca4f14706a9590407f14c9c76e5a8bb663e9df.tar.gz
spack-5eca4f14706a9590407f14c9c76e5a8bb663e9df.tar.bz2
spack-5eca4f14706a9590407f14c9c76e5a8bb663e9df.tar.xz
spack-5eca4f14706a9590407f14c9c76e5a8bb663e9df.zip
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
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/llnl/util/cpu/detect.py45
-rw-r--r--lib/spack/llnl/util/cpu/microarchitectures.json68
-rw-r--r--lib/spack/llnl/util/cpu/schema.py16
-rw-r--r--lib/spack/spack/test/llnl/util/cpu.py2
4 files changed, 102 insertions, 29 deletions
diff --git a/lib/spack/llnl/util/cpu/detect.py b/lib/spack/llnl/util/cpu/detect.py
index 4c34a5cc73..76465037bf 100644
--- a/lib/spack/llnl/util/cpu/detect.py
+++ b/lib/spack/llnl/util/cpu/detect.py
@@ -13,6 +13,7 @@ import warnings
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,21 +109,37 @@ def sysctl_info_dict():
'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', [])
+ 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():
@@ -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
diff --git a/lib/spack/llnl/util/cpu/microarchitectures.json b/lib/spack/llnl/util/cpu/microarchitectures.json
index 0b934e5157..10cad1670a 100644
--- a/lib/spack/llnl/util/cpu/microarchitectures.json
+++ b/lib/spack/llnl/util/cpu/microarchitectures.json
@@ -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"
+ }
}
}
diff --git a/lib/spack/llnl/util/cpu/schema.py b/lib/spack/llnl/util/cpu/schema.py
index d13d014c01..cc15cb64ba 100644
--- a/lib/spack/llnl/util/cpu/schema.py
+++ b/lib/spack/llnl/util/cpu/schema.py
@@ -72,7 +72,21 @@ properties = {
'additionalProperties': False
}
},
-
+ },
+ 'conversions': {
+ 'type': 'object',
+ 'properties': {
+ 'description': {
+ 'type': 'string'
+ },
+ 'arm_vendors': {
+ 'type': 'object',
+ },
+ 'darwin_flags': {
+ 'type': 'object'
+ }
+ },
+ 'additionalProperties': False
}
}
diff --git a/lib/spack/spack/test/llnl/util/cpu.py b/lib/spack/spack/test/llnl/util/cpu.py
index 5f82fd63ae..2ed96e3724 100644
--- a/lib/spack/spack/test/llnl/util/cpu.py
+++ b/lib/spack/spack/test/llnl/util/cpu.py
@@ -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',