From 95e2fa3157342e750ac65609b1e88c8d1ca19673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Martinez=20Caama=C3=B1o?= Date: Fri, 12 Dec 2025 11:42:30 +0100 Subject: [PATCH 1/3] [HIP] Add an --offload-arch option to hip-tpl.py We add a --offload-arch=... option, that we can use to switch the target architecture. This can be a string such as 'gfx{version}', or 'amdgcnspirv'. This option defaults to 'gfx90a' such that if it is not specified, we keep the old behaviour ('gfx90a' was hardcoded). --- zorg/buildbot/builders/annotated/hip-tpl.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/zorg/buildbot/builders/annotated/hip-tpl.py b/zorg/buildbot/builders/annotated/hip-tpl.py index 48083f87b..7c2f9d740 100755 --- a/zorg/buildbot/builders/annotated/hip-tpl.py +++ b/zorg/buildbot/builders/annotated/hip-tpl.py @@ -2,6 +2,7 @@ import argparse import os +import re import subprocess import sys import traceback @@ -9,8 +10,20 @@ import tempfile from contextlib import contextmanager +def amdgpu_target(target): + if re.match("^(gfx[0-9a-f]+|amdgcnspirv)$", target): + return target + raise ValueError def main(argv): + parser = argparse.ArgumentParser(prog=os.path.basename(__file__)) + parser.add_argument("--offload-arch", default="gfx90a", type=amdgpu_target, + help="Offload architecture to be forwarded to AMDGPU_ARCHS " + "during the test suite configuration. " + "e.g. gfx90a, gfx1010, amdgcnspirv") + parsed_args = parser.parse_args(argv[1:]) + offload_arch = parsed_args.offload_arch + source_dir = os.path.join("..", "llvm-project") test_suite_source_dir = os.path.join("/opt/botworker/llvm", "llvm-test-suite") test_suite_build_dir = "TS-build" @@ -63,8 +76,7 @@ def main(argv): test_suite_cmake_args = ["-GNinja", "-B", test_suite_build_dir, "-S", "."] test_suite_cmake_args.append("-DTEST_SUITE_EXTERNALS_DIR=/opt/botworker/llvm/External") - # XXX: Use some utility to determine arch? - test_suite_cmake_args.append("-DAMDGPU_ARCHS=gfx90a") + test_suite_cmake_args.append(f"-DAMDGPU_ARCHS={offload_arch}") test_suite_cmake_args.append("-DTEST_SUITE_SUBDIRS=External") # Giving only this flag enables to pull the default Kokkos version. test_suite_cmake_args.append("-DEXTERNAL_HIP_TESTS_KOKKOS=ON") From 4761dafc324234895b96d9f1b44d0a6ca716236b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Martinez=20Caama=C3=B1o?= Date: Mon, 15 Dec 2025 15:16:44 +0100 Subject: [PATCH 2/3] [HIP] Enable SPIRV backend when testing HIP --- zorg/buildbot/builders/annotated/hip-build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zorg/buildbot/builders/annotated/hip-build.sh b/zorg/buildbot/builders/annotated/hip-build.sh index 83b4b095e..fa31c97c3 100755 --- a/zorg/buildbot/builders/annotated/hip-build.sh +++ b/zorg/buildbot/builders/annotated/hip-build.sh @@ -84,7 +84,7 @@ cmake -G Ninja \ -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ -DCMAKE_VERBOSE_MAKEFILE=1 \ - -DLLVM_TARGETS_TO_BUILD="AMDGPU;X86" \ + -DLLVM_TARGETS_TO_BUILD="AMDGPU;X86;SPIRV" \ -DLLVM_ENABLE_PROJECTS="clang;lld;clang-tools-extra" \ -DLLVM_ENABLE_RUNTIMES="compiler-rt;libcxx;libcxxabi;libunwind" \ -DCLANG_DEFAULT_LINKER=lld \ From 1669a416d5a3bd3239a8eaeda36c0ff2ea25a0c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Martinez=20Caama=C3=B1o?= Date: Tue, 16 Dec 2025 12:31:51 +0100 Subject: [PATCH 3/3] [Review] Turn --offload-arch into a list --- zorg/buildbot/builders/annotated/hip-tpl.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/zorg/buildbot/builders/annotated/hip-tpl.py b/zorg/buildbot/builders/annotated/hip-tpl.py index 7c2f9d740..9a9047c61 100755 --- a/zorg/buildbot/builders/annotated/hip-tpl.py +++ b/zorg/buildbot/builders/annotated/hip-tpl.py @@ -17,12 +17,19 @@ def amdgpu_target(target): def main(argv): parser = argparse.ArgumentParser(prog=os.path.basename(__file__)) - parser.add_argument("--offload-arch", default="gfx90a", type=amdgpu_target, - help="Offload architecture to be forwarded to AMDGPU_ARCHS " - "during the test suite configuration. " - "e.g. gfx90a, gfx1010, amdgcnspirv") - parsed_args = parser.parse_args(argv[1:]) - offload_arch = parsed_args.offload_arch + parser.add_argument("--offload-arch", action='append', type=amdgpu_target, + help="Offload architectures to be forwarded to AMDGPU_ARCHS " + "during the test suite configuration. This option can appear multiple times. " + "e.g. '--offload-arch gfx90a --offload-arch gfx1010 --offload-arch amdgcnspirv'") + + parsed_args = parser.parse_args(sys.argv[1:]) + + if parsed_args.offload_arch is None: + DEFAULT_OFFLOAD_ARCH = "gfx90a" + offload_arch_cmake_arg = DEFAULT_OFFLOAD_ARCH + else: + offload_arch = set(parsed_args.offload_arch) + offload_arch_cmake_arg = ";".join(sorted(offload_arch)) source_dir = os.path.join("..", "llvm-project") test_suite_source_dir = os.path.join("/opt/botworker/llvm", "llvm-test-suite") @@ -76,7 +83,7 @@ def main(argv): test_suite_cmake_args = ["-GNinja", "-B", test_suite_build_dir, "-S", "."] test_suite_cmake_args.append("-DTEST_SUITE_EXTERNALS_DIR=/opt/botworker/llvm/External") - test_suite_cmake_args.append(f"-DAMDGPU_ARCHS={offload_arch}") + test_suite_cmake_args.append(f"-DAMDGPU_ARCHS={offload_arch_cmake_arg}") test_suite_cmake_args.append("-DTEST_SUITE_SUBDIRS=External") # Giving only this flag enables to pull the default Kokkos version. test_suite_cmake_args.append("-DEXTERNAL_HIP_TESTS_KOKKOS=ON")