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
17 changes: 14 additions & 3 deletions toolchain/scripts/common_vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,20 @@ SETUPFILE=${SETUPFILE:-"${INSTALLDIR}/setup"}
ARCH_FILE_TEMPLATE=${ARCH_FILE_TEMPLATE:-"${SCRIPTDIR}/arch_base.tmpl"}
VERSION_FILE=${VERSION_FILE:-"${SCRIPTDIR}/VERSION"}

# system arch gotten from OpenBLAS prebuild
OPENBLAS_ARCH=${OPENBLAS_ARCH:-''}
OPENBLAS_LIBCORE=${OPENBLAS_LIBCORE:-''}
# host architecture
SYSTEM_ARCH=${SYSTEM_ARCH:-"$(uname -m)"}
case "${SYSTEM_ARCH}" in
x86_64 | amd64)
SYSTEM_ARCH="x86_64"
;;
aarch64 | arm64)
SYSTEM_ARCH="arm64"
;;
*)
# Keep other architectures as reported by uname.
;;
esac
export SYSTEM_ARCH

# search paths
SYS_INCLUDE_PATH=${SYS_INCLUDE_PATH:-'/usr/local/include:/usr/include'}
Expand Down
76 changes: 0 additions & 76 deletions toolchain/scripts/get_openblas_arch.sh

This file was deleted.

14 changes: 0 additions & 14 deletions toolchain/scripts/package_versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,24 +139,10 @@ load_package_vars() {
fi
;;
"cmake")
# Determine architecture for SHA256 selection
local arch_suffix=""
if [ "${OPENBLAS_ARCH}" = "arm64" ]; then
if [ "$(uname -s)" = "Darwin" ]; then
arch_suffix="_macos"
else
arch_suffix="_aarch64"
fi
else
arch_suffix="_x86_64"
fi

if [ "${version_suffix}" = "alt" ]; then
cmake_ver="${cmake_alt_ver}"
eval "cmake_sha256=\${cmake_alt_sha256${arch_suffix}}"
else
cmake_ver="${cmake_main_ver}"
eval "cmake_sha256=\${cmake_main_sha256${arch_suffix}}"
fi
;;
"openmpi")
Expand Down
62 changes: 22 additions & 40 deletions toolchain/scripts/stage0/install_cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,64 +29,46 @@ if [[ -z "$version_suffix" && -n "${ABACUS_TOOLCHAIN_VERSION_SUFFIX}" ]]; then
version_suffix="${ABACUS_TOOLCHAIN_VERSION_SUFFIX}"
fi

# Ensure OPENBLAS_ARCH is set before loading package variables
# This is needed for architecture-specific SHA256 selection
# In --pack-run mode, openblas_arch file may contain empty values, so we need fallback
if [ -f "${BUILDDIR}/openblas_arch" ]; then
source "${BUILDDIR}/openblas_arch"
fi

if [ -z "${OPENBLAS_ARCH}" ]; then
case "$(uname -m)" in
x86_64|amd64) OPENBLAS_ARCH="x86_64" ;;
aarch64|arm64) OPENBLAS_ARCH="arm64" ;;
*) OPENBLAS_ARCH="x86_64" ;; # default fallback
esac
echo "OPENBLAS_ARCH not set, using fallback: ${OPENBLAS_ARCH}"
fi

# Export OPENBLAS_ARCH to ensure it's available throughout the script
export OPENBLAS_ARCH

# Load package variables with appropriate version
load_package_vars "cmake" "$version_suffix"

source "${INSTALLDIR}"/toolchain.conf
source "${INSTALLDIR}"/toolchain.env

# Re-apply architecture detection if OPENBLAS_ARCH is still empty after sourcing
if [ -z "${OPENBLAS_ARCH}" ]; then
case "$(uname -m)" in
x86_64|amd64) OPENBLAS_ARCH="x86_64" ;;
aarch64|arm64) OPENBLAS_ARCH="arm64" ;;
*) OPENBLAS_ARCH="x86_64" ;; # default fallback
esac
export OPENBLAS_ARCH
fi

[ -f "${BUILDDIR}/setup_cmake" ] && rm "${BUILDDIR}/setup_cmake"

! [ -d "${BUILDDIR}" ] && mkdir -p "${BUILDDIR}"
cd "${BUILDDIR}"
case "${with_cmake}" in
__INSTALL__)
echo "==================== Installing CMake ===================="
if [ "${OPENBLAS_ARCH}" = "arm64" ]; then
if [ "$(uname -s)" = "Darwin" ]; then
case "$(uname -s):${SYSTEM_ARCH}" in
Darwin:x86_64 | Darwin:arm64)
cmake_arch="macos-universal"
elif [ "$(uname -s)" = "Linux" ]; then
cmake_checksum_arch="macos"
;;
Linux:x86_64)
cmake_arch="linux-x86_64"
cmake_checksum_arch="x86_64"
;;
Linux:arm64)
cmake_arch="linux-aarch64"
else
cmake_checksum_arch="aarch64"
;;
*)
report_error ${LINENO} \
"cmake installation for ARCH=${OPENBLAS_ARCH} under $(uname -s) is not supported. You can try to use the system installation using the flag --with-cmake=system instead."
fi
elif [ "${OPENBLAS_ARCH}" = "x86_64" ]; then
cmake_arch="linux-x86_64"
"cmake installation for ARCH=${SYSTEM_ARCH} under $(uname -s) is not supported. You can try to use the system installation using the flag \"--with-cmake=system\" instead."
exit 1
;;
esac

if [ "${version_suffix}" = "alt" ]; then
cmake_checksum_var="cmake_alt_sha256_${cmake_checksum_arch}"
else
report_error ${LINENO} \
"cmake installation for ARCH=${OPENBLAS_ARCH} is not supported. You can try to use the system installation using the flag --with-cmake=system instead."
exit 1
cmake_checksum_var="cmake_main_sha256_${cmake_checksum_arch}"
fi
cmake_sha256="${!cmake_checksum_var}"

pkg_install_dir="${INSTALLDIR}/cmake-${cmake_ver}"
#pkg_install_dir="${HOME}/apps/cmake/${cmake_ver}"
install_lock_file="${pkg_install_dir}/install_successful"
Expand Down
4 changes: 0 additions & 4 deletions toolchain/scripts/stage0/setup_buildtools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ else
fi
export LDFLAGS="${TSANFLAGS}"

# get system arch information using OpenBLAS prebuild
${SCRIPTDIR}/get_openblas_arch.sh
load "${BUILDDIR}/openblas_arch"

write_toolchain_env "${INSTALLDIR}"

#EOF
2 changes: 1 addition & 1 deletion toolchain/scripts/stage1/install_openmpi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ case "${with_openmpi}" in
[ -d openmpi-${openmpi_ver} ] && rm -rf openmpi-${openmpi_ver}
tar -xjf ${openmpi_pkg}
cd openmpi-${openmpi_ver}
if [ "${OPENBLAS_ARCH}" = "x86_64" ]; then
if [ "${SYSTEM_ARCH}" = "x86_64" ]; then
# can have issue with older glibc libraries, in which case
# we need to add the -fgnu89-inline to CFLAGS. We can check
# the version of glibc using ldd --version, as ldd is part of
Expand Down
4 changes: 2 additions & 2 deletions toolchain/scripts/stage2/install_mkl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ case "${with_mkl}" in
;;
esac
if [ "${with_mkl}" != "__DONTUSE__" ]; then
case ${OPENBLAS_ARCH} in
case "${SYSTEM_ARCH}" in
x86_64)
mkl_arch_dir="intel64"
MKL_CFLAGS="-m64"
Expand All @@ -67,7 +67,7 @@ if [ "${with_mkl}" != "__DONTUSE__" ]; then
MKL_CFLAGS="-m32"
;;
*)
report_error $LINENO "MKL only supports intel64 (x86_64) and ia32 (i386) at the moment, and your arch obtained from OpenBLAS prebuild is $OPENBLAS_ARCH"
report_error $LINENO "MKL only supports intel64 (x86_64) and ia32 (i386) at the moment, but the detected architecture is ${SYSTEM_ARCH}"
exit 1
;;
esac
Expand Down
82 changes: 31 additions & 51 deletions toolchain/scripts/stage2/install_openblas.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,70 +60,50 @@ case "${with_openblas}" in
[ -d OpenBLAS-${openblas_ver} ] && rm -rf OpenBLAS-${openblas_ver}
tar -zxf ${openblas_pkg}
cd OpenBLAS-${openblas_ver}

# First attempt to make openblas using auto detected
# TARGET, if this fails, then make with forced
# TARGET=NEHALEM
# Build OpenBLAS with DYNAMIC_ARCH unless native architecture is requested.
# If the latter fails, then build with DYNAMIC_ARCH.
#
# wrt NUM_THREADS=64: this is what the most common Linux distros seem to choose atm
# for a good compromise between memory usage and scalability
#
# Unfortunately, NO_SHARED=1 breaks ScaLAPACK build.
case "${TARGET_CPU}" in
"generic")
TARGET="NEHALEM"
;;
"native")
TARGET=${OPENBLAS_LIBCORE}
;;
"broadwell" | "skylake")
TARGET="HASWELL"
;;
"skylake-avx512")
TARGET="SKYLAKEX"
;;
*)
TARGET=${TARGET_CPU}
;;
esac
TARGET=$(echo ${TARGET} | tr '[:lower:]' '[:upper:]')
echo "Installing OpenBLAS library for target ${TARGET}"
(
make -j $(get_nprocs) \
MAKE_NB_JOBS=0 \
TARGET=${TARGET} \
NUM_THREADS=64 \
USE_THREAD=1 \
USE_OPENMP=1 \
NO_AFFINITY=1 \
CC="${CC}" \
FC="${FC}" \
PREFIX="${pkg_install_dir}" \
> make.log 2>&1 || tail -n ${LOG_LINES} make.log
) || (
make -j $(get_nprocs) \
MAKE_NB_JOBS=0 \
TARGET=NEHALEM \
NUM_THREADS=64 \
USE_THREAD=1 \
USE_OPENMP=1 \
NO_AFFINITY=1 \
CC="${CC}" \
FC="${FC}" \
PREFIX="${pkg_install_dir}" \
> make.nehalem.log 2>&1 || tail -n ${LOG_LINES} make.nehalem.log
)
make -j $(get_nprocs) \
BUILD_DYNAMIC=0
if [ "native" != "${TARGET_CPU}" ]; then
BUILD_DYNAMIC=1
fi
if [ "${BUILD_DYNAMIC}" = "0" ]; then
echo "Installing OpenBLAS library for native target"
if ! make -j "$(get_nprocs)" \
MAKE_NB_JOBS=0 \
NUM_THREADS=64 \
USE_THREAD=1 \
USE_OPENMP=1 \
NO_AFFINITY=1 \
CC="${CC}" \
FC="${FC}" \
PREFIX="${pkg_install_dir}" \
> make.log 2>&1; then
tail -n "${LOG_LINES}" make.log
BUILD_DYNAMIC=1
fi
fi
if [ "${BUILD_DYNAMIC}" != "0" ]; then
echo "Installing OpenBLAS library for dynamic target"
if ! make -j "$(get_nprocs)" \
MAKE_NB_JOBS=0 \
TARGET=${TARGET} \
DYNAMIC_ARCH=1 \
NUM_THREADS=64 \
USE_THREAD=1 \
USE_OPENMP=1 \
NO_AFFINITY=1 \
CC="${CC}" \
FC="${FC}" \
PREFIX="${pkg_install_dir}" \
install > install.log 2>&1 || tail -n ${LOG_LINES} install.log
install > install.log 2>&1; then
tail -n "${LOG_LINES}" install.log
exit 1
fi
fi
cd ..
write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage2/$(basename ${SCRIPT_NAME})"
fi
Expand Down
2 changes: 1 addition & 1 deletion toolchain/scripts/stage3/install_elpa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ case "$with_elpa" in
SSE4_flag=""
config_flags="--disable-avx-kernels --disable-avx2-kernels --disable-avx512-kernels --disable-sse-kernels --disable-sse-assembly-kernels"
if [ "${TARGET_CPU}" = "native" ]; then
if [ -f /proc/cpuinfo ] && [ "${OPENBLAS_ARCH}" = "x86_64" ]; then
if [ -f /proc/cpuinfo ] && [ "${SYSTEM_ARCH}" = "x86_64" ]; then
has_AVX=$(grep '\bavx\b' /proc/cpuinfo 1> /dev/null && echo 'yes' || echo 'no')
[ "${has_AVX}" = "yes" ] && AVX_flag="-mavx" || AVX_flag=""
has_AVX2=$(grep '\bavx2\b' /proc/cpuinfo 1> /dev/null && echo 'yes' || echo 'no')
Expand Down
Loading