From aaeb66d7b179bde2f687194ab6b4d2f9bf320526 Mon Sep 17 00:00:00 2001 From: Jan Patrick Lehr Date: Mon, 15 Jun 2026 13:31:32 +0200 Subject: [PATCH 1/2] [llvm-test-suite] add --rocprim option to enable rocPRIM tests (#2254) Introduce a data-driven library-component table mapping a long option to its CMake enable variable. The long options are registered with getopt from this table, so it is the single source of truth. --rocprim sets EXTERNAL_HIP_TESTS_ROCPRIM=ON at configure and adds the build-rocprim/ test-rocprim targets to the build and test phases. Options are additive and combine with the short flags. Further components can be added with a single table entry. --- bin/run_llvm-test-suite.sh | 64 ++++++++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 6 deletions(-) diff --git a/bin/run_llvm-test-suite.sh b/bin/run_llvm-test-suite.sh index 60abe11c6..f2ef8960d 100755 --- a/bin/run_llvm-test-suite.sh +++ b/bin/run_llvm-test-suite.sh @@ -51,6 +51,18 @@ DoTest='no' DoUpdate='no' IsVerbose='no' +# Optional External/HIP library components, selectable via long options. +# Maps the long-option name (e.g. --rocprim) to the CMake variable that +# enables it. The build/test targets follow the build-/test- +# convention used by External/HIP/CMakeLists.txt. Adding a new component is +# a single entry here; it is wired into getopt and the build/test phases +# automatically. +declare -A LIB_CMAKE_VAR=( + [rocprim]=EXTERNAL_HIP_TESTS_ROCPRIM +) +# Populated by the argument parser with the components the user requested. +declare -A LIB_ENABLED=() + usage() { echo "Usage: $(basename "$0") [-j build_jobs] [-c configure] [-b build] [-t test] [-v verbose] [-u update_sources]" echo "" @@ -63,6 +75,12 @@ usage() { echo " -v Verbose mode (set -x)" echo " -h Show this help message" echo "" + echo "Library Options (additive; enable extra External/HIP components):" + for Lib in "${!LIB_CMAKE_VAR[@]}"; do + echo " --${Lib}" + done + echo " Combine with phase flags, e.g. -cbt --rocprim" + echo "" echo "Environment Variables:" echo " LLVMTS_TLDIR - Top-level directory (default: \$AOMP_REPOS_TEST/llvm-test-suite)" echo " LLVMTS_GPU - Target GPU(s) (default: \$AOMP_GPU)" @@ -73,9 +91,16 @@ usage() { echo " Only needed if AOMP doesn't contain HIP libraries" } -# Parse options with GNU getopt, which supports long options (added later) and -# the bundled/short forms (-cbt, -j8, -j 8) the script already accepted. -if ! ParsedArgs=$(getopt -o j:cbtvhu -n "$(basename "$0")" -- "$@"); then +# Parse options with GNU getopt, which supports both the bundled/short forms +# (-cbt, -j8, -j 8) the script already accepted and the long library options. +# The library long options are derived from LIB_CMAKE_VAR so the table is the +# single source of truth. +LongOpts="help" +for Lib in "${!LIB_CMAKE_VAR[@]}"; do + LongOpts+=",${Lib}" +done + +if ! ParsedArgs=$(getopt -o j:cbtvhu -l "${LongOpts}" -n "$(basename "$0")" -- "$@"); then usage >&2 exit 1 fi @@ -107,7 +132,7 @@ while true; do DoUpdate='yes' shift ;; - -h) + -h | --help) usage exit 0 ;; @@ -115,6 +140,12 @@ while true; do shift break ;; + *) + # getopt has already validated long options against LongOpts, so any + # remaining -- is a known library component from LIB_CMAKE_VAR. + LIB_ENABLED["${1#--}"]='yes' + shift + ;; esac done @@ -207,6 +238,14 @@ fi # Configure with CMake if [ "${DoConfigure}" == "yes" ]; then echo "Configuring build with CMake..." + + # Enable any requested External/HIP library components. + ExtraCmakeArgs=() + for Lib in "${!LIB_ENABLED[@]}"; do + ExtraCmakeArgs+=("-D${LIB_CMAKE_VAR[${Lib}]}=ON") + echo "Enabling library component: ${Lib} (${LIB_CMAKE_VAR[${Lib}]})" + done + rm -rf "${LLVMTS_BUILD_DIR}" cmake ${CmakeGenerator} \ -B "${LLVMTS_BUILD_DIR}" \ @@ -222,13 +261,20 @@ if [ "${DoConfigure}" == "yes" ]; then -DENABLE_HIP_CATCH_TESTS=ON \ -DCMAKE_BUILD_TYPE="${LLVMTS_BUILD_TYPE}" \ -DCMAKE_C_COMPILER="${AOMP}/bin/clang" \ - -DCMAKE_CXX_COMPILER="${AOMP}/bin/clang++" + -DCMAKE_CXX_COMPILER="${AOMP}/bin/clang++" \ + "${ExtraCmakeArgs[@]}" fi # Build if [ "${DoCompile}" == "yes" ]; then echo "Building llvm-test-suite..." cmake --build "${LLVMTS_BUILD_DIR}" --parallel -j "${AOMP_BUILD_JOBS}" + + # Build the targets for any requested library components. + for Lib in "${!LIB_ENABLED[@]}"; do + echo "Building library component target: build-${Lib}" + cmake --build "${LLVMTS_BUILD_DIR}" --target "build-${Lib}" --parallel -j "${AOMP_BUILD_JOBS}" + done fi # Run tests @@ -238,7 +284,13 @@ if [ "${DoTest}" == "yes" ]; then echo "Log in ${LLVMTS_LOGS_DIR}/test-output.log" - for TestTarget in check-hip-simple check-hip-catch; do + # Base HIP test targets plus a test- target per requested library. + TestTargets=(check-hip-simple check-hip-catch) + for Lib in "${!LIB_ENABLED[@]}"; do + TestTargets+=("test-${Lib}") + done + + for TestTarget in "${TestTargets[@]}"; do # Use timeout to prevent tests from hanging # -k 30: Send SIGKILL after 30 seconds if SIGTERM doesn't terminate the process # This ensures even completely hung processes are killed From baa5dbbfd322e7677f034f7dac2839f2f96a9b2a Mon Sep 17 00:00:00 2001 From: dpalermo Date: Mon, 15 Jun 2026 13:59:26 -0500 Subject: [PATCH 2/2] [srock] Activate venv in both setup & build (#2261) --- srock-bin/build_srock.sh | 2 ++ srock-bin/setup_srock.sh | 18 +----------------- srock-bin/srock_common_vars | 21 +++++++++++++++++++++ 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/srock-bin/build_srock.sh b/srock-bin/build_srock.sh index 3e74a2912..c415cf987 100755 --- a/srock-bin/build_srock.sh +++ b/srock-bin/build_srock.sh @@ -25,6 +25,8 @@ if [ ! -d "$SROCK_THEROCK_DIR" ] ; then exit 1 fi +srock_venv_activate + # Print the start banner similar to DONE banner, useful if fails echo echo "===== START $0 on $_start_date" diff --git a/srock-bin/setup_srock.sh b/srock-bin/setup_srock.sh index 835d859f1..0cd672c48 100755 --- a/srock-bin/setup_srock.sh +++ b/srock-bin/setup_srock.sh @@ -62,23 +62,7 @@ fi cd "$SROCK_THEROCK_DIR" || exit -if [ -d "$SROCK_THEROCK_DIR/.venv/bin" ] ; then - echo - echo "===== Activating virtual environment =====" - cd "$SROCK_THEROCK_DIR" || exit - echo "source .venv/bin/activate" - source ".venv/bin/activate" -else - echo - echo "===== Building virtual environment in .venv and updating PATH =====" - cd "$SROCK_THEROCK_DIR" || exit - echo "python3 -m venv .venv && source .venv/bin/activate" - # shellcheck disable=1091 - python3 -m venv .venv && source ".venv/bin/activate" -fi -echo "pip install -r requirements.txt" -pip install -r requirements.txt -export PATH=$SROCK_THEROCK_DIR/.venv/bin:$PATH +srock_venv_activate if [ "$ARG" != "restart" ]; then echo diff --git a/srock-bin/srock_common_vars b/srock-bin/srock_common_vars index be759e368..cbac014ee 100644 --- a/srock-bin/srock_common_vars +++ b/srock-bin/srock_common_vars @@ -25,6 +25,27 @@ function test_apply_patch() { fi } +function srock_venv_activate() { + if [ -d "$SROCK_THEROCK_DIR/.venv/bin" ] ; then + echo + echo "===== Activating virtual environment =====" + cd "$SROCK_THEROCK_DIR" || exit + echo "source .venv/bin/activate" + # shellcheck disable=1091 # don't analyze activate + source ".venv/bin/activate" + else + echo + echo "===== Building virtual environment in .venv and updating PATH =====" + cd "$SROCK_THEROCK_DIR" || exit + echo "python3 -m venv .venv && source .venv/bin/activate" + # shellcheck disable=1091 # don't analyze activate + python3 -m venv .venv && source ".venv/bin/activate" + fi + echo "pip install -r requirements.txt" + pip install -r requirements.txt + export PATH=$SROCK_THEROCK_DIR/.venv/bin:$PATH +} + SROCK="NEVER_USE_'\$SROCK'_ENV_VARIABLE" # Use SROCK_LINK # SROCK_REPOS is the parent directory for TheRock and srock repos.