Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Comment on lines 162 to 172

This comment was marked as resolved.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed. The fallback path was dropped; ENABLE_RAPIDJSON now requires the exported RapidJSON target and links it through abacus_external_deps.

Expand Down
2 changes: 0 additions & 2 deletions toolchain/build_abacus_aocc-aocl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion toolchain/install_abacus_toolchain_new.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 27 additions & 15 deletions toolchain/scripts/lib/config_manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -1262,4 +1272,6 @@ config_apply_modes() {
;;
esac
fi

return 0
}
11 changes: 11 additions & 0 deletions toolchain/scripts/lib/wrapper_runner.sh
Original file line number Diff line number Diff line change
@@ -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"
}
5 changes: 5 additions & 0 deletions toolchain/scripts/stage1/install_openmpi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}"
Expand Down
74 changes: 74 additions & 0 deletions toolchain/tests/test_installer_argument_failures.sh
Original file line number Diff line number Diff line change
@@ -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'
127 changes: 127 additions & 0 deletions toolchain/tests/test_openmpi_binding_policy_setup.sh
Original file line number Diff line number Diff line change
@@ -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" <<EOF
#!/usr/bin/env bash
if [[ "\$1" == "--version" ]]; then
printf 'mpiexec (Open MPI) ${version}\n'
exit 0
fi
exit 0
EOF
cat >"${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'
Loading
Loading