From b2c806f6fcd73ae624582c84a177e465a7877cf7 Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Tue, 20 Dec 2022 11:22:50 +0100 Subject: archspec: add support for zen4 (#34609) Also add: - Upper bound for Xeon Phi compiler support - Better detection for a64fx --- lib/spack/external/__init__.py | 2 +- lib/spack/external/archspec/__init__.py | 2 +- lib/spack/external/archspec/cpu/alias.py | 5 +- lib/spack/external/archspec/cpu/detect.py | 11 +-- .../external/archspec/cpu/microarchitecture.py | 14 +--- lib/spack/external/archspec/cpu/schema.py | 10 +-- .../archspec/json/cpu/microarchitectures.json | 87 +++++++++++++++++++++- 7 files changed, 98 insertions(+), 33 deletions(-) diff --git a/lib/spack/external/__init__.py b/lib/spack/external/__init__.py index 89928fae59..ce5924a9a5 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.2.0 (commit 77640e572725ad97f18e63a04857155752ace045) +* Version: 0.2.0 (commit e44bad9c7b6defac73696f64078b2fe634719b62) argparse -------- diff --git a/lib/spack/external/archspec/__init__.py b/lib/spack/external/archspec/__init__.py index 1188c6cecc..fbbab9f78a 100644 --- a/lib/spack/external/archspec/__init__.py +++ b/lib/spack/external/archspec/__init__.py @@ -1,2 +1,2 @@ """Init file to avoid namespace packages""" -__version__ = "0.1.2" +__version__ = "0.2.0" diff --git a/lib/spack/external/archspec/cpu/alias.py b/lib/spack/external/archspec/cpu/alias.py index b93972fe81..783a67d3ea 100644 --- a/lib/spack/external/archspec/cpu/alias.py +++ b/lib/spack/external/archspec/cpu/alias.py @@ -3,13 +3,12 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) """Aliases for microarchitecture features.""" -# pylint: disable=useless-object-inheritance from .schema import TARGETS_JSON, LazyDictionary _FEATURE_ALIAS_PREDICATE = {} -class FeatureAliasTest(object): +class FeatureAliasTest: """A test that must be passed for a feature alias to succeed. Args: @@ -48,7 +47,7 @@ def alias_predicate(func): # Check we didn't register anything else with the same name if name in _FEATURE_ALIAS_PREDICATE: - msg = 'the alias predicate "{0}" already exists'.format(name) + msg = f'the alias predicate "{name}" already exists' raise KeyError(msg) _FEATURE_ALIAS_PREDICATE[name] = func diff --git a/lib/spack/external/archspec/cpu/detect.py b/lib/spack/external/archspec/cpu/detect.py index a7cc4481f6..305bf9d9d6 100644 --- a/lib/spack/external/archspec/cpu/detect.py +++ b/lib/spack/external/archspec/cpu/detect.py @@ -11,8 +11,6 @@ import re import subprocess import warnings -import six - from .microarchitecture import generic_microarchitecture, TARGETS from .schema import TARGETS_JSON @@ -80,10 +78,9 @@ def proc_cpuinfo(): def _check_output(args, env): - output = subprocess.Popen( # pylint: disable=consider-using-with - args, stdout=subprocess.PIPE, env=env - ).communicate()[0] - return six.text_type(output.decode("utf-8")) + with subprocess.Popen(args, stdout=subprocess.PIPE, env=env) as proc: + output = proc.communicate()[0] + return str(output.decode("utf-8")) def _machine(): @@ -273,7 +270,7 @@ def compatibility_check(architecture_family): this test can be used, e.g. x86_64 or ppc64le etc. """ # Turn the argument into something iterable - if isinstance(architecture_family, six.string_types): + if isinstance(architecture_family, str): architecture_family = (architecture_family,) def decorator(func): diff --git a/lib/spack/external/archspec/cpu/microarchitecture.py b/lib/spack/external/archspec/cpu/microarchitecture.py index 125d36e61b..471c6f2074 100644 --- a/lib/spack/external/archspec/cpu/microarchitecture.py +++ b/lib/spack/external/archspec/cpu/microarchitecture.py @@ -5,14 +5,11 @@ """Types and functions to manage information on CPU microarchitectures. """ -# pylint: disable=useless-object-inheritance import functools import platform import re import warnings -import six - import archspec import archspec.cpu.alias import archspec.cpu.schema @@ -27,7 +24,7 @@ def coerce_target_names(func): @functools.wraps(func) def _impl(self, other): - if isinstance(other, six.string_types): + if isinstance(other, str): if other not in TARGETS: msg = '"{0}" is not a valid target name' raise ValueError(msg.format(other)) @@ -38,7 +35,7 @@ def coerce_target_names(func): return _impl -class Microarchitecture(object): +class Microarchitecture: """Represents a specific CPU micro-architecture. Args: @@ -150,7 +147,7 @@ class Microarchitecture(object): def __contains__(self, feature): # Feature must be of a string type, so be defensive about that - if not isinstance(feature, six.string_types): + if not isinstance(feature, str): msg = "only objects of string types are accepted [got {0}]" raise TypeError(msg.format(str(type(feature)))) @@ -168,7 +165,7 @@ class Microarchitecture(object): """Returns the architecture family a given target belongs to""" roots = [x for x in [self] + self.ancestors if not x.ancestors] msg = "a target is expected to belong to just one architecture family" - msg += "[found {0}]".format(", ".join(str(x) for x in roots)) + msg += f"[found {', '.join(str(x) for x in roots)}]" assert len(roots) == 1, msg return roots.pop() @@ -318,9 +315,6 @@ def _known_microarchitectures(): """Returns a dictionary of the known micro-architectures. If the current host platform is unknown adds it too as a generic target. """ - # pylint: disable=fixme - # TODO: Simplify this logic using object_pairs_hook to OrderedDict - # TODO: when we stop supporting python2.6 def fill_target_from_dict(name, data, targets): """Recursively fills targets by adding the micro-architecture diff --git a/lib/spack/external/archspec/cpu/schema.py b/lib/spack/external/archspec/cpu/schema.py index e268232b6c..d560ce4e3c 100644 --- a/lib/spack/external/archspec/cpu/schema.py +++ b/lib/spack/external/archspec/cpu/schema.py @@ -5,16 +5,12 @@ """Global objects with the content of the microarchitecture JSON file and its schema """ +import collections.abc import json import os.path -try: - from collections.abc import MutableMapping # novm -except ImportError: - from collections import MutableMapping # pylint: disable=deprecated-class - -class LazyDictionary(MutableMapping): +class LazyDictionary(collections.abc.MutableMapping): """Lazy dictionary that gets constructed on first access to any object key Args: @@ -56,7 +52,7 @@ def _load_json_file(json_file): def _factory(): filename = os.path.join(json_dir, json_file) - with open(filename, "r") as file: # pylint: disable=unspecified-encoding + with open(filename, "r", encoding="utf-8") as file: 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 15d32e9fa0..b63149fc4b 100644 --- a/lib/spack/external/archspec/json/cpu/microarchitectures.json +++ b/lib/spack/external/archspec/json/cpu/microarchitectures.json @@ -961,21 +961,21 @@ ], "intel": [ { - "versions": "18.0:", + "versions": "18.0:2021.2", "name": "knl", "flags": "-march={name} -mtune={name}" } ], "oneapi": [ { - "versions": ":", + "versions": ":2021.2", "name": "knl", "flags": "-march={name} -mtune={name}" } ], "dpcpp": [ { - "versions": ":", + "versions": ":2021.2", "name": "knl", "flags": "-march={name} -mtune={name}" } @@ -1905,6 +1905,86 @@ ] } }, + "zen4": { + "from": ["zen3", "x86_64_v4"], + "vendor": "AuthenticAMD", + "features": [ + "bmi1", + "bmi2", + "f16c", + "fma", + "fsgsbase", + "avx", + "avx2", + "rdseed", + "clzero", + "aes", + "pclmulqdq", + "cx16", + "movbe", + "mmx", + "sse", + "sse2", + "sse4a", + "ssse3", + "sse4_1", + "sse4_2", + "abm", + "xsavec", + "xsaveopt", + "clflushopt", + "popcnt", + "clwb", + "vaes", + "vpclmulqdq", + "pku", + "gfni", + "flush_l1d", + "erms", + "avic", + "avx512f", + "avx512dq", + "avx512ifma", + "avx512cd", + "avx512bw", + "avx512vl", + "avx512_bf16", + "avx512vbmi", + "avx512_vbmi2", + "avx512_vnni", + "avx512_bitalg", + "avx512_vpopcntdq" + ], + "compilers": { + "gcc": [ + { + "versions": "10.3:", + "name": "znver3", + "flags": "-march={name} -mtune={name} -mavx512f -mavx512dq -mavx512ifma -mavx512cd -mavx512bw -mavx512vl -mavx512vbmi -mavx512vbmi2 -mavx512vnni -mavx512bitalg" + } + ], + "clang": [ + { + "versions": "12.0:", + "name": "znver3", + "flags": "-march={name} -mtune={name} -mavx512f -mavx512dq -mavx512ifma -mavx512cd -mavx512bw -mavx512vl -mavx512vbmi -mavx512vbmi2 -mavx512vnni -mavx512bitalg" + } + ], + "aocc": [ + { + "versions": "3.0:3.9", + "name": "znver3", + "flags": "-march={name} -mtune={name} -mavx512f -mavx512dq -mavx512ifma -mavx512cd -mavx512bw -mavx512vl -mavx512vbmi -mavx512vbmi2 -mavx512vnni -mavx512bitalg", + "warnings": "Zen4 processors are not fully supported by AOCC versions < 4.0. For optimal performance please upgrade to a newer version of AOCC" + }, + { + "versions": "4.0:", + "name": "znver4", + "flags": "-march={name} -mtune={name}" + } + ] + } + }, "ppc64": { "from": [], "vendor": "generic", @@ -2302,7 +2382,6 @@ "fp", "asimd", "evtstrm", - "pmull", "sha1", "sha2", "crc32", -- cgit v1.2.3-70-g09d2