diff options
author | Massimiliano Culpo <massimiliano.culpo@gmail.com> | 2022-05-18 11:31:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-18 11:31:20 +0200 |
commit | c775c322ecb95828cc5b4ea6cabbb670423a2d5d (patch) | |
tree | 7ff8996b225198604b48677af6c9c9452dd8a9e0 /lib | |
parent | 1185eb9199565303e9767f2e480ae10ac37a1261 (diff) | |
download | spack-c775c322ecb95828cc5b4ea6cabbb670423a2d5d.tar.gz spack-c775c322ecb95828cc5b4ea6cabbb670423a2d5d.tar.bz2 spack-c775c322ecb95828cc5b4ea6cabbb670423a2d5d.tar.xz spack-c775c322ecb95828cc5b4ea6cabbb670423a2d5d.zip |
vendored externals: update archspec (#30683)
- Better support for 164fx
- Better support for Apple M1(pro)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/external/__init__.py | 2 | ||||
-rw-r--r-- | lib/spack/external/archspec/cpu/detect.py | 75 | ||||
-rw-r--r-- | lib/spack/external/archspec/cpu/schema.py | 4 | ||||
-rw-r--r-- | lib/spack/external/archspec/json/cpu/microarchitectures.json | 66 |
4 files changed, 109 insertions, 38 deletions
diff --git a/lib/spack/external/__init__.py b/lib/spack/external/__init__.py index c0b131807b..ccca22ae3e 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.2 (commit 85757b6666422fca86aa882a769bf78b0f992f54) +* Version: 0.1.2 (commit 147942bd96219cf39e7001aef3644b43af76bdf6) argparse -------- diff --git a/lib/spack/external/archspec/cpu/detect.py b/lib/spack/external/archspec/cpu/detect.py index 31cde2af6d..3df04585c7 100644 --- a/lib/spack/external/archspec/cpu/detect.py +++ b/lib/spack/external/archspec/cpu/detect.py @@ -61,7 +61,7 @@ def proc_cpuinfo(): ``/proc/cpuinfo`` """ info = {} - with open("/proc/cpuinfo") as file: + with open("/proc/cpuinfo") as file: # pylint: disable=unspecified-encoding for line in file: key, separator, value = line.partition(":") @@ -80,26 +80,46 @@ def proc_cpuinfo(): def _check_output(args, env): - output = subprocess.Popen(args, stdout=subprocess.PIPE, env=env).communicate()[0] + output = subprocess.Popen( # pylint: disable=consider-using-with + args, stdout=subprocess.PIPE, env=env + ).communicate()[0] return six.text_type(output.decode("utf-8")) +def _machine(): + """ "Return the machine architecture we are on""" + operating_system = platform.system() + + # If we are not on Darwin, trust what Python tells us + if operating_system != "Darwin": + return platform.machine() + + # On Darwin it might happen that we are on M1, but using an interpreter + # built for x86_64. In that case "platform.machine() == 'x86_64'", so we + # need to fix that. + # + # See: https://bugs.python.org/issue42704 + output = _check_output( + ["sysctl", "-n", "machdep.cpu.brand_string"], env=_ensure_bin_usrbin_in_path() + ).strip() + + if "Apple" in output: + # Note that a native Python interpreter on Apple M1 would return + # "arm64" instead of "aarch64". Here we normalize to the latter. + return "aarch64" + + return "x86_64" + + @info_dict(operating_system="Darwin") def sysctl_info_dict(): """Returns a raw info dictionary parsing the output of sysctl.""" - # Make sure that /sbin and /usr/sbin are in PATH as sysctl is - # usually found there - child_environment = dict(os.environ.items()) - search_paths = child_environment.get("PATH", "").split(os.pathsep) - for additional_path in ("/sbin", "/usr/sbin"): - if additional_path not in search_paths: - search_paths.append(additional_path) - child_environment["PATH"] = os.pathsep.join(search_paths) + child_environment = _ensure_bin_usrbin_in_path() def sysctl(*args): return _check_output(["sysctl"] + list(args), env=child_environment).strip() - if platform.machine() == "x86_64": + if _machine() == "x86_64": flags = ( sysctl("-n", "machdep.cpu.features").lower() + " " @@ -125,6 +145,18 @@ def sysctl_info_dict(): return info +def _ensure_bin_usrbin_in_path(): + # Make sure that /sbin and /usr/sbin are in PATH as sysctl is + # usually found there + child_environment = dict(os.environ.items()) + search_paths = child_environment.get("PATH", "").split(os.pathsep) + for additional_path in ("/sbin", "/usr/sbin"): + if additional_path not in search_paths: + search_paths.append(additional_path) + child_environment["PATH"] = os.pathsep.join(search_paths) + return child_environment + + def adjust_raw_flags(info): """Adjust the flags detected on the system to homogenize slightly different representations. @@ -184,12 +216,7 @@ def compatible_microarchitectures(info): Args: info (dict): dictionary containing information on the host cpu """ - architecture_family = platform.machine() - # On Apple M1 platform.machine() returns "arm64" instead of "aarch64" - # so we should normalize the name here - if architecture_family == "arm64": - architecture_family = "aarch64" - + architecture_family = _machine() # If a tester is not registered, be conservative and assume no known # target is compatible with the host tester = COMPATIBILITY_CHECKS.get(architecture_family, lambda x, y: False) @@ -244,12 +271,7 @@ def compatibility_check(architecture_family): architecture_family = (architecture_family,) def decorator(func): - # pylint: disable=fixme - # TODO: on removal of Python 2.6 support this can be re-written as - # TODO: an update + a dict comprehension - for arch_family in architecture_family: - COMPATIBILITY_CHECKS[arch_family] = func - + COMPATIBILITY_CHECKS.update({family: func for family in architecture_family}) return func return decorator @@ -288,7 +310,7 @@ def compatibility_check_for_x86_64(info, target): arch_root = TARGETS[basename] return ( (target == arch_root or arch_root in target.ancestors) - and (target.vendor == vendor or target.vendor == "generic") + and target.vendor in (vendor, "generic") and target.features.issubset(features) ) @@ -303,8 +325,9 @@ def compatibility_check_for_aarch64(info, target): arch_root = TARGETS[basename] return ( (target == arch_root or arch_root in target.ancestors) - and (target.vendor == vendor or target.vendor == "generic") - and target.features.issubset(features) + 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") ) diff --git a/lib/spack/external/archspec/cpu/schema.py b/lib/spack/external/archspec/cpu/schema.py index 4a9299271b..e268232b6c 100644 --- a/lib/spack/external/archspec/cpu/schema.py +++ b/lib/spack/external/archspec/cpu/schema.py @@ -11,7 +11,7 @@ import os.path try: from collections.abc import MutableMapping # novm except ImportError: - from collections import MutableMapping + from collections import MutableMapping # pylint: disable=deprecated-class class LazyDictionary(MutableMapping): @@ -56,7 +56,7 @@ def _load_json_file(json_file): def _factory(): filename = os.path.join(json_dir, json_file) - with open(filename, "r") as file: + with open(filename, "r") as file: # pylint: disable=unspecified-encoding return json.load(file) return _factory diff --git a/lib/spack/external/archspec/json/cpu/microarchitectures.json b/lib/spack/external/archspec/json/cpu/microarchitectures.json index 0be30c25e0..839d83887e 100644 --- a/lib/spack/external/archspec/json/cpu/microarchitectures.json +++ b/lib/spack/external/archspec/json/cpu/microarchitectures.json @@ -1788,7 +1788,6 @@ "fp", "asimd", "evtstrm", - "aes", "pmull", "sha1", "sha2", @@ -1821,18 +1820,26 @@ "flags": "-march=armv8.2-a+crc+crypto+fp16" }, { - "versions": "8:", - "flags": "-march=armv8.2-a+crc+aes+sha2+fp16+sve -msve-vector-bits=512" + "versions": "8:10.2", + "flags": "-march=armv8.2-a+crc+sha2+fp16+sve -msve-vector-bits=512" + }, + { + "versions": "10.3:", + "flags": "-mcpu=a64fx -msve-vector-bits=512" } ], "clang": [ { "versions": "3.9:4.9", - "flags": "-march=armv8.2-a+crc+crypto+fp16" + "flags": "-march=armv8.2-a+crc+sha2+fp16" }, { - "versions": "5:", - "flags": "-march=armv8.2-a+crc+crypto+fp16+sve" + "versions": "5:10", + "flags": "-march=armv8.2-a+crc+sha2+fp16+sve" + }, + { + "versions": "11:", + "flags": "-mcpu=a64fx" } ], "arm": [ @@ -1954,7 +1961,40 @@ "m1": { "from": ["aarch64"], "vendor": "Apple", - "features": [], + "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" + ], "compilers": { "gcc": [ { @@ -1964,14 +2004,22 @@ ], "clang" : [ { - "versions": "9.0:", + "versions": "9.0:12.0", "flags" : "-march=armv8.4-a" + }, + { + "versions": "13.0:", + "flags" : "-mcpu=apple-m1" } ], "apple-clang": [ { - "versions": "11.0:", + "versions": "11.0:12.5", "flags" : "-march=armv8.4-a" + }, + { + "versions": "13.0:", + "flags" : "-mcpu=apple-m1" } ] } |