From 5e7b9ebea0d6adb92cb1928af0a50cb7259a2d5a Mon Sep 17 00:00:00 2001 From: Mckinsey Date: Thu, 27 Feb 2025 14:22:10 -0800 Subject: [PATCH 01/22] Add script to check repos in specific spack tag against benchpark repos --- lib/scripts/spackdiff.py | 87 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 lib/scripts/spackdiff.py diff --git a/lib/scripts/spackdiff.py b/lib/scripts/spackdiff.py new file mode 100644 index 000000000..e3df8acc5 --- /dev/null +++ b/lib/scripts/spackdiff.py @@ -0,0 +1,87 @@ +import argparse +import difflib +import os +import subprocess +import sys +import itertools + +parser = argparse.ArgumentParser( + description="Script to compare packages in benchpark against upstream spack packages." +) +parser.add_argument( + "--spack-tag", + default="develop", + help="Specify the spack version in the format 'vX.Y.Z', e.g., 'v0.23.1'.", +) +parser.add_argument("--print-diff", action="store_true", help="Print file diff") +args = parser.parse_args() + +print(f"Comparing benchpark packages to packages in spack {args.spack_tag}") + +if "spack" not in os.listdir(os.getcwd()): + subprocess.run(["git", "clone", "https://github.com/spack/spack.git"]) +subprocess.run(["git", "checkout", args.spack_tag], cwd="spack") + +sys.path.append("spack/lib/spack") +import llnl.util.tty.color as color # noqa: E402 + + +spack_dir = "spack/var/spack/repos/builtin/packages/" +benchpark_dir = "../../repo/" + +for package in sorted(os.listdir(benchpark_dir)): + if package not in ["repo.yaml"]: + spack_package_path = spack_dir + package + "/package.py" + benchpark_package_path = benchpark_dir + package + "/package.py" + + if not os.path.exists(spack_package_path): + color.cprint("@*b" + package + "@.") + color.cprint( + " " + package + "/package.py @*rdoes not@. exist in @*ospack@." + ) + continue + elif not os.path.exists(benchpark_package_path): + # color.cprint(" "+package+" package.py @*rdoes not@. exist in @*obenchpark@.") + continue + + color.cprint("@*b" + package + "@.") + + # Read the files + with open(spack_package_path, "r") as file1, open( + benchpark_package_path, "r" + ) as file2: + spack_lines = [line for line in file1 if not line.lstrip().startswith("#")] + benchpark_lines = [ + line for line in file2 if not line.lstrip().startswith("#") + ] + + # Compare the files + diff = difflib.unified_diff( + spack_lines, + benchpark_lines, + fromfile="spack " + package, + tofile="benchpark " + package, + lineterm="", + ) + + diff, dc, dc2 = itertools.tee(diff, 3) + + diff_list = list(diff) + # Check if there is no diff + if not diff_list: + color.cprint( + f" @*gNo differences found. '{benchpark_package_path}' can be upstreamed to '{spack_package_path}'@." + ) + + # Use difflib.ndiff to compare the lines + dc3 = difflib.ndiff(spack_lines, benchpark_lines) + # Count the differing lines (ignoring duplicates) + differing_lines_count = sum( + 1 for line in dc3 if line.startswith("- ") or line.startswith("+ ") + ) + print(" ", differing_lines_count // 2, "different lines") + # print(" ",sum(1 for _ in dc2), "different lines") + + if args.print_diff: + # Print the differences + print("\n".join(dc)) From b8167090ff0b40faa21fbd15910aa840ddd37bb4 Mon Sep 17 00:00:00 2001 From: Mckinsey Date: Mon, 3 Mar 2025 12:37:32 -0800 Subject: [PATCH 02/22] Rename scripts in lib/scripts/ --- lib/scripts/{spackdiff.py => diffPackages.py} | 0 lib/scripts/{altdiff.py => diffSpecs.py} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename lib/scripts/{spackdiff.py => diffPackages.py} (100%) rename lib/scripts/{altdiff.py => diffSpecs.py} (100%) diff --git a/lib/scripts/spackdiff.py b/lib/scripts/diffPackages.py similarity index 100% rename from lib/scripts/spackdiff.py rename to lib/scripts/diffPackages.py diff --git a/lib/scripts/altdiff.py b/lib/scripts/diffSpecs.py similarity index 100% rename from lib/scripts/altdiff.py rename to lib/scripts/diffSpecs.py From fbd1842c5112e46c7115a3cf5ad2b6bad180adc0 Mon Sep 17 00:00:00 2001 From: Mckinsey Date: Mon, 3 Mar 2025 13:46:48 -0800 Subject: [PATCH 03/22] Use benchpark path. Refactor into main() --- lib/scripts/diffPackages.py | 117 +++++++++++++++++++----------------- 1 file changed, 63 insertions(+), 54 deletions(-) diff --git a/lib/scripts/diffPackages.py b/lib/scripts/diffPackages.py index e3df8acc5..07237755a 100644 --- a/lib/scripts/diffPackages.py +++ b/lib/scripts/diffPackages.py @@ -5,8 +5,11 @@ import sys import itertools +import benchpark.paths + parser = argparse.ArgumentParser( - description="Script to compare packages in benchpark against upstream spack packages." + description="Script to compare packages in benchpark against upstream spack packages.", + usage="benchpark-python diffPackages.py [OPTIONS]", ) parser.add_argument( "--spack-tag", @@ -26,62 +29,68 @@ import llnl.util.tty.color as color # noqa: E402 -spack_dir = "spack/var/spack/repos/builtin/packages/" -benchpark_dir = "../../repo/" +def main(): + spack_dir = "spack/var/spack/repos/builtin/packages/" + benchpark_dir = str(benchpark.paths.benchpark_root) + "/repo/" + + for package in sorted(os.listdir(benchpark_dir)): + if package not in ["repo.yaml"]: + spack_package_path = spack_dir + package + "/package.py" + benchpark_package_path = benchpark_dir + package + "/package.py" -for package in sorted(os.listdir(benchpark_dir)): - if package not in ["repo.yaml"]: - spack_package_path = spack_dir + package + "/package.py" - benchpark_package_path = benchpark_dir + package + "/package.py" + if not os.path.exists(spack_package_path): + color.cprint("@*b" + package + "@.") + color.cprint( + " " + package + "/package.py @*rdoes not@. exist in @*ospack@." + ) + continue + elif not os.path.exists(benchpark_package_path): + # color.cprint(" "+package+" package.py @*rdoes not@. exist in @*obenchpark@.") + continue - if not os.path.exists(spack_package_path): color.cprint("@*b" + package + "@.") - color.cprint( - " " + package + "/package.py @*rdoes not@. exist in @*ospack@." + + # Read the files + with open(spack_package_path, "r") as file1, open( + benchpark_package_path, "r" + ) as file2: + spack_lines = [ + line for line in file1 if not line.lstrip().startswith("#") + ] + benchpark_lines = [ + line for line in file2 if not line.lstrip().startswith("#") + ] + + # Compare the files + diff = difflib.unified_diff( + spack_lines, + benchpark_lines, + fromfile="spack " + package, + tofile="benchpark " + package, + lineterm="", ) - continue - elif not os.path.exists(benchpark_package_path): - # color.cprint(" "+package+" package.py @*rdoes not@. exist in @*obenchpark@.") - continue - - color.cprint("@*b" + package + "@.") - - # Read the files - with open(spack_package_path, "r") as file1, open( - benchpark_package_path, "r" - ) as file2: - spack_lines = [line for line in file1 if not line.lstrip().startswith("#")] - benchpark_lines = [ - line for line in file2 if not line.lstrip().startswith("#") - ] - - # Compare the files - diff = difflib.unified_diff( - spack_lines, - benchpark_lines, - fromfile="spack " + package, - tofile="benchpark " + package, - lineterm="", - ) - - diff, dc, dc2 = itertools.tee(diff, 3) - - diff_list = list(diff) - # Check if there is no diff - if not diff_list: - color.cprint( - f" @*gNo differences found. '{benchpark_package_path}' can be upstreamed to '{spack_package_path}'@." + + diff, dc, dc2 = itertools.tee(diff, 3) + + diff_list = list(diff) + # Check if there is no diff + if not diff_list: + color.cprint( + f" @*gNo differences found. '{benchpark_package_path}' can be upstreamed to '{spack_package_path}'@." + ) + + # Use difflib.ndiff to compare the lines + dc3 = difflib.ndiff(spack_lines, benchpark_lines) + # Count the differing lines (ignoring duplicates) + differing_lines_count = sum( + 1 for line in dc3 if line.startswith("- ") or line.startswith("+ ") ) + print(" ", differing_lines_count // 2, "different lines") + + if args.print_diff: + # Print the differences + print("\n".join(dc)) + - # Use difflib.ndiff to compare the lines - dc3 = difflib.ndiff(spack_lines, benchpark_lines) - # Count the differing lines (ignoring duplicates) - differing_lines_count = sum( - 1 for line in dc3 if line.startswith("- ") or line.startswith("+ ") - ) - print(" ", differing_lines_count // 2, "different lines") - # print(" ",sum(1 for _ in dc2), "different lines") - - if args.print_diff: - # Print the differences - print("\n".join(dc)) +if __name__ == "__main__": + main() From 8e933f4011f3dcc8c154485355ef5a746de3276a Mon Sep 17 00:00:00 2001 From: Mckinsey Date: Mon, 3 Mar 2025 14:13:40 -0800 Subject: [PATCH 04/22] Add option to specify package subset --- lib/scripts/diffPackages.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/scripts/diffPackages.py b/lib/scripts/diffPackages.py index 07237755a..a04c5b580 100644 --- a/lib/scripts/diffPackages.py +++ b/lib/scripts/diffPackages.py @@ -17,6 +17,11 @@ help="Specify the spack version in the format 'vX.Y.Z', e.g., 'v0.23.1'.", ) parser.add_argument("--print-diff", action="store_true", help="Print file diff") +parser.add_argument( + "--packages", + nargs="+", # Allows one or more package names + help="Specify one or more packages to compare. If not provided, all packages will be compared.", +) args = parser.parse_args() print(f"Comparing benchpark packages to packages in spack {args.spack_tag}") @@ -33,7 +38,15 @@ def main(): spack_dir = "spack/var/spack/repos/builtin/packages/" benchpark_dir = str(benchpark.paths.benchpark_root) + "/repo/" - for package in sorted(os.listdir(benchpark_dir)): + # Get the list of packages to process + if args.packages: + # Use only the specified packages + packages_to_compare = args.packages + else: + # Process all packages if --packages is not provided + packages_to_compare = sorted(os.listdir(benchpark_dir)) + + for package in packages_to_compare: if package not in ["repo.yaml"]: spack_package_path = spack_dir + package + "/package.py" benchpark_package_path = benchpark_dir + package + "/package.py" @@ -93,4 +106,4 @@ def main(): if __name__ == "__main__": - main() + main() \ No newline at end of file From e556a2210098606a07ec7c4a2bf6bf05688b8be5 Mon Sep 17 00:00:00 2001 From: Mckinsey Date: Mon, 3 Mar 2025 14:14:06 -0800 Subject: [PATCH 05/22] Make -i optional for benchpark-python --- bin/benchpark-python | 9 ++++++++- lib/benchpark/cmd/unit_test.py | 2 +- pyproject.toml | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/bin/benchpark-python b/bin/benchpark-python index a7fd9c642..6911ad7ce 100755 --- a/bin/benchpark-python +++ b/bin/benchpark-python @@ -18,4 +18,11 @@ # SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) export PYTHONPATH="${SCRIPT_DIR}/../lib":$PYTHONPATH -exec python3 -i "$@" +# Check if the first argument is -i +if [ "$1" = "-i" ]; then + # Shift the arguments to remove the first one (-i) + shift + exec python3 -i "$@" +else + exec python3 "$@" +fi diff --git a/lib/benchpark/cmd/unit_test.py b/lib/benchpark/cmd/unit_test.py index e5fec327c..6fb9b81f8 100644 --- a/lib/benchpark/cmd/unit_test.py +++ b/lib/benchpark/cmd/unit_test.py @@ -221,7 +221,7 @@ def command(args, unknown_args): "--dist", "loadfile", "--tx", - f"{args.numprocesses}*popen//python=benchpark-tmpconfig benchpark-python", + f"{args.numprocesses}*popen//python=benchpark-tmpconfig benchpark-python -i", ] ) diff --git a/pyproject.toml b/pyproject.toml index 4a27db4dc..a5c9bef04 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ force-exclude = ''' '/lib/benchpark/test_repo/(/.*)?$' | /lib/benchpark/test_repo(/.*)?$ | lib/benchpark/test_repo - | '/bin/benchpark-python' + | '/bin/benchpark-python -i' | \.github )/ ''' From 6d1a6ca5e735924b149986e712accaaad0beb068 Mon Sep 17 00:00:00 2001 From: Mckinsey Date: Mon, 3 Mar 2025 14:20:20 -0800 Subject: [PATCH 06/22] Update upstream message to be more clear about intent --- lib/scripts/diffPackages.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/scripts/diffPackages.py b/lib/scripts/diffPackages.py index a04c5b580..8bbb135ba 100644 --- a/lib/scripts/diffPackages.py +++ b/lib/scripts/diffPackages.py @@ -89,7 +89,7 @@ def main(): # Check if there is no diff if not diff_list: color.cprint( - f" @*gNo differences found. '{benchpark_package_path}' can be upstreamed to '{spack_package_path}'@." + f" @*gNo differences found. We can safely delete '{benchpark_package_path}' in favor of spack upstream@." ) # Use difflib.ndiff to compare the lines @@ -106,4 +106,4 @@ def main(): if __name__ == "__main__": - main() \ No newline at end of file + main() From 31c8b8f445534a5edd693e7e569959f01dc842df Mon Sep 17 00:00:00 2001 From: Michael McKinsey Date: Wed, 5 Mar 2025 16:49:55 -0800 Subject: [PATCH 07/22] Add new workflow and test --- .github/workflows/ci.yml | 8 ++++++++ .github/workflows/diffpackages.yml | 20 ++++++++++++++++++++ bin/benchpark-python | 2 +- lib/scripts/diffPackages.py | 6 ++++++ repo/raja-perf/package.py | 4 ++++ 5 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/diffpackages.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f69e6985f..b0f1c5099 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,6 +23,7 @@ jobs: run: ${{ steps.filter.outputs.run }} coverage: ${{ steps.filter.outputs.coverage }} license: ${{ steps.filter.outputs.license }} + diffpackages: ${{ steps.filter.outputs.diffpackages }} steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # @v2 @@ -96,6 +97,8 @@ jobs: - 'repo/**' - 'systems/**' - 'var/**' + diffpackages: + - 'repo/**/package.py' docs: if: ${{ needs.changes.outputs.docs == 'true' }} @@ -127,6 +130,11 @@ jobs: needs: changes uses: ./.github/workflows/license.yml + diffpackages: + if: ${{ needs.changes.outputs.diffpackages == 'true' }} + needs: changes + uses: ./.github/workflows/diffpackages.yml + all: needs: - changes diff --git a/.github/workflows/diffpackages.yml b/.github/workflows/diffpackages.yml new file mode 100644 index 000000000..2dfe8f602 --- /dev/null +++ b/.github/workflows/diffpackages.yml @@ -0,0 +1,20 @@ +name: Check Packages Against Spack +on: + pull_request: + paths: + - repo/**/package.py + +jobs: + diffPackages: + runs-on: ubuntu-22.04 + steps: + - name: Checkout repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + + - name: Add needed Python libs + run: | + pip install -r ./requirements.txt + + - name: Run diffPackages.py + run: | + ./bin/benchpark-python lib/scripts/diffPackages.py diff --git a/bin/benchpark-python b/bin/benchpark-python index 6911ad7ce..aadb208d7 100755 --- a/bin/benchpark-python +++ b/bin/benchpark-python @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Copyright 2023 Lawrence Livermore National Security, LLC and other # Benchpark Project Developers. See the top-level COPYRIGHT file for details. diff --git a/lib/scripts/diffPackages.py b/lib/scripts/diffPackages.py index 8bbb135ba..8f5f23716 100644 --- a/lib/scripts/diffPackages.py +++ b/lib/scripts/diffPackages.py @@ -7,6 +7,8 @@ import benchpark.paths +EXIT_CODE=0 + parser = argparse.ArgumentParser( description="Script to compare packages in benchpark against upstream spack packages.", usage="benchpark-python diffPackages.py [OPTIONS]", @@ -35,6 +37,7 @@ def main(): + global EXIT_CODE spack_dir = "spack/var/spack/repos/builtin/packages/" benchpark_dir = str(benchpark.paths.benchpark_root) + "/repo/" @@ -91,6 +94,7 @@ def main(): color.cprint( f" @*gNo differences found. We can safely delete '{benchpark_package_path}' in favor of spack upstream@." ) + EXIT_CODE=1 # Use difflib.ndiff to compare the lines dc3 = difflib.ndiff(spack_lines, benchpark_lines) @@ -104,6 +108,8 @@ def main(): # Print the differences print("\n".join(dc)) + return EXIT_CODE + if __name__ == "__main__": main() diff --git a/repo/raja-perf/package.py b/repo/raja-perf/package.py index a3353a3b3..f41187671 100644 --- a/repo/raja-perf/package.py +++ b/repo/raja-perf/package.py @@ -360,3 +360,7 @@ def initconfig_package_entries(self): def cmake_args(self): options = [f"-DMPI_CXX_LINK_FLAGS='{self.spec['mpi'].libs.ld_flags}'"] return options + + +def _test_func(): + pass \ No newline at end of file From 3847ee8cccb908809510b0171e3a4006950c518f Mon Sep 17 00:00:00 2001 From: Michael McKinsey Date: Wed, 26 Mar 2025 12:29:28 -0700 Subject: [PATCH 08/22] Undo function --- lib/scripts/diffPackages.py | 1 + repo/raja-perf/package.py | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/scripts/diffPackages.py b/lib/scripts/diffPackages.py index 8f5f23716..961b24453 100644 --- a/lib/scripts/diffPackages.py +++ b/lib/scripts/diffPackages.py @@ -108,6 +108,7 @@ def main(): # Print the differences print("\n".join(dc)) + print(f"EXIT_CODE: {EXIT_CODE}") return EXIT_CODE diff --git a/repo/raja-perf/package.py b/repo/raja-perf/package.py index f41187671..a3353a3b3 100644 --- a/repo/raja-perf/package.py +++ b/repo/raja-perf/package.py @@ -360,7 +360,3 @@ def initconfig_package_entries(self): def cmake_args(self): options = [f"-DMPI_CXX_LINK_FLAGS='{self.spec['mpi'].libs.ld_flags}'"] return options - - -def _test_func(): - pass \ No newline at end of file From bfc8695fe5172adc1e8b5ad2f7e03c65785988cb Mon Sep 17 00:00:00 2001 From: Michael McKinsey Date: Wed, 26 Mar 2025 12:30:41 -0700 Subject: [PATCH 09/22] Make raja-perf package the same to test --- repo/raja-perf/package.py | 441 ++++++++++++++++++-------------------- 1 file changed, 211 insertions(+), 230 deletions(-) diff --git a/repo/raja-perf/package.py b/repo/raja-perf/package.py index a3353a3b3..652fe0c7b 100644 --- a/repo/raja-perf/package.py +++ b/repo/raja-perf/package.py @@ -1,264 +1,204 @@ -# Copyright 2023 Lawrence Livermore National Security, LLC and other -# Benchpark Project Developers. See the top-level COPYRIGHT file for details. +# Copyright Spack Project Developers. See COPYRIGHT file for details. # -# SPDX-License-Identifier: Apache-2.0 +# SPDX-License-Identifier: (Apache-2.0 OR MIT) -import glob -import os -import re import socket -from os import environ as env -from os.path import join as pjoin -from spack import * +from spack.package import * +from .blt import llnl_link_helpers -def spec_uses_toolchain(spec): - gcc_toolchain_regex = re.compile(".*gcc-toolchain.*") - using_toolchain = list(filter(gcc_toolchain_regex.match, spec.compiler_flags["cxxflags"])) - return using_toolchain -def spec_uses_gccname(spec): - gcc_name_regex = re.compile(".*gcc-name.*") - using_gcc_name = list(filter(gcc_name_regex.match, spec.compiler_flags["cxxflags"])) - return using_gcc_name - -def hip_repair_options(options, spec): - # there is only one dir like this, but the version component is unknown - options.append( - "-DHIP_CLANG_INCLUDE_PATH=" - + glob.glob("{}/lib/clang/*/include".format(spec["llvm-amdgpu"].prefix))[0] - ) - -def hip_repair_cache(options, spec): - # there is only one dir like this, but the version component is unknown - options.append( - cmake_cache_path( - "HIP_CLANG_INCLUDE_PATH", - glob.glob("{}/lib/clang/*/include".format(spec["llvm-amdgpu"].prefix))[0], - ) - ) - -def hip_for_radiuss_projects(options, spec, spec_compiler): - # Here is what is typically needed for radiuss projects when building with rocm - hip_root = spec["hip"].prefix - rocm_root = hip_root + "/.." - options.append(cmake_cache_path("HIP_ROOT_DIR", hip_root)) - options.append(cmake_cache_path("ROCM_ROOT_DIR", rocm_root)) +class RajaPerf(CachedCMakePackage, CudaPackage, ROCmPackage): + """RAJA Performance Suite.""" - hip_repair_cache(options, spec) + homepage = "https://github.com/LLNL/RAJAPerf" + git = "https://github.com/LLNL/RAJAPerf.git" + tags = ["radiuss"] - archs = spec.variants["amdgpu_target"].value - if archs != "none": - arch_str = ",".join(archs) - options.append( - cmake_cache_string("AMDGPU_TARGETS", "{0}".format(arch_str)) - ) - options.append( - cmake_cache_string("HIP_HIPCC_FLAGS", "--amdgpu-target={0}".format(arch_str)) - ) - options.append( - cmake_cache_string("CMAKE_HIP_ARCHITECTURES", arch_str) - ) + maintainers("davidbeckingsale", "adrienbernede") - # adrienbernede-22-11: - # Specific to Umpire, attempt port to RAJA and CHAI - hip_link_flags = "" - if "%gcc" in spec or spec_uses_toolchain(spec): - if "%gcc" in spec: - gcc_bin = os.path.dirname(spec_compiler.cxx) - gcc_prefix = join_path(gcc_bin, "..") - else: - gcc_prefix = spec_uses_toolchain(spec)[0] - options.append(cmake_cache_string("HIP_CLANG_FLAGS", "--gcc-toolchain={0}".format(gcc_prefix))) - options.append(cmake_cache_string("CMAKE_EXE_LINKER_FLAGS", hip_link_flags + " -Wl,-rpath {}/lib64".format(gcc_prefix))) - else: - options.append(cmake_cache_string("CMAKE_EXE_LINKER_FLAGS", "-Wl,-rpath={0}/llvm/lib/".format(rocm_root))) - -def cuda_for_radiuss_projects(options, spec): - # Here is what is typically needed for radiuss projects when building with cuda - - cuda_flags = [] - if not spec.satisfies("cuda_arch=none"): - cuda_arch = spec.variants["cuda_arch"].value - cuda_flags.append("-arch sm_{0}".format(cuda_arch[0])) - options.append( - cmake_cache_string("CUDA_ARCH", "sm_{0}".format(cuda_arch[0]))) - options.append( - cmake_cache_string("CMAKE_CUDA_ARCHITECTURES", "{0}".format(cuda_arch[0]))) - if spec_uses_toolchain(spec): - cuda_flags.append("-Xcompiler {}".format(spec_uses_toolchain(spec)[0])) - if (spec.satisfies("%gcc@8.1: target=ppc64le")): - cuda_flags.append("-Xcompiler -mno-float128") - options.append(cmake_cache_string("CMAKE_CUDA_FLAGS", " ".join(cuda_flags))) - -def blt_link_helpers(options, spec, spec_compiler): - - ### From local package: - fortran_compilers = ["gfortran", "xlf"] - if any(compiler in spec_compiler.fc for compiler in fortran_compilers) and ("clang" in spec_compiler.cxx): - # Pass fortran compiler lib as rpath to find missing libstdc++ - libdir = os.path.join(os.path.dirname( - os.path.dirname(spec_compiler.fc)), "lib") - flags = "" - for _libpath in [libdir, libdir + "64"]: - if os.path.exists(_libpath): - flags += " -Wl,-rpath,{0}".format(_libpath) - description = ("Adds a missing libstdc++ rpath") - if flags: - options.append(cmake_cache_string("BLT_EXE_LINKER_FLAGS", flags, description)) - - # Ignore conflicting default gcc toolchain - options.append(cmake_cache_string("BLT_CMAKE_IMPLICIT_LINK_DIRECTORIES_EXCLUDE", - "/usr/tce/packages/gcc/gcc-4.9.3/lib64;/usr/tce/packages/gcc/gcc-4.9.3/gnu/lib64/gcc/powerpc64le-unknown-linux-gnu/4.9.3;/usr/tce/packages/gcc/gcc-4.9.3/gnu/lib64;/usr/tce/packages/gcc/gcc-4.9.3/lib64/gcc/x86_64-unknown-linux-gnu/4.9.3")) - - compilers_using_toolchain = ["pgi", "xl", "icpc"] - if any(compiler in spec_compiler.cxx for compiler in compilers_using_toolchain): - if spec_uses_toolchain(spec) or spec_uses_gccname(spec): - - # Ignore conflicting default gcc toolchain - options.append(cmake_cache_string("BLT_CMAKE_IMPLICIT_LINK_DIRECTORIES_EXCLUDE", - "/usr/tce/packages/gcc/gcc-4.9.3/lib64;/usr/tce/packages/gcc/gcc-4.9.3/gnu/lib64/gcc/powerpc64le-unknown-linux-gnu/4.9.3;/usr/tce/packages/gcc/gcc-4.9.3/gnu/lib64;/usr/tce/packages/gcc/gcc-4.9.3/lib64/gcc/x86_64-unknown-linux-gnu/4.9.3")) + license("BSD-3-Clause") -class RajaPerf(CachedCMakePackage, CudaPackage, ROCmPackage): - """RAJA Performance Suite.""" + version("develop", branch="develop", submodules="True") + version("main", branch="main", submodules="True") + version( + "2024.07.0", + tag="v2024.07.0", + commit="6e81aa58af244a13755a694bfdc7bc301139a244", + submodules="True", + ) + version( + "2023.06.0", + tag="v2023.06.0", + commit="e5b2102f50e4642f53d9c86fb622b398a748974a", + submodules="True", + ) + version( + "2022.10.0", + tag="v2022.10.0", + commit="57ee53e402d2ac0a398df39ad1ca85cf1d2be45b", + submodules="True", + ) + version( + "0.12.0", + tag="v0.12.0", + commit="388c1d7562e1cb364191cb34c1ff62f3cadf54a0", + submodules="True", + ) + version( + "0.11.0", + tag="v0.11.0", + commit="22ac1de533ebd477c781d53962a92478c0a11d43", + submodules="True", + ) + version( + "0.10.0", + tag="v0.10.0", + commit="6bf725af38da41b1ebd1d29c75ffa5b8e57f7cbf", + submodules="True", + ) + version( + "0.9.0", tag="v0.9.0", commit="064dd17dae696c3e440eeb7469fa90341858a636", submodules="True" + ) + version( + "0.8.0", tag="v0.8.0", commit="94c65b2caefec2220f712f34c2a198b682ca7e23", submodules="True" + ) + version( + "0.7.0", tag="v0.7.0", commit="a6ef0279d9d240199947d872d8f28bf121f2192c", submodules="True" + ) + version( + "0.6.0", tag="v0.6.0", commit="21e476f031bc10bbdb8514425c380553bfb23bdc", submodules="True" + ) + version( + "0.5.2", tag="v0.5.2", commit="2da5e27bc648ff5540ffa69bbde67f125e4581d3", submodules="True" + ) + version( + "0.5.1", tag="v0.5.1", commit="a7b6f63e4fef2d0146932eff409788da51ab0cb3", submodules="True" + ) + version( + "0.5.0", tag="v0.5.0", commit="888f5ebe69a9b2ae35058cf8fb8d89d91a379bea", submodules="True" + ) + version( + "0.4.0", tag="v0.4.0", commit="a8f669c1ad01d51132a4e3d9d6aa8b2cabc9eff0", submodules="True" + ) - homepage = "http://software.llnl.gov/RAJAPerf/" - git = "https://github.com/LLNL/RAJAPerf.git" + depends_on("cxx", type="build") # generated - version("develop", branch="develop", submodules="True") - version("main", branch="main", submodules="True") - version("2022.10.0", tag="v2022.10.0", submodules="True") - version("0.12.0", tag="v0.12.0", submodules="True") - version("0.11.0", tag="v0.11.0", submodules="True") - version("0.10.0", tag="v0.10.0", submodules="True") - version("0.9.0", tag="v0.9.0", submodules="True") - version("0.8.0", tag="v0.8.0", submodules="True") - version("0.7.0", tag="v0.7.0", submodules="True") - version("0.6.0", tag="v0.6.0", submodules="True") - version("0.5.2", tag="v0.5.2", submodules="True") - version("0.5.1", tag="v0.5.1", submodules="True") - version("0.5.0", tag="v0.5.0", submodules="True") - version("0.4.0", tag="v0.4.0", submodules="True") - - variant("mpi", default=True, description="Enable MPI support") - variant("openmp", default=True, description="Build OpenMP backend") - variant("openmp_target", default=False, description="Build with OpenMP target support") + variant("mpi", default=False, description="Enable MPI support") + variant("openmp", default=False, description="Build OpenMP backend") + variant("omptarget", default=False, description="Build with OpenMP target support") + variant("sycl", default=False, description="Build sycl backend") variant("shared", default=False, description="Build Shared Libs") - variant("libcpp", default=False, description="Uses libc++ instead of libstdc++") - variant("tests", default="basic", values=("none", "basic", "benchmarks"), - multi=False, description="Tests to run") - variant("caliper",default=False, description="Build with support for Caliper based profiling") + variant("omptask", default=False, description="Build OpenMP task variants of algorithms") + variant( + "tests", + default="basic", + values=("none", "basic", "benchmarks"), + multi=False, + description="Tests to run", + ) + variant("caliper", default=False, description="Build with support for Caliper based profiling") depends_on("blt") - depends_on("blt@0.5.2:", type="build", when="@2022.10.0:") + depends_on("blt@0.6.2:", type="build", when="@2024.07.0:") + depends_on("blt@0.5.3", type="build", when="@2023.06") + depends_on("blt@0.5.2:0.5.3", type="build", when="@2022.10") depends_on("blt@0.5.0:", type="build", when="@0.12.0:") depends_on("blt@0.4.1:", type="build", when="@0.11.0:") depends_on("blt@0.4.0:", type="build", when="@0.8.0:") depends_on("blt@0.3.0:", type="build", when="@:0.7.0") - depends_on("cmake@3.20:", when="@0.12.0:", type="build") - depends_on("cmake@3.23:", when="@0.12.0: +rocm", type="build") - depends_on("cmake@3.23:", when="@0.12.0: +cuda") + depends_on("cmake@3.23:", when="@2024.07.0:", type="build") + depends_on("cmake@3.23:", when="@0.12.0:2023.06.0 +rocm", type="build") + depends_on("cmake@3.20:", when="@0.12.0:2023.06.0", type="build") depends_on("cmake@3.14:", when="@:0.12.0", type="build") + depends_on("mpi", when="+mpi") + depends_on("llvm-openmp", when="+openmp %apple-clang") depends_on("rocprim", when="+rocm") - - - conflicts("~openmp", when="+openmp_target", msg="OpenMP target requires OpenMP") - conflicts("+cuda", when="+openmp_target", msg="Cuda may not be activated when openmp_target is ON") - - depends_on("caliper", when="+caliper") - depends_on("adiak@0.4:", when="+caliper") - - depends_on("mpi", when="+mpi") + depends_on("caliper@2.9.0:", when="+caliper") + depends_on("caliper@2.9.0: +cuda", when="+caliper +cuda") + depends_on("caliper@2.9.0: +rocm", when="+caliper +rocm") + + with when("@0.12.0: +rocm +caliper"): + depends_on("caliper +rocm") + for arch in ROCmPackage.amdgpu_targets: + depends_on( + "caliper +rocm amdgpu_target={0}".format(arch), + when="amdgpu_target={0}".format(arch), + ) + conflicts("+openmp", when="@:2022.03") + + with when("@0.12.0: +cuda +caliper"): + depends_on("caliper +cuda") + for sm_ in CudaPackage.cuda_arch_values: + depends_on("caliper +cuda cuda_arch={0}".format(sm_), when="cuda_arch={0}".format(sm_)) + + conflicts("~openmp", when="+omptarget", msg="OpenMP target requires OpenMP") + conflicts("+cuda", when="+omptarget", msg="Cuda may not be activated when omptarget is ON") + conflicts("+omptarget +rocm") + conflicts("+sycl +omptarget") + conflicts("+sycl +rocm") + # Using RAJA version as threshold on purpose (no 2024.02 version of RAJAPerf were released). + conflicts( + "+sycl", + when="@:2024.02.99", + msg="Support for SYCL was introduced in RAJA after 2024.02 release, " + "please use a newer release.", + ) def _get_sys_type(self, spec): sys_type = str(spec.architecture) - # if on llnl systems, we can use the SYS_TYPE if "SYS_TYPE" in env: sys_type = env["SYS_TYPE"] return sys_type @property - # TODO: name cache file conditionally to cuda and libcpp variants def cache_name(self): hostname = socket.gethostname() if "SYS_TYPE" in env: hostname = hostname.rstrip("1234567890") - var="" - if "+cuda" in self.spec: - var= "-".join([var,"cuda"]) - if "+libcpp" in self.spec: - var="-".join([var,"libcpp"]) - - return "{0}-{1}{2}-{3}@{4}-{5}.cmake".format( + return "{0}-{1}-{2}@{3}-{4}.cmake".format( hostname, self._get_sys_type(self.spec), - var, self.spec.compiler.name, self.spec.compiler.version, - self.spec.dag_hash(8) + self.spec.dag_hash(8), ) def initconfig_compiler_entries(self): spec = self.spec compiler = self.compiler # Default entries are already defined in CachedCMakePackage, inherit them: - entries = super(RajaPerf, self).initconfig_compiler_entries() - - # Switch to hip as a CPP compiler. - # adrienbernede-22-11: - # This was only done in upstream Spack raja package. - # I could not find the equivalent logic in Spack source, so keeping it. - #if "+rocm" in spec: - # entries.insert(0, cmake_cache_path("CMAKE_CXX_COMPILER", spec["hip"].hipcc)) - - # Override CachedCMakePackage CMAKE_C_FLAGS and CMAKE_CXX_FLAGS add - # +libcpp specific flags - flags = spec.compiler_flags - - # use global spack compiler flags - cppflags = " ".join(flags["cppflags"]) - if cppflags: - # avoid always ending up with " " with no flags defined - cppflags += " " - - cflags = cppflags + " ".join(flags["cflags"]) - if "+libcpp" in spec: - cflags += " ".join([cflags,"-DGTEST_HAS_CXXABI_H_=0"]) - if cflags: - entries.append(cmake_cache_string("CMAKE_C_FLAGS", cflags)) - - cxxflags = cppflags + " ".join(flags["cxxflags"]) - if "+libcpp" in spec: - cxxflags += " ".join([cxxflags,"-stdlib=libc++ -DGTEST_HAS_CXXABI_H_=0"]) - if cxxflags: - entries.append(cmake_cache_string("CMAKE_CXX_FLAGS", cxxflags)) - - blt_link_helpers(entries, spec, compiler) + entries = super().initconfig_compiler_entries() + + if spec.satisfies("+rocm ^blt@:0.6"): + entries.insert(0, cmake_cache_path("CMAKE_CXX_COMPILER", spec["hip"].hipcc)) # adrienbernede-23-01 - # Maybe we want to share this in the above blt_link_helpers function. + # Maybe we want to share this in the above llnl_link_helpers function. compilers_using_cxx14 = ["intel-17", "intel-18", "xl"] if any(compiler in self.compiler.cxx for compiler in compilers_using_cxx14): entries.append(cmake_cache_string("BLT_CXX_STD", "c++14")) + llnl_link_helpers(entries, spec, compiler) + return entries def initconfig_hardware_entries(self): spec = self.spec compiler = self.compiler - entries = super(RajaPerf, self).initconfig_hardware_entries() + entries = super().initconfig_hardware_entries() - entries.append(cmake_cache_option("ENABLE_OPENMP", "+openmp" in spec)) + entries.append("#------------------{0}".format("-" * 30)) + entries.append("# Package custom hardware settings") + entries.append("#------------------{0}\n".format("-" * 30)) - entries.append(cmake_cache_option("ENABLE_MPI", "+mpi" in spec)) - if "+mpi" in spec: - entries.append(cmake_cache_string("MPI_CXX_COMPILER", spec["mpi"].mpicxx)) + entries.append(cmake_cache_option("ENABLE_OPENMP", "+openmp" in spec)) # T benefit from the shared function "cuda_for_radiuss_projects", # we do not modify CMAKE_CUDA_FLAGS: it is already appended by the @@ -266,20 +206,22 @@ def initconfig_hardware_entries(self): if "+cuda" in spec: entries.append(cmake_cache_option("ENABLE_CUDA", True)) # Shared handling of cuda. - cuda_for_radiuss_projects(entries, spec) - - # Custom options. We place everything in CMAKE_CUDA_FLAGS_(RELEASE|RELWITHDEBINFO|DEBUG) which are not set by cuda_for_radiuss_projects - if ("xl" in self.compiler.cxx): - all_targets_flags = "-Xcompiler -qstrict -Xcompiler -qxlcompatmacros -Xcompiler -qalias=noansi" \ - + "-Xcompiler -qsmp=omp -Xcompiler -qhot -Xcompiler -qnoeh" \ - + "-Xcompiler -qsuppress=1500-029 -Xcompiler -qsuppress=1500-036" \ - + "-Xcompiler -qsuppress=1500-030" \ + # Custom options. + # We place everything in CMAKE_CUDA_FLAGS_(RELEASE|RELWITHDEBINFO|DEBUG) + # which are not set by cuda_for_radiuss_projects + if "xl" in compiler.cxx: + all_targets_flags = ( + "-Xcompiler -qstrict -Xcompiler -qxlcompatmacros -Xcompiler -qalias=noansi" + + "-Xcompiler -qsmp=omp -Xcompiler -qhot -Xcompiler -qnoeh" + + "-Xcompiler -qsuppress=1500-029 -Xcompiler -qsuppress=1500-036" + + "-Xcompiler -qsuppress=1500-030" + ) cuda_release_flags = "-O3 -Xcompiler -O2 " + all_targets_flags cuda_reldebinf_flags = "-O3 -g -Xcompiler -O2 " + all_targets_flags cuda_debug_flags = "-O0 -g -Xcompiler -O2 " + all_targets_flags - elif ("gcc" in self.compiler.cxx): + elif "gcc" in compiler.cxx: all_targets_flags = "-Xcompiler -finline-functions -Xcompiler -finline-limit=20000" cuda_release_flags = "-O3 -Xcompiler -Ofast " + all_targets_flags @@ -294,7 +236,9 @@ def initconfig_hardware_entries(self): cuda_debug_flags = "-O0 -g -Xcompiler -O0 " + all_targets_flags entries.append(cmake_cache_string("CMAKE_CUDA_FLAGS_RELEASE", cuda_release_flags)) - entries.append(cmake_cache_string("CMAKE_CUDA_FLAGS_RELWITHDEBINFO", cuda_reldebinf_flags)) + entries.append( + cmake_cache_string("CMAKE_CUDA_FLAGS_RELWITHDEBINFO", cuda_reldebinf_flags) + ) entries.append(cmake_cache_string("CMAKE_CUDA_FLAGS_DEBUG", cuda_debug_flags)) else: @@ -302,18 +246,41 @@ def initconfig_hardware_entries(self): if "+rocm" in spec: entries.append(cmake_cache_option("ENABLE_HIP", True)) - hip_for_radiuss_projects(entries, spec, compiler) else: entries.append(cmake_cache_option("ENABLE_HIP", False)) - entries.append(cmake_cache_option("ENABLE_OPENMP_TARGET", "+openmp_target" in spec)) - if "+openmp_target" in spec: - if ("%xl" in spec): - entries.append(cmake_cache_string("BLT_OPENMP_COMPILE_FLAGS", "-qoffload;-qsmp=omp;-qnoeh;-qalias=noansi")) - entries.append(cmake_cache_string("BLT_OPENMP_LINK_FLAGS", "-qoffload;-qsmp=omp;-qnoeh;-qalias=noansi")) - if ("%clang" in spec): - entries.append(cmake_cache_string("BLT_OPENMP_COMPILE_FLAGS", "-fopenmp;-fopenmp-targets=nvptx64-nvidia-cuda")) - entries.append(cmake_cache_string("BLT_OPENMP_LINK_FLAGS", "-fopenmp;-fopenmp-targets=nvptx64-nvidia-cuda")) + entries.append(cmake_cache_option("ENABLE_OPENMP_TARGET", "+omptarget" in spec)) + if "+omptarget" in spec: + if "%xl" in spec: + entries.append( + cmake_cache_string( + "BLT_OPENMP_COMPILE_FLAGS", "-qoffload;-qsmp=omp;-qnoeh;-qalias=noansi" + ) + ) + entries.append( + cmake_cache_string( + "BLT_OPENMP_LINK_FLAGS", "-qoffload;-qsmp=omp;-qnoeh;-qalias=noansi" + ) + ) + if "%clang" in spec: + entries.append( + cmake_cache_string( + "BLT_OPENMP_COMPILE_FLAGS", "-fopenmp;-fopenmp-targets=nvptx64-nvidia-cuda" + ) + ) + entries.append( + cmake_cache_string( + "BLT_OPENMP_LINK_FLAGS", "-fopenmp;-fopenmp-targets=nvptx64-nvidia-cuda" + ) + ) + + return entries + + def initconfig_mpi_entries(self): + spec = self.spec + entries = super().initconfig_mpi_entries() + + entries.append(cmake_cache_option("ENABLE_MPI", "+mpi" in spec)) return entries @@ -321,7 +288,7 @@ def initconfig_package_entries(self): spec = self.spec entries = [] - option_prefix = "RAJA_" if spec.satisfies("@0.14.0:") else "" + # option_prefix = "RAJA_" if spec.satisfies("@0.14.0:") else "" # TPL locations entries.append("#------------------{0}".format("-" * 60)) @@ -329,14 +296,20 @@ def initconfig_package_entries(self): entries.append("#------------------{0}\n".format("-" * 60)) entries.append(cmake_cache_path("BLT_SOURCE_DIR", spec["blt"].prefix)) + if "caliper" in self.spec: + entries.append( + cmake_cache_path("caliper_DIR", spec["caliper"].prefix + "/share/cmake/caliper/") + ) + entries.append( + cmake_cache_path("adiak_DIR", spec["adiak"].prefix + "/lib/cmake/adiak/") + ) # Build options entries.append("#------------------{0}".format("-" * 60)) entries.append("# Build Options") entries.append("#------------------{0}\n".format("-" * 60)) - entries.append(cmake_cache_string( - "CMAKE_BUILD_TYPE", spec.variants["build_type"].value)) + entries.append(cmake_cache_string("CMAKE_BUILD_TYPE", spec.variants["build_type"].value)) entries.append(cmake_cache_string("RAJA_RANGE_ALIGN", "4")) entries.append(cmake_cache_string("RAJA_RANGE_MIN_LENGTH", "32")) @@ -344,19 +317,27 @@ def initconfig_package_entries(self): entries.append(cmake_cache_option("RAJA_HOST_CONFIG_LOADED", True)) - entries.append(cmake_cache_option("BUILD_SHARED_LIBS","+shared" in spec)) - entries.append(cmake_cache_option("ENABLE_OPENMP","+openmp" in spec)) + entries.append(cmake_cache_option("BUILD_SHARED_LIBS", "+shared" in spec)) + entries.append(cmake_cache_option("ENABLE_OPENMP", "+openmp" in spec)) + entries.append(cmake_cache_option("RAJA_ENABLE_OPENMP_TASK", "+omptask" in spec)) + entries.append(cmake_cache_option("ENABLE_SYCL", spec.satisfies("+sycl"))) + + # C++17 + if spec.satisfies("@2024.07.0:") and spec.satisfies("+sycl"): + entries.append(cmake_cache_string("BLT_CXX_STD", "c++17")) + # C++14 + # Using RAJA version as threshold on purpose (no 0.14 version of RAJAPerf were released). + elif spec.satisfies("@0.14.0:"): + entries.append(cmake_cache_string("BLT_CXX_STD", "c++14")) entries.append(cmake_cache_option("ENABLE_BENCHMARKS", "tests=benchmarks" in spec)) - entries.append(cmake_cache_option("ENABLE_TESTS", not "tests=none" in spec or self.run_tests)) + entries.append( + cmake_cache_option("ENABLE_TESTS", "tests=none" not in spec or self.run_tests) + ) - entries.append(cmake_cache_option("RAJA_PERFSUITE_USE_CALIPER","+caliper" in spec)) - if "+caliper" in self.spec: - entries.append(cmake_cache_path("caliper_DIR", spec["caliper"].prefix+"/share/cmake/caliper/")) - entries.append(cmake_cache_path("adiak_DIR", spec["adiak"].prefix+"/lib/cmake/adiak/")) + entries.append(cmake_cache_option("RAJA_PERFSUITE_USE_CALIPER", "+caliper" in spec)) return entries def cmake_args(self): - options = [f"-DMPI_CXX_LINK_FLAGS='{self.spec['mpi'].libs.ld_flags}'"] - return options + return [] From 51a49aaa42b660a37cade5df0a48307d5f07df18 Mon Sep 17 00:00:00 2001 From: Michael McKinsey Date: Wed, 26 Mar 2025 12:34:10 -0700 Subject: [PATCH 10/22] Update yaml --- .github/workflows/ci.yml | 41 ++++++++++++++++++++---------- .github/workflows/diffpackages.yml | 13 +++++----- lib/scripts/diffPackages.py | 7 ++--- 3 files changed, 39 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b0f1c5099..38d6a7c29 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,10 +24,10 @@ jobs: coverage: ${{ steps.filter.outputs.coverage }} license: ${{ steps.filter.outputs.license }} diffpackages: ${{ steps.filter.outputs.diffpackages }} + modified_repo_dirs: ${{ steps.get_modified_repo_dirs.outputs.modified_repo_dirs }} steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # @v2 - if: ${{ github.event_name == 'push' || github.event_name == 'merge_group' }} + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 with: fetch-depth: 0 @@ -100,6 +100,21 @@ jobs: diffpackages: - 'repo/**/package.py' + - name: Fetch develop branch + run: git fetch origin develop:develop + + - name: Get modified directories in repo/ + id: get_modified_repo_dirs + run: | + # Get the modified directories under 'repo/' + MODIFIED_REPO_DIRS=$(git diff --name-only develop | grep 'repo/' | xargs -n1 dirname | sed 's|^repo/||') + + # Debugging: Print the modified directories + echo "Modified directories: $MODIFIED_REPO_DIRS" + + # Output the modified directories as a GitHub Actions output + echo "modified_repo_dirs=$MODIFIED_REPO_DIRS" >> $GITHUB_OUTPUT + docs: if: ${{ needs.changes.outputs.docs == 'true' }} needs: changes @@ -119,9 +134,6 @@ jobs: if: ${{ needs.changes.outputs.coverage == 'true' }} needs: changes uses: ./.github/workflows/coverage.yml - # 'workflow_call' actions do not get access to secrets - # normally. So, we add this (plus the corresponding) - # settings in coverage.yml to pass the token on secrets: BENCHPARK_CODECOV_TOKEN: ${{ secrets.BENCHPARK_CODECOV_TOKEN }} @@ -134,6 +146,8 @@ jobs: if: ${{ needs.changes.outputs.diffpackages == 'true' }} needs: changes uses: ./.github/workflows/diffpackages.yml + with: + modified_repo_dirs: ${{ needs.changes.outputs.modified_repo_dirs }} all: needs: @@ -143,14 +157,15 @@ jobs: - run - coverage - license + - diffpackages if: always() runs-on: ubuntu-latest steps: - - name: Status summary - run: | - if [[ "${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}" == "true" ]]; then - echo "One or more required jobs failed or were cancelled" - exit 1 - else - echo "All jobs completed successfully" - fi + - name: Status summary + run: | + if [[ "${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}" == "true" ]]; then + echo "One or more required jobs failed or were cancelled" + exit 1 + else + echo "All jobs completed successfully" + fi diff --git a/.github/workflows/diffpackages.yml b/.github/workflows/diffpackages.yml index 2dfe8f602..f520f8668 100644 --- a/.github/workflows/diffpackages.yml +++ b/.github/workflows/diffpackages.yml @@ -1,8 +1,9 @@ -name: Check Packages Against Spack on: - pull_request: - paths: - - repo/**/package.py + workflow_call: + inputs: + modified_repo_dirs: + required: true + type: string jobs: diffPackages: @@ -15,6 +16,6 @@ jobs: run: | pip install -r ./requirements.txt - - name: Run diffPackages.py + - name: Check Packages Against Spack run: | - ./bin/benchpark-python lib/scripts/diffPackages.py + ./bin/benchpark-python lib/scripts/diffPackages.py --packages "${{ inputs.modified_repo_dirs }}" diff --git a/lib/scripts/diffPackages.py b/lib/scripts/diffPackages.py index 961b24453..76e06802d 100644 --- a/lib/scripts/diffPackages.py +++ b/lib/scripts/diffPackages.py @@ -7,7 +7,7 @@ import benchpark.paths -EXIT_CODE=0 +EXIT_CODE = 0 parser = argparse.ArgumentParser( description="Script to compare packages in benchpark against upstream spack packages.", @@ -94,7 +94,7 @@ def main(): color.cprint( f" @*gNo differences found. We can safely delete '{benchpark_package_path}' in favor of spack upstream@." ) - EXIT_CODE=1 + EXIT_CODE = 1 # Use difflib.ndiff to compare the lines dc3 = difflib.ndiff(spack_lines, benchpark_lines) @@ -113,4 +113,5 @@ def main(): if __name__ == "__main__": - main() + exit_code = main() + sys.exit(EXIT_CODE) From 478a9c7aefebbecfb3f039761ec43c26bbcb244a Mon Sep 17 00:00:00 2001 From: Michael McKinsey Date: Wed, 26 Mar 2025 16:46:42 -0700 Subject: [PATCH 11/22] test another repo --- repo/amg2023/package.py | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/repo/amg2023/package.py b/repo/amg2023/package.py index 5cc54af78..d674149b1 100644 --- a/repo/amg2023/package.py +++ b/repo/amg2023/package.py @@ -1,7 +1,6 @@ -# Copyright 2023 Lawrence Livermore National Security, LLC and other -# Benchpark Project Developers. See the top-level COPYRIGHT file for details. +# Copyright Spack Project Developers. See COPYRIGHT file for details. # -# SPDX-License-Identifier: Apache-2.0 +# SPDX-License-Identifier: (Apache-2.0 OR MIT) from spack.package import * @@ -10,7 +9,7 @@ class Amg2023(CMakePackage, CudaPackage, ROCmPackage): """AMG2023 is a parallel algebraic multigrid solver for linear systems arising from problems on unstructured grids. The driver provided here builds linear systems for various 3-dimensional problems. It requires - an installation of hypre-2.31.0 or higher. + an installation of hypre-2.27.0 or higher. """ tags = ["benchmark"] @@ -21,6 +20,8 @@ class Amg2023(CMakePackage, CudaPackage, ROCmPackage): version("develop", branch="main") + depends_on("c", type="build") # generated + variant("mpi", default=True, description="Enable MPI support") variant("openmp", default=False, description="Enable OpenMP support") variant("caliper", default=False, description="Enable Caliper monitoring") @@ -31,22 +32,11 @@ class Amg2023(CMakePackage, CudaPackage, ROCmPackage): depends_on("caliper", when="+caliper") depends_on("adiak", when="+caliper") depends_on("hypre+caliper", when="+caliper") - depends_on("hypre@2.31.0:") - depends_on("hypre+mixedint~fortran") - + depends_on("hypre@2.27.0:") depends_on("hypre+cuda", when="+cuda") requires("+cuda", when="^hypre+cuda") - for arch in ("none", "50", "60", "70", "80", "90"): - depends_on(f"hypre cuda_arch={arch}", when=f"cuda_arch={arch}") - depends_on("hypre+rocm", when="+rocm") requires("+rocm", when="^hypre+rocm") - for target in ("none", "gfx803", "gfx900", "gfx906", "gfx908", "gfx90a", "gfx942"): - depends_on(f"hypre amdgpu_target={target}", when=f"amdgpu_target={target}") - - def setup_build_environment(self, env): - if "+cuda" in self.spec: - env.set("NVCC_APPEND_FLAGS", "-allow-unsupported-compiler") def cmake_args(self): cmake_options = [] From 6d05357cc6921713da09e58d9b7a3bd85fd15a98 Mon Sep 17 00:00:00 2001 From: Michael McKinsey Date: Wed, 26 Mar 2025 16:46:57 -0700 Subject: [PATCH 12/22] Improve error message --- lib/scripts/diffPackages.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/scripts/diffPackages.py b/lib/scripts/diffPackages.py index 76e06802d..d356ee3f9 100644 --- a/lib/scripts/diffPackages.py +++ b/lib/scripts/diffPackages.py @@ -92,7 +92,7 @@ def main(): # Check if there is no diff if not diff_list: color.cprint( - f" @*gNo differences found. We can safely delete '{benchpark_package_path}' in favor of spack upstream@." + f" @*gNo differences found. Please delete 'benchpark/repo/{package}/package.py' (use spack upstream)@." ) EXIT_CODE = 1 From 49644e8aba20b30d8f99afee7b087ea7dc4433c7 Mon Sep 17 00:00:00 2001 From: Michael McKinsey Date: Wed, 26 Mar 2025 16:55:36 -0700 Subject: [PATCH 13/22] Convert newline to space --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 38d6a7c29..e80689431 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -107,7 +107,7 @@ jobs: id: get_modified_repo_dirs run: | # Get the modified directories under 'repo/' - MODIFIED_REPO_DIRS=$(git diff --name-only develop | grep 'repo/' | xargs -n1 dirname | sed 's|^repo/||') + MODIFIED_REPO_DIRS=$(git diff --name-only develop | grep 'repo/' | xargs -n1 dirname | sed 's|^repo/||' | tr '\n' ' ') # Debugging: Print the modified directories echo "Modified directories: $MODIFIED_REPO_DIRS" From b2fe2d82967722b564edfd8a439026e38f6812f9 Mon Sep 17 00:00:00 2001 From: Michael McKinsey Date: Wed, 26 Mar 2025 17:14:49 -0700 Subject: [PATCH 14/22] Handle spaces --- lib/scripts/diffPackages.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/scripts/diffPackages.py b/lib/scripts/diffPackages.py index d356ee3f9..176e8a788 100644 --- a/lib/scripts/diffPackages.py +++ b/lib/scripts/diffPackages.py @@ -44,7 +44,9 @@ def main(): # Get the list of packages to process if args.packages: # Use only the specified packages - packages_to_compare = args.packages + packages_to_compare = [] + for item in args.packages: + packages_to_compare.extend(item.strip().split()) else: # Process all packages if --packages is not provided packages_to_compare = sorted(os.listdir(benchpark_dir)) From f435a32f1116dfa040728de981b35b6db50ec553 Mon Sep 17 00:00:00 2001 From: Michael McKinsey Date: Wed, 26 Mar 2025 17:58:16 -0700 Subject: [PATCH 15/22] Undo changes made for testing --- repo/amg2023/package.py | 22 +- repo/raja-perf/package.py | 441 ++++++++++++++++++++------------------ 2 files changed, 246 insertions(+), 217 deletions(-) diff --git a/repo/amg2023/package.py b/repo/amg2023/package.py index d674149b1..5cc54af78 100644 --- a/repo/amg2023/package.py +++ b/repo/amg2023/package.py @@ -1,6 +1,7 @@ -# Copyright Spack Project Developers. See COPYRIGHT file for details. +# Copyright 2023 Lawrence Livermore National Security, LLC and other +# Benchpark Project Developers. See the top-level COPYRIGHT file for details. # -# SPDX-License-Identifier: (Apache-2.0 OR MIT) +# SPDX-License-Identifier: Apache-2.0 from spack.package import * @@ -9,7 +10,7 @@ class Amg2023(CMakePackage, CudaPackage, ROCmPackage): """AMG2023 is a parallel algebraic multigrid solver for linear systems arising from problems on unstructured grids. The driver provided here builds linear systems for various 3-dimensional problems. It requires - an installation of hypre-2.27.0 or higher. + an installation of hypre-2.31.0 or higher. """ tags = ["benchmark"] @@ -20,8 +21,6 @@ class Amg2023(CMakePackage, CudaPackage, ROCmPackage): version("develop", branch="main") - depends_on("c", type="build") # generated - variant("mpi", default=True, description="Enable MPI support") variant("openmp", default=False, description="Enable OpenMP support") variant("caliper", default=False, description="Enable Caliper monitoring") @@ -32,11 +31,22 @@ class Amg2023(CMakePackage, CudaPackage, ROCmPackage): depends_on("caliper", when="+caliper") depends_on("adiak", when="+caliper") depends_on("hypre+caliper", when="+caliper") - depends_on("hypre@2.27.0:") + depends_on("hypre@2.31.0:") + depends_on("hypre+mixedint~fortran") + depends_on("hypre+cuda", when="+cuda") requires("+cuda", when="^hypre+cuda") + for arch in ("none", "50", "60", "70", "80", "90"): + depends_on(f"hypre cuda_arch={arch}", when=f"cuda_arch={arch}") + depends_on("hypre+rocm", when="+rocm") requires("+rocm", when="^hypre+rocm") + for target in ("none", "gfx803", "gfx900", "gfx906", "gfx908", "gfx90a", "gfx942"): + depends_on(f"hypre amdgpu_target={target}", when=f"amdgpu_target={target}") + + def setup_build_environment(self, env): + if "+cuda" in self.spec: + env.set("NVCC_APPEND_FLAGS", "-allow-unsupported-compiler") def cmake_args(self): cmake_options = [] diff --git a/repo/raja-perf/package.py b/repo/raja-perf/package.py index 652fe0c7b..a3353a3b3 100644 --- a/repo/raja-perf/package.py +++ b/repo/raja-perf/package.py @@ -1,227 +1,285 @@ -# Copyright Spack Project Developers. See COPYRIGHT file for details. +# Copyright 2023 Lawrence Livermore National Security, LLC and other +# Benchpark Project Developers. See the top-level COPYRIGHT file for details. # -# SPDX-License-Identifier: (Apache-2.0 OR MIT) +# SPDX-License-Identifier: Apache-2.0 +import glob +import os +import re import socket +from os import environ as env +from os.path import join as pjoin -from spack.package import * +from spack import * -from .blt import llnl_link_helpers +def spec_uses_toolchain(spec): + gcc_toolchain_regex = re.compile(".*gcc-toolchain.*") + using_toolchain = list(filter(gcc_toolchain_regex.match, spec.compiler_flags["cxxflags"])) + return using_toolchain -class RajaPerf(CachedCMakePackage, CudaPackage, ROCmPackage): - """RAJA Performance Suite.""" +def spec_uses_gccname(spec): + gcc_name_regex = re.compile(".*gcc-name.*") + using_gcc_name = list(filter(gcc_name_regex.match, spec.compiler_flags["cxxflags"])) + return using_gcc_name - homepage = "https://github.com/LLNL/RAJAPerf" - git = "https://github.com/LLNL/RAJAPerf.git" - tags = ["radiuss"] +def hip_repair_options(options, spec): + # there is only one dir like this, but the version component is unknown + options.append( + "-DHIP_CLANG_INCLUDE_PATH=" + + glob.glob("{}/lib/clang/*/include".format(spec["llvm-amdgpu"].prefix))[0] + ) - maintainers("davidbeckingsale", "adrienbernede") +def hip_repair_cache(options, spec): + # there is only one dir like this, but the version component is unknown + options.append( + cmake_cache_path( + "HIP_CLANG_INCLUDE_PATH", + glob.glob("{}/lib/clang/*/include".format(spec["llvm-amdgpu"].prefix))[0], + ) + ) - license("BSD-3-Clause") +def hip_for_radiuss_projects(options, spec, spec_compiler): + # Here is what is typically needed for radiuss projects when building with rocm + hip_root = spec["hip"].prefix + rocm_root = hip_root + "/.." + options.append(cmake_cache_path("HIP_ROOT_DIR", hip_root)) + options.append(cmake_cache_path("ROCM_ROOT_DIR", rocm_root)) - version("develop", branch="develop", submodules="True") - version("main", branch="main", submodules="True") - version( - "2024.07.0", - tag="v2024.07.0", - commit="6e81aa58af244a13755a694bfdc7bc301139a244", - submodules="True", - ) - version( - "2023.06.0", - tag="v2023.06.0", - commit="e5b2102f50e4642f53d9c86fb622b398a748974a", - submodules="True", - ) - version( - "2022.10.0", - tag="v2022.10.0", - commit="57ee53e402d2ac0a398df39ad1ca85cf1d2be45b", - submodules="True", - ) - version( - "0.12.0", - tag="v0.12.0", - commit="388c1d7562e1cb364191cb34c1ff62f3cadf54a0", - submodules="True", - ) - version( - "0.11.0", - tag="v0.11.0", - commit="22ac1de533ebd477c781d53962a92478c0a11d43", - submodules="True", - ) - version( - "0.10.0", - tag="v0.10.0", - commit="6bf725af38da41b1ebd1d29c75ffa5b8e57f7cbf", - submodules="True", - ) - version( - "0.9.0", tag="v0.9.0", commit="064dd17dae696c3e440eeb7469fa90341858a636", submodules="True" - ) - version( - "0.8.0", tag="v0.8.0", commit="94c65b2caefec2220f712f34c2a198b682ca7e23", submodules="True" - ) - version( - "0.7.0", tag="v0.7.0", commit="a6ef0279d9d240199947d872d8f28bf121f2192c", submodules="True" - ) - version( - "0.6.0", tag="v0.6.0", commit="21e476f031bc10bbdb8514425c380553bfb23bdc", submodules="True" - ) - version( - "0.5.2", tag="v0.5.2", commit="2da5e27bc648ff5540ffa69bbde67f125e4581d3", submodules="True" - ) - version( - "0.5.1", tag="v0.5.1", commit="a7b6f63e4fef2d0146932eff409788da51ab0cb3", submodules="True" - ) - version( - "0.5.0", tag="v0.5.0", commit="888f5ebe69a9b2ae35058cf8fb8d89d91a379bea", submodules="True" - ) - version( - "0.4.0", tag="v0.4.0", commit="a8f669c1ad01d51132a4e3d9d6aa8b2cabc9eff0", submodules="True" - ) + hip_repair_cache(options, spec) + + archs = spec.variants["amdgpu_target"].value + if archs != "none": + arch_str = ",".join(archs) + options.append( + cmake_cache_string("AMDGPU_TARGETS", "{0}".format(arch_str)) + ) + options.append( + cmake_cache_string("HIP_HIPCC_FLAGS", "--amdgpu-target={0}".format(arch_str)) + ) + options.append( + cmake_cache_string("CMAKE_HIP_ARCHITECTURES", arch_str) + ) - depends_on("cxx", type="build") # generated + # adrienbernede-22-11: + # Specific to Umpire, attempt port to RAJA and CHAI + hip_link_flags = "" + if "%gcc" in spec or spec_uses_toolchain(spec): + if "%gcc" in spec: + gcc_bin = os.path.dirname(spec_compiler.cxx) + gcc_prefix = join_path(gcc_bin, "..") + else: + gcc_prefix = spec_uses_toolchain(spec)[0] + options.append(cmake_cache_string("HIP_CLANG_FLAGS", "--gcc-toolchain={0}".format(gcc_prefix))) + options.append(cmake_cache_string("CMAKE_EXE_LINKER_FLAGS", hip_link_flags + " -Wl,-rpath {}/lib64".format(gcc_prefix))) + else: + options.append(cmake_cache_string("CMAKE_EXE_LINKER_FLAGS", "-Wl,-rpath={0}/llvm/lib/".format(rocm_root))) + +def cuda_for_radiuss_projects(options, spec): + # Here is what is typically needed for radiuss projects when building with cuda + + cuda_flags = [] + if not spec.satisfies("cuda_arch=none"): + cuda_arch = spec.variants["cuda_arch"].value + cuda_flags.append("-arch sm_{0}".format(cuda_arch[0])) + options.append( + cmake_cache_string("CUDA_ARCH", "sm_{0}".format(cuda_arch[0]))) + options.append( + cmake_cache_string("CMAKE_CUDA_ARCHITECTURES", "{0}".format(cuda_arch[0]))) + if spec_uses_toolchain(spec): + cuda_flags.append("-Xcompiler {}".format(spec_uses_toolchain(spec)[0])) + if (spec.satisfies("%gcc@8.1: target=ppc64le")): + cuda_flags.append("-Xcompiler -mno-float128") + options.append(cmake_cache_string("CMAKE_CUDA_FLAGS", " ".join(cuda_flags))) + +def blt_link_helpers(options, spec, spec_compiler): + + ### From local package: + fortran_compilers = ["gfortran", "xlf"] + if any(compiler in spec_compiler.fc for compiler in fortran_compilers) and ("clang" in spec_compiler.cxx): + # Pass fortran compiler lib as rpath to find missing libstdc++ + libdir = os.path.join(os.path.dirname( + os.path.dirname(spec_compiler.fc)), "lib") + flags = "" + for _libpath in [libdir, libdir + "64"]: + if os.path.exists(_libpath): + flags += " -Wl,-rpath,{0}".format(_libpath) + description = ("Adds a missing libstdc++ rpath") + if flags: + options.append(cmake_cache_string("BLT_EXE_LINKER_FLAGS", flags, description)) + + # Ignore conflicting default gcc toolchain + options.append(cmake_cache_string("BLT_CMAKE_IMPLICIT_LINK_DIRECTORIES_EXCLUDE", + "/usr/tce/packages/gcc/gcc-4.9.3/lib64;/usr/tce/packages/gcc/gcc-4.9.3/gnu/lib64/gcc/powerpc64le-unknown-linux-gnu/4.9.3;/usr/tce/packages/gcc/gcc-4.9.3/gnu/lib64;/usr/tce/packages/gcc/gcc-4.9.3/lib64/gcc/x86_64-unknown-linux-gnu/4.9.3")) + + compilers_using_toolchain = ["pgi", "xl", "icpc"] + if any(compiler in spec_compiler.cxx for compiler in compilers_using_toolchain): + if spec_uses_toolchain(spec) or spec_uses_gccname(spec): + + # Ignore conflicting default gcc toolchain + options.append(cmake_cache_string("BLT_CMAKE_IMPLICIT_LINK_DIRECTORIES_EXCLUDE", + "/usr/tce/packages/gcc/gcc-4.9.3/lib64;/usr/tce/packages/gcc/gcc-4.9.3/gnu/lib64/gcc/powerpc64le-unknown-linux-gnu/4.9.3;/usr/tce/packages/gcc/gcc-4.9.3/gnu/lib64;/usr/tce/packages/gcc/gcc-4.9.3/lib64/gcc/x86_64-unknown-linux-gnu/4.9.3")) + +class RajaPerf(CachedCMakePackage, CudaPackage, ROCmPackage): + """RAJA Performance Suite.""" - variant("mpi", default=False, description="Enable MPI support") - variant("openmp", default=False, description="Build OpenMP backend") - variant("omptarget", default=False, description="Build with OpenMP target support") - variant("sycl", default=False, description="Build sycl backend") + homepage = "http://software.llnl.gov/RAJAPerf/" + git = "https://github.com/LLNL/RAJAPerf.git" + + version("develop", branch="develop", submodules="True") + version("main", branch="main", submodules="True") + version("2022.10.0", tag="v2022.10.0", submodules="True") + version("0.12.0", tag="v0.12.0", submodules="True") + version("0.11.0", tag="v0.11.0", submodules="True") + version("0.10.0", tag="v0.10.0", submodules="True") + version("0.9.0", tag="v0.9.0", submodules="True") + version("0.8.0", tag="v0.8.0", submodules="True") + version("0.7.0", tag="v0.7.0", submodules="True") + version("0.6.0", tag="v0.6.0", submodules="True") + version("0.5.2", tag="v0.5.2", submodules="True") + version("0.5.1", tag="v0.5.1", submodules="True") + version("0.5.0", tag="v0.5.0", submodules="True") + version("0.4.0", tag="v0.4.0", submodules="True") + + variant("mpi", default=True, description="Enable MPI support") + variant("openmp", default=True, description="Build OpenMP backend") + variant("openmp_target", default=False, description="Build with OpenMP target support") variant("shared", default=False, description="Build Shared Libs") - variant("omptask", default=False, description="Build OpenMP task variants of algorithms") - variant( - "tests", - default="basic", - values=("none", "basic", "benchmarks"), - multi=False, - description="Tests to run", - ) - variant("caliper", default=False, description="Build with support for Caliper based profiling") + variant("libcpp", default=False, description="Uses libc++ instead of libstdc++") + variant("tests", default="basic", values=("none", "basic", "benchmarks"), + multi=False, description="Tests to run") + variant("caliper",default=False, description="Build with support for Caliper based profiling") depends_on("blt") - depends_on("blt@0.6.2:", type="build", when="@2024.07.0:") - depends_on("blt@0.5.3", type="build", when="@2023.06") - depends_on("blt@0.5.2:0.5.3", type="build", when="@2022.10") + depends_on("blt@0.5.2:", type="build", when="@2022.10.0:") depends_on("blt@0.5.0:", type="build", when="@0.12.0:") depends_on("blt@0.4.1:", type="build", when="@0.11.0:") depends_on("blt@0.4.0:", type="build", when="@0.8.0:") depends_on("blt@0.3.0:", type="build", when="@:0.7.0") - depends_on("cmake@3.23:", when="@2024.07.0:", type="build") - depends_on("cmake@3.23:", when="@0.12.0:2023.06.0 +rocm", type="build") - depends_on("cmake@3.20:", when="@0.12.0:2023.06.0", type="build") + depends_on("cmake@3.20:", when="@0.12.0:", type="build") + depends_on("cmake@3.23:", when="@0.12.0: +rocm", type="build") + depends_on("cmake@3.23:", when="@0.12.0: +cuda") depends_on("cmake@3.14:", when="@:0.12.0", type="build") - depends_on("mpi", when="+mpi") - depends_on("llvm-openmp", when="+openmp %apple-clang") depends_on("rocprim", when="+rocm") - depends_on("caliper@2.9.0:", when="+caliper") - depends_on("caliper@2.9.0: +cuda", when="+caliper +cuda") - depends_on("caliper@2.9.0: +rocm", when="+caliper +rocm") - - with when("@0.12.0: +rocm +caliper"): - depends_on("caliper +rocm") - for arch in ROCmPackage.amdgpu_targets: - depends_on( - "caliper +rocm amdgpu_target={0}".format(arch), - when="amdgpu_target={0}".format(arch), - ) - conflicts("+openmp", when="@:2022.03") - - with when("@0.12.0: +cuda +caliper"): - depends_on("caliper +cuda") - for sm_ in CudaPackage.cuda_arch_values: - depends_on("caliper +cuda cuda_arch={0}".format(sm_), when="cuda_arch={0}".format(sm_)) - - conflicts("~openmp", when="+omptarget", msg="OpenMP target requires OpenMP") - conflicts("+cuda", when="+omptarget", msg="Cuda may not be activated when omptarget is ON") - conflicts("+omptarget +rocm") - conflicts("+sycl +omptarget") - conflicts("+sycl +rocm") - # Using RAJA version as threshold on purpose (no 2024.02 version of RAJAPerf were released). - conflicts( - "+sycl", - when="@:2024.02.99", - msg="Support for SYCL was introduced in RAJA after 2024.02 release, " - "please use a newer release.", - ) + + + conflicts("~openmp", when="+openmp_target", msg="OpenMP target requires OpenMP") + conflicts("+cuda", when="+openmp_target", msg="Cuda may not be activated when openmp_target is ON") + + depends_on("caliper", when="+caliper") + depends_on("adiak@0.4:", when="+caliper") + + depends_on("mpi", when="+mpi") def _get_sys_type(self, spec): sys_type = str(spec.architecture) + # if on llnl systems, we can use the SYS_TYPE if "SYS_TYPE" in env: sys_type = env["SYS_TYPE"] return sys_type @property + # TODO: name cache file conditionally to cuda and libcpp variants def cache_name(self): hostname = socket.gethostname() if "SYS_TYPE" in env: hostname = hostname.rstrip("1234567890") - return "{0}-{1}-{2}@{3}-{4}.cmake".format( + var="" + if "+cuda" in self.spec: + var= "-".join([var,"cuda"]) + if "+libcpp" in self.spec: + var="-".join([var,"libcpp"]) + + return "{0}-{1}{2}-{3}@{4}-{5}.cmake".format( hostname, self._get_sys_type(self.spec), + var, self.spec.compiler.name, self.spec.compiler.version, - self.spec.dag_hash(8), + self.spec.dag_hash(8) ) def initconfig_compiler_entries(self): spec = self.spec compiler = self.compiler # Default entries are already defined in CachedCMakePackage, inherit them: - entries = super().initconfig_compiler_entries() - - if spec.satisfies("+rocm ^blt@:0.6"): - entries.insert(0, cmake_cache_path("CMAKE_CXX_COMPILER", spec["hip"].hipcc)) + entries = super(RajaPerf, self).initconfig_compiler_entries() + + # Switch to hip as a CPP compiler. + # adrienbernede-22-11: + # This was only done in upstream Spack raja package. + # I could not find the equivalent logic in Spack source, so keeping it. + #if "+rocm" in spec: + # entries.insert(0, cmake_cache_path("CMAKE_CXX_COMPILER", spec["hip"].hipcc)) + + # Override CachedCMakePackage CMAKE_C_FLAGS and CMAKE_CXX_FLAGS add + # +libcpp specific flags + flags = spec.compiler_flags + + # use global spack compiler flags + cppflags = " ".join(flags["cppflags"]) + if cppflags: + # avoid always ending up with " " with no flags defined + cppflags += " " + + cflags = cppflags + " ".join(flags["cflags"]) + if "+libcpp" in spec: + cflags += " ".join([cflags,"-DGTEST_HAS_CXXABI_H_=0"]) + if cflags: + entries.append(cmake_cache_string("CMAKE_C_FLAGS", cflags)) + + cxxflags = cppflags + " ".join(flags["cxxflags"]) + if "+libcpp" in spec: + cxxflags += " ".join([cxxflags,"-stdlib=libc++ -DGTEST_HAS_CXXABI_H_=0"]) + if cxxflags: + entries.append(cmake_cache_string("CMAKE_CXX_FLAGS", cxxflags)) + + blt_link_helpers(entries, spec, compiler) # adrienbernede-23-01 - # Maybe we want to share this in the above llnl_link_helpers function. + # Maybe we want to share this in the above blt_link_helpers function. compilers_using_cxx14 = ["intel-17", "intel-18", "xl"] if any(compiler in self.compiler.cxx for compiler in compilers_using_cxx14): entries.append(cmake_cache_string("BLT_CXX_STD", "c++14")) - llnl_link_helpers(entries, spec, compiler) - return entries def initconfig_hardware_entries(self): spec = self.spec compiler = self.compiler - entries = super().initconfig_hardware_entries() - - entries.append("#------------------{0}".format("-" * 30)) - entries.append("# Package custom hardware settings") - entries.append("#------------------{0}\n".format("-" * 30)) + entries = super(RajaPerf, self).initconfig_hardware_entries() entries.append(cmake_cache_option("ENABLE_OPENMP", "+openmp" in spec)) + entries.append(cmake_cache_option("ENABLE_MPI", "+mpi" in spec)) + if "+mpi" in spec: + entries.append(cmake_cache_string("MPI_CXX_COMPILER", spec["mpi"].mpicxx)) + # T benefit from the shared function "cuda_for_radiuss_projects", # we do not modify CMAKE_CUDA_FLAGS: it is already appended by the # shared function. if "+cuda" in spec: entries.append(cmake_cache_option("ENABLE_CUDA", True)) # Shared handling of cuda. + cuda_for_radiuss_projects(entries, spec) + + # Custom options. We place everything in CMAKE_CUDA_FLAGS_(RELEASE|RELWITHDEBINFO|DEBUG) which are not set by cuda_for_radiuss_projects + if ("xl" in self.compiler.cxx): + all_targets_flags = "-Xcompiler -qstrict -Xcompiler -qxlcompatmacros -Xcompiler -qalias=noansi" \ + + "-Xcompiler -qsmp=omp -Xcompiler -qhot -Xcompiler -qnoeh" \ + + "-Xcompiler -qsuppress=1500-029 -Xcompiler -qsuppress=1500-036" \ + + "-Xcompiler -qsuppress=1500-030" \ - # Custom options. - # We place everything in CMAKE_CUDA_FLAGS_(RELEASE|RELWITHDEBINFO|DEBUG) - # which are not set by cuda_for_radiuss_projects - if "xl" in compiler.cxx: - all_targets_flags = ( - "-Xcompiler -qstrict -Xcompiler -qxlcompatmacros -Xcompiler -qalias=noansi" - + "-Xcompiler -qsmp=omp -Xcompiler -qhot -Xcompiler -qnoeh" - + "-Xcompiler -qsuppress=1500-029 -Xcompiler -qsuppress=1500-036" - + "-Xcompiler -qsuppress=1500-030" - ) cuda_release_flags = "-O3 -Xcompiler -O2 " + all_targets_flags cuda_reldebinf_flags = "-O3 -g -Xcompiler -O2 " + all_targets_flags cuda_debug_flags = "-O0 -g -Xcompiler -O2 " + all_targets_flags - elif "gcc" in compiler.cxx: + elif ("gcc" in self.compiler.cxx): all_targets_flags = "-Xcompiler -finline-functions -Xcompiler -finline-limit=20000" cuda_release_flags = "-O3 -Xcompiler -Ofast " + all_targets_flags @@ -236,9 +294,7 @@ def initconfig_hardware_entries(self): cuda_debug_flags = "-O0 -g -Xcompiler -O0 " + all_targets_flags entries.append(cmake_cache_string("CMAKE_CUDA_FLAGS_RELEASE", cuda_release_flags)) - entries.append( - cmake_cache_string("CMAKE_CUDA_FLAGS_RELWITHDEBINFO", cuda_reldebinf_flags) - ) + entries.append(cmake_cache_string("CMAKE_CUDA_FLAGS_RELWITHDEBINFO", cuda_reldebinf_flags)) entries.append(cmake_cache_string("CMAKE_CUDA_FLAGS_DEBUG", cuda_debug_flags)) else: @@ -246,41 +302,18 @@ def initconfig_hardware_entries(self): if "+rocm" in spec: entries.append(cmake_cache_option("ENABLE_HIP", True)) + hip_for_radiuss_projects(entries, spec, compiler) else: entries.append(cmake_cache_option("ENABLE_HIP", False)) - entries.append(cmake_cache_option("ENABLE_OPENMP_TARGET", "+omptarget" in spec)) - if "+omptarget" in spec: - if "%xl" in spec: - entries.append( - cmake_cache_string( - "BLT_OPENMP_COMPILE_FLAGS", "-qoffload;-qsmp=omp;-qnoeh;-qalias=noansi" - ) - ) - entries.append( - cmake_cache_string( - "BLT_OPENMP_LINK_FLAGS", "-qoffload;-qsmp=omp;-qnoeh;-qalias=noansi" - ) - ) - if "%clang" in spec: - entries.append( - cmake_cache_string( - "BLT_OPENMP_COMPILE_FLAGS", "-fopenmp;-fopenmp-targets=nvptx64-nvidia-cuda" - ) - ) - entries.append( - cmake_cache_string( - "BLT_OPENMP_LINK_FLAGS", "-fopenmp;-fopenmp-targets=nvptx64-nvidia-cuda" - ) - ) - - return entries - - def initconfig_mpi_entries(self): - spec = self.spec - entries = super().initconfig_mpi_entries() - - entries.append(cmake_cache_option("ENABLE_MPI", "+mpi" in spec)) + entries.append(cmake_cache_option("ENABLE_OPENMP_TARGET", "+openmp_target" in spec)) + if "+openmp_target" in spec: + if ("%xl" in spec): + entries.append(cmake_cache_string("BLT_OPENMP_COMPILE_FLAGS", "-qoffload;-qsmp=omp;-qnoeh;-qalias=noansi")) + entries.append(cmake_cache_string("BLT_OPENMP_LINK_FLAGS", "-qoffload;-qsmp=omp;-qnoeh;-qalias=noansi")) + if ("%clang" in spec): + entries.append(cmake_cache_string("BLT_OPENMP_COMPILE_FLAGS", "-fopenmp;-fopenmp-targets=nvptx64-nvidia-cuda")) + entries.append(cmake_cache_string("BLT_OPENMP_LINK_FLAGS", "-fopenmp;-fopenmp-targets=nvptx64-nvidia-cuda")) return entries @@ -288,7 +321,7 @@ def initconfig_package_entries(self): spec = self.spec entries = [] - # option_prefix = "RAJA_" if spec.satisfies("@0.14.0:") else "" + option_prefix = "RAJA_" if spec.satisfies("@0.14.0:") else "" # TPL locations entries.append("#------------------{0}".format("-" * 60)) @@ -296,20 +329,14 @@ def initconfig_package_entries(self): entries.append("#------------------{0}\n".format("-" * 60)) entries.append(cmake_cache_path("BLT_SOURCE_DIR", spec["blt"].prefix)) - if "caliper" in self.spec: - entries.append( - cmake_cache_path("caliper_DIR", spec["caliper"].prefix + "/share/cmake/caliper/") - ) - entries.append( - cmake_cache_path("adiak_DIR", spec["adiak"].prefix + "/lib/cmake/adiak/") - ) # Build options entries.append("#------------------{0}".format("-" * 60)) entries.append("# Build Options") entries.append("#------------------{0}\n".format("-" * 60)) - entries.append(cmake_cache_string("CMAKE_BUILD_TYPE", spec.variants["build_type"].value)) + entries.append(cmake_cache_string( + "CMAKE_BUILD_TYPE", spec.variants["build_type"].value)) entries.append(cmake_cache_string("RAJA_RANGE_ALIGN", "4")) entries.append(cmake_cache_string("RAJA_RANGE_MIN_LENGTH", "32")) @@ -317,27 +344,19 @@ def initconfig_package_entries(self): entries.append(cmake_cache_option("RAJA_HOST_CONFIG_LOADED", True)) - entries.append(cmake_cache_option("BUILD_SHARED_LIBS", "+shared" in spec)) - entries.append(cmake_cache_option("ENABLE_OPENMP", "+openmp" in spec)) - entries.append(cmake_cache_option("RAJA_ENABLE_OPENMP_TASK", "+omptask" in spec)) - entries.append(cmake_cache_option("ENABLE_SYCL", spec.satisfies("+sycl"))) - - # C++17 - if spec.satisfies("@2024.07.0:") and spec.satisfies("+sycl"): - entries.append(cmake_cache_string("BLT_CXX_STD", "c++17")) - # C++14 - # Using RAJA version as threshold on purpose (no 0.14 version of RAJAPerf were released). - elif spec.satisfies("@0.14.0:"): - entries.append(cmake_cache_string("BLT_CXX_STD", "c++14")) + entries.append(cmake_cache_option("BUILD_SHARED_LIBS","+shared" in spec)) + entries.append(cmake_cache_option("ENABLE_OPENMP","+openmp" in spec)) entries.append(cmake_cache_option("ENABLE_BENCHMARKS", "tests=benchmarks" in spec)) - entries.append( - cmake_cache_option("ENABLE_TESTS", "tests=none" not in spec or self.run_tests) - ) + entries.append(cmake_cache_option("ENABLE_TESTS", not "tests=none" in spec or self.run_tests)) - entries.append(cmake_cache_option("RAJA_PERFSUITE_USE_CALIPER", "+caliper" in spec)) + entries.append(cmake_cache_option("RAJA_PERFSUITE_USE_CALIPER","+caliper" in spec)) + if "+caliper" in self.spec: + entries.append(cmake_cache_path("caliper_DIR", spec["caliper"].prefix+"/share/cmake/caliper/")) + entries.append(cmake_cache_path("adiak_DIR", spec["adiak"].prefix+"/lib/cmake/adiak/")) return entries def cmake_args(self): - return [] + options = [f"-DMPI_CXX_LINK_FLAGS='{self.spec['mpi'].libs.ld_flags}'"] + return options From c6403e78cf420095493b83891f71ca092988d2c9 Mon Sep 17 00:00:00 2001 From: Michael McKinsey Date: Wed, 26 Mar 2025 18:01:08 -0700 Subject: [PATCH 16/22] Undo deletion --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e80689431..7807b6662 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -134,6 +134,9 @@ jobs: if: ${{ needs.changes.outputs.coverage == 'true' }} needs: changes uses: ./.github/workflows/coverage.yml + # 'workflow_call' actions do not get access to secrets + # normally. So, we add this (plus the corresponding) + # settings in coverage.yml to pass the token on secrets: BENCHPARK_CODECOV_TOKEN: ${{ secrets.BENCHPARK_CODECOV_TOKEN }} From 0fb2ab789aa7eb4ef621b272bae9cb3b193930ca Mon Sep 17 00:00:00 2001 From: Michael McKinsey Date: Wed, 26 Mar 2025 18:02:03 -0700 Subject: [PATCH 17/22] Undo formatting --- .github/workflows/ci.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7807b6662..284c62e98 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -164,11 +164,11 @@ jobs: if: always() runs-on: ubuntu-latest steps: - - name: Status summary - run: | - if [[ "${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}" == "true" ]]; then - echo "One or more required jobs failed or were cancelled" - exit 1 - else - echo "All jobs completed successfully" - fi + - name: Status summary + run: | + if [[ "${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}" == "true" ]]; then + echo "One or more required jobs failed or were cancelled" + exit 1 + else + echo "All jobs completed successfully" + fi From 62203a99d710c11264f0684466f062cc1af9505d Mon Sep 17 00:00:00 2001 From: Michael McKinsey Date: Wed, 26 Mar 2025 18:03:52 -0700 Subject: [PATCH 18/22] Undo artifact --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a5c9bef04..4a27db4dc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ force-exclude = ''' '/lib/benchpark/test_repo/(/.*)?$' | /lib/benchpark/test_repo(/.*)?$ | lib/benchpark/test_repo - | '/bin/benchpark-python -i' + | '/bin/benchpark-python' | \.github )/ ''' From 4358e30429262a77109393374c295266f8fda8d7 Mon Sep 17 00:00:00 2001 From: Michael McKinsey Date: Wed, 26 Mar 2025 18:26:21 -0700 Subject: [PATCH 19/22] Test --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 284c62e98..91493c706 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,7 @@ jobs: steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + if: ${{ github.event_name == 'push' || github.event_name == 'merge_group' }} with: fetch-depth: 0 @@ -100,6 +101,9 @@ jobs: diffpackages: - 'repo/**/package.py' + - name: test event + run: echo "Event name ${{ github.event_name }}" + - name: Fetch develop branch run: git fetch origin develop:develop From 1d2264704032ad3fbd90dbc1b8808b8344a8f6fd Mon Sep 17 00:00:00 2001 From: Michael McKinsey Date: Wed, 26 Mar 2025 18:29:18 -0700 Subject: [PATCH 20/22] Add correct event name --- .github/workflows/ci.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 91493c706..9453a891c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,7 @@ jobs: steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - if: ${{ github.event_name == 'push' || github.event_name == 'merge_group' }} + if: ${{ github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'pull_request' }} with: fetch-depth: 0 @@ -101,9 +101,6 @@ jobs: diffpackages: - 'repo/**/package.py' - - name: test event - run: echo "Event name ${{ github.event_name }}" - - name: Fetch develop branch run: git fetch origin develop:develop From 1dcd4a9dfd2e2e07c42dd0b49823e7499d867cdb Mon Sep 17 00:00:00 2001 From: Michael McKinsey Date: Wed, 26 Mar 2025 18:30:52 -0700 Subject: [PATCH 21/22] Combine steps --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9453a891c..650d4cea4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -101,12 +101,12 @@ jobs: diffpackages: - 'repo/**/package.py' - - name: Fetch develop branch - run: git fetch origin develop:develop - - name: Get modified directories in repo/ id: get_modified_repo_dirs run: | + # Fetch develop branch + git fetch origin develop:develop + # Get the modified directories under 'repo/' MODIFIED_REPO_DIRS=$(git diff --name-only develop | grep 'repo/' | xargs -n1 dirname | sed 's|^repo/||' | tr '\n' ' ') From 37458a20ab1b6a34d18aef6b838a193e09892635 Mon Sep 17 00:00:00 2001 From: Michael McKinsey Date: Thu, 27 Mar 2025 10:37:13 -0700 Subject: [PATCH 22/22] Update names to match change in script name --- lib/scripts/diffExperiments.py | 2 +- lib/scripts/diffSpecs.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/scripts/diffExperiments.py b/lib/scripts/diffExperiments.py index 5975d2cd2..553be3f1a 100644 --- a/lib/scripts/diffExperiments.py +++ b/lib/scripts/diffExperiments.py @@ -201,7 +201,7 @@ def main(): # Path to the Spack setup script spack_setup_script = f"{old_name}/wkp/setup.sh" # Define the ramble command - cmd = f"{old_name}/wkp/spack/bin/spack-python altdiff.py -t -d {old_file} {new_file}" + cmd = f"{old_name}/wkp/spack/bin/spack-python diffSpecs.py -t -d {old_file} {new_file}" # Combine sourcing the script and running the command try: diff = subprocess.run( diff --git a/lib/scripts/diffSpecs.py b/lib/scripts/diffSpecs.py index 80ffd5550..c3abdef25 100644 --- a/lib/scripts/diffSpecs.py +++ b/lib/scripts/diffSpecs.py @@ -152,13 +152,13 @@ def main(): parser = argparse.ArgumentParser( description="""Diff two specs. -(spack-python altdiff.py spec1 spec2) +(spack-python diffSpecs.py spec1 spec2) Example usage: $ spack spec --yaml dray+mpi > dray-mpi.yaml $ spack spec --yaml dray~mpi > dray-nompi.yaml - $ spack-python lib/scripts/altdiff.py --truncate ./dray-mpi.yaml ./dray-nompi.yaml + $ spack-python lib/scripts/diffSpecs.py --truncate ./dray-mpi.yaml ./dray-nompi.yaml """, formatter_class=argparse.RawTextHelpFormatter, )