diff --git a/CMakeLists.txt b/CMakeLists.txt index 23583375bb3..d0a76e9a21e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -161,6 +161,12 @@ endfunction() # enable json support if(ENABLE_RAPIDJSON) find_package(RapidJSON CONFIG REQUIRED) + if(NOT TARGET RapidJSON) + message( + FATAL_ERROR + "RapidJSON was found, but target RapidJSON is missing. Check if your RapidJSON installation provides a complete exported CMake configuration." + ) + endif() abacus_add_feature_definitions(__RAPIDJSON) target_link_libraries(abacus_external_deps INTERFACE RapidJSON) endif() diff --git a/toolchain/build_abacus_aocc-aocl.sh b/toolchain/build_abacus_aocc-aocl.sh index b32295bf119..c8a991f17d5 100755 --- a/toolchain/build_abacus_aocc-aocl.sh +++ b/toolchain/build_abacus_aocc-aocl.sh @@ -24,7 +24,6 @@ rm -rf $BUILD_DIR PREFIX=$ABACUS_DIR ELPA=${ELPA_ROOT} CEREAL=${CEREAL_ROOT}/include -RAPIDJSON=${RAPIDJSON_ROOT} LAPACK=$AOCLhome/lib SCALAPACK=$AOCLhome/lib FFTW3=$AOCLhome @@ -75,7 +74,6 @@ cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \ -DUSE_OPENMP=ON \ -DUSE_ELPA=ON \ -DENABLE_RAPIDJSON=ON \ - -DRapidJSON_DIR=$RAPIDJSON \ -DENABLE_LIBRI=ON \ -DLIBRI_DIR=$LIBRI \ -DLIBCOMM_DIR=$LIBCOMM \ diff --git a/toolchain/install_abacus_toolchain_new.sh b/toolchain/install_abacus_toolchain_new.sh index 0f0d85d42e3..cbcd4385589 100755 --- a/toolchain/install_abacus_toolchain_new.sh +++ b/toolchain/install_abacus_toolchain_new.sh @@ -50,7 +50,7 @@ main() { # Initialize configuration with command line arguments if ! config_init "${args[@]}"; then show_help - exit 0 + exit 1 fi # Handle special version-related requests diff --git a/toolchain/scripts/lib/config_manager.sh b/toolchain/scripts/lib/config_manager.sh index fc7ca306837..249e6515566 100644 --- a/toolchain/scripts/lib/config_manager.sh +++ b/toolchain/scripts/lib/config_manager.sh @@ -456,13 +456,13 @@ config_validate() { if [[ -n "${CONFIG_CACHE[NPROCS_OVERWRITE]}" ]]; then if ! [[ "${CONFIG_CACHE[NPROCS_OVERWRITE]}" =~ ^[0-9]+$ ]]; then report_error ${LINENO} "Invalid number of processes: ${CONFIG_CACHE[NPROCS_OVERWRITE]}" - exit 1 + return 1 fi fi if ! [[ "${CONFIG_CACHE[LOG_LINES]}" =~ ^[0-9]+$ ]]; then report_error ${LINENO} "Invalid log lines value: ${CONFIG_CACHE[LOG_LINES]}" - exit 1 + return 1 fi # Validate GPU version - support only numeric formats @@ -476,7 +476,7 @@ config_validate() { CONFIG_CACHE["ARCH_NUM"]="$arch_num" else report_error ${LINENO} "Invalid GPU version: $gpu_ver. Supported formats: numeric with decimal (6.0, 7.0, 8.0, 8.9, etc.) or numeric without decimal (60, 70, 80, 89, etc.)" - exit 1 + return 1 fi else CONFIG_CACHE["ARCH_NUM"]="no" @@ -1166,27 +1166,37 @@ config_parse_arguments() { config_init() { # Set defaults first config_set_defaults - + # Initialize version helper to ensure VERSION_STRATEGY defaults are set if command -v version_helper_init > /dev/null 2>&1; then version_helper_init fi - + # Load configuration from file (if available) - this will override defaults - config_load_from_file - + if ! config_load_from_file; then + return 1 + fi + # Apply mode-based configurations from file - this will override defaults - config_apply_modes_from_file - + if ! config_apply_modes_from_file; then + return 1 + fi + # Parse command line arguments - this will override file settings - config_parse_arguments "$@" - + if ! config_parse_arguments "$@"; then + return 1 + fi + # Apply mode-based configurations from command line - config_apply_modes - + if ! config_apply_modes; then + return 1 + fi + # Validate configuration - config_validate - + if ! config_validate; then + return 1 + fi + return 0 } @@ -1262,4 +1272,6 @@ config_apply_modes() { ;; esac fi + + return 0 } diff --git a/toolchain/scripts/lib/wrapper_runner.sh b/toolchain/scripts/lib/wrapper_runner.sh new file mode 100644 index 00000000000..81adb56c1ac --- /dev/null +++ b/toolchain/scripts/lib/wrapper_runner.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +run_toolchain_with_log() { + local log_file="$1" + shift + + "$@" | tee "$log_file" + local installer_status=${PIPESTATUS[0]} + + return "$installer_status" +} diff --git a/toolchain/scripts/stage1/install_openmpi.sh b/toolchain/scripts/stage1/install_openmpi.sh index 423e6943d1c..e798cc7325e 100755 --- a/toolchain/scripts/stage1/install_openmpi.sh +++ b/toolchain/scripts/stage1/install_openmpi.sh @@ -167,6 +167,10 @@ else grep "(Open MPI)" | awk '{print $4}') major_version=$(echo ${raw_version} | cut -d '.' -f 1) minor_version=$(echo ${raw_version} | cut -d '.' -f 2) + OPENMPI_BINDING_POLICY_ENV="export OMPI_MCA_hwloc_base_binding_policy=none" + if [[ "${major_version}" =~ ^[0-9]+$ && "${major_version}" -ge 5 ]]; then + OPENMPI_BINDING_POLICY_ENV="export PRTE_MCA_hwloc_default_binding_policy=none" + fi OPENMPI_LIBS="" # grab additional runtime libs (for C/C++) from the mpicxx wrapper, # and remove them from the LDFLAGS if present @@ -182,6 +186,7 @@ export MPICXX="${MPICXX}" export MPIFC="${MPIFC}" export MPIFORT="${MPIFORT}" export MPIF77="${MPIF77}" +${OPENMPI_BINDING_POLICY_ENV} export OPENMPI_CFLAGS="${OPENMPI_CFLAGS}" export OPENMPI_LDFLAGS="${OPENMPI_LDFLAGS}" export OPENMPI_LIBS="${OPENMPI_LIBS}" diff --git a/toolchain/tests/test_installer_argument_failures.sh b/toolchain/tests/test_installer_argument_failures.sh new file mode 100755 index 00000000000..0bdb1d85345 --- /dev/null +++ b/toolchain/tests/test_installer_argument_failures.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env bash +set -u + +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)" +TOOLCHAIN_DIR="${REPO_ROOT}/toolchain" +FAILURES=0 + +fail() { + printf 'FAIL: %s\n' "$*" >&2 + FAILURES=$((FAILURES + 1)) +} + +copy_toolchain() { + local tmpdir="$1" + local entry name + mkdir -p "${tmpdir}/toolchain" + while IFS= read -r -d '' entry; do + name="${entry##*/}" + case "$name" in + build|install) continue ;; + esac + cp -a "$entry" "${tmpdir}/toolchain/" + done < <(find "${TOOLCHAIN_DIR}" -mindepth 1 -maxdepth 1 -print0) +} + +run_installer_in_copy() { + local tmpdir="$1" + shift + (cd "${tmpdir}/toolchain" && ./install_abacus_toolchain_new.sh "$@") >"${tmpdir}/output.log" 2>&1 +} + +assert_invalid_input_fails() { + local name="$1" + local expected_text="$2" + shift 2 + + local tmpdir status + tmpdir="$(mktemp -d)" + copy_toolchain "$tmpdir" + + run_installer_in_copy "$tmpdir" "$@" + status=$? + + if [[ "$status" -eq 0 ]]; then + cat "${tmpdir}/output.log" >&2 + fail "${name} exited 0; expected nonzero" + fi + + if ! grep -Fq -- "$expected_text" "${tmpdir}/output.log"; then + cat "${tmpdir}/output.log" >&2 + fail "${name} did not report expected error: ${expected_text}" + fi + + if ! grep -Fq "install_abacus_toolchain_new.sh [OPTIONS]" "${tmpdir}/output.log"; then + cat "${tmpdir}/output.log" >&2 + fail "${name} output did not contain usage text" + fi + + if [[ -e "${tmpdir}/toolchain/install/setup" ]]; then + fail "${name} wrote install/setup even though argument parsing failed" + fi + + rm -rf "$tmpdir" +} + +assert_invalid_input_fails "invalid package version" "Invalid package version format" --dry-run --package-version bad:wrong +assert_invalid_input_fails "invalid gpu version" "Invalid GPU version" --dry-run --gpu-ver bad + +if [[ "$FAILURES" -ne 0 ]]; then + printf '%s installer argument failure test(s) failed\n' "$FAILURES" >&2 + exit 1 +fi + +printf 'installer argument failure tests passed\n' diff --git a/toolchain/tests/test_openmpi_binding_policy_setup.sh b/toolchain/tests/test_openmpi_binding_policy_setup.sh new file mode 100755 index 00000000000..5ae0bfb9c6d --- /dev/null +++ b/toolchain/tests/test_openmpi_binding_policy_setup.sh @@ -0,0 +1,127 @@ +#!/usr/bin/env bash +set -u + +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)" +TOOLCHAIN_DIR="${REPO_ROOT}/toolchain" +FAILURES=0 + +fail() { + printf 'FAIL: %s\n' "$*" >&2 + FAILURES=$((FAILURES + 1)) +} + +write_fake_openmpi_commands() { + local bindir="$1" + local version="$2" + + mkdir -p "$bindir" + cat >"${bindir}/mpiexec" <"${bindir}/mpicxx" <<'EOF' +#!/usr/bin/env bash +if [[ "$1" == "--showme:libs" ]]; then + printf 'mpi\n' + exit 0 +fi +exit 0 +EOF + cp "${bindir}/mpicxx" "${bindir}/mpicc" + cp "${bindir}/mpicxx" "${bindir}/mpifort" + chmod +x "${bindir}/mpiexec" "${bindir}/mpicc" "${bindir}/mpicxx" "${bindir}/mpifort" +} + +run_openmpi_system_setup() { + local tmpdir="$1" + local version="$2" + + mkdir -p "${tmpdir}/install" "${tmpdir}/build" + : >"${tmpdir}/install/setup" + : >"${tmpdir}/install/toolchain.env" + cat >"${tmpdir}/install/toolchain.conf" <<'EOF' +MPI_MODE="openmpi" +with_openmpi="__SYSTEM__" +PACK_RUN="__FALSE__" +EOF + + write_fake_openmpi_commands "${tmpdir}/fake-bin" "$version" + PATH="${tmpdir}/fake-bin:${PATH}" \ + ROOTDIR="$tmpdir" \ + SCRIPTDIR="${TOOLCHAIN_DIR}/scripts" \ + INSTALLDIR="${tmpdir}/install" \ + BUILDDIR="${tmpdir}/build" \ + SETUPFILE="${tmpdir}/install/setup" \ + bash "${TOOLCHAIN_DIR}/scripts/stage1/install_openmpi.sh" \ + >"${tmpdir}/openmpi.log" 2>&1 +} + +assert_setup_contains() { + local file="$1" + local expected="$2" + + if ! grep -Fq "$expected" "$file"; then + cat "$file" >&2 + fail "${file} does not contain expected text: ${expected}" + fi +} + +assert_setup_not_contains() { + local file="$1" + local unexpected="$2" + + if grep -Fq "$unexpected" "$file"; then + cat "$file" >&2 + fail "${file} contains unexpected text: ${unexpected}" + fi +} + +test_openmpi5_setup_disables_prte_binding() { + local tmpdir status + tmpdir="$(mktemp -d)" + + run_openmpi_system_setup "$tmpdir" "5.0.10" + status=$? + + if [[ "$status" -ne 0 ]]; then + cat "${tmpdir}/openmpi.log" >&2 + fail "OpenMPI 5 setup generation failed with status ${status}" + else + assert_setup_contains "${tmpdir}/install/setup" "export PRTE_MCA_hwloc_default_binding_policy=none" + assert_setup_not_contains "${tmpdir}/install/setup" "export OMPI_MCA_hwloc_base_binding_policy=none" + fi + + rm -rf "$tmpdir" +} + +test_openmpi4_setup_disables_ompi_binding() { + local tmpdir status + tmpdir="$(mktemp -d)" + + run_openmpi_system_setup "$tmpdir" "4.1.8" + status=$? + + if [[ "$status" -ne 0 ]]; then + cat "${tmpdir}/openmpi.log" >&2 + fail "OpenMPI 4 setup generation failed with status ${status}" + else + assert_setup_contains "${tmpdir}/install/setup" "export OMPI_MCA_hwloc_base_binding_policy=none" + assert_setup_not_contains "${tmpdir}/install/setup" "export PRTE_MCA_hwloc_default_binding_policy=none" + fi + + rm -rf "$tmpdir" +} + +test_openmpi5_setup_disables_prte_binding +test_openmpi4_setup_disables_ompi_binding + +if [[ "$FAILURES" -ne 0 ]]; then + printf '%s OpenMPI binding policy setup test(s) failed\n' "$FAILURES" >&2 + exit 1 +fi + +printf 'OpenMPI binding policy setup tests passed\n' diff --git a/toolchain/tests/test_rapidjson_cmake.sh b/toolchain/tests/test_rapidjson_cmake.sh new file mode 100755 index 00000000000..0b3c0e689f2 --- /dev/null +++ b/toolchain/tests/test_rapidjson_cmake.sh @@ -0,0 +1,123 @@ +#!/usr/bin/env bash +set -u + +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)" +FAILURES=0 + +fail() { + printf 'FAIL: %s\n' "$*" >&2 + FAILURES=$((FAILURES + 1)) +} + +write_target_package() { + local prefix="$1" + mkdir -p "${prefix}/include/rapidjson" "${prefix}/lib/cmake/RapidJSON" + printf '#pragma once\n' >"${prefix}/include/rapidjson/document.h" + cat >"${prefix}/lib/cmake/RapidJSON/RapidJSONConfig.cmake" <<'EOF' +message(STATUS "Loaded fake RapidJSON target package") +get_filename_component(RapidJSON_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +get_filename_component(_rapidjson_prefix "${RapidJSON_CMAKE_DIR}/../../.." ABSOLUTE) +if(NOT TARGET RapidJSON) + add_library(RapidJSON INTERFACE IMPORTED) + set_property(TARGET RapidJSON PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${_rapidjson_prefix}/include") +endif() +EOF +} + +write_fake_mkl() { + local prefix="$1" + mkdir -p "${prefix}/include" "${prefix}/lib" + printf '#pragma once\n' >"${prefix}/include/mkl_service.h" + : >"${prefix}/lib/libmkl_core.so" + : >"${prefix}/lib/libmkl_gf_lp64.so" + : >"${prefix}/lib/libmkl_gnu_thread.so" +} + +write_variable_only_package() { + local prefix="$1" + mkdir -p "${prefix}/include/rapidjson" "${prefix}/lib/cmake/RapidJSON" + printf '#pragma once\n' >"${prefix}/include/rapidjson/document.h" + cat >"${prefix}/lib/cmake/RapidJSON/RapidJSONConfig.cmake" <<'EOF' +get_filename_component(RapidJSON_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +get_filename_component(_rapidjson_prefix "${RapidJSON_CMAKE_DIR}/../../.." ABSOLUTE) +set(RapidJSON_INCLUDE_DIR "${_rapidjson_prefix}/include") +set(RapidJSON_INCLUDE_DIRS "${RapidJSON_INCLUDE_DIR}") +EOF +} + +run_top_level_configure() { + local build_dir="$1" + local prefix="$2" + local mkl_root="$3" + + cmake -S "$REPO_ROOT" -B "$build_dir" \ + -DENABLE_RAPIDJSON=ON \ + -DENABLE_LCAO=OFF \ + -DENABLE_MPI=OFF \ + -DUSE_OPENMP=OFF \ + -DMKLROOT="$mkl_root" \ + -DCMAKE_PREFIX_PATH="$prefix" \ + >"${build_dir}.log" 2>&1 +} + +test_top_level_accepts_rapidjson_target_package() { + local tmpdir prefix mkl_root build_dir status + tmpdir="$(mktemp -d)" + prefix="${tmpdir}/prefix" + mkl_root="${tmpdir}/mkl" + build_dir="${tmpdir}/target-build" + + write_target_package "$prefix" + write_fake_mkl "$mkl_root" + run_top_level_configure "$build_dir" "$prefix" "$mkl_root" + status=$? + + if ! grep -Fq "Loaded fake RapidJSON target package" "${build_dir}.log"; then + cat "${build_dir}.log" >&2 + fail "top-level CMake did not load the fake RapidJSON target package" + elif grep -Fq "RapidJSON was found, but target RapidJSON is missing" "${build_dir}.log"; then + cat "${build_dir}.log" >&2 + fail "top-level CMake rejected RapidJSON target package as target-missing" + elif grep -Fq 'Could not find a package configuration file provided by "RapidJSON"' "${build_dir}.log"; then + cat "${build_dir}.log" >&2 + fail "top-level CMake did not find the fake RapidJSON target package" + elif [[ "$status" -ne 0 ]]; then + cat "${build_dir}.log" >&2 + fail "top-level CMake failed with a RapidJSON target package" + fi + + rm -rf "$tmpdir" +} + +test_top_level_rejects_variable_only_package() { + local tmpdir prefix mkl_root build_dir status + tmpdir="$(mktemp -d)" + prefix="${tmpdir}/prefix" + mkl_root="${tmpdir}/mkl" + build_dir="${tmpdir}/variable-build" + + write_variable_only_package "$prefix" + write_fake_mkl "$mkl_root" + run_top_level_configure "$build_dir" "$prefix" "$mkl_root" + status=$? + + if [[ "$status" -eq 0 ]]; then + cat "${build_dir}.log" >&2 + fail "top-level CMake configured with variable-only RapidJSON package; expected target-missing failure" + elif ! grep -Fq "RapidJSON was found, but target RapidJSON is missing." "${build_dir}.log"; then + cat "${build_dir}.log" >&2 + fail "top-level CMake failed for the wrong reason with variable-only RapidJSON package" + fi + + rm -rf "$tmpdir" +} + +test_top_level_accepts_rapidjson_target_package +test_top_level_rejects_variable_only_package + +if [[ "$FAILURES" -ne 0 ]]; then + printf '%s RapidJSON CMake test(s) failed\n' "$FAILURES" >&2 + exit 1 +fi + +printf 'RapidJSON CMake tests passed\n' diff --git a/toolchain/tests/test_wrapper_failure_propagation.sh b/toolchain/tests/test_wrapper_failure_propagation.sh new file mode 100755 index 00000000000..5e33ebb2434 --- /dev/null +++ b/toolchain/tests/test_wrapper_failure_propagation.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +set -u + +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)" +TOOLCHAIN_DIR="${REPO_ROOT}/toolchain" +FAILURES=0 + +fail() { + printf 'FAIL: %s\n' "$*" >&2 + FAILURES=$((FAILURES + 1)) +} + +assert_file_contains() { + local file="$1" + local text="$2" + if ! grep -Fq "$text" "$file"; then + fail "${file} does not contain expected text: ${text}" + fi +} + +test_runner_preserves_command_failure() { + # shellcheck source=/dev/null + source "${TOOLCHAIN_DIR}/scripts/lib/wrapper_runner.sh" + + local tmpdir log status + tmpdir="$(mktemp -d)" + log="${tmpdir}/compile.log" + + run_toolchain_with_log "$log" bash -c 'printf "installer stdout\n"; exit 37' + status=$? + + if [[ "$status" -ne 37 ]]; then + fail "run_toolchain_with_log returned ${status}; expected 37" + fi + assert_file_contains "$log" "installer stdout" + + rm -rf "$tmpdir" +} + +test_wrappers_use_runner() { + local wrappers=( + "${TOOLCHAIN_DIR}/toolchain_gnu.sh" + "${TOOLCHAIN_DIR}/toolchain_intel.sh" + "${TOOLCHAIN_DIR}/toolchain_gcc-mkl.sh" + "${TOOLCHAIN_DIR}/toolchain_gcc-aocl.sh" + "${TOOLCHAIN_DIR}/toolchain_aocc-aocl.sh" + ) + + local wrapper + for wrapper in "${wrappers[@]}"; do + assert_file_contains "$wrapper" 'source "${SCRIPT_DIR}/scripts/lib/wrapper_runner.sh"' + assert_file_contains "$wrapper" 'run_toolchain_with_log compile.log ./install_abacus_toolchain_new.sh' + + if grep -Eq '\|\s*tee[[:space:]]+compile\.log' "$wrapper"; then + fail "${wrapper} still contains a raw pipe to tee compile.log" + fi + + if grep -Eq '^exec[[:space:]]+\./install_abacus_toolchain_new\.sh' "$wrapper"; then + fail "${wrapper} still execs the installer directly" + fi + done +} + +test_runner_preserves_command_failure +test_wrappers_use_runner + +if [[ "$FAILURES" -ne 0 ]]; then + printf '%s wrapper failure propagation test(s) failed\n' "$FAILURES" >&2 + exit 1 +fi + +printf 'wrapper failure propagation tests passed\n' diff --git a/toolchain/toolchain_aocc-aocl.sh b/toolchain/toolchain_aocc-aocl.sh index bfc4b4bc1a2..83ad0a1c841 100755 --- a/toolchain/toolchain_aocc-aocl.sh +++ b/toolchain/toolchain_aocc-aocl.sh @@ -5,6 +5,9 @@ #SBATCH -o compile.log #SBATCH -e compile.err +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" +source "${SCRIPT_DIR}/scripts/lib/wrapper_runner.sh" + # Users can easily modify these parameters to customize the build # Before running this script, ensure you have loaded your system packages @@ -84,7 +87,7 @@ LIBTORCH_VERSION="main" # main=2.1.2, alt=1.12.1 (use alt for older GLIBC) # ============================================================================ # Call the main installation script with configured parameters -exec ./install_abacus_toolchain_new.sh \ +run_toolchain_with_log compile.log ./install_abacus_toolchain_new.sh \ --with-amd="$WITH_AMD" \ --with-gcc="$WITH_GCC" \ --math-mode="$MATH_MODE" \ @@ -115,5 +118,4 @@ exec ./install_abacus_toolchain_new.sh \ ${PACK_RUN_MODE:+$([ "$PACK_RUN_MODE" = "yes" ] && echo "--pack-run")} \ ${ENABLE_CUDA:+--enable-cuda} \ ${GPU_VERSION:+--gpu-ver="$GPU_VERSION"} \ - "$@" \ - | tee compile.log + "$@" diff --git a/toolchain/toolchain_gcc-aocl.sh b/toolchain/toolchain_gcc-aocl.sh index f77b533989c..1238defd361 100755 --- a/toolchain/toolchain_gcc-aocl.sh +++ b/toolchain/toolchain_gcc-aocl.sh @@ -5,6 +5,9 @@ #SBATCH -o compile.log #SBATCH -e compile.err +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" +source "${SCRIPT_DIR}/scripts/lib/wrapper_runner.sh" + # Users can easily modify these parameters to customize the build # Before running this script, ensure you have loaded your system packages @@ -81,7 +84,7 @@ LIBTORCH_VERSION="main" # main=2.1.2, alt=1.12.1 (use alt for older GLIBC) # ============================================================================ # Call the main installation script with configured parameters -exec ./install_abacus_toolchain_new.sh \ +run_toolchain_with_log compile.log ./install_abacus_toolchain_new.sh \ --with-gcc="$WITH_GCC" \ --with-amd="$WITH_AMD" \ --math-mode="$MATH_MODE" \ @@ -111,5 +114,4 @@ exec ./install_abacus_toolchain_new.sh \ ${PACK_RUN_MODE:+$([ "$PACK_RUN_MODE" = "yes" ] && echo "--pack-run")} \ ${ENABLE_CUDA:+--enable-cuda} \ ${GPU_VERSION:+--gpu-ver="$GPU_VERSION"} \ - "$@" \ - | tee compile.log + "$@" diff --git a/toolchain/toolchain_gcc-mkl.sh b/toolchain/toolchain_gcc-mkl.sh index bac479c38f7..df0fc04d108 100755 --- a/toolchain/toolchain_gcc-mkl.sh +++ b/toolchain/toolchain_gcc-mkl.sh @@ -5,6 +5,9 @@ #SBATCH -o compile.log #SBATCH -e compile.err +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" +source "${SCRIPT_DIR}/scripts/lib/wrapper_runner.sh" + # Users can easily modify these parameters to customize the build # Before running this script, ensure you have loaded your system packages @@ -84,7 +87,7 @@ LIBTORCH_VERSION="main" # main=2.1.2, alt=1.12.1 (use alt for older GLIBC) # ============================================================================ # Call the main installation script with configured parameters -exec ./install_abacus_toolchain_new.sh \ +run_toolchain_with_log compile.log ./install_abacus_toolchain_new.sh \ --with-gcc="$WITH_GCC" \ --math-mode="$MATH_MODE" \ --mpi-mode="$MPI_MODE" \ @@ -114,5 +117,4 @@ exec ./install_abacus_toolchain_new.sh \ ${PACK_RUN_MODE:+$([ "$PACK_RUN_MODE" = "yes" ] && echo "--pack-run")} \ ${ENABLE_CUDA:+--enable-cuda} \ ${GPU_VERSION:+--gpu-ver="$GPU_VERSION"} \ - "$@" \ - | tee compile.log + "$@" diff --git a/toolchain/toolchain_gnu.sh b/toolchain/toolchain_gnu.sh index a934fed0181..e297c0e453b 100755 --- a/toolchain/toolchain_gnu.sh +++ b/toolchain/toolchain_gnu.sh @@ -4,6 +4,10 @@ #SBATCH -n 16 #SBATCH -o compile.log #SBATCH -e compile.err + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" +source "${SCRIPT_DIR}/scripts/lib/wrapper_runner.sh" + # Users can easily modify these parameters to customize the build # Before running this script, ensure you have loaded your system packages @@ -84,7 +88,7 @@ LIBTORCH_VERSION="main" # main=2.1.2, alt=1.12.1 (use alt for older GLIBC) # ============================================================================ # Call the main installation script with configured parameters -exec ./install_abacus_toolchain_new.sh \ +run_toolchain_with_log compile.log ./install_abacus_toolchain_new.sh \ --with-gcc="$WITH_GCC" \ --with-intel="$WITH_INTEL" \ --with-amd="$WITH_AMD" \ @@ -119,5 +123,4 @@ exec ./install_abacus_toolchain_new.sh \ ${PACK_RUN_MODE:+$([ "$PACK_RUN_MODE" = "yes" ] && echo "--pack-run")} \ ${ENABLE_CUDA:+--enable-cuda} \ ${GPU_VERSION:+--gpu-ver="$GPU_VERSION"} \ - "$@" \ - | tee compile.log + "$@" diff --git a/toolchain/toolchain_intel.sh b/toolchain/toolchain_intel.sh index ab40cf55b2b..9f854a0b4a1 100755 --- a/toolchain/toolchain_intel.sh +++ b/toolchain/toolchain_intel.sh @@ -5,6 +5,9 @@ #SBATCH -o compile.log #SBATCH -e compile.err +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" +source "${SCRIPT_DIR}/scripts/lib/wrapper_runner.sh" + # Users can easily modify these parameters to customize the build # Before running this script, ensure you have loaded your system packages @@ -103,7 +106,7 @@ LIBTORCH_VERSION="main" # main=2.1.2, alt=1.12.1 (use alt for older GLIBC) # ============================================================================ # Call the main installation script with configured parameters -exec ./install_abacus_toolchain_new.sh \ +run_toolchain_with_log compile.log ./install_abacus_toolchain_new.sh \ --with-intel="$WITH_INTEL" \ --with-gcc="$WITH_GCC" \ --math-mode="$MATH_MODE" \ @@ -136,5 +139,4 @@ exec ./install_abacus_toolchain_new.sh \ ${PACK_RUN_MODE:+$([ "$PACK_RUN_MODE" = "yes" ] && echo "--pack-run")} \ ${ENABLE_CUDA:+--enable-cuda} \ ${GPU_VERSION:+--gpu-ver="$GPU_VERSION"} \ - "$@" \ - | tee compile.log + "$@"