From 80f78ddbd3955275afccaa5024bf3d20ec6a2283 Mon Sep 17 00:00:00 2001 From: Hans Pabst Date: Tue, 3 Sep 2024 18:31:27 +0200 Subject: [PATCH] Accommodate toolchain for Alps * OpenBLAS - Alps CPU is correctly detected as NeoverseV2 which is suddenly not in the TargetList of OpenBLAS - This is despite OpenBLAS itself detecting a NeoverseV2 CPU (reported in LIBCORE statement). - Building and installing OpenBLAS is now more robust relying more on DYNAMIC_ARCH feature. - On ARM in particular, "generic" was hard-coded as TARGET=NEHALEM. - The USE_THREAD setting is not necessary for CP2K (PThread flavor). * MPICH/2 - Apply --without-slurm as it otherwise is likely to meet an incompatible Slurm include file. - Resulted in compilation error on Alps-like self-hosted SuperMicro system (w/ Ubuntu LTS). --- .../toolchain/scripts/stage1/install_mpich.sh | 2 +- .../scripts/stage2/install_openblas.sh | 88 +++++++------------ 2 files changed, 35 insertions(+), 55 deletions(-) diff --git a/tools/toolchain/scripts/stage1/install_mpich.sh b/tools/toolchain/scripts/stage1/install_mpich.sh index de80eb96a6..f4ee37edb1 100755 --- a/tools/toolchain/scripts/stage1/install_mpich.sh +++ b/tools/toolchain/scripts/stage1/install_mpich.sh @@ -56,7 +56,7 @@ case "${with_mpich}" in MPICC="" \ FFLAGS="${FCFLAGS} ${compat_flag}" \ FCFLAGS="${FCFLAGS} ${compat_flag}" \ - --without-x \ + --without-x --without-slurm \ --enable-gl=no \ --with-device=${MPICH_DEVICE} \ > configure.log 2>&1 || tail -n ${LOG_LINES} configure.log diff --git a/tools/toolchain/scripts/stage2/install_openblas.sh b/tools/toolchain/scripts/stage2/install_openblas.sh index e0be7fc1e9..a1f42fe0ae 100755 --- a/tools/toolchain/scripts/stage2/install_openblas.sh +++ b/tools/toolchain/scripts/stage2/install_openblas.sh @@ -44,72 +44,52 @@ case "${with_openblas}" in 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. Relying on DYNAMIC_ARCH + # is more flexible and more reliable on ARM64. However, it increaes the time + # needed to build OpenBLAS. + # It is supported to omit the PREFIX when building OpenBLAS as well as + # omitting build-keys for the install target. # - # wrt NUM_THREADS=128: this is what the most common Linux distros seem to choose atm - # for a good compromise between memory usage and scalability + # NUM_THREADS=128: this is what the most common Linux distros seem to choose atm + # for a good compromise between memory usage and scalability + # USE_THREADS=1: is not needed since CP2K's ARCH-files do not rely on + # plain PThread based OpenBLAS (OpenMP is used). # # 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" - ;; - znver*) - TARGET="ZEN" - ;; - *) - TARGET=${TARGET_CPU} - ;; - esac - TARGET=$(echo ${TARGET} | tr '[:lower:]' '[:upper:]') - echo "Installing OpenBLAS library for target ${TARGET}" - ( + BUILD_DYNAMIC=0 + if [ "native" != "${TARGET_CPU}" ] || [ ! "${OPENBLAS_LIBCORE}" ]; then + BUILD_DYNAMIC=1 + fi + if [ "0" = "${BUILD_DYNAMIC}" ]; then + TARGET=$(tr '[:lower:]' '[:upper:]' <<< "${OPENBLAS_LIBCORE}") + echo "Installing OpenBLAS library for target ${TARGET}" make -j $(get_nprocs) \ - MAKE_NB_JOBS=0 \ TARGET=${TARGET} \ + MAKE_NB_JOBS=0 \ + NUM_THREADS=128 \ + USE_OPENMP=1 \ + NO_AFFINITY=1 \ + CC="${CC}" \ + FC="${FC}" \ + PREFIX="${pkg_install_dir}" \ + > make.${OPENBLAS_LIBCORE}.log 2>&1 || tail -n ${LOG_LINES} make.${OPENBLAS_LIBCORE}.log + BUILD_DYNAMIC=$? + fi + if [ "0" != "${BUILD_DYNAMIC}" ]; then + echo "Installing OpenBLAS library for dynamic target" + make -j $(get_nprocs) \ + DYNAMIC_ARCH=1 \ + MAKE_NB_JOBS=0 \ NUM_THREADS=128 \ - 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=128 \ - 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) \ - MAKE_NB_JOBS=0 \ - TARGET=${TARGET} \ - NUM_THREADS=128 \ - 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 + fi + make MAKE_NB_JOBS=0 PREFIX="${pkg_install_dir}" install > install.log 2>&1 || tail -n ${LOG_LINES} install.log cd .. write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage2/$(basename ${SCRIPT_NAME})" fi