archspec: update version, translate renamed uarchs (#33556)

* Update archspec version

* Add a translation table from old names
This commit is contained in:
Massimiliano Culpo 2022-11-07 13:50:38 +01:00 committed by GitHub
parent f8e4ad5209
commit e045dabb3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 288 additions and 24 deletions

View File

@ -18,7 +18,7 @@
* Homepage: https://pypi.python.org/pypi/archspec * Homepage: https://pypi.python.org/pypi/archspec
* Usage: Labeling, comparison and detection of microarchitectures * Usage: Labeling, comparison and detection of microarchitectures
* Version: 0.1.4 (commit e2cfdc266174488dee78b8c9058e36d60dc1b548) * Version: 0.2.0 (commit 77640e572725ad97f18e63a04857155752ace045)
argparse argparse
-------- --------

View File

@ -132,9 +132,15 @@ def sysctl(*args):
"model name": sysctl("-n", "machdep.cpu.brand_string"), "model name": sysctl("-n", "machdep.cpu.brand_string"),
} }
else: else:
model = ( model = "unknown"
"m1" if "Apple" in sysctl("-n", "machdep.cpu.brand_string") else "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 = { info = {
"vendor_id": "Apple", "vendor_id": "Apple",
"flags": [], "flags": [],
@ -322,14 +328,26 @@ def compatibility_check_for_aarch64(info, target):
features = set(info.get("Features", "").split()) features = set(info.get("Features", "").split())
vendor = info.get("CPU implementer", "generic") 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] arch_root = TARGETS[basename]
return ( arch_root_and_vendor = arch_root == target.family and target.vendor in (
(target == arch_root or arch_root in target.ancestors) vendor,
and target.vendor in (vendor, "generic") "generic",
# On macOS it seems impossible to get all the CPU features with syctl info
and (target.features.issubset(features) or platform.system() == "Darwin")
) )
# 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") @compatibility_check(architecture_family="riscv64")
def compatibility_check_for_riscv64(info, target): def compatibility_check_for_riscv64(info, target):

View File

@ -85,7 +85,7 @@
"intel": [ "intel": [
{ {
"versions": ":", "versions": ":",
"name": "x86-64", "name": "pentium4",
"flags": "-march={name} -mtune=generic" "flags": "-march={name} -mtune=generic"
} }
], ],
@ -2093,8 +2093,163 @@
] ]
} }
}, },
"thunderx2": { "armv8.1a": {
"from": ["aarch64"], "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", "vendor": "Cavium",
"features": [ "features": [
"fp", "fp",
@ -2141,7 +2296,7 @@
} }
}, },
"a64fx": { "a64fx": {
"from": ["aarch64"], "from": ["armv8.2a"],
"vendor": "Fujitsu", "vendor": "Fujitsu",
"features": [ "features": [
"fp", "fp",
@ -2209,7 +2364,7 @@
] ]
} }
}, },
"graviton": { "cortex_a72": {
"from": ["aarch64"], "from": ["aarch64"],
"vendor": "ARM", "vendor": "ARM",
"features": [ "features": [
@ -2235,19 +2390,19 @@
}, },
{ {
"versions": "6:", "versions": "6:",
"flags" : "-march=armv8-a+crc+crypto -mtune=cortex-a72" "flags" : "-mcpu=cortex-a72"
} }
], ],
"clang" : [ "clang" : [
{ {
"versions": "3.9:", "versions": "3.9:",
"flags" : "-march=armv8-a+crc+crypto" "flags" : "-mcpu=cortex-a72"
} }
] ]
} }
}, },
"graviton2": { "neoverse_n1": {
"from": ["graviton"], "from": ["cortex_a72", "armv8.2a"],
"vendor": "ARM", "vendor": "ARM",
"features": [ "features": [
"fp", "fp",
@ -2296,7 +2451,7 @@
}, },
{ {
"versions": "9.0:", "versions": "9.0:",
"flags" : "-march=armv8.2-a+fp16+rcpc+dotprod+crypto -mtune=neoverse-n1" "flags" : "-mcpu=neoverse-n1"
} }
], ],
"clang" : [ "clang" : [
@ -2307,6 +2462,10 @@
{ {
"versions": "5:", "versions": "5:",
"flags" : "-march=armv8.2-a+fp16+rcpc+dotprod+crypto" "flags" : "-march=armv8.2-a+fp16+rcpc+dotprod+crypto"
},
{
"versions": "10:",
"flags" : "-mcpu=neoverse-n1"
} }
], ],
"arm" : [ "arm" : [
@ -2317,11 +2476,11 @@
] ]
} }
}, },
"graviton3": { "neoverse_v1": {
"from": ["graviton2"], "from": ["neoverse_n1", "armv8.4a"],
"vendor": "ARM", "vendor": "ARM",
"features": [ "features": [
"fp", "fp",
"asimd", "asimd",
"evtstrm", "evtstrm",
"aes", "aes",
@ -2384,11 +2543,11 @@
}, },
{ {
"versions": "9.0:9.9", "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:", "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:", "versions": "11:",
"flags" : "-march=armv8.4-a+sve+ssbs+fp16+bf16+crypto+i8mm+rng" "flags" : "-march=armv8.4-a+sve+ssbs+fp16+bf16+crypto+i8mm+rng"
},
{
"versions": "12:",
"flags" : "-mcpu=neoverse-v1"
} }
], ],
"arm" : [ "arm" : [
@ -2419,7 +2582,7 @@
} }
}, },
"m1": { "m1": {
"from": ["aarch64"], "from": ["armv8.4a"],
"vendor": "Apple", "vendor": "Apple",
"features": [ "features": [
"fp", "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": { "arm": {
"from": [], "from": [],
"vendor": "generic", "vendor": "generic",

View File

@ -3,6 +3,7 @@
# #
# SPDX-License-Identifier: (Apache-2.0 OR MIT) # SPDX-License-Identifier: (Apache-2.0 OR MIT)
import functools import functools
import warnings
import six import six
@ -34,6 +35,14 @@ def _impl(self, other):
return _impl return _impl
#: Translation table from archspec deprecated names
_DEPRECATED_ARCHSPEC_NAMES = {
"graviton": "cortex_a72",
"graviton2": "neoverse_n1",
"graviton3": "neoverse_v1",
}
class Target(object): class Target(object):
def __init__(self, name, module_name=None): def __init__(self, name, module_name=None):
"""Target models microarchitectures and their compatibility. """Target models microarchitectures and their compatibility.
@ -45,6 +54,10 @@ def __init__(self, name, module_name=None):
like Cray (e.g. craype-compiler) like Cray (e.g. craype-compiler)
""" """
if not isinstance(name, archspec.cpu.Microarchitecture): 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)) name = archspec.cpu.TARGETS.get(name, archspec.cpu.generic_microarchitecture(name))
self.microarchitecture = name self.microarchitecture = name
self.module_name = module_name self.module_name = module_name