From 69abc4d860695eeaaa314ac3bf5655b57f2f5b55 Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Mon, 4 Oct 2021 09:34:53 +0200 Subject: Build ppc64le docker images (#26442) * Update archspec * Add ppc64le to docker images --- lib/spack/external/__init__.py | 2 +- lib/spack/external/archspec/cpu/detect.py | 29 +++++++++++++++++++--- .../external/archspec/cpu/microarchitecture.py | 6 +++++ 3 files changed, 32 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/spack/external/__init__.py b/lib/spack/external/__init__.py index 7ae506a46b..112ad9e9af 100644 --- a/lib/spack/external/__init__.py +++ b/lib/spack/external/__init__.py @@ -11,7 +11,7 @@ archspec * Homepage: https://pypi.python.org/pypi/archspec * Usage: Labeling, comparison and detection of microarchitectures -* Version: 0.1.2 (commit 4dbf253daf37e4a008e4beb6489f347b4a35aed4) +* Version: 0.1.2 (commit 8940a8b099a54ded21f8cf4314c4b83b558bb6d1) argparse -------- diff --git a/lib/spack/external/archspec/cpu/detect.py b/lib/spack/external/archspec/cpu/detect.py index eb75cdfb0e..56b73b3a75 100644 --- a/lib/spack/external/archspec/cpu/detect.py +++ b/lib/spack/external/archspec/cpu/detect.py @@ -206,11 +206,26 @@ def host(): # Get a list of possible candidates for this micro-architecture candidates = compatible_microarchitectures(info) + # Sorting criteria for candidates + def sorting_fn(item): + return len(item.ancestors), len(item.features) + + # Get the best generic micro-architecture + generic_candidates = [c for c in candidates if c.vendor == "generic"] + best_generic = max(generic_candidates, key=sorting_fn) + + # Filter the candidates to be descendant of the best generic candidate. + # This is to avoid that the lack of a niche feature that can be disabled + # from e.g. BIOS prevents detection of a reasonably performant architecture + candidates = [c for c in candidates if c > best_generic] + + # If we don't have candidates, return the best generic micro-architecture + if not candidates: + return best_generic + # Reverse sort of the depth for the inheritance tree among only targets we # can use. This gets the newest target we satisfy. - return sorted( - candidates, key=lambda t: (len(t.ancestors), len(t.features)), reverse=True - )[0] + return max(candidates, key=sorting_fn) def compatibility_check(architecture_family): @@ -245,7 +260,13 @@ def compatibility_check_for_power(info, target): """Compatibility check for PPC64 and PPC64LE architectures.""" basename = platform.machine() generation_match = re.search(r"POWER(\d+)", info.get("cpu", "")) - generation = int(generation_match.group(1)) + try: + generation = int(generation_match.group(1)) + except AttributeError: + # There might be no match under emulated environments. For instance + # emulating a ppc64le with QEMU and Docker still reports the host + # /proc/cpuinfo and not a Power + generation = 0 # We can use a target if it descends from our machine type and our # generation (9 for POWER9, etc) is at least its generation. diff --git a/lib/spack/external/archspec/cpu/microarchitecture.py b/lib/spack/external/archspec/cpu/microarchitecture.py index 1b4f6485d5..410d83c3dc 100644 --- a/lib/spack/external/archspec/cpu/microarchitecture.py +++ b/lib/spack/external/archspec/cpu/microarchitecture.py @@ -173,6 +173,12 @@ class Microarchitecture(object): return roots.pop() + @property + def generic(self): + """Returns the best generic architecture that is compatible with self""" + generics = [x for x in [self] + self.ancestors if x.vendor == "generic"] + return max(generics, key=lambda x: len(x.ancestors)) + def to_dict(self, return_list_of_items=False): """Returns a dictionary representation of this object. -- cgit v1.2.3-60-g2f50