archspec: add support for zen4 (#34609)

Also add:
- Upper bound for Xeon Phi compiler support
- Better detection for a64fx
This commit is contained in:
Massimiliano Culpo 2022-12-20 11:22:50 +01:00 committed by GitHub
parent bd613b3124
commit b2c806f6fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 98 additions and 33 deletions

View File

@ -18,7 +18,7 @@
* 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
--------

View File

@ -1,2 +1,2 @@
"""Init file to avoid namespace packages"""
__version__ = "0.1.2"
__version__ = "0.2.0"

View File

@ -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

View File

@ -11,8 +11,6 @@
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):

View File

@ -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 _impl(self, other):
return _impl
class Microarchitecture(object):
class Microarchitecture:
"""Represents a specific CPU micro-architecture.
Args:
@ -150,7 +147,7 @@ def __str__(self):
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 @@ def family(self):
"""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

View File

@ -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

View File

@ -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",