diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/external/__init__.py | 2 | ||||
-rw-r--r-- | lib/spack/external/archspec/cpu/detect.py | 34 | ||||
-rw-r--r-- | lib/spack/external/archspec/json/cpu/microarchitectures.json | 263 | ||||
-rw-r--r-- | lib/spack/spack/target.py | 13 |
4 files changed, 288 insertions, 24 deletions
diff --git a/lib/spack/external/__init__.py b/lib/spack/external/__init__.py index bcb9ed9bec..89928fae59 100644 --- a/lib/spack/external/__init__.py +++ b/lib/spack/external/__init__.py @@ -18,7 +18,7 @@ archspec * Homepage: https://pypi.python.org/pypi/archspec * Usage: Labeling, comparison and detection of microarchitectures -* Version: 0.1.4 (commit e2cfdc266174488dee78b8c9058e36d60dc1b548) +* Version: 0.2.0 (commit 77640e572725ad97f18e63a04857155752ace045) argparse -------- diff --git a/lib/spack/external/archspec/cpu/detect.py b/lib/spack/external/archspec/cpu/detect.py index 3df04585c7..a7cc4481f6 100644 --- a/lib/spack/external/archspec/cpu/detect.py +++ b/lib/spack/external/archspec/cpu/detect.py @@ -132,9 +132,15 @@ def sysctl_info_dict(): "model name": sysctl("-n", "machdep.cpu.brand_string"), } else: - model = ( - "m1" if "Apple" in sysctl("-n", "machdep.cpu.brand_string") else "unknown" - ) + model = "unknown" + model_str = sysctl("-n", "machdep.cpu.brand_string").lower() + if "m2" in model_str: + model = "m2" + elif "m1" in model_str: + model = "m1" + elif "apple" in model_str: + model = "m1" + info = { "vendor_id": "Apple", "flags": [], @@ -322,14 +328,26 @@ def compatibility_check_for_aarch64(info, target): features = set(info.get("Features", "").split()) vendor = info.get("CPU implementer", "generic") + # At the moment it's not clear how to detect compatibility with + # a specific version of the architecture + if target.vendor == "generic" and target.name != "aarch64": + return False + arch_root = TARGETS[basename] - return ( - (target == arch_root or arch_root in target.ancestors) - and target.vendor in (vendor, "generic") - # On macOS it seems impossible to get all the CPU features with syctl info - and (target.features.issubset(features) or platform.system() == "Darwin") + arch_root_and_vendor = arch_root == target.family and target.vendor in ( + vendor, + "generic", ) + # On macOS it seems impossible to get all the CPU features + # with syctl info, but for ARM we can get the exact model + if platform.system() == "Darwin": + model_key = info.get("model", basename) + model = TARGETS[model_key] + return arch_root_and_vendor and (target == model or target in model.ancestors) + + return arch_root_and_vendor and target.features.issubset(features) + @compatibility_check(architecture_family="riscv64") def compatibility_check_for_riscv64(info, target): diff --git a/lib/spack/external/archspec/json/cpu/microarchitectures.json b/lib/spack/external/archspec/json/cpu/microarchitectures.json index 308f0e5152..15d32e9fa0 100644 --- a/lib/spack/external/archspec/json/cpu/microarchitectures.json +++ b/lib/spack/external/archspec/json/cpu/microarchitectures.json @@ -85,7 +85,7 @@ "intel": [ { "versions": ":", - "name": "x86-64", + "name": "pentium4", "flags": "-march={name} -mtune=generic" } ], @@ -2093,8 +2093,163 @@ ] } }, - "thunderx2": { + "armv8.1a": { "from": ["aarch64"], + "vendor": "generic", + "features": [], + "compilers": { + "gcc": [ + { + "versions": "5:", + "flags": "-march=armv8.1-a -mtune=generic" + } + ], + "clang": [ + { + "versions": ":", + "flags": "-march=armv8.1-a -mtune=generic" + } + ], + "apple-clang": [ + { + "versions": ":", + "flags": "-march=armv8.1-a -mtune=generic" + } + ], + "arm": [ + { + "versions": ":", + "flags": "-march=armv8.1-a -mtune=generic" + } + ] + } + }, + "armv8.2a": { + "from": ["armv8.1a"], + "vendor": "generic", + "features": [], + "compilers": { + "gcc": [ + { + "versions": "6:", + "flags": "-march=armv8.2-a -mtune=generic" + } + ], + "clang": [ + { + "versions": ":", + "flags": "-march=armv8.2-a -mtune=generic" + } + ], + "apple-clang": [ + { + "versions": ":", + "flags": "-march=armv8.2-a -mtune=generic" + } + ], + "arm": [ + { + "versions": ":", + "flags": "-march=armv8.2-a -mtune=generic" + } + ] + } + }, + "armv8.3a": { + "from": ["armv8.2a"], + "vendor": "generic", + "features": [], + "compilers": { + "gcc": [ + { + "versions": "6:", + "flags": "-march=armv8.3-a -mtune=generic" + } + ], + "clang": [ + { + "versions": "6:", + "flags": "-march=armv8.3-a -mtune=generic" + } + ], + "apple-clang": [ + { + "versions": ":", + "flags": "-march=armv8.3-a -mtune=generic" + } + ], + "arm": [ + { + "versions": ":", + "flags": "-march=armv8.3-a -mtune=generic" + } + ] + } + }, + "armv8.4a": { + "from": ["armv8.3a"], + "vendor": "generic", + "features": [], + "compilers": { + "gcc": [ + { + "versions": "8:", + "flags": "-march=armv8.4-a -mtune=generic" + } + ], + "clang": [ + { + "versions": "8:", + "flags": "-march=armv8.4-a -mtune=generic" + } + ], + "apple-clang": [ + { + "versions": ":", + "flags": "-march=armv8.4-a -mtune=generic" + } + ], + "arm": [ + { + "versions": ":", + "flags": "-march=armv8.4-a -mtune=generic" + } + ] + } + }, + "armv8.5a": { + "from": ["armv8.4a"], + "vendor": "generic", + "features": [], + "compilers": { + "gcc": [ + { + "versions": "9:", + "flags": "-march=armv8.5-a -mtune=generic" + } + ], + "clang": [ + { + "versions": "11:", + "flags": "-march=armv8.5-a -mtune=generic" + } + ], + "apple-clang": [ + { + "versions": ":", + "flags": "-march=armv8.5-a -mtune=generic" + } + ], + "arm": [ + { + "versions": ":", + "flags": "-march=armv8.5-a -mtune=generic" + } + ] + } + }, + "thunderx2": { + "from": ["armv8.1a"], "vendor": "Cavium", "features": [ "fp", @@ -2141,7 +2296,7 @@ } }, "a64fx": { - "from": ["aarch64"], + "from": ["armv8.2a"], "vendor": "Fujitsu", "features": [ "fp", @@ -2209,7 +2364,7 @@ ] } }, - "graviton": { + "cortex_a72": { "from": ["aarch64"], "vendor": "ARM", "features": [ @@ -2235,19 +2390,19 @@ }, { "versions": "6:", - "flags" : "-march=armv8-a+crc+crypto -mtune=cortex-a72" + "flags" : "-mcpu=cortex-a72" } ], "clang" : [ { "versions": "3.9:", - "flags" : "-march=armv8-a+crc+crypto" + "flags" : "-mcpu=cortex-a72" } ] } }, - "graviton2": { - "from": ["graviton"], + "neoverse_n1": { + "from": ["cortex_a72", "armv8.2a"], "vendor": "ARM", "features": [ "fp", @@ -2296,7 +2451,7 @@ }, { "versions": "9.0:", - "flags" : "-march=armv8.2-a+fp16+rcpc+dotprod+crypto -mtune=neoverse-n1" + "flags" : "-mcpu=neoverse-n1" } ], "clang" : [ @@ -2307,6 +2462,10 @@ { "versions": "5:", "flags" : "-march=armv8.2-a+fp16+rcpc+dotprod+crypto" + }, + { + "versions": "10:", + "flags" : "-mcpu=neoverse-n1" } ], "arm" : [ @@ -2317,11 +2476,11 @@ ] } }, - "graviton3": { - "from": ["graviton2"], + "neoverse_v1": { + "from": ["neoverse_n1", "armv8.4a"], "vendor": "ARM", "features": [ - "fp", + "fp", "asimd", "evtstrm", "aes", @@ -2384,11 +2543,11 @@ }, { "versions": "9.0:9.9", - "flags" : "-march=armv8.4-a+crypto+rcpc+sha3+sm4+sve+rng+nodotprod -mtune=neoverse-v1" + "flags" : "-mcpu=neoverse-v1" }, { "versions": "10.0:", - "flags" : "-march=armv8.4-a+crypto+rcpc+sha3+sm4+sve+rng+ssbs+i8mm+bf16+nodotprod -mtune=neoverse-v1" + "flags" : "-mcpu=neoverse-v1" } ], @@ -2404,6 +2563,10 @@ { "versions": "11:", "flags" : "-march=armv8.4-a+sve+ssbs+fp16+bf16+crypto+i8mm+rng" + }, + { + "versions": "12:", + "flags" : "-mcpu=neoverse-v1" } ], "arm" : [ @@ -2419,7 +2582,7 @@ } }, "m1": { - "from": ["aarch64"], + "from": ["armv8.4a"], "vendor": "Apple", "features": [ "fp", @@ -2484,6 +2647,76 @@ ] } }, + "m2": { + "from": ["m1", "armv8.5a"], + "vendor": "Apple", + "features": [ + "fp", + "asimd", + "evtstrm", + "aes", + "pmull", + "sha1", + "sha2", + "crc32", + "atomics", + "fphp", + "asimdhp", + "cpuid", + "asimdrdm", + "jscvt", + "fcma", + "lrcpc", + "dcpop", + "sha3", + "asimddp", + "sha512", + "asimdfhm", + "dit", + "uscat", + "ilrcpc", + "flagm", + "ssbs", + "sb", + "paca", + "pacg", + "dcpodp", + "flagm2", + "frint", + "ecv", + "bf16", + "i8mm", + "bti" + ], + "compilers": { + "gcc": [ + { + "versions": "8.0:", + "flags" : "-march=armv8.5-a -mtune=generic" + } + ], + "clang" : [ + { + "versions": "9.0:12.0", + "flags" : "-march=armv8.5-a" + }, + { + "versions": "13.0:", + "flags" : "-mcpu=apple-m1" + } + ], + "apple-clang": [ + { + "versions": "11.0:12.5", + "flags" : "-march=armv8.5-a" + }, + { + "versions": "13.0:", + "flags" : "-mcpu=vortex" + } + ] + } + }, "arm": { "from": [], "vendor": "generic", diff --git a/lib/spack/spack/target.py b/lib/spack/spack/target.py index a85baa4d45..d51ca3aa99 100644 --- a/lib/spack/spack/target.py +++ b/lib/spack/spack/target.py @@ -3,6 +3,7 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) import functools +import warnings import six @@ -34,6 +35,14 @@ def _ensure_other_is_target(method): return _impl +#: Translation table from archspec deprecated names +_DEPRECATED_ARCHSPEC_NAMES = { + "graviton": "cortex_a72", + "graviton2": "neoverse_n1", + "graviton3": "neoverse_v1", +} + + class Target(object): def __init__(self, name, module_name=None): """Target models microarchitectures and their compatibility. @@ -45,6 +54,10 @@ class Target(object): like Cray (e.g. craype-compiler) """ if not isinstance(name, archspec.cpu.Microarchitecture): + if name in _DEPRECATED_ARCHSPEC_NAMES: + msg = "'target={}' is deprecated, use 'target={}' instead" + name, old_name = _DEPRECATED_ARCHSPEC_NAMES[name], name + warnings.warn(msg.format(old_name, name)) name = archspec.cpu.TARGETS.get(name, archspec.cpu.generic_microarchitecture(name)) self.microarchitecture = name self.module_name = module_name |