diff --git a/.github/workflows/aomp-shell.yml b/.github/workflows/aomp-shell.yml new file mode 100644 index 0000000000..f989b39404 --- /dev/null +++ b/.github/workflows/aomp-shell.yml @@ -0,0 +1,16 @@ +name: AOMP Lint + +on: + push: + pull_request: + +jobs: + aomp-lint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Run shellcheck + run: | + find . -name "*.sh" -exec shellcheck -S info {} + diff --git a/.shellcheckrc b/.shellcheckrc new file mode 100644 index 0000000000..ec6f4bb8bb --- /dev/null +++ b/.shellcheckrc @@ -0,0 +1 @@ +disable=SC2016,SC2002,SC2004 diff --git a/bin/aomp-shellcheck b/bin/aomp-shellcheck new file mode 100755 index 0000000000..d96582d49b --- /dev/null +++ b/bin/aomp-shellcheck @@ -0,0 +1,146 @@ +#!/bin/bash +# +# aomp-shell-format: Run shellcheck and shfmt to cleanup aomp shell script. +# +# Process: +# 1. RUn shellcheck --include $_fixByHand, fail if any found +# 2. Run shellcheck --include $_patchable to generate patch +# 3 Apply patch +# 4. Run shellcheck --exclude $_alwaysExclude +# if any fails then +# return 1 +# proceed to update this aomp-shell-format utility by adding +# falled codes to either _fixByHand, _patchable, or _alwaysExclude +# else +# return 0 +# + +# Join list of arguments using separator passed as first argument. +# join ',' a b c +# -> a,b,c +join() { + local IFS=$1 + shift + printf "%s" "$*" +} + +_fixByHand=(SC2050 # Forgotten $ on variable + SC2046 # Quote to prevent word splitting + SC2291 # Quote repeated spaces + SC2181 # Check exit code directly not with $? + SC2236 # Use -n instead of ! -z + SC2086 # Double quote to prevent globbing and word splitting + SC2034 # Ignore unused vars + SC1083 # Accidentally literal braces + SC2076 # Regex syntax check + SC2038 # find -print0 + SC2068) # Avoid re-splitting array expansion +_fixByHandOpts=(--shell=bash --include="$(join ',' "${_fixByHand[@]}")") + +_patchable=(SC2164 # Use cd ... || exit + SC2006) # Use $(...) instead of legacy backticks +_patchableOpts=(--shell=bash --include="$(join ',' "${_patchable[@]}")") + +_alwaysExclude=(SC2016 # Use double quote instead of single + SC2002 # Useless cat + SC2004) # '$' on arithmetic vars +_alwaysExcludeOpts=(--shell=bash --exclude="$(join ',' "${_alwaysExclude[@]}")") + +_check_only=false + +if [ $1 == "--check-only" ]; then + _check_only=true + shift +fi + +declare -a _shellfiles=( "$@" ) +_missing=0 +for _shellfile in "${_shellfiles[@]}"; do + if [ ! -f "$_shellfile" ]; then + (( _missing++ )) + fi +done +unset _shellfile + +if [ "${#_shellfiles[@]}" -eq 0 ] || [ "$_missing" -gt 0 ] ; then + echo "ERROR: please specify an existing input file as 1st argument" + exit 1 +fi + +_shellcheck_bin=$(which shellcheck) +if [ "$_shellcheck_bin" == "" ] ; then + echo "ERROR: please install shellcheck" + exit 1 +fi + +echo +echo "---- STEP 1 ---- Check for fixByHand fails -----" +echo "$_shellcheck_bin -x ${_fixByHandOpts[*]} ${_shellfiles[*]}" + +$_shellcheck_bin -x "${_fixByHandOpts[@]}" "${_shellfiles[@]}" +_rc=$? +if [[ $_rc != 0 ]]; then + echo + echo "ERROR: shellcheck found errors that must be fixed by hand. rc=$_rc" + exit 1 +fi + +if $_check_only; then + echo + echo "---- STEP 2 ---- Check patchable fails -----" + echo "$_shellcheck_bin -x ${_patchableOpts[@]} ${_shellfiles[@]}" + $_shellcheck_bin -x "${_patchableOpts[@]}" "${_shellfiles[@]}" + + echo + echo "---- STEP 3 ---- (Skipping for --check-only)" +else + echo + echo "---- STEP 2 ---- Check and repair patchable fails -----" + + _patchfile=/tmp/patchfile$$ + + if ! touch "$_patchfile"; then + echo "ERROR: Could not create or update $_patchfile" + exit 1 + fi + + echo "$_shellcheck_bin -x ${_patchableOpts[*]} -f diff ${_shellfiles[*]} \>$_patchfile" + $_shellcheck_bin -x "${_patchableOpts[@]}" -f diff "${_shellfiles[@]}" >$_patchfile + + if ! patch -p1 --dry-run <"$_patchfile"; then + echo "ERROR: Could not dryrun patch in $_patchfile to file ${_shellfiles[*]}" + exit 1 + fi + echo + echo "---- STEP 3 ---- Applying patch $_patchfile to ${_shellfiles[*]}" + patch -p1 <"$_patchfile" + echo "rm $_patchfile" + rm "$_patchfile" # patch should work because of dryrun test above +fi + +echo +echo "---- STEP 4 ---- Test for codes not handled in $0" +if $_check_only; then + # A non-check-only run would avoid triggering the patchable checks again + # in this invocation. Mask them out for a check-only run. + _excludeOpts=(--shell=bash --exclude="$(join ',' "${_alwaysExclude[@]}" "${_patchable[@]}")") + echo "$_shellcheck_bin -x ${_excludeOpts[*]} ${_shellfiles[*]}" + $_shellcheck_bin -x "${_excludeOpts[@]}" "${_shellfiles[@]}" + _rc=$? +else + echo "$_shellcheck_bin -x ${_alwaysExcludeOpts[*]} ${_shellfiles[*]}" + $_shellcheck_bin -x "${_alwaysExcludeOpts[@]}" "${_shellfiles[@]}" + _rc=$? +fi +if [ $_rc != 0 ] ; then + echo + echo "ERROR: shellcheck found codes not yet handled, must fix $0" + exit $_rc +fi +echo +if [ "${#_shellfiles[@]}" -eq 1 ]; then + echo "DONE: script ${_shellfiles[*]} is clean" +else + echo "DONE: scripts $(join ',' ${_shellfiles[@]}) are clean" +fi +exit 0 diff --git a/bin/run_llama.sh b/bin/run_llama.sh index 2772764577..24cbc44757 100755 --- a/bin/run_llama.sh +++ b/bin/run_llama.sh @@ -23,8 +23,8 @@ : ${LLAMA_BENCH_HF_ID:="ggml-org/gemma-3-1b-it-GGUF"} : ${LLAMA_CACHE:="$HOME/.cache/llama.cpp"} -pushd ${AOMP_REPOS_TEST} -mkdir -p ${LLAMA_TLDIR} && cd ${LLAMA_TLDIR} +pushd "${AOMP_REPOS_TEST}" || exit +mkdir -p "${LLAMA_TLDIR}" && cd "${LLAMA_TLDIR}" || exit # Run CMake configuration DoConfigure='no' @@ -63,22 +63,20 @@ if [ "${IsVerbose}" == "yes" ]; then set -x fi -TestBuildTool='make' if command -v ninja >/dev/null; then CmakeGenerator="-GNinja" - TestBuildTool='ninja' fi -if [ ! -d ${LLAMA_TESTS_LOG_LOCATION} ]; then - mkdir -p ${LLAMA_TESTS_LOG_LOCATION} +if [ ! -d "${LLAMA_TESTS_LOG_LOCATION}" ]; then + mkdir -p "${LLAMA_TESTS_LOG_LOCATION}" fi -if [ ! -d ${LLAMA_SRC_DIR} ]; then +if [ ! -d "${LLAMA_SRC_DIR}" ]; then echo "Cloning llama.cpp repository..." git clone https://github.com/ggml-org/llama.cpp.git src elif [ "${DoUpdate}" == "yes" ]; then echo "Updating llama.cpp repository..." - cd ${LLAMA_SRC_DIR} + cd "${LLAMA_SRC_DIR}" || exit git pull cd .. fi @@ -87,7 +85,7 @@ if ! command -v git-lfs >/dev/null; then echo "WARNING: git-lfs is not installed. Expect some tests to fail." else # Ensure git-lfs is initialized and pulls any large files - cd ${LLAMA_SRC_DIR} + cd "${LLAMA_SRC_DIR}" || exit git lfs install git lfs pull cd .. @@ -95,27 +93,27 @@ fi echo "Configuring build with CMake..." if [ "${DoConfigure}" == "yes" ]; then - rm -rf ${LLAMA_BUILD_DIR} + rm -rf "${LLAMA_BUILD_DIR}" cmake -B build \ -S src \ - -DCMAKE_PREFIX_PATH=${AOMP}/lib/cmake \ + -DCMAKE_PREFIX_PATH="${AOMP}"/lib/cmake \ -DGGML_HIP=On \ -DCMAKE_BUILD_TYPE=${LLAMA_BUILD_MODE} \ -DGPU_TARGETS=${LLAMA_GPU} \ ${CmakeGenerator} \ - -DCMAKE_C_COMPILER=${AOMP}/bin/clang \ - -DCMAKE_CXX_COMPILER=${AOMP}/bin/clang++ \ - -DCMAKE_HIP_COMPILER=${AOMP}/bin/clang++ + -DCMAKE_C_COMPILER="${AOMP}"/bin/clang \ + -DCMAKE_CXX_COMPILER="${AOMP}"/bin/clang++ \ + -DCMAKE_HIP_COMPILER="${AOMP}"/bin/clang++ fi if [ "${DoCompile}" == "yes" ]; then echo "Building LLaMA..." - cmake --build ${LLAMA_BUILD_DIR} --parallel -j ${AOMP_BUILD_JOBS} + cmake --build "${LLAMA_BUILD_DIR}" --parallel -j "${AOMP_BUILD_JOBS}" fi if [ "${DoCTest}" == "yes" ]; then echo "Running tests..." - cd ${LLAMA_BUILD_DIR} + cd "${LLAMA_BUILD_DIR}" || exit echo "Log in ${LLAMA_TESTS_LOG_LOCATION}/ctest.log" # Some model files are git-lfs and come from huggingface. They will auto-download during test @@ -124,7 +122,7 @@ fi if [ "${DoBenchmark}" == "yes" ]; then echo "Running benchmark..." - cd ${LLAMA_BUILD_DIR} + cd "${LLAMA_BUILD_DIR}" || exit # Download model from HF (this will make it avail in local cache); bench call requires local model file # llama-cli will turn on interactive mode, so echo /exit to it immediately echo "/exit" | ./bin/llama-cli -hf ${LLAMA_BENCH_HF_ID} @@ -140,4 +138,4 @@ if [ "${DoBenchmark}" == "yes" ]; then ./bin/llama-bench -ngl 999 -fa 1 -ub 2048 -m "$LlamaModelPath" 2>&1 | tee -a "${LLAMA_TESTS_LOG_LOCATION}/llama-bench.log" fi -popd +popd || exit diff --git a/bin/run_llvm-test-suite.sh b/bin/run_llvm-test-suite.sh new file mode 100755 index 0000000000..1f4be38149 --- /dev/null +++ b/bin/run_llvm-test-suite.sh @@ -0,0 +1,231 @@ +#!/usr/bin/env bash + +# +#Copyright © Advanced Micro Devices, Inc., or its affiliates. +# +#SPDX-License-Identifier: MIT +# + +# Build script for llvm-test-suite with HIP support using AOMP compiler + +# --- Start standard header to set AOMP environment variables ---- +realpath=$(realpath "$0") +thisdir=$(dirname "$realpath") +export AOMP_USE_CCACHE=0 + +# shellcheck source=aomp_common_vars +. "$thisdir/aomp_common_vars" +# --- end standard header ---- + +# Environment variable defaults +: "${LLVMTS_TLDIR:=$AOMP_REPOS_TEST/llvm-test-suite}" +: "${LLVMTS_SRC_DIR:=$LLVMTS_TLDIR/src}" +: "${LLVMTS_BUILD_DIR:=$LLVMTS_TLDIR/build}" +: "${LLVMTS_EXTERNAL_DIR:=$LLVMTS_TLDIR/External}" +: "${LLVMTS_LOGS_DIR:=$LLVMTS_TLDIR/logs}" +: "${LLVMTS_GPU:=$AOMP_GPU}" +: "${LLVMTS_BUILD_TYPE:=Release}" +: "${LLVMTS_TEST_TIMEOUT:=840}" +# Fallback to system ROCm if AOMP doesn't have HIP libraries +: "${ROCM:=/opt/rocm}" + +# Determine clang major version for device libs path +CLANG_VERSION=$("${AOMP}/bin/clang" --version | head -1 | grep -o 'version [0-9]*' | awk '{print $2}') +if [ -z "${CLANG_VERSION}" ]; then + echo "WARNING: Could not determine clang version, defaulting to 23" + CLANG_VERSION=23 +fi + +# Set AMD device libs path for HIP compilation +# HIP tests need to find device bitcode libraries +HIP_DEVICE_LIB_PATH="${AOMP}/lib/clang/${CLANG_VERSION}/lib/amdgcn/bitcode" +export HIP_DEVICE_LIB_PATH + +pushd "${AOMP_REPOS_TEST}" || exit +mkdir -p "${LLVMTS_TLDIR}" && cd "${LLVMTS_TLDIR}" || exit + +# Control variables +DoConfigure='no' +DoCompile='no' +DoTest='no' +DoUpdate='no' +IsVerbose='no' + +while getopts "j:cbtvhu" opt; do + case ${opt} in + j) AOMP_BUILD_JOBS=${OPTARG} ;; + c) DoConfigure='yes' ;; + b) DoCompile='yes' ;; + t) DoTest='yes' ;; + v) IsVerbose='yes' ;; + u) DoUpdate='yes' ;; + h) + echo "Usage: $(basename "$0") [-j build_jobs] [-c configure] [-b build] [-t test] [-v verbose] [-u update_sources]" + echo "" + echo "Options:" + echo " -c Run CMake configuration" + echo " -b Build the test suite" + echo " -t Run tests" + echo " -u Update sources (git pull)" + echo " -j Number of parallel build jobs (default: $AOMP_BUILD_JOBS)" + echo " -v Verbose mode (set -x)" + echo " -h Show this help message" + 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)" + echo " LLVMTS_BUILD_TYPE - CMake build type (default: Release)" + echo " LLVMTS_TEST_TIMEOUT - Test timeout in seconds (default: 800)" + echo " AOMP - AOMP compiler location (default: \$HOME/rocm/aomp)" + echo " ROCM - ROCm installation path (fallback, default: /opt/rocm)" + echo " Only needed if AOMP doesn't contain HIP libraries" + exit 0 + ;; + \?) + echo "Usage: $(basename "$0") [-j build_jobs] [-c configure] [-b build] [-t test] [-v verbose] [-u update_sources] [-h help]" + exit 1 + ;; + esac +done + +if [ "${IsVerbose}" == "yes" ]; then + set -x +fi + +# Detect ninja vs make +TestBuildTool='make' +CmakeGenerator="" +if command -v ninja >/dev/null; then + CmakeGenerator="-GNinja" + TestBuildTool='ninja' +fi + +# Create log directory +if [ ! -d "${LLVMTS_LOGS_DIR}" ]; then + mkdir -p "${LLVMTS_LOGS_DIR}" +fi + +# Clone or update repository +if [ ! -d "${LLVMTS_SRC_DIR}" ]; then + echo "Cloning llvm-test-suite repository..." + git clone https://github.com/llvm/llvm-test-suite.git "${LLVMTS_SRC_DIR}" +elif [ "${DoUpdate}" == "yes" ]; then + echo "Updating llvm-test-suite repository..." + cd "${LLVMTS_SRC_DIR}" || exit + git pull + cd "${LLVMTS_TLDIR}" || exit +fi + +# Check for HIP tests in the cloned suite +if [ -d "${LLVMTS_SRC_DIR}" ] && [ ! -d "${LLVMTS_SRC_DIR}/External/HIP" ]; then + echo "WARNING: External/HIP tests not found in llvm-test-suite" + echo " The test suite may not have HIP tests available" +fi + +# Determine ROCm path for HIP tests +# Prefer using AOMP's root directory (which contains HIP runtime and libraries) +# over system ROCm installation. AOMP root is typically $AOMP/../.. when AOMP points +# to lib/llvm subdirectory +AOMP_ROOT_DIR=$(cd "${AOMP}/../.." && pwd) +if [ -f "${AOMP_ROOT_DIR}/lib/libamdhip64.so" ]; then + ROCM_FOR_TESTS="${AOMP_ROOT_DIR}" + echo "Using AOMP installation for HIP tests: ${ROCM_FOR_TESTS}" +elif [ -f "${AOMP}/../lib/libamdhip64.so" ]; then + # Handle case where AOMP points directly to root (e.g., /opt/rocm/llvm) + AOMP_ROOT_DIR=$(cd "${AOMP}/.." && pwd) + ROCM_FOR_TESTS="${AOMP_ROOT_DIR}" + echo "Using AOMP installation for HIP tests: ${ROCM_FOR_TESTS}" +else + if [ ! -d "${ROCM}" ]; then + echo "ERROR: AOMP installation does not contain HIP libraries and system ROCm not found at ${ROCM}" + echo " Please set ROCM environment variable to a valid ROCm installation" + exit 1 + fi + ROCM_FOR_TESTS="${ROCM}" + echo "Using system ROCm for HIP tests: ${ROCM_FOR_TESTS}" +fi + +# Export ROCm CMake directories based on selected ROCm path +export hsaruntime64_DIR=${ROCM_FOR_TESTS}/lib/cmake/hsa-runtime64/ +export hipblas_DIR=${ROCM_FOR_TESTS}/lib/cmake/hipblas/ +export hip_DIR=${ROCM_FOR_TESTS}/lib/cmake/hip +export AMDDeviceLibs_DIR=${ROCM_FOR_TESTS}/lib/cmake/AMDDeviceLibs/ +export amd_comgr_DIR=${ROCM_FOR_TESTS}/lib/cmake/amd_comgr/ + +# Get ROCm version and create symlink +if [ -f "${ROCM_FOR_TESTS}/.info/version" ]; then + ROCM_VERSION_FILE=$(cat "${ROCM_FOR_TESTS}/.info/version") +elif command -v dpkg >/dev/null && dpkg -l rocm-core >/dev/null 2>&1; then + ROCM_VERSION_FILE=$(dpkg -l rocm-core | grep rocm-core | awk '{print $3}' | cut -d- -f1) +else + # Default fallback version + ROCM_VERSION_FILE="6.0.0" +fi + +# Create hip subdirectory and symlink to ROCm installation +# This is a prerequisite / assumption that the LLVM test suite makes +if [ ! -d "${LLVMTS_EXTERNAL_DIR}/hip" ]; then + mkdir -p "${LLVMTS_EXTERNAL_DIR}/hip" +fi + +ROCM_LINK="${LLVMTS_EXTERNAL_DIR}/hip/rocm-${ROCM_VERSION_FILE}" +if [ ! -L "${ROCM_LINK}" ] && [ ! -d "${ROCM_LINK}" ]; then + echo "Creating symlink: ${ROCM_LINK} -> ${ROCM_FOR_TESTS}" + ln -sf "${ROCM_FOR_TESTS}" "${ROCM_LINK}" +fi + +# Configure with CMake +if [ "${DoConfigure}" == "yes" ]; then + echo "Configuring build with CMake..." + rm -rf "${LLVMTS_BUILD_DIR}" + cmake ${CmakeGenerator} \ + -B "${LLVMTS_BUILD_DIR}" \ + -S "${LLVMTS_SRC_DIR}" \ + -DTEST_SUITE_SUBDIRS=External \ + -DTEST_SUITE_EXTERNALS_DIR="${LLVMTS_EXTERNAL_DIR}" \ + -DTEST_SUITE_COLLECT_CODE_SIZE=OFF \ + -DTEST_SUITE_COLLECT_COMPILE_TIME=OFF \ + -DTEST_SUITE_LIT="${AOMP}/bin/llvm-lit" \ + -DCMAKE_STRIP="" \ + -DAMDGPU_ARCHS="${LLVMTS_GPU}" \ + -DHIP_EXPORT_XUNIT_XML=ON \ + -DENABLE_HIP_CATCH_TESTS=ON \ + -DCMAKE_BUILD_TYPE="${LLVMTS_BUILD_TYPE}" \ + -DCMAKE_C_COMPILER="${AOMP}/bin/clang" \ + -DCMAKE_CXX_COMPILER="${AOMP}/bin/clang++" +fi + +# Build +if [ "${DoCompile}" == "yes" ]; then + echo "Building llvm-test-suite..." + cmake --build "${LLVMTS_BUILD_DIR}" --parallel -j "${AOMP_BUILD_JOBS}" +fi + +# Run tests +if [ "${DoTest}" == "yes" ]; then + echo "Running HIP tests (timeout: ${LLVMTS_TEST_TIMEOUT}s)..." + cd "${LLVMTS_BUILD_DIR}" || exit + + echo "Log in ${LLVMTS_LOGS_DIR}/test-output.log" + + for TestTarget in check-hip-simple check-hip-catch; 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 + if command -v timeout >/dev/null; then + timeout -k 30 "${LLVMTS_TEST_TIMEOUT}" "${TestBuildTool}" "${TestTarget}" 2>&1 | tee "${LLVMTS_LOGS_DIR}/test-output.log" + test_exit_code="${PIPESTATUS[0]}" + if [ "${test_exit_code}" -eq 124 ]; then + echo "WARNING: Tests timed out after ${LLVMTS_TEST_TIMEOUT} seconds" + elif [ "${test_exit_code}" -eq 137 ]; then + echo "WARNING: Tests were forcefully killed (SIGKILL) after timeout grace period" + fi + else + echo "WARNING: timeout command not found. Not running tests" + popd || exit 1 + exit 1 + fi + done +fi + +popd || exit diff --git a/bin/run_miniQMC.sh b/bin/run_miniQMC.sh index fef7f6244e..64ddd31d09 100755 --- a/bin/run_miniQMC.sh +++ b/bin/run_miniQMC.sh @@ -9,11 +9,11 @@ # ROCM_INSTALL_PATH top-level ROCm install directory (default: /opt/rocm-5.3.0) # --- Start standard header to set AOMP environment variables ---- -realpath=`realpath $0` -thisdir=`dirname $realpath` +realpath=`realpath "$0"` +thisdir=`dirname "$realpath"` export AOMP_USE_CCACHE=0 -. $thisdir/aomp_common_vars +. "$thisdir"/aomp_common_vars # --- end standard header ---- # Default ROCm installation @@ -46,31 +46,31 @@ export rocsolver_DIR=${ROCM}/lib/cmake/rocsolver/ : ${MQMC_GIT_TAG:=9d9d7d3} -if [ ! -d $MQMC_SOURCE_DIR ]; then - git clone https://github.com/ye-luo/miniqmc $MQMC_SOURCE_DIR - git checkout ${MQMC_GIT_TAG} +if [ ! -d "$MQMC_SOURCE_DIR" ]; then + git clone https://github.com/ye-luo/miniqmc "$MQMC_SOURCE_DIR" + git checkout "${MQMC_GIT_TAG}" fi -rm -rf ${MQMC_BUILD_DIR} +rm -rf "${MQMC_BUILD_DIR}" # Note: We currently need the -fopenmp-assume-no-nested-parallelism to work around a call to malloc which probably should not be there. # In the case that we disable hostservices, the application crashes when trying to call malloc. -CMAKE_PREFIX_PATH=${ROCM}/lib/cmake/ cmake -B ${MQMC_BUILD_DIR} -S ${MQMC_SOURCE_DIR} -DCMAKE_CXX_COMPILER=clang++ -DENABLE_OFFLOAD=ON -DQMC_ENABLE_ROCM=ON -DCMAKE_CXX_FLAGS='-fopenmp-assume-no-nested-parallelism -DCUDART_VERSION=10000 -DcudaMemoryTypeManaged=hipMemoryTypeManaged ' -DAMDGPU_DISABLE_HOST_DEVMEM=ON -DCMAKE_VERBOSE_MAKEFILE=ON +CMAKE_PREFIX_PATH=${ROCM}/lib/cmake/ cmake -B "${MQMC_BUILD_DIR}" -S "${MQMC_SOURCE_DIR}" -DCMAKE_CXX_COMPILER=clang++ -DENABLE_OFFLOAD=ON -DQMC_ENABLE_ROCM=ON -DCMAKE_CXX_FLAGS='-fopenmp-assume-no-nested-parallelism -DCUDART_VERSION=10000 -DcudaMemoryTypeManaged=hipMemoryTypeManaged ' -DAMDGPU_DISABLE_HOST_DEVMEM=ON -DCMAKE_VERBOSE_MAKEFILE=ON # Build miniqmc binaries #cmake --build ${MQMC_BUILD_DIR} --clean-first -j ${MQMC_NUM_BUILD_PROCS} -pushd ${MQMC_BUILD_DIR} +pushd "${MQMC_BUILD_DIR}" || exit make clean -make --output-sync -j ${MQMC_NUM_BUILD_PROCS} -popd +make --output-sync -j "${MQMC_NUM_BUILD_PROCS}" +popd || exit echo "Running Tests" echo "OMP_NUM_THREADS=${MQMC_OMP_NUM_THREADS} ${MQMC_BUILD_DIR}/bin/check_spo_batched_reduction -n 10" -OMP_NUM_THREADS=${MQMC_OMP_NUM_THREADS} ${MQMC_BUILD_DIR}/bin/check_spo_batched_reduction -n 10 +OMP_NUM_THREADS=${MQMC_OMP_NUM_THREADS} "${MQMC_BUILD_DIR}"/bin/check_spo_batched_reduction -n 10 echo "" echo "OMP_NUM_THREADS=${MQMC_OMP_NUM_THREADS} ${MQMC_BUILD_DIR}/bin/miniqmc" -OMP_NUM_THREADS=${MQMC_OMP_NUM_THREADS} ${MQMC_BUILD_DIR}/bin/miniqmc -v +OMP_NUM_THREADS=${MQMC_OMP_NUM_THREADS} "${MQMC_BUILD_DIR}"/bin/miniqmc -v echo "" echo "OMP_NUM_THREADS=${MQMC_OMP_NUM_THREADS} ${MQMC_BUILD_DIR}/bin/check_spo -n 10" -OMP_NUM_THREADS=${MQMC_OMP_NUM_THREADS} ${MQMC_BUILD_DIR}/bin/check_spo -n 10 -v +OMP_NUM_THREADS=${MQMC_OMP_NUM_THREADS} "${MQMC_BUILD_DIR}"/bin/check_spo -n 10 -v diff --git a/srock-bin/patches/amd-staging/_TheRock.patch b/srock-bin/patches/amd-staging/_TheRock.patch index 92013f8c9b..eab4d1475c 100644 --- a/srock-bin/patches/amd-staging/_TheRock.patch +++ b/srock-bin/patches/amd-staging/_TheRock.patch @@ -1,3 +1,15 @@ +diff --git a/cmake/therock_subproject.cmake b/cmake/therock_subproject.cmake +index e8356406..d3373e56 100644 +--- a/cmake/therock_subproject.cmake ++++ b/cmake/therock_subproject.cmake +@@ -1410,6 +1410,7 @@ function(_therock_cmake_subproject_setup_toolchain + string(APPEND _toolchain_contents "set(AMDGPU_TARGETS @_filtered_gpu_targets@ CACHE STRING \"From super-project\" FORCE)\n") + string(APPEND _toolchain_contents "set(GPU_TARGETS @_filtered_gpu_targets@ CACHE STRING \"From super-project\" FORCE)\n") + string(APPEND _toolchain_contents "set(CMAKE_HIP_ARCHITECTURES @_filtered_gpu_targets@ CACHE STRING \"From super-project\" FORCE)\n") ++ string(APPEND _toolchain_contents "set(CMAKE_HIP_COMPILER \"@AMD_LLVM_CXX_COMPILER@\")\n") + endif() + + # General settings applicable to all toolchains. diff --git a/compiler/CMakeLists.txt b/compiler/CMakeLists.txt index 9db31320..8552b77c 100644 --- a/compiler/CMakeLists.txt @@ -63,10 +75,10 @@ index 48aa6a8b..20ea73f1 100644 # Setup the install rpath (let CMake handle build RPATH per usual): # * Executables and libraries can always search their adjacent lib directory diff --git a/profiler/CMakeLists.txt b/profiler/CMakeLists.txt -index 4b1f02ef..fef7efed 100644 +index de446e14..af47ddad 100644 --- a/profiler/CMakeLists.txt +++ b/profiler/CMakeLists.txt -@@ -81,11 +81,16 @@ endif(THEROCK_BUILD_TESTING) +@@ -82,11 +82,16 @@ endif(THEROCK_BUILD_TESTING) EXTERNAL_SOURCE_DIR "${THEROCK_ROCM_SYSTEMS_SOURCE_DIR}/projects/rocprofiler-sdk" BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/rocprofiler-sdk" BACKGROUND_BUILD @@ -83,7 +95,7 @@ index 4b1f02ef..fef7efed 100644 COMPILER_TOOLCHAIN amd-hip RUNTIME_DEPS -@@ -160,11 +165,15 @@ endif(THEROCK_BUILD_TESTING) +@@ -163,11 +168,15 @@ endif(THEROCK_BUILD_TESTING) # Must build with the HIP compiler. amd-hip CMAKE_ARGS diff --git a/srock-bin/patches/amd-staging/compiler_amd-llvm.patch b/srock-bin/patches/amd-staging/compiler_amd-llvm.patch new file mode 100644 index 0000000000..3ae33ffbec --- /dev/null +++ b/srock-bin/patches/amd-staging/compiler_amd-llvm.patch @@ -0,0 +1,16 @@ +diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt +index 46d799cbec11..e1228651d856 100644 +--- a/libc/CMakeLists.txt ++++ b/libc/CMakeLists.txt +@@ -420,10 +420,9 @@ add_subdirectory(lib) + if(LLVM_INCLUDE_TESTS) + add_subdirectory(test) + add_subdirectory(fuzzing) ++# add_subdirectory(benchmarks) + endif() + +-add_subdirectory(benchmarks) +- + if (LIBC_INCLUDE_DOCS) + add_subdirectory(docs) + endif()