diff --git a/tools/autotools/autogen.sh b/tools/autotools/autogen.sh index 0af06cb9a4..f18dca7991 100755 --- a/tools/autotools/autogen.sh +++ b/tools/autotools/autogen.sh @@ -3,9 +3,13 @@ rm -rf autom4te.cache rm -f aclocal.m4 ltmain.sh -echo "Running aclocal..." ; aclocal $ACLOCAL_FLAGS -I m4 || exit 1 -echo "Running autoheader..." ; autoheader || exit 1 -echo "Running autoconf..." ; autoconf || exit 1 -echo "Running libtoolize..." ; (libtoolize --copy --automake || glibtoolize --automake) || exit 1 -echo "Running automake..." ; automake --add-missing --copy --gnu || exit 1 - +echo "Running aclocal..." +aclocal $ACLOCAL_FLAGS -I m4 || exit 1 +echo "Running autoheader..." +autoheader || exit 1 +echo "Running autoconf..." +autoconf || exit 1 +echo "Running libtoolize..." +(libtoolize --copy --automake || glibtoolize --automake) || exit 1 +echo "Running automake..." +automake --add-missing --copy --gnu || exit 1 diff --git a/tools/autotune_grid/generate_makefile.sh b/tools/autotune_grid/generate_makefile.sh index 21b1861861..e5bfcdb5fd 100755 --- a/tools/autotune_grid/generate_makefile.sh +++ b/tools/autotune_grid/generate_makefile.sh @@ -8,22 +8,19 @@ source config.in - - - ( -echo FC_comp=$FC_comp -echo FCFLAGS_OPT=$FCFLAGS_OPT -echo FCFLAGS_NATIVE=$FCFLAGS_NATIVE -echo FC_tune=\$\(FC_comp\) \$\(FCFLAGS_OPT\) -echo FC_native=\$\(FC_comp\) \$\(FCFLAGS_NATIVE\) + echo FC_comp=$FC_comp + echo FCFLAGS_OPT=$FCFLAGS_OPT + echo FCFLAGS_NATIVE=$FCFLAGS_NATIVE + echo FC_tune=\$\(FC_comp\) \$\(FCFLAGS_OPT\) + echo FC_native=\$\(FC_comp\) \$\(FCFLAGS_NATIVE\) ) > config.mk # Write a makefile to generate all different combinations ( -printf "########## DO NOT EDIT THIS FILE + printf "########## DO NOT EDIT THIS FILE include config.mk @@ -52,7 +49,8 @@ objfiles: \$(OBJ_FILES) libtest.a: objfiles \tar r libtest.a \$(OBJ_FILES) -" ) > $makefile_name +" +) > $makefile_name printf " include ../config.mk @@ -73,37 +71,37 @@ test.x: main.o qs_integrate_potential.o qs_collocate_density.o integrate_fast.o #7 ! generate up to l = l_max_a + l_max_b #1 ! use the best of three timings -Ncomb=$(( 2**$Nopt )) +Ncomb=$((2 ** $Nopt)) TARGETS_EXE="" TARGETS_RUN="" # For each value of l and iopt -for l in `seq 0 $lmax`; do -# First optimisation starts at ONE (all_options[0] is not initialised and generate does not produces valid code) -for iopt in `seq 1 $Ncomb`;do -TARGETS_EXE="gen_${l}_${iopt}.exists $TARGETS_EXE" -TARGETS_RUN="run_${l}_${iopt}_0.exists run_${l}_${iopt}_1.exists $TARGETS_RUN" -DIRECTORIES="out_${l}_${iopt} $TMPBASE/TMP_${l}_${iopt} $DIRECTORIES" +for l in $(seq 0 $lmax); do + # First optimisation starts at ONE (all_options[0] is not initialised and generate does not produces valid code) + for iopt in $(seq 1 $Ncomb); do + TARGETS_EXE="gen_${l}_${iopt}.exists $TARGETS_EXE" + TARGETS_RUN="run_${l}_${iopt}_0.exists run_${l}_${iopt}_1.exists $TARGETS_RUN" + DIRECTORIES="out_${l}_${iopt} $TMPBASE/TMP_${l}_${iopt} $DIRECTORIES" -icollo=1 -is_icollo_1="" -is_icollo_0="" + icollo=1 + is_icollo_1="" + is_icollo_0="" -if [[ $icollo -eq 1 ]]; then - is_icollo_1="echo -1;" -fi + if [[ $icollo -eq 1 ]]; then + is_icollo_1="echo -1;" + fi -if [[ $icollo -eq 0 ]]; then - is_icollo_0="echo -1;" -fi + if [[ $icollo -eq 0 ]]; then + is_icollo_0="echo -1;" + fi -# Makefile entries for this case -printf " + # Makefile entries for this case + printf " gen_${l}_${iopt}.exists: libtest.a generate.x \t-mkdir out_${l}_${iopt} -\t(${is_icollo_1} printf \"${l}\\\n\"; yes ${iopt} | head -n $((${l}+1)); ${is_icollo_0}) > generate_${l}_${iopt}.in +\t(${is_icollo_1} printf \"${l}\\\n\"; yes ${iopt} | head -n $((${l} + 1)); ${is_icollo_0}) > generate_${l}_${iopt}.in \t./generate.x < generate_${l}_${iopt}.in -\t(${is_icollo_0} printf \"${l}\\\n\"; yes ${iopt} | head -n $((${l}+1)); ${is_icollo_1}) > generate_${l}_${iopt}.in +\t(${is_icollo_0} printf \"${l}\\\n\"; yes ${iopt} | head -n $((${l} + 1)); ${is_icollo_1}) > generate_${l}_${iopt}.in \t./generate.x < generate_${l}_${iopt}.in \t-rm generate_${l}_${iopt}.in \tcp qs_collocate_density.F qs_integrate_potential.F main.F out_${l}_${iopt}/ @@ -114,13 +112,13 @@ gen_${l}_${iopt}.exists: libtest.a generate.x \ttouch gen_${l}_${iopt}.exists " >> $makefile_name -#printf """ -#gen_${l}_${iopt}: libtest.a -# -#""" >> /dev/null # $makefile_name #/dev/null + #printf """ + #gen_${l}_${iopt}: libtest.a + # + #""" >> /dev/null # $makefile_name #/dev/null -icollo=0 -printf " + icollo=0 + printf " run_${l}_${iopt}_${icollo}.exists: gen_${l}_${iopt}.exists \tprintf \" ${icollo}\\\\n T\\\\n ${l} 0 0 0\\\\n ${Nrun}\\\n\" > out_${l}_${iopt}/run_${l}_${iopt}_T_${icollo}.in \ttest -f out_${l}_${iopt}/out_test_${l}_${iopt}_T_${icollo} || ./out_${l}_${iopt}/test.x < out_${l}_${iopt}/run_${l}_${iopt}_T_${icollo}.in > out_${l}_${iopt}/out_test_${l}_${iopt}_T_${icollo} @@ -129,8 +127,8 @@ run_${l}_${iopt}_${icollo}.exists: gen_${l}_${iopt}.exists \ttouch run_${l}_${iopt}_${icollo}.exists " >> $makefile_name -icollo=1 -printf " + icollo=1 + printf " run_${l}_${iopt}_${icollo}.exists: run_${l}_${iopt}_0.exists \tprintf \" ${icollo}\\\\n T\\\\n ${l} 0 0 0\\\\n ${Nrun}\\\n\" > out_${l}_${iopt}/run_${l}_${iopt}_T_${icollo}.in \ttest -f out_${l}_${iopt}/out_test_${l}_${iopt}_T_${icollo} ||./out_${l}_${iopt}/test.x < out_${l}_${iopt}/run_${l}_${iopt}_T_${icollo}.in > out_${l}_${iopt}/out_test_${l}_${iopt}_T_${icollo} @@ -139,12 +137,12 @@ run_${l}_${iopt}_${icollo}.exists: run_${l}_${iopt}_0.exists \ttouch run_${l}_${iopt}_${icollo}.exists " >> $makefile_name + done -done done ( -printf " + printf " all: libgrid.a generate.x: @@ -174,5 +172,5 @@ libgrid.a: gen_best xyz_to_vab.o \tar r libgrid.a out_best/collocate_fast.o out_best/integrate_fast.o xyz_to_vab_optimised.o " - -) >> $makefile_name +) \ + >> $makefile_name diff --git a/tools/autotune_grid/get_results.sh b/tools/autotune_grid/get_results.sh index 563a4f3364..29a378cf1d 100755 --- a/tools/autotune_grid/get_results.sh +++ b/tools/autotune_grid/get_results.sh @@ -10,73 +10,72 @@ source config.in # Number of combinations with the existing options -Ncomb=$(( 2**$Nopt )) +Ncomb=$((2 ** $Nopt)) # Error tolerance err_tol="1.0E-10" # For both collocate (0) and integrate (1) for icollo in 0 1; do -echo "$icollo" -echo "l - Time - Best Opt" -echo "l Time Opt" > best_timings - for l in `seq 0 $lmax`; do - bsf=999999.0 -# First optimisation starts at ONE (all_options[0] is not initialised and generate does not produces valid code) - for iopt in `seq 1 $Ncomb`;do - # Extract the error - tmp=$(cat out_${l}_${iopt}/out_test_${l}_${iopt}_F_${icollo} | tr -s ' ' | grep "largest error" | cut -f 5 -d ' ') - test "$tmp" || continue - error=$(python -c "print $err_tol>$tmp") - # Skip if error is too big - if [[ $error == "False" ]]; then - # echo "($error) Error $tmp was too big for $iopt" - continue - fi - # echo "($error) Error was $tmp , accepted $iopt" - # Extract the time of the combination - tmp=$(cat out_${l}_${iopt}/out_test_${l}_${iopt}_T_${icollo} | tr -s ' ' | grep "best time" | cut -f 5 -d ' ') + echo "$icollo" + echo "l - Time - Best Opt" + echo "l Time Opt" > best_timings + for l in $(seq 0 $lmax); do + bsf=999999.0 + # First optimisation starts at ONE (all_options[0] is not initialised and generate does not produces valid code) + for iopt in $(seq 1 $Ncomb); do + # Extract the error + tmp=$(cat out_${l}_${iopt}/out_test_${l}_${iopt}_F_${icollo} | tr -s ' ' | grep "largest error" | cut -f 5 -d ' ') + test "$tmp" || continue + error=$(python -c "print $err_tol>$tmp") + # Skip if error is too big + if [[ $error == "False" ]]; then + # echo "($error) Error $tmp was too big for $iopt" + continue + fi + # echo "($error) Error was $tmp , accepted $iopt" + # Extract the time of the combination + tmp=$(cat out_${l}_${iopt}/out_test_${l}_${iopt}_T_${icollo} | tr -s ' ' | grep "best time" | cut -f 5 -d ' ') - test "$tmp" || continue - dif=$(python -c "print $bsf>$tmp") + test "$tmp" || continue + dif=$(python -c "print $bsf>$tmp") - if [[ $dif == "True" ]]; then - # echo " New bsf is $tmp from $bsf " - bsf=$tmp - bsf_iopt=$iopt - #else - # echo " $bsf is lower than $tmp ($dif, print $bsf>$tmp)" - fi - done # for iopt + if [[ $dif == "True" ]]; then + # echo " New bsf is $tmp from $bsf " + bsf=$tmp + bsf_iopt=$iopt + #else + # echo " $bsf is lower than $tmp ($dif, print $bsf>$tmp)" + fi + done # for iopt - bsf_global[$l]=$bsf - bsf_iopt_global[$l]=$bsf_iopt + bsf_global[$l]=$bsf + bsf_iopt_global[$l]=$bsf_iopt - echo $l -- ${bsf_global[$l]} -- ${bsf_iopt_global[$l]} - echo $l ${bsf_global[$l]} ${bsf_iopt_global[$l]} >> best_timings + echo $l -- ${bsf_global[$l]} -- ${bsf_iopt_global[$l]} + echo $l ${bsf_global[$l]} ${bsf_iopt_global[$l]} >> best_timings - done # for l + done # for l -if [[ $icollo -eq 0 ]]; then - bsf_global_0=("${bsf_global[@]}") - bsf_iopt_global_0=("${bsf_iopt_global[@]}") -else - bsf_global_1=("${bsf_global[@]}") - bsf_iopt_global_1=("${bsf_iopt_global[@]}") -fi + if [[ $icollo -eq 0 ]]; then + bsf_global_0=("${bsf_global[@]}") + bsf_iopt_global_0=("${bsf_iopt_global[@]}") + else + bsf_global_1=("${bsf_global[@]}") + bsf_iopt_global_1=("${bsf_iopt_global[@]}") + fi done # for icollo # Generate the input file for generate.x with the optimal combinations for each problem size echo " Generating optimal combination " ( - echo $lmax - for l in `seq 0 $lmax`; do - echo ${bsf_iopt_global_0[$l]} - done - echo $lmax - for l in `seq 0 $lmax`; do - echo ${bsf_iopt_global_1[$l]} - done + echo $lmax + for l in $(seq 0 $lmax); do + echo ${bsf_iopt_global_0[$l]} + done + echo $lmax + for l in $(seq 0 $lmax); do + echo ${bsf_iopt_global_1[$l]} + done ) > generate_best - diff --git a/tools/conventions/test_conventions.sh b/tools/conventions/test_conventions.sh index 8a8ef8be20..3e2b769663 100755 --- a/tools/conventions/test_conventions.sh +++ b/tools/conventions/test_conventions.sh @@ -13,24 +13,24 @@ date --utc --rfc-3339=seconds set -e # abort if error is encountered cd ../../ make -j ARCH=Linux-x86-64-gfortran VERSION="dumpast" > make_conventions1.out - make -j ARCH=local_warn VERSION="psmp" > make_conventions2.out + make -j ARCH=local_warn VERSION="psmp" > make_conventions2.out ) MAKE_EXIT_CODE=$? -if (( $MAKE_EXIT_CODE )); then - cd ../../obj/local_warn/psmp/ - echo "" - grep -B 2 Error *.warn - echo "" - echo "Summary: Compilation failed." - echo "Status: FAILED" +if (($MAKE_EXIT_CODE)); then + cd ../../obj/local_warn/psmp/ + echo "" + grep -B 2 Error *.warn + echo "" + echo "Summary: Compilation failed." + echo "Status: FAILED" else - rm -f *.issues + rm -f *.issues - set -o errexit + set -o errexit - ./analyze_gfortran_ast.py ../../obj/Linux-x86-64-gfortran/dumpast/*.ast > ast.issues - ./analyze_gfortran_warnings.py ../../obj/local_warn/psmp/*.warn > warn.issues - ./analyze_src.py -b ../../ > src.issues - ./summarize_issues.py --suppressions=conventions.supp *.issues + ./analyze_gfortran_ast.py ../../obj/Linux-x86-64-gfortran/dumpast/*.ast > ast.issues + ./analyze_gfortran_warnings.py ../../obj/local_warn/psmp/*.warn > warn.issues + ./analyze_src.py -b ../../ > src.issues + ./summarize_issues.py --suppressions=conventions.supp *.issues fi diff --git a/tools/docker/build_test.sh b/tools/docker/build_test.sh index f662d373e4..85788a1443 100755 --- a/tools/docker/build_test.sh +++ b/tools/docker/build_test.sh @@ -2,10 +2,10 @@ # author: Ole Schuett -if (( $# < 1 )); then - echo "usage: build_test.sh [additional-args]" - echo "example: build_test.sh python" - exit 1 +if (($# < 1)); then + echo "usage: build_test.sh [additional-args]" + echo "example: build_test.sh python" + exit 1 fi set -e diff --git a/tools/docker/run_test.sh b/tools/docker/run_test.sh index fb51c6a547..cb06067a9a 100755 --- a/tools/docker/run_test.sh +++ b/tools/docker/run_test.sh @@ -2,10 +2,10 @@ # author: Ole Schuett -if (( $# < 1 )); then - echo "usage: run_test.sh [additional-docker-run-args]" - echo "example: run_test.sh python" - exit 1 +if (($# < 1)); then + echo "usage: run_test.sh [additional-docker-run-args]" + echo "example: run_test.sh python" + exit 1 fi set -e diff --git a/tools/docker/run_test_master.sh b/tools/docker/run_test_master.sh index 8203a24125..60851b019d 100755 --- a/tools/docker/run_test_master.sh +++ b/tools/docker/run_test_master.sh @@ -2,10 +2,10 @@ # author: Ole Schuett -if (( $# < 1 )); then - echo "usage: run_test_master.sh [additional-docker-run-args]" - echo "example: run_test_master.sh python" - exit 1 +if (($# < 1)); then + echo "usage: run_test_master.sh [additional-docker-run-args]" + echo "example: run_test_master.sh python" + exit 1 fi set -e @@ -23,5 +23,4 @@ ${DOCKER:-docker} run -i --init --rm --cap-add=SYS_PTRACE \ -e "GIT_BRANCH=${GIT_BRANCH}" -e "GIT_REF=${GIT_REF}" \ "$@" "img_cp2k_test_${TESTNAME}" - #EOF diff --git a/tools/docker/run_test_pr.sh b/tools/docker/run_test_pr.sh index 8461910235..c425f165b0 100755 --- a/tools/docker/run_test_pr.sh +++ b/tools/docker/run_test_pr.sh @@ -7,9 +7,9 @@ set -o nounset set -o pipefail if [[ $# -lt 2 ]]; then - echo "usage: $0 [optional-docker-run-arguments]" - echo "example: $0 python 506" - exit 1 + echo "usage: $0 [optional-docker-run-arguments]" + echo "example: $0 python 506" + exit 1 fi TESTNAME=$1 @@ -17,7 +17,7 @@ PR_NUMBER=$2 shift 2 GIT_BRANCH="pull/${PR_NUMBER}/merge" -GIT_REF=$(curl -s "https://api.github.com/repos/cp2k/cp2k/pulls/${PR_NUMBER}" | jq -r '.merge_commit_sha') +GIT_REF=$(curl -s "https://api.github.com/repos/cp2k/cp2k/pulls/${PR_NUMBER}" | jq -r '.merge_commit_sha') echo "Running ${TESTNAME} on Branch ${GIT_BRANCH} (ref: ${GIT_REF})..." @@ -25,7 +25,7 @@ set -o xtrace # SYS_PTRACE needed by LeakSanitizer. ${DOCKER:-docker} run -i --init --rm --cap-add=SYS_PTRACE \ - -e "GIT_BRANCH=${GIT_BRANCH}" -e "GIT_REF=${GIT_REF}" \ - "$@" "img_cp2k_test_${TESTNAME}" + -e "GIT_BRANCH=${GIT_BRANCH}" -e "GIT_REF=${GIT_REF}" \ + "$@" "img_cp2k_test_${TESTNAME}" #EOF diff --git a/tools/docker/scripts/ci_entrypoint.sh b/tools/docker/scripts/ci_entrypoint.sh index 054815b61f..599083e8df 100755 --- a/tools/docker/scripts/ci_entrypoint.sh +++ b/tools/docker/scripts/ci_entrypoint.sh @@ -3,63 +3,63 @@ # author: Ole Schuett set -eo pipefail -ulimit -c 0 # Disable core dumps as they can take a very long time to write. +ulimit -c 0 # Disable core dumps as they can take a very long time to write. # Calculate checksums of critical files. CHECKSUMS=/workspace/checksums.md5 -shopt -s nullglob # ignore missing files +shopt -s nullglob # ignore missing files md5sum /workspace/cp2k/Makefile \ - /workspace/cp2k/tools/build_utils/* \ - /workspace/cp2k/arch/local* \ - > $CHECKSUMS + /workspace/cp2k/tools/build_utils/* \ + /workspace/cp2k/arch/local* \ + > $CHECKSUMS shopt -u nullglob # Get cp2k sources. if [ -n "${GIT_REF}" ]; then - echo -e "\n========== Fetching Git Commit ==========" - cd /workspace/cp2k - git fetch --quiet origin "${GIT_BRANCH}" - git reset --quiet --hard "${GIT_REF}" - git submodule update --init --recursive - git --no-pager log -1 --pretty='%nCommitSHA: %H%nCommitTime: %ci%nCommitAuthor: %an%nCommitSubject: %s%n' + echo -e "\n========== Fetching Git Commit ==========" + cd /workspace/cp2k + git fetch --quiet origin "${GIT_BRANCH}" + git reset --quiet --hard "${GIT_REF}" + git submodule update --init --recursive + git --no-pager log -1 --pretty='%nCommitSHA: %H%nCommitTime: %ci%nCommitAuthor: %an%nCommitSubject: %s%n' -elif [ -d /mnt/cp2k ]; then - echo -e "\n========== Copying Changed Files ==========" - # We can't rely on timestamps as they depend on the git checkout time. - # Hence, we use checksums despite the IO because a full rebuild would be even more costly. - rsync --checksum \ - --delete \ - --executability \ - --verbose \ - --recursive \ - --exclude="*~" \ - --exclude=".*/" \ - --exclude="*.py[cod]" \ - --exclude="__pycache__" \ - --exclude="/obj/" \ - --exclude="/lib/" \ - --exclude="/exe/" \ - --exclude="/regtesting/" \ - --exclude="/arch/local*" \ - --exclude="/tools/toolchain/build/" \ - --exclude="/tools/toolchain/install/" \ - /mnt/cp2k/ /workspace/cp2k/ +elif [ -d /mnt/cp2k ]; then + echo -e "\n========== Copying Changed Files ==========" + # We can't rely on timestamps as they depend on the git checkout time. + # Hence, we use checksums despite the IO because a full rebuild would be even more costly. + rsync --checksum \ + --delete \ + --executability \ + --verbose \ + --recursive \ + --exclude="*~" \ + --exclude=".*/" \ + --exclude="*.py[cod]" \ + --exclude="__pycache__" \ + --exclude="/obj/" \ + --exclude="/lib/" \ + --exclude="/exe/" \ + --exclude="/regtesting/" \ + --exclude="/arch/local*" \ + --exclude="/tools/toolchain/build/" \ + --exclude="/tools/toolchain/install/" \ + /mnt/cp2k/ /workspace/cp2k/ else - echo "Neither GIT_REF nor /mnt/cp2k found - aborting." - exit 255 + echo "Neither GIT_REF nor /mnt/cp2k found - aborting." + exit 255 fi if ! md5sum --status --check ${CHECKSUMS}; then - echo -e "\n========== Cleaning Build Cache ==========" - cd /workspace/cp2k - make distclean + echo -e "\n========== Cleaning Build Cache ==========" + cd /workspace/cp2k + make distclean fi # Run actual test. echo -e "\n========== Running Test ==========" cd /workspace -if ! "$@" ; then - echo -e "\nSummary: Test had non-zero exit status.\nStatus: FAILED" +if ! "$@"; then + echo -e "\nSummary: Test had non-zero exit status.\nStatus: FAILED" fi #EOF diff --git a/tools/docker/scripts/install_aiida.sh b/tools/docker/scripts/install_aiida.sh index bad4a6db78..32618d3fef 100755 --- a/tools/docker/scripts/install_aiida.sh +++ b/tools/docker/scripts/install_aiida.sh @@ -7,14 +7,14 @@ apt-get update -qq export DEBIAN_FRONTEND=noninteractive export DEBCONF_NONINTERACTIVE_SEEN=true apt-get install -qq --no-install-recommends \ - python3-setuptools \ - python3-wheel \ - python3-pip \ - python3-dev \ - postgresql \ - rabbitmq-server \ - sudo \ - ssh + python3-setuptools \ + python3-wheel \ + python3-pip \ + python3-dev \ + postgresql \ + rabbitmq-server \ + sudo \ + ssh rm -rf /var/lib/apt/lists/* # install dependencies of aiida-cp2k @@ -25,14 +25,14 @@ pip3 uninstall --quiet --yes aiida-cp2k # create ubuntu user with sudo powers adduser --disabled-password --gecos "" ubuntu -echo "ubuntu ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers +echo "ubuntu ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers # shellcheck disable=SC1091 source /opt/cp2k-toolchain/install/setup # link mpi executables into path MPI_INSTALL_DIR=$(dirname "$(command -v mpirun)") -for i in "${MPI_INSTALL_DIR}"/* ; do ln -sf "$i" /usr/bin/; done +for i in "${MPI_INSTALL_DIR}"/*; do ln -sf "$i" /usr/bin/; done # setup arch files cd /workspace/cp2k/arch @@ -41,10 +41,10 @@ ln -vs /opt/cp2k-toolchain/install/arch/local* . # pre-build cp2k cd /workspace/cp2k echo -n "Warming cache by trying to compile... " -if make -j VERSION=pdbg &> /dev/null ; then - echo "done." +if make -j VERSION=pdbg &> /dev/null; then + echo "done." else - echo "failed." + echo "failed." fi rm -rf lib exe diff --git a/tools/docker/scripts/install_ase.sh b/tools/docker/scripts/install_ase.sh index c3dc52f6a5..c29c040dfb 100755 --- a/tools/docker/scripts/install_ase.sh +++ b/tools/docker/scripts/install_ase.sh @@ -5,12 +5,12 @@ # install python packages apt-get update -qq apt-get install -qq --no-install-recommends \ - python3 \ - python3-dev \ - python3-pip \ - python3-wheel \ - python3-setuptools \ - build-essential + python3 \ + python3-dev \ + python3-pip \ + python3-wheel \ + python3-setuptools \ + build-essential rm -rf /var/lib/apt/lists/* # install python packages @@ -29,10 +29,10 @@ ln -vs /opt/cp2k-toolchain/install/arch/local* . # pre-build cp2k cd /workspace/cp2k echo -n "Warming cache by trying to compile... " -if make -j VERSION=pdbg &> /dev/null ; then - echo "done." +if make -j VERSION=pdbg &> /dev/null; then + echo "done." else - echo "failed." + echo "failed." fi rm -rf lib exe diff --git a/tools/docker/scripts/install_basics.sh b/tools/docker/scripts/install_basics.sh index 5c8bc7b6b2..c6f43ea5d6 100755 --- a/tools/docker/scripts/install_basics.sh +++ b/tools/docker/scripts/install_basics.sh @@ -2,36 +2,36 @@ # author: Ole Schuett -if grep -q -e "Ubuntu" -e "Debian" /etc/os-release ; then - echo -n "Installing Ubuntu packages... " - apt-get update -qq - apt-get install -qq --no-install-recommends \ - ca-certificates \ - git \ - less \ - nano \ - python3 \ - rsync \ - wget - rm -rf /var/lib/apt/lists/* - echo "done." +if grep -q -e "Ubuntu" -e "Debian" /etc/os-release; then + echo -n "Installing Ubuntu packages... " + apt-get update -qq + apt-get install -qq --no-install-recommends \ + ca-certificates \ + git \ + less \ + nano \ + python3 \ + rsync \ + wget + rm -rf /var/lib/apt/lists/* + echo "done." -elif grep -q "Fedora" /etc/os-release ; then - echo -n "Installing Fedora packages... " - dnf -qy install \ - ca-certificates \ - git \ - less \ - nano \ - python3 \ - rsync \ - wget - dnf -q clean all - echo "done." +elif grep -q "Fedora" /etc/os-release; then + echo -n "Installing Fedora packages... " + dnf -qy install \ + ca-certificates \ + git \ + less \ + nano \ + python3 \ + rsync \ + wget + dnf -q clean all + echo "done." else - echo "Unknown Linux distribution." - exit 1 + echo "Unknown Linux distribution." + exit 1 fi diff --git a/tools/docker/scripts/install_conventions.sh b/tools/docker/scripts/install_conventions.sh index 8dc24ccac4..aeb56ca4f7 100755 --- a/tools/docker/scripts/install_conventions.sh +++ b/tools/docker/scripts/install_conventions.sh @@ -12,10 +12,10 @@ ln -vs /opt/cp2k-toolchain/install/arch/local* . # pre-build cp2k cd /workspace/cp2k/tools/conventions echo -n "Warming cache by trying to run test_conventions.sh... " -if ./test_conventions.sh &> /dev/null ; then - echo "done." +if ./test_conventions.sh &> /dev/null; then + echo "done." else - echo "failed." + echo "failed." fi rm -rf ../lib/ ../exe/ diff --git a/tools/docker/scripts/install_coverage.sh b/tools/docker/scripts/install_coverage.sh index 2e113a2692..792bbf6ae5 100755 --- a/tools/docker/scripts/install_coverage.sh +++ b/tools/docker/scripts/install_coverage.sh @@ -8,8 +8,8 @@ lcov_sha256="c1cda2fa33bec9aa2c2c73c87226cfe97de0831887176b45ee523c5e30f8053a" # LCOV dependencies apt-get update -qq apt-get install -qq --no-install-recommends \ - libperlio-gzip-perl \ - libjson-perl + libperlio-gzip-perl \ + libjson-perl rm -rf /var/lib/apt/lists/* cd /tmp diff --git a/tools/docker/scripts/install_formatting.sh b/tools/docker/scripts/install_formatting.sh index fb0fc69880..66c33ee616 100755 --- a/tools/docker/scripts/install_formatting.sh +++ b/tools/docker/scripts/install_formatting.sh @@ -5,13 +5,13 @@ # install Ubuntu packages apt-get update -qq apt-get install -qq --no-install-recommends \ - libfindbin-libs-perl \ - build-essential \ - make \ - perl \ - python3-{pip,setuptools,wheel,dev} \ - nodejs \ - clang-format + libfindbin-libs-perl \ + build-essential \ + make \ + perl \ + python3-{pip,setuptools,wheel,dev} \ + nodejs \ + clang-format rm -rf /var/lib/apt/lists/* diff --git a/tools/docker/scripts/install_i-pi.sh b/tools/docker/scripts/install_i-pi.sh index b264e879b0..38261f5552 100755 --- a/tools/docker/scripts/install_i-pi.sh +++ b/tools/docker/scripts/install_i-pi.sh @@ -5,10 +5,10 @@ # install Ubuntu packages apt-get update -qq apt-get install -qq --no-install-recommends \ - python3 \ - python3-pip \ - python3-wheel \ - python3-setuptools + python3 \ + python3-pip \ + python3-wheel \ + python3-setuptools rm -rf /var/lib/apt/lists/* # install python packages @@ -27,10 +27,10 @@ ln -vs /opt/cp2k-toolchain/install/arch/local* . # pre-build cp2k cd /workspace/cp2k echo -n "Warming cache by trying to compile... " -if make -j VERSION=pdbg &> /dev/null ; then - echo "done." +if make -j VERSION=pdbg &> /dev/null; then + echo "done." else - echo "failed." + echo "failed." fi rm -rf lib exe diff --git a/tools/docker/scripts/install_manual.sh b/tools/docker/scripts/install_manual.sh index bdbde6ec0c..9533f5d38d 100755 --- a/tools/docker/scripts/install_manual.sh +++ b/tools/docker/scripts/install_manual.sh @@ -4,9 +4,9 @@ # install Ubuntu packages apt-get update -qq -apt-get install -qq --no-install-recommends \ - default-jre-headless \ - libsaxonhe-java +apt-get install -qq --no-install-recommends \ + default-jre-headless \ + libsaxonhe-java rm -rf /var/lib/apt/lists/* # shellcheck disable=SC1091 @@ -19,10 +19,10 @@ ln -vs /opt/cp2k-toolchain/install/arch/local* . # pre-build cp2k cd /workspace/cp2k echo -n "Warming cache by trying to compile... " -if make -j VERSION=psmp &> /dev/null ; then - echo "done." +if make -j VERSION=psmp &> /dev/null; then + echo "done." else - echo "failed." + echo "failed." fi rm -rf lib exe diff --git a/tools/docker/scripts/install_python.sh b/tools/docker/scripts/install_python.sh index e04ac90e4f..68a5bd98f0 100755 --- a/tools/docker/scripts/install_python.sh +++ b/tools/docker/scripts/install_python.sh @@ -5,13 +5,13 @@ # install Ubuntu packages apt-get update -qq apt-get install -qq --no-install-recommends \ - libpython3-stdlib \ - python3 \ - python3-pip \ - python3-wheel \ - python3-setuptools \ - python3-dev \ - build-essential + libpython3-stdlib \ + python3 \ + python3-pip \ + python3-wheel \ + python3-setuptools \ + python3-dev \ + build-essential rm -rf /var/lib/apt/lists/* # install python packages diff --git a/tools/docker/scripts/install_regtest.sh b/tools/docker/scripts/install_regtest.sh index bc770801ae..12cd3ead09 100755 --- a/tools/docker/scripts/install_regtest.sh +++ b/tools/docker/scripts/install_regtest.sh @@ -2,9 +2,9 @@ # author: Ole Schuett -if (( $# != 2 )) ; then - echo "Usage: install_regtest.sh " - exit 1 +if (($# != 2)); then + echo "Usage: install_regtest.sh " + exit 1 fi ARCH=$1 @@ -18,18 +18,18 @@ ln -vs /opt/cp2k-toolchain/install/arch/local* . source /opt/cp2k-toolchain/install/setup # Make OpenMPI happy. -if command -v ompi_info &> /dev/null ; then - TESTOPTS="-mpiexec 'mpiexec --bind-to none --allow-run-as-root' ${TESTOPTS}" - export OMPI_MCA_plm_rsh_agent=/bin/false +if command -v ompi_info &> /dev/null; then + TESTOPTS="-mpiexec 'mpiexec --bind-to none --allow-run-as-root' ${TESTOPTS}" + export OMPI_MCA_plm_rsh_agent=/bin/false fi # pre-build cp2k cd /workspace/cp2k || exit 1 echo -n "Warming cache by trying to compile... " -if make -j ARCH="${ARCH}" VERSION="${VERSION}" &> /dev/null ; then - echo "done." +if make -j ARCH="${ARCH}" VERSION="${VERSION}" &> /dev/null; then + echo "done." else - echo "failed." + echo "failed." fi # remove binaries to reduce image size diff --git a/tools/docker/scripts/install_scaling.sh b/tools/docker/scripts/install_scaling.sh index 71712a2902..46dc7550c6 100755 --- a/tools/docker/scripts/install_scaling.sh +++ b/tools/docker/scripts/install_scaling.sh @@ -17,12 +17,12 @@ source /opt/cp2k-toolchain/install/setup # pre-build cp2k cd /workspace/cp2k for VERSION in 'psmp' 'ssmp'; do - echo -n "Warming cache by trying to compile cp2k.${VERSION}... " - if make -j VERSION="${VERSION}" &> /dev/null ; then - echo 'done.' - else - echo 'failed.' - fi + echo -n "Warming cache by trying to compile cp2k.${VERSION}... " + if make -j VERSION="${VERSION}" &> /dev/null; then + echo 'done.' + else + echo 'failed.' + fi done rm -rf lib exe diff --git a/tools/docker/scripts/test_aiida.sh b/tools/docker/scripts/test_aiida.sh index 77c743f1bc..98f2a55981 100755 --- a/tools/docker/scripts/test_aiida.sh +++ b/tools/docker/scripts/test_aiida.sh @@ -8,14 +8,14 @@ source /opt/cp2k-toolchain/install/setup echo -e "\n========== Compiling CP2K ==========" cd /workspace/cp2k echo -n "Compiling cp2k... " -if make -j VERSION=pdbg &> make.out ; then - echo "done." +if make -j VERSION=pdbg &> make.out; then + echo "done." else - echo -e "failed.\n\n" - tail -n 100 make.out - echo -e "\nSummary: Compilation failed." - echo -e "Status: FAILED\n" - exit 0 + echo -e "failed.\n\n" + tail -n 100 make.out + echo -e "\nSummary: Compilation failed." + echo -e "Status: FAILED\n" + exit 0 fi echo -e "\n========== Installing AiiDA-CP2K plugin ==========" @@ -44,13 +44,13 @@ EndOfMessage chmod +x /usr/bin/cp2k echo -e "\n========== Running AiiDA-CP2K Tests ==========" -cd /opt/aiida-cp2k/ +cd /opt/aiida-cp2k/ set +e # disable error trapping for remainder of script ( -set -e # abort on error -ulimit -t 1800 # abort after 30 minutes -$AS_UBUNTU_USER py.test + set -e # abort on error + ulimit -t 1800 # abort after 30 minutes + $AS_UBUNTU_USER py.test ) EXIT_CODE=$? @@ -58,12 +58,12 @@ EXIT_CODE=$? echo "" AIIDA_COMMIT=$(git rev-parse --short HEAD) -if (( EXIT_CODE )); then - echo "Summary: Something is wrong with aiida-cp2k commit ${AIIDA_COMMIT}." - echo "Status: FAILED" +if ((EXIT_CODE)); then + echo "Summary: Something is wrong with aiida-cp2k commit ${AIIDA_COMMIT}." + echo "Status: FAILED" else - echo "Summary: aiida-cp2k commit ${AIIDA_COMMIT} works fine." - echo "Status: OK" + echo "Summary: aiida-cp2k commit ${AIIDA_COMMIT} works fine." + echo "Status: OK" fi #EOF diff --git a/tools/docker/scripts/test_ase.sh b/tools/docker/scripts/test_ase.sh index 51f8aa86a9..d3e43a2dcf 100755 --- a/tools/docker/scripts/test_ase.sh +++ b/tools/docker/scripts/test_ase.sh @@ -7,14 +7,14 @@ source /opt/cp2k-toolchain/install/setup cd /workspace/cp2k echo -n "Compiling cp2k... " -if make -j VERSION=pdbg &> make.out ; then - echo "done." +if make -j VERSION=pdbg &> make.out; then + echo "done." else - echo -e "failed.\n\n" - tail -n 100 make.out - echo -e "\nSummary: Compilation failed." - echo -e "Status: FAILED\n" - exit 0 + echo -e "failed.\n\n" + tail -n 100 make.out + echo -e "\nSummary: Compilation failed." + echo -e "Status: FAILED\n" + exit 0 fi echo -e "\n========== Installing CP2K ==========" @@ -48,12 +48,12 @@ echo -e "\n========== Running ASE Tests ==========" cd /opt/ase/ ASE_REVISION=$(git rev-parse --short HEAD) -if ase test -j 0 -c cp2k calculator/cp2k ; then - echo "Summary: ASE commit ${ASE_REVISION} works fine." - echo "Status: OK" +if ase test -j 0 -c cp2k calculator/cp2k; then + echo "Summary: ASE commit ${ASE_REVISION} works fine." + echo "Status: OK" else - echo "Summary: Something is wrong with ASE commit ${ASE_REVISION}." - echo "Status: FAILED" + echo "Summary: Something is wrong with ASE commit ${ASE_REVISION}." + echo "Status: FAILED" fi #EOF diff --git a/tools/docker/scripts/test_conventions.sh b/tools/docker/scripts/test_conventions.sh index 2db9b87fdd..8aea9fed8a 100755 --- a/tools/docker/scripts/test_conventions.sh +++ b/tools/docker/scripts/test_conventions.sh @@ -7,6 +7,6 @@ source /opt/cp2k-toolchain/install/setup echo -e "\n========== Running Conventions Test ==========" cd /workspace/cp2k/tools/conventions -./test_conventions.sh #TODO port to Python3 +./test_conventions.sh #TODO port to Python3 #EOF diff --git a/tools/docker/scripts/test_coverage.sh b/tools/docker/scripts/test_coverage.sh index 43917ad3b5..0126e6399f 100755 --- a/tools/docker/scripts/test_coverage.sh +++ b/tools/docker/scripts/test_coverage.sh @@ -2,9 +2,9 @@ # author: Ole Schuett -if (( $# != 1 )) ; then - echo "Usage: test_coverage.sh " - exit 1 +if (($# != 1)); then + echo "Usage: test_coverage.sh " + exit 1 fi ARCH=local_coverage @@ -16,7 +16,7 @@ source /opt/cp2k-toolchain/install/setup echo -e "\n========== Running Regtests ==========" cd /workspace/cp2k || exit 1 CP2K_REVISION=$(./tools/build_utils/get_revision_number ./src) -rm -rf "obj/${ARCH}/${VERSION}"/*.gcda # remove old gcov statistics +rm -rf "obj/${ARCH}/${VERSION}"/*.gcda # remove old gcov statistics make ARCH="${ARCH}" VERSION="${VERSION}" TESTOPTS="${TESTOPTS}" test @@ -26,11 +26,11 @@ make ARCH="${ARCH}" VERSION="${VERSION}" TESTOPTS="${TESTOPTS}" test rm -f "/workspace/cp2k/obj/${ARCH}/${VERSION}"/exts/*/*.gcda cd /tmp || exit 1 GCOV_TIMEOUT="10s" -for fn in "/workspace/cp2k/obj/${ARCH}/${VERSION}"/*.gcda ; do - if ! timeout "${GCOV_TIMEOUT}" gcov "$fn" &> /dev/null ; then - echo "Skipping ${fn} because gcov took longer than ${GCOV_TIMEOUT}." - rm "${fn}" - fi +for fn in "/workspace/cp2k/obj/${ARCH}/${VERSION}"/*.gcda; do + if ! timeout "${GCOV_TIMEOUT}" gcov "$fn" &> /dev/null; then + echo "Skipping ${fn} because gcov took longer than ${GCOV_TIMEOUT}." + rm "${fn}" + fi done # collect coverage stats diff --git a/tools/docker/scripts/test_doxygen.sh b/tools/docker/scripts/test_doxygen.sh index d23459022b..3f5c844993 100755 --- a/tools/docker/scripts/test_doxygen.sh +++ b/tools/docker/scripts/test_doxygen.sh @@ -4,12 +4,12 @@ echo -e "\n========== Generating Doxygen ==========" cd /workspace/cp2k -if ! make doxygen &> make.out ; then - echo -e "failed.\n\n" - tail -n 100 make.out - echo -e "\nSummary: Doxygen generation failed." - echo -e "Status: FAILED\n" - exit 0 +if ! make doxygen &> make.out; then + echo -e "failed.\n\n" + tail -n 100 make.out + echo -e "\nSummary: Doxygen generation failed." + echo -e "Status: FAILED\n" + exit 0 fi mkdir -p /workspace/artifacts diff --git a/tools/docker/scripts/test_i-pi.sh b/tools/docker/scripts/test_i-pi.sh index b136e515a8..b533e82315 100755 --- a/tools/docker/scripts/test_i-pi.sh +++ b/tools/docker/scripts/test_i-pi.sh @@ -8,14 +8,14 @@ source /opt/cp2k-toolchain/install/setup echo -e "\n========== Compiling CP2K ==========" cd /workspace/cp2k echo -n "Compiling cp2k... " -if make -j VERSION=pdbg &> make.out ; then - echo "done." +if make -j VERSION=pdbg &> make.out; then + echo "done." else - echo -e "failed.\n\n" - tail -n 100 make.out - echo -e "\nSummary: Compilation failed." - echo -e "Status: FAILED\n" - exit 0 + echo -e "failed.\n\n" + tail -n 100 make.out + echo -e "\nSummary: Compilation failed." + echo -e "Status: FAILED\n" + exit 0 fi echo -e "\n========== Installing i-Pi ==========" @@ -25,11 +25,11 @@ pip3 install --quiet . echo -e "\n========== Running i-Pi Tests ==========" -cd /opt/i-pi/examples/cp2k/nvt-cl +cd /opt/i-pi/examples/cp2k/nvt-cl set +e # disable error trapping for remainder of script TIMEOUT_SEC="300" -ulimit -t ${TIMEOUT_SEC} # Limit cpu time. +ulimit -t ${TIMEOUT_SEC} # Limit cpu time. # launch cp2k ( @@ -56,12 +56,12 @@ echo "CP2K exit code: ${CP2K_EXIT_CODE}" echo "i-Pi exit code: ${IPI_EXIT_CODE}" IPI_REVISION=$(git rev-parse --short HEAD) -if (( IPI_EXIT_CODE )) || (( CP2K_EXIT_CODE )) ; then - echo "Summary: Something is wrong with i-Pi commit ${IPI_REVISION}." - echo "Status: FAILED" +if ((IPI_EXIT_CODE)) || ((CP2K_EXIT_CODE)); then + echo "Summary: Something is wrong with i-Pi commit ${IPI_REVISION}." + echo "Status: FAILED" else - echo "Summary: i-Pi commit ${IPI_REVISION} works fine." - echo "Status: OK" + echo "Summary: i-Pi commit ${IPI_REVISION} works fine." + echo "Status: OK" fi #EOF diff --git a/tools/docker/scripts/test_manual.sh b/tools/docker/scripts/test_manual.sh index 8000e918bd..e26f07d702 100755 --- a/tools/docker/scripts/test_manual.sh +++ b/tools/docker/scripts/test_manual.sh @@ -7,16 +7,16 @@ source /opt/cp2k-toolchain/install/setup echo -e "\n========== Compiling CP2K ==========" cd /workspace/cp2k -touch src/cp2k_info.F # ensure latest REVISION is picked up. +touch src/cp2k_info.F # ensure latest REVISION is picked up. echo -n "Compiling cp2k... " -if make -j VERSION=psmp &> make.out ; then - echo "done." +if make -j VERSION=psmp &> make.out; then + echo "done." else - echo -e "failed.\n\n" - tail -n 100 make.out - echo -e "\nSummary: Compilation failed." - echo -e "Status: FAILED\n" - exit 0 + echo -e "failed.\n\n" + tail -n 100 make.out + echo -e "\nSummary: Compilation failed." + echo -e "Status: FAILED\n" + exit 0 fi echo -e "\n========== Generating Manual ==========" @@ -33,21 +33,21 @@ cp ${TOOLS}/manual/toggle_folding.js . set +e # disable error trapping for remainder of script ( -set -e # abort if error is encountered -sed -i 's/\x0/?/g' cp2k_input.xml # replace null bytes which would crash saxon -SAXON="java -jar /usr/share/java/Saxon-HE.jar" -$SAXON -o:index.html ./cp2k_input.xml ${TOOLS}/manual/cp2k_input.xsl add_edit_links=yes -$SAXON -o:cp2k.vim ./cp2k_input.xml ${TOOLS}/input_editing/vim/vim.xsl + set -e # abort if error is encountered + sed -i 's/\x0/?/g' cp2k_input.xml # replace null bytes which would crash saxon + SAXON="java -jar /usr/share/java/Saxon-HE.jar" + $SAXON -o:index.html ./cp2k_input.xml ${TOOLS}/manual/cp2k_input.xsl add_edit_links=yes + $SAXON -o:cp2k.vim ./cp2k_input.xml ${TOOLS}/input_editing/vim/vim.xsl ) EXIT_CODE=$? echo "" -if (( EXIT_CODE )); then - echo "Summary: Something is wrong." - echo "Status: FAILED" +if ((EXIT_CODE)); then + echo "Summary: Something is wrong." + echo "Status: FAILED" else - echo "Summary: Manual generation works fine." - echo "Status: OK" + echo "Summary: Manual generation works fine." + echo "Status: OK" fi #EOF diff --git a/tools/docker/scripts/test_python.sh b/tools/docker/scripts/test_python.sh index f90a2d7687..e7135b665b 100755 --- a/tools/docker/scripts/test_python.sh +++ b/tools/docker/scripts/test_python.sh @@ -3,34 +3,34 @@ # author: Ole Schuett function run_tests { - PYTHON=$1 - SCRIPTS=$2 - BASEDIR=$(pwd) - VERSION=$(${PYTHON} -V 2>&1 | tr -d '\n') - echo "" - echo "========== Running ${VERSION} Tests ==========" - #find ./src/ ./tools/ -name "*.pyc" -exec rm {} \; - for i in $SCRIPTS ; do - set +e #disable error trapping - echo "Running $i" - cd "$(dirname "$i")" - SCRIPT=$(basename "$i") - if ! $PYTHON -B "./${SCRIPT}" ; then - echo "Test $i failed" - ERRORS=$((ERRORS+1)) - fi - set -e #re-enable error trapping - cd "$BASEDIR" - done + PYTHON=$1 + SCRIPTS=$2 + BASEDIR=$(pwd) + VERSION=$(${PYTHON} -V 2>&1 | tr -d '\n') + echo "" + echo "========== Running ${VERSION} Tests ==========" + #find ./src/ ./tools/ -name "*.pyc" -exec rm {} \; + for i in $SCRIPTS; do + set +e #disable error trapping + echo "Running $i" + cd "$(dirname "$i")" + SCRIPT=$(basename "$i") + if ! $PYTHON -B "./${SCRIPT}"; then + echo "Test $i failed" + ERRORS=$((ERRORS + 1)) + fi + set -e #re-enable error trapping + cd "$BASEDIR" + done } function run_pre_commit { - set +e #disable error trapping - if ! pre-commit run --all-files --hook-stage manual check-ast ; then - echo "Syntax check failed." - ERRORS=$((ERRORS+1)) - fi - set -e #re-enable error trapping + set +e #disable error trapping + if ! pre-commit run --all-files --hook-stage manual check-ast; then + echo "Syntax check failed." + ERRORS=$((ERRORS + 1)) + fi + set -e #re-enable error trapping } #=============================================================================== @@ -39,7 +39,7 @@ ERRORS=0 cd /workspace/cp2k # find executable python scripts -ALL_TEST_SCRIPTS=$(find ./src/ ./tools/ -name "*_test.py" -executable) +ALL_TEST_SCRIPTS=$(find ./src/ ./tools/ -name "*_test.py" -executable) # python 3.x run_tests python3 "${ALL_TEST_SCRIPTS}" @@ -48,11 +48,11 @@ run_tests python3 "${ALL_TEST_SCRIPTS}" run_pre_commit # print report -NUM_TEST_SCRIPTS=$(( $(wc -w <<< "${ALL_TEST_SCRIPTS}") + 1 )) +NUM_TEST_SCRIPTS=$(($(wc -w <<< "${ALL_TEST_SCRIPTS}") + 1)) echo "" echo "Summary: Run ${NUM_TEST_SCRIPTS} Python test scripts, found ${ERRORS} errors." if [ $ERRORS == 0 ]; then - echo "Status: OK" + echo "Status: OK" else - echo "Status: FAILED" + echo "Status: FAILED" fi diff --git a/tools/docker/scripts/test_regtest.sh b/tools/docker/scripts/test_regtest.sh index f41b8c2bd0..92a1f5363a 100755 --- a/tools/docker/scripts/test_regtest.sh +++ b/tools/docker/scripts/test_regtest.sh @@ -2,9 +2,9 @@ # author: Ole Schuett -if (( $# != 2 )) ; then - echo "Usage: test_regtest.sh " - exit 1 +if (($# != 2)); then + echo "Usage: test_regtest.sh " + exit 1 fi ARCH=$1 @@ -14,43 +14,43 @@ VERSION=$2 source /opt/cp2k-toolchain/install/setup # Make OpenMPI happy. -if command -v ompi_info &> /dev/null ; then - TESTOPTS="-mpiexec 'mpiexec --bind-to none --allow-run-as-root' ${TESTOPTS}" - export OMPI_MCA_plm_rsh_agent=/bin/false +if command -v ompi_info &> /dev/null; then + TESTOPTS="-mpiexec 'mpiexec --bind-to none --allow-run-as-root' ${TESTOPTS}" + export OMPI_MCA_plm_rsh_agent=/bin/false fi # Switch to stable DBCSR version if requested. -if [ -n "${USE_STABLE_DBCSR}" ] ; then - echo "Switching to stable DBCSR version..." - if ! git -C cp2k/exts/dbcsr checkout v2.1.0-rc16 ; then - echo -e "\nSummary: Could not checkout stable DBCSR version." - echo -e "Status: FAILED\n" - exit 0 - fi - ln -fs python3 /usr/bin/python # DBCSR v2.1.0-rc16 needs the python binary. +if [ -n "${USE_STABLE_DBCSR}" ]; then + echo "Switching to stable DBCSR version..." + if ! git -C cp2k/exts/dbcsr checkout v2.1.0-rc16; then + echo -e "\nSummary: Could not checkout stable DBCSR version." + echo -e "Status: FAILED\n" + exit 0 + fi + ln -fs python3 /usr/bin/python # DBCSR v2.1.0-rc16 needs the python binary. fi # Compile cp2k. echo -en "\nCompiling cp2k... " cd /workspace/cp2k || exit 1 -if make -j ARCH="${ARCH}" VERSION="${VERSION}" &> make.out ; then - echo "done." +if make -j ARCH="${ARCH}" VERSION="${VERSION}" &> make.out; then + echo "done." else - echo -e "failed.\n\n" - tail -n 100 make.out - echo -e "\nSummary: Compilation failed." - echo -e "Status: FAILED\n" - exit 0 + echo -e "failed.\n\n" + tail -n 100 make.out + echo -e "\nSummary: Compilation failed." + echo -e "Status: FAILED\n" + exit 0 fi # Check benchmark files for input errors. -if [[ "${ARCH}" == "local" ]] ; then - echo -en "\nChecking benchmarks... " - if ! ./tools/regtesting/check_inputs.py "./exe/${ARCH}/cp2k.${VERSION}" "./benchmarks/" ; then - echo -e "\nSummary: Some benchmark inputs could not be parsed." - echo -e "Status: FAILED\n" - exit 0 - fi +if [[ "${ARCH}" == "local" ]]; then + echo -en "\nChecking benchmarks... " + if ! ./tools/regtesting/check_inputs.py "./exe/${ARCH}/cp2k.${VERSION}" "./benchmarks/"; then + echo -e "\nSummary: Some benchmark inputs could not be parsed." + echo -e "Status: FAILED\n" + exit 0 + fi fi # Run regtests. diff --git a/tools/docker/scripts/test_scaling.sh b/tools/docker/scripts/test_scaling.sh index b8a3d7b40b..0839780ff2 100755 --- a/tools/docker/scripts/test_scaling.sh +++ b/tools/docker/scripts/test_scaling.sh @@ -7,17 +7,17 @@ source /opt/cp2k-toolchain/install/setup echo -e '\n========== Compiling CP2K ==========' cd /workspace/cp2k -for VERSION in 'psmp' 'ssmp' ; do - echo -n "Compiling cp2k.${VERSION}... " - if make -j VERSION="${VERSION}" &> make.out ; then - echo "done." - else - echo -e "failed.\n\n" - tail -n 100 make.out - echo -e "\nSummary: Compilation failed." - echo -e "Status: FAILED\n" - exit 0 - fi +for VERSION in 'psmp' 'ssmp'; do + echo -n "Compiling cp2k.${VERSION}... " + if make -j VERSION="${VERSION}" &> make.out; then + echo "done." + else + echo -e "failed.\n\n" + tail -n 100 make.out + echo -e "\nSummary: Compilation failed." + echo -e "Status: FAILED\n" + exit 0 + fi done echo -e '\n========== Running Scaling Test ==========' diff --git a/tools/doxify/doxify.sh b/tools/doxify/doxify.sh index 04dc93a95c..47472839ff 100755 --- a/tools/doxify/doxify.sh +++ b/tools/doxify/doxify.sh @@ -3,38 +3,41 @@ set -eo pipefail ARGS=${ARGS:-} # Set to "-v" for debugging -SCRIPTDIR=$(cd $(dirname "$0"); pwd) # Pick up full path to scripts from wherever doxify.sh lives +SCRIPTDIR=$( + cd $(dirname "$0") + pwd +) # Pick up full path to scripts from wherever doxify.sh lives nwarnings=0 for file in "$@"; do - "${SCRIPTDIR}/is_fypp.py" "${file}" && continue + "${SCRIPTDIR}/is_fypp.py" "${file}" && continue - # generate temp-file names - tmp_file=`mktemp` + # generate temp-file names + tmp_file=$(mktemp) - # * Run the fixcomments.pl script. This adds comment blocks to any subroutine/function - # definitions that don't have any and checks that existing comments are complete, - # fixing these if required. - # * After adding comments, remove any double comment header lines - "${SCRIPTDIR}/fixcomments.pl" ${ARGS} "${file}" \ - | "${SCRIPTDIR}/remove_extra_comments.pl" ${ARGS} > "${tmp_file}" + # * Run the fixcomments.pl script. This adds comment blocks to any subroutine/function + # definitions that don't have any and checks that existing comments are complete, + # fixing these if required. + # * After adding comments, remove any double comment header lines + "${SCRIPTDIR}/fixcomments.pl" ${ARGS} "${file}" | + "${SCRIPTDIR}/remove_extra_comments.pl" ${ARGS} > "${tmp_file}" - # Copy the final modified source file on top of the original file - if ! cmp -s "${file}" "${tmp_file}" ; then - cp "${tmp_file}" "${file}" - fi + # Copy the final modified source file on top of the original file + if ! cmp -s "${file}" "${tmp_file}"; then + cp "${tmp_file}" "${file}" + fi - # Remove temp-file - rm -f "${tmp_file}" + # Remove temp-file + rm -f "${tmp_file}" - if grep -e "UNMATCHED_PROCEDURE_ARGUMENT" \ - -e "UNKNOWN_DOXYGEN_COMMENT" \ - -e "UNKNOWN_COMMENT" \ - "${file}" ; then - echo "Found doxify warnings in ${file}" - ((nwarnings++)) - fi + if grep -e "UNMATCHED_PROCEDURE_ARGUMENT" \ + -e "UNKNOWN_DOXYGEN_COMMENT" \ + -e "UNKNOWN_COMMENT" \ + "${file}"; then + echo "Found doxify warnings in ${file}" + ((nwarnings++)) + fi done exit ${nwarnings} diff --git a/tools/doxify/generate_doxygen.sh b/tools/doxify/generate_doxygen.sh index 6d0b1848d4..e68acd845e 100755 --- a/tools/doxify/generate_doxygen.sh +++ b/tools/doxify/generate_doxygen.sh @@ -4,15 +4,15 @@ DOXYGENDIR="./doxygen" -for SRC_FN in $(find ./src/ -type f) ; do - echo "Preprocessing ${SRC_FN}" - DEST_FN="${DOXYGENDIR}/${SRC_FN}" - mkdir -p $(dirname "${DEST_FN}") - if [[ "${SRC_FN}" == *.F ]] ; then - ./tools/build_utils/fypp "${SRC_FN}" "${DEST_FN}" &> /dev/null - else - cp "${SRC_FN}" "${DEST_FN}" - fi +for SRC_FN in $(find ./src/ -type f); do + echo "Preprocessing ${SRC_FN}" + DEST_FN="${DOXYGENDIR}/${SRC_FN}" + mkdir -p $(dirname "${DEST_FN}") + if [[ "${SRC_FN}" == *.F ]]; then + ./tools/build_utils/fypp "${SRC_FN}" "${DEST_FN}" &> /dev/null + else + cp "${SRC_FN}" "${DEST_FN}" + fi done cp tools/logo/cp2k_logo_100.png ${DOXYGENDIR}/cp2k_logo.png diff --git a/tools/formatting/test_formatting.sh b/tools/formatting/test_formatting.sh index a5ac7784c7..53fd06e366 100755 --- a/tools/formatting/test_formatting.sh +++ b/tools/formatting/test_formatting.sh @@ -10,29 +10,29 @@ find ./src/ -type f -not -path "*/preprettify/*" -not -path "*/.git/*" -print0 | md5sum ./data/POTENTIAL >> checksums.md5 make -j 16 pretty -make -j 16 pretty # run twice to ensure consistency with doxify +make -j 16 pretty # run twice to ensure consistency with doxify cd data cat GTH_POTENTIALS HF_POTENTIALS NLCC_POTENTIALS ALL_POTENTIALS > POTENTIAL cd .. -nfiles=`wc -l checksums.md5 | cut -f 1 -d " "` +nfiles=$(wc -l checksums.md5 | cut -f 1 -d " ") summary="Checked $nfiles files." status="OK" echo "Searching for doxify warnings ..." if grep -r -e "UNMATCHED_PROCEDURE_ARGUMENT" \ - -e "UNKNOWN_DOXYGEN_COMMENT" \ - -e "UNKNOWN_COMMENT" \ - --exclude-dir=".git" \ - --exclude-dir="preprettify" \ - ./src/* ; then + -e "UNKNOWN_DOXYGEN_COMMENT" \ + -e "UNKNOWN_COMMENT" \ + --exclude-dir=".git" \ + --exclude-dir="preprettify" \ + ./src/*; then summary="Found doxify warnings" status="FAILED" fi echo "Comparing MD5-sums ..." -if ! md5sum --quiet --check checksums.md5 ; then +if ! md5sum --quiet --check checksums.md5; then summary='Code not invariant under "make pretty"' status="FAILED" fi diff --git a/tools/plan_mpi_omp/plan.sh b/tools/plan_mpi_omp/plan.sh index 96fd634af1..0e58b703ea 100755 --- a/tools/plan_mpi_omp/plan.sh +++ b/tools/plan_mpi_omp/plan.sh @@ -33,25 +33,31 @@ TR=$(command -v tr) if [ "" != "${HOME}" ]; then CONFIGFILE=${HOME}/.xconfigure-cp2k-plan else - HERE=$(cd $(dirname $0); pwd -P) + HERE=$( + cd $(dirname $0) + pwd -P + ) CONFIGFILE=${HERE}/.xconfigure-cp2k-plan fi function isqrt { - s=1073741824; x=$1; y=0 + s=1073741824 + x=$1 + y=0 while [ "0" != "$((0 < s))" ]; do - b=$((y | s)); y=$((y >> 1)) + b=$((y | s)) + y=$((y >> 1)) if [ "0" != "$((b <= x))" ]; then - x=$((x - b)); y=$((y | s)) + x=$((x - b)) + y=$((y | s)) fi s=$((s >> 2)) done echo "${y}" } -if [ "" != "${GREP}" ] && [ "" != "${SORT}" ] && [ "" != "${HEAD}" ] && \ - [ "" != "${SEQ}" ] && [ "" != "${CUT}" ] && [ "" != "${TR}" ]; -then +if [ "" != "${GREP}" ] && [ "" != "${SORT}" ] && [ "" != "${HEAD}" ] && + [ "" != "${SEQ}" ] && [ "" != "${CUT}" ] && [ "" != "${TR}" ]; then HELP=0 if [ "--help" = "$1" ] || [ "-help" = "$1" ] || [ "-h" = "$1" ]; then HELP=1 @@ -60,10 +66,9 @@ then TOTALNUMNODES=$1 shift fi - if [ -e /proc/cpuinfo ] && [ "" != "$(command -v wc)" ]; - then + if [ -e /proc/cpuinfo ] && [ "" != "$(command -v wc)" ]; then NS=$(${GREP} "physical id" /proc/cpuinfo | ${SORT} -u | wc -l | ${TR} -d " ") - NC=$((NS*$(${GREP} -m1 "cpu cores" /proc/cpuinfo | ${TR} -d " " | ${CUT} -d: -f2))) + NC=$((NS * $(${GREP} -m1 "cpu cores" /proc/cpuinfo | ${TR} -d " " | ${CUT} -d: -f2))) NT=$(${GREP} "core id" /proc/cpuinfo | wc -l | ${TR} -d " ") elif [ "Darwin" = "$(uname)" ] && [ "" != "$(command -v sysctl)" ]; then NS=$(sysctl hw.packages | ${CUT} -d: -f2 | ${TR} -d " ") @@ -71,11 +76,11 @@ then NT=$(sysctl hw.logicalcpu | ${CUT} -d: -f2 | ${TR} -d " ") fi if [ "" != "${NC}" ] && [ "" != "${NT}" ]; then - HT=$((NT/NC)) + HT=$((NT / NC)) fi OUTPUT=0 if [ "" = "$1" ]; then - if [ -e ${CONFIGFILE} ]; then # remind configuration + if [ -e ${CONFIGFILE} ]; then # remind configuration NCORESPERNODE=$(${CUT} -d" " -f1 ${CONFIGFILE}) elif [ "" != "${NC}" ]; then NCORESPERNODE=${NC} @@ -86,7 +91,7 @@ then shift fi if [ "" = "$1" ]; then - if [ -e ${CONFIGFILE} ]; then # remind configuration + if [ -e ${CONFIGFILE} ]; then # remind configuration NTHREADSPERCORE=$(${CUT} -d" " -f2 ${CONFIGFILE}) elif [ "" != "${HT}" ]; then NTHREADSPERCORE=${HT} @@ -97,7 +102,7 @@ then shift fi if [ "" = "$1" ]; then - if [ -e ${CONFIGFILE} ]; then # remind configuration + if [ -e ${CONFIGFILE} ]; then # remind configuration NPROCSPERNODE=$(${CUT} -d" " -f3 ${CONFIGFILE}) elif [ "" != "${NS}" ]; then NPROCSPERNODE=${NS} @@ -120,31 +125,30 @@ then exit 0 fi # min. number of ranks per node - MIN_NRANKS=$((PENALTY_MIN*NPROCSPERNODE)) + MIN_NRANKS=$((PENALTY_MIN * NPROCSPERNODE)) # remember system configuration if [ "0" != "${OUTPUT}" ]; then echo "${NCORESPERNODE} ${NTHREADSPERCORE} ${NPROCSPERNODE}" > ${CONFIGFILE} 2> /dev/null fi - NCORESTOTAL=$((TOTALNUMNODES*NCORESPERNODE)) - NCORESOCKET=$((NCORESPERNODE/NPROCSPERNODE)) + NCORESTOTAL=$((TOTALNUMNODES * NCORESPERNODE)) + NCORESOCKET=$((NCORESPERNODE / NPROCSPERNODE)) echo "================================================================================" echo "${NCORESTOTAL} cores: ${TOTALNUMNODES} node(s) with ${NPROCSPERNODE}x${NCORESOCKET} core(s) per node and ${NTHREADSPERCORE} thread(s) per core" echo "================================================================================" - NRANKSMIN=$((TOTALNUMNODES*NPROCSPERNODE)) + NRANKSMIN=$((TOTALNUMNODES * NPROCSPERNODE)) NSQRT_MIN=$(isqrt ${NRANKSMIN}) NSQRT_MAX=$(isqrt ${NCORESTOTAL}) for NSQRT in $(${SEQ} ${NSQRT_MIN} ${NSQRT_MAX}); do - NSQR=$((NSQRT*NSQRT)) - NRANKSPERNODE=$((NSQR/TOTALNUMNODES)) - if [ "${NSQR}" = "$((TOTALNUMNODES*NRANKSPERNODE))" ]; then - REST=$((NCORESPERNODE%NRANKSPERNODE)) - ODD=$(((NRANKSPERNODE%NPROCSPERNODE)!=0)) + NSQR=$((NSQRT * NSQRT)) + NRANKSPERNODE=$((NSQR / TOTALNUMNODES)) + if [ "${NSQR}" = "$((TOTALNUMNODES * NRANKSPERNODE))" ]; then + REST=$((NCORESPERNODE % NRANKSPERNODE)) + ODD=$(((NRANKSPERNODE % NPROCSPERNODE) != 0)) # criterion to add penalty in case of unbalanced load - if [ "0" != "$((PENALTY_ODD*MIN_NRANKS*REST <= NCORESPERNODE))" ] || [ "0" = "${ODD}" ]; then - if [ "0" != "$((MIN_NRANKS*REST <= NCORESPERNODE))" ] && \ - [ "0" != "$((MIN_NRANKS <= NRANKSPERNODE))" ]; - then - PENALTY=$(((100*REST+ODD*PENALTY_ODD+NCORESPERNODE-1)/NCORESPERNODE)) + if [ "0" != "$((PENALTY_ODD * MIN_NRANKS * REST <= NCORESPERNODE))" ] || [ "0" = "${ODD}" ]; then + if [ "0" != "$((MIN_NRANKS * REST <= NCORESPERNODE))" ] && + [ "0" != "$((MIN_NRANKS <= NRANKSPERNODE))" ]; then + PENALTY=$(((100 * REST + ODD * PENALTY_ODD + NCORESPERNODE - 1) / NCORESPERNODE)) RESULTS+="${NRANKSPERNODE};${PENALTY};${NSQRT}\n" fi fi @@ -152,28 +156,27 @@ then done RESULTS=$(echo -e "${RESULTS}" | ${GREP} -v "^$" | ${SORT} -t";" -u -k2n -k1nr) NRANKSPERNODE_TOP=$(echo "${RESULTS}" | ${CUT} -d";" -f1 | ${HEAD} -n1) - NTHREADSPERNODE=$((NCORESPERNODE*NTHREADSPERCORE)) - NSQR_MAX=$((NSQRT_MAX*NSQRT_MAX)) - PENALTY_NCORES=$((NCORESTOTAL-NSQR_MAX)) - PENALTY_TOP=$(((100*PENALTY_NCORES+NCORESTOTAL-1)/NCORESTOTAL)) + NTHREADSPERNODE=$((NCORESPERNODE * NTHREADSPERCORE)) + NSQR_MAX=$((NSQRT_MAX * NSQRT_MAX)) + PENALTY_NCORES=$((NCORESTOTAL - NSQR_MAX)) + PENALTY_TOP=$(((100 * PENALTY_NCORES + NCORESTOTAL - 1) / NCORESTOTAL)) NRANKSPERNODE=${NCORESPERNODE} OUTPUT_POT=0 while [ "0" != "$((NRANKSPERNODE_TOP < NRANKSPERNODE))" ]; do # criterion to add penalty in case of unbalanced load - ODD=$(((NRANKSPERNODE%NPROCSPERNODE)!=0)) - if [ "0" != "$((PENALTY_ODD*MIN_NRANKS*PENALTY_NCORES <= NCORESTOTAL))" ] || [ "0" = "${ODD}" ]; then - NTHREADSPERRANK=$((NTHREADSPERNODE/NRANKSPERNODE)) - if [ "0" != "$((MIN_NRANKS*PENALTY_NCORES <= NCORESTOTAL))" ] && \ - [ "0" != "$((MIN_NRANKS <= NRANKSPERNODE))" ]; - then - NRANKS_CUR=$((TOTALNUMNODES*NRANKSPERNODE)) + ODD=$(((NRANKSPERNODE % NPROCSPERNODE) != 0)) + if [ "0" != "$((PENALTY_ODD * MIN_NRANKS * PENALTY_NCORES <= NCORESTOTAL))" ] || [ "0" = "${ODD}" ]; then + NTHREADSPERRANK=$((NTHREADSPERNODE / NRANKSPERNODE)) + if [ "0" != "$((MIN_NRANKS * PENALTY_NCORES <= NCORESTOTAL))" ] && + [ "0" != "$((MIN_NRANKS <= NRANKSPERNODE))" ]; then + NRANKS_CUR=$((TOTALNUMNODES * NRANKSPERNODE)) SQRTNRANKS=$(isqrt $((NRANKS_CUR))) - NRANKS_SQR=$((SQRTNRANKS*SQRTNRANKS)) - NRANKS_COM=$((NRANKSPERNODE> 1)) @@ -186,59 +189,56 @@ then RESULTS=$(echo -e "${RESULTS}" | ${TR} " " "\n" | ${SORT} -t";" -k1nr -k2n) for RESULT in ${RESULTS}; do NRANKSPERNODE=$(echo "${RESULT}" | ${CUT} -d";" -f1) - NTHREADSPERRANK=$((NTHREADSPERNODE/NRANKSPERNODE)) + NTHREADSPERRANK=$((NTHREADSPERNODE / NRANKSPERNODE)) PENALTY=$(echo "${RESULT}" | ${CUT} -d";" -f2) - if [ "0" != "$((OUTPUT_SQR < OUTPUT_POT))" ] || \ - [ "0" != "$((PENALTY <= PENALTY_TOP))" ]; - then + if [ "0" != "$((OUTPUT_SQR < OUTPUT_POT))" ] || + [ "0" != "$((PENALTY <= PENALTY_TOP))" ]; then NSQRT=$(echo "${RESULT}" | ${CUT} -d";" -f3) echo "[${NRANKSPERNODE}x${NTHREADSPERRANK}]: ${NRANKSPERNODE} ranks per node with ${NTHREADSPERRANK} thread(s) per rank (${PENALTY}% penalty) -> ${NSQRT}x${NSQRT}" - OUTPUT_SQR=$((OUTPUT_SQR+1)) + OUTPUT_SQR=$((OUTPUT_SQR + 1)) fi done if [ "0" != "${OUTPUT_SQR}" ]; then echo "--------------------------------------------------------------------------------" fi for NRANKSPERNODE in $(${SEQ} ${MIN_NRANKS} ${NCORESPERNODE}); do - REST=$((NCORESPERNODE%NRANKSPERNODE)) - PENALTY=$(((100*REST+NCORESPERNODE-1)/NCORESPERNODE)) + REST=$((NCORESPERNODE % NRANKSPERNODE)) + PENALTY=$(((100 * REST + NCORESPERNODE - 1) / NCORESPERNODE)) # criterion to add penalty in case of unbalanced load - ODD=$(((NRANKSPERNODE%NPROCSPERNODE)!=0)) - if [ "0" != "$((PENALTY_ODD*MIN_NRANKS*REST <= NCORESPERNODE))" ] || [ "0" = "${ODD}" ]; - then - if [ "0" != "$((MIN_NRANKS*REST <= NCORESPERNODE))" ] && \ - [ "0" != "$((MIN_NRANKS <= NRANKSPERNODE))" ]; - then - SQRT=$(isqrt $((TOTALNUMNODES*NRANKSPERNODE))) - NUMCORES=$((SQRT*SQRT)) - NUMNODES=$((NUMCORES/NRANKSPERNODE)) - if [ "0" = "$((NUMCORES-NUMNODES*NRANKSPERNODE))" ]; then + ODD=$(((NRANKSPERNODE % NPROCSPERNODE) != 0)) + if [ "0" != "$((PENALTY_ODD * MIN_NRANKS * REST <= NCORESPERNODE))" ] || [ "0" = "${ODD}" ]; then + if [ "0" != "$((MIN_NRANKS * REST <= NCORESPERNODE))" ] && + [ "0" != "$((MIN_NRANKS <= NRANKSPERNODE))" ]; then + SQRT=$(isqrt $((TOTALNUMNODES * NRANKSPERNODE))) + NUMCORES=$((SQRT * SQRT)) + NUMNODES=$((NUMCORES / NRANKSPERNODE)) + if [ "0" = "$((NUMCORES - NUMNODES * NRANKSPERNODE))" ]; then SUGGEST_LO+="${NUMNODES}\n" fi - NUMCORES=$(((SQRT-1)*(SQRT-1))) - NUMNODES=$((NUMCORES/NRANKSPERNODE)) - if [ "0" = "$((NUMCORES-NUMNODES*NRANKSPERNODE))" ]; then + NUMCORES=$(((SQRT - 1) * (SQRT - 1))) + NUMNODES=$((NUMCORES / NRANKSPERNODE)) + if [ "0" = "$((NUMCORES - NUMNODES * NRANKSPERNODE))" ]; then SUGGEST_LO+="${NUMNODES}\n" fi - NUMCORES=$(((SQRT+1)*(SQRT+1))) - NUMNODES=$((NUMCORES/NRANKSPERNODE)) - if [ "0" = "$((NUMCORES-NUMNODES*NRANKSPERNODE))" ]; then + NUMCORES=$(((SQRT + 1) * (SQRT + 1))) + NUMNODES=$((NUMCORES / NRANKSPERNODE)) + if [ "0" = "$((NUMCORES - NUMNODES * NRANKSPERNODE))" ]; then SUGGEST_HI+="${NUMNODES}\n" fi - NUMCORES=$(((SQRT+2)*(SQRT+2))) - NUMNODES=$((NUMCORES/NRANKSPERNODE)) - if [ "0" = "$((NUMCORES-NUMNODES*NRANKSPERNODE))" ] && [ "" = "${SUGGEST_HI}" ]; then + NUMCORES=$(((SQRT + 2) * (SQRT + 2))) + NUMNODES=$((NUMCORES / NRANKSPERNODE)) + if [ "0" = "$((NUMCORES - NUMNODES * NRANKSPERNODE))" ] && [ "" = "${SUGGEST_HI}" ]; then SUGGEST_HI+="${NUMNODES}\n" fi fi fi done - SUGGEST_LO=$(echo -e "${SUGGEST_LO}" \ - | ${GREP} -vw "${TOTALNUMNODES}" \ - | ${SORT} -nr | ${GREP} -v "^$" -m1) - SUGGEST_HI=$(echo -e "${SUGGEST_HI}" \ - | ${GREP} -vw "${TOTALNUMNODES}" \ - | ${SORT} -n | ${GREP} -v "^$" -m1) + SUGGEST_LO=$(echo -e "${SUGGEST_LO}" | + ${GREP} -vw "${TOTALNUMNODES}" | + ${SORT} -nr | ${GREP} -v "^$" -m1) + SUGGEST_HI=$(echo -e "${SUGGEST_HI}" | + ${GREP} -vw "${TOTALNUMNODES}" | + ${SORT} -n | ${GREP} -v "^$" -m1) if [ "0" != "${SUGGEST_LO}" ]; then echo "Try also the following node counts: ${SUGGEST_LO} ${SUGGEST_HI}" else @@ -248,4 +248,3 @@ else echo "Error: missing prerequisites!" exit 1 fi - diff --git a/tools/pre-commit-install.sh b/tools/pre-commit-install.sh index 82b072050e..4bb262abcf 100755 --- a/tools/pre-commit-install.sh +++ b/tools/pre-commit-install.sh @@ -7,9 +7,9 @@ set -o nounset PYTHON=$(command -v python3 || true) -if [ -z "${PYTHON}" ] ; then - echo "ERROR: the python3 executable could not be found, but is required for the complete build process" - exit 1 +if [ -z "${PYTHON}" ]; then + echo "ERROR: the python3 executable could not be found, but is required for the complete build process" + exit 1 fi SCRIPTDIR=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd) @@ -17,16 +17,16 @@ SCRIPTDIR=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd) # here we assume that this script is located in the tools/ subfolder ENVDIR="${SCRIPTDIR}/../.pre-commit-env" -if [ -f "${ENVDIR}/bootstrap_done" ] ; then - echo "The environment in /.pre-commit-env/ is ready to use..." - exit 0 +if [ -f "${ENVDIR}/bootstrap_done" ]; then + echo "The environment in /.pre-commit-env/ is ready to use..." + exit 0 fi echo "Installing all required tools to run pre-commit in /.pre-commit-env/" echo "Creating the virtualenv for pre-commit..." -if [ ! -d "${ENVDIR}" ] ; then - "${PYTHON}" -m venv "${ENVDIR}" +if [ ! -d "${ENVDIR}" ]; then + "${PYTHON}" -m venv "${ENVDIR}" fi # resolve the relative path now that we have it: @@ -39,28 +39,28 @@ ENVDIR=$(CDPATH='' cd -- "${ENVDIR}" && pwd) PYTHON=$(command -v python) PIP=$(command -v pip || true) -if [ -z "${PIP}" ] ; then - echo "Bootstrapping the pip command inside the virtual environment..." +if [ -z "${PIP}" ]; then + echo "Bootstrapping the pip command inside the virtual environment..." - FETCHER="$(command -v curl || true)" - FETCHER_OPTS="" + FETCHER="$(command -v curl || true)" + FETCHER_OPTS="" - if [ -z "${FETCHER}" ] ; then - FETCHER="$(command -v wget || true)" - FETCHER_OPTS="-O-" - fi + if [ -z "${FETCHER}" ]; then + FETCHER="$(command -v wget || true)" + FETCHER_OPTS="-O-" + fi - if [ -z "${FETCHER}" ] ; then - echo "ERROR: neither wget nor curl seem to be available, please download" - echo " https://bootstrap.pypa.io/get-pip.py" - echo "manually and run:" - echo " python3 get-pip.py" - echo "to install the pip command, then rerun this script." - rm -rf "${ENVDIR}" # cleaning up to avoid picking up the unprefixed pip on the rerun - exit 1 - fi + if [ -z "${FETCHER}" ]; then + echo "ERROR: neither wget nor curl seem to be available, please download" + echo " https://bootstrap.pypa.io/get-pip.py" + echo "manually and run:" + echo " python3 get-pip.py" + echo "to install the pip command, then rerun this script." + rm -rf "${ENVDIR}" # cleaning up to avoid picking up the unprefixed pip on the rerun + exit 1 + fi - "${FETCHER}" ${FETCHER_OPTS} "https://bootstrap.pypa.io/get-pip.py" | "${PYTHON}" + "${FETCHER}" ${FETCHER_OPTS} "https://bootstrap.pypa.io/get-pip.py" | "${PYTHON}" fi PIP=$(command -v pip) diff --git a/tools/precommit/deploy.sh b/tools/precommit/deploy.sh index e4dc10c6a5..0b4442daa2 100755 --- a/tools/precommit/deploy.sh +++ b/tools/precommit/deploy.sh @@ -13,6 +13,6 @@ docker push gcr.io/cp2k-org-project/img_cp2kprecommit:${SHORT_SHA} docker push gcr.io/cp2k-org-project/img_cp2kprecommit:latest gcloud run deploy cp2k-precommit --platform=managed --region=us-central1 \ - --image=gcr.io/cp2k-org-project/img_cp2kprecommit:${SHORT_SHA} + --image=gcr.io/cp2k-org-project/img_cp2kprecommit:${SHORT_SHA} #EOF diff --git a/tools/precommit/entrypoint.sh b/tools/precommit/entrypoint.sh index e1210b4aaf..f2e74a0fd8 100755 --- a/tools/precommit/entrypoint.sh +++ b/tools/precommit/entrypoint.sh @@ -5,27 +5,27 @@ trap "exit" INT if [ -z "${GIT_REF}" ]; then - # Server mode. - gunicorn --bind=:8080 --workers=1 --threads=8 --timeout=0 precommit_server:app & - wait # Can be interrupted with ctrl-C. + # Server mode. + gunicorn --bind=:8080 --workers=1 --threads=8 --timeout=0 precommit_server:app & + wait # Can be interrupted with ctrl-C. else - # CI mode. - echo -e "\n========== Fetching Git Commit ==========" - cd /workspace/cp2k - git fetch --quiet origin "${GIT_BRANCH}" - git reset --quiet --hard "${GIT_REF}" - git submodule update --init --recursive - git --no-pager log -1 --pretty='%nCommitSHA: %H%nCommitTime: %ci%nCommitAuthor: %an%nCommitSubject: %s%n' + # CI mode. + echo -e "\n========== Fetching Git Commit ==========" + cd /workspace/cp2k + git fetch --quiet origin "${GIT_BRANCH}" + git reset --quiet --hard "${GIT_REF}" + git submodule update --init --recursive + git --no-pager log -1 --pretty='%nCommitSHA: %H%nCommitTime: %ci%nCommitAuthor: %an%nCommitSubject: %s%n' - echo -e "\n========== Starting Precommit Server ==========" - cd ./tools/precommit/ - gunicorn --bind=:8080 --workers=1 --threads=8 --timeout=0 precommit_server:app &> server.logs & - sleep 3 - cat server.logs + echo -e "\n========== Starting Precommit Server ==========" + cd ./tools/precommit/ + gunicorn --bind=:8080 --workers=1 --threads=8 --timeout=0 precommit_server:app &> server.logs & + sleep 3 + cat server.logs - echo -e "\n========== Running Precommit Checks ==========" - export CP2K_PRECOMMIT_SERVER="http://127.0.0.1:8080" - ./precommit.py --no-cache --progressbar-wait=10 || true + echo -e "\n========== Running Precommit Checks ==========" + export CP2K_PRECOMMIT_SERVER="http://127.0.0.1:8080" + ./precommit.py --no-cache --progressbar-wait=10 || true fi #EOF diff --git a/tools/toolchain-spack/install_cp2k_toolchain.sh b/tools/toolchain-spack/install_cp2k_toolchain.sh index 6ff387eff4..7fabefd1dc 100755 --- a/tools/toolchain-spack/install_cp2k_toolchain.sh +++ b/tools/toolchain-spack/install_cp2k_toolchain.sh @@ -6,21 +6,21 @@ set -o errexit set -o nounset PYTHON=$(command -v python3 || true) -if [ -z "${PYTHON}" ] ; then - echo "ERROR: the python3 executable could not be found, but is required for the complete build process" - exit 1 +if [ -z "${PYTHON}" ]; then + echo "ERROR: the python3 executable could not be found, but is required for the complete build process" + exit 1 fi CURL="$(command -v curl || true)" -if [ -z "${CURL}" ] ; then - echo "ERROR: curl is missing, but required by Spack" - exit 1 +if [ -z "${CURL}" ]; then + echo "ERROR: curl is missing, but required by Spack" + exit 1 fi GIT="$(command -v git || true)" -if [ -z "${GIT}" ] ; then - echo "ERROR: the git command is missing, but required by Spack" - exit 1 +if [ -z "${GIT}" ]; then + echo "ERROR: the git command is missing, but required by Spack" + exit 1 fi SCRIPTDIR=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd) @@ -49,33 +49,33 @@ smm_driver="libxsmm" libint_lmax=5 -nprocs=$(nproc 2>/dev/null || echo 1) +nprocs=$(nproc 2> /dev/null || echo 1) no_check_certificates=0 parse_with_arg() { - # shellcheck disable=SC2039 - # ... non-posix but almost all shells support it - local input_var="${1#--with*=}" - case "${input_var}" in - "$1"|install) - # lone --with- treated as --with-=install - echo "__INSTALL__" - ;; - system) - echo "__SYSTEM__" - ;; - no) - echo "__DONTUSE__" - ;; - *) - echo "${input_var}" - ;; - esac + # shellcheck disable=SC2039 + # ... non-posix but almost all shells support it + local input_var="${1#--with*=}" + case "${input_var}" in + "$1" | install) + # lone --with- treated as --with-=install + echo "__INSTALL__" + ;; + system) + echo "__SYSTEM__" + ;; + no) + echo "__DONTUSE__" + ;; + *) + echo "${input_var}" + ;; + esac } usage() { - cat << eof + cat << eof install_cp2k_toolchain.sh: [args] Install Spack environments with CP2K dependencies and generate corresponding CP2K arch files @@ -92,319 +92,320 @@ eof } usage_error() { - echo "ERROR: $1" - usage - exit 1 + echo "ERROR: $1" + usage + exit 1 } configure_spack_env() { - # shellcheck disable=SC2039 - local env="$1" - shift + # shellcheck disable=SC2039 + local env="$1" + shift - # add all the other settings - while [ "$#" -ge 1 ]; do - "${SPACK}" --env-dir "${SPACKENVDIR}/${env}" config add "$1" - shift - done + # add all the other settings + while [ "$#" -ge 1 ]; do + "${SPACK}" --env-dir "${SPACKENVDIR}/${env}" config add "$1" + shift + done } -while [ "$#" -ge 1 ] ; do - case "$1" in - -j|--jobs) - nprocs=$1 - shift - ;; - --no-check-certificate) - no_check_certificates=1 - ;; - --install-all) - # enable (almost) all variants - for variant in ${AVAILABLE_VARIANTS} ; do - eval "with_${variant}=__INSTALL__" - done - mpi_provider="mpich" - ;; - --mpi-mode=*) - case "${1#*=}" in - mpich) - mpi_provider="mpich" - ;; - openmpi) - mpi_provider="openmpi" - ;; - intelmpi) - mpi_provider="intel-mpi" - ;; - no) - mpi_provider="none" - ;; - *) - usage_error "'$1' is not supported" - ;; - esac - break - ;; - --math-mode=*) - case "${1#*=}" in - cray) - lapack_provider="cray-libsci" - fftw_provider="cray-libsci" - scalapack_provider="cray-libsci" - ;; - mkl) - lapack_provider="intel-mkl" - fftw_provider="intel-mkl" - scalapack_provider="intel-mkl" - ;; - openblas) - lapack_provider="openblas" - ;; - reflapack) - lapack_provider="netlib-lapack" - ;; - *) - usage_error "'$1' is not supported" - esac - break - ;; - #--gpu-ver=*) - # case "${1#*=}" in - # K20X) - # gpuver="K20X" - # ;; - # K40) - # gpuver="K40" - # ;; - # K80) - # gpuver="K80" - # ;; - # P100) - # gpuver="P100" - # ;; - # V100) - # gpuver="V100" - # ;; - # no) - # gpuver="no" - # ;; - # *) - # usage_error "'$1' is not supported" - # esac - # ;; - --libint-lmax=*) - libint_lmax="${1#*=}" - ;; - --with-mpich*) - with_mpich=$(parse_with_arg "$1") - if [ "${with_mpich}" != __DONTUSE__ ] ; then - mpi_provider="mpich" - fi - ;; - --with-openmpi*) - with_openmpi=$(parse_with_arg "$1") - if [ "${with_openmpi}" = __INSTALL__ ] ; then - mpi_provider="openmpi" - elif [ "${with_openmpi}" = __DONTUSE__ ] ; then - if [ "${mpi_provider}" = none ] || [ "${mpi_provider}" = openmpi ] ; then - echo "ERROR: an MPI library is required to build CP2K since you didn't pass --mpi-mode=no" - mpi_provider="openmpi" - fi - else - echo "ERROR: explicitly requesting a system library or setting a path is not yet supported (for $1)" - exit 1 - fi - ;; - --with-intelmpi*) - with_intelmpi=$(parse_with_arg "$1") - if [ "${with_intelmpi}" = __INSTALL__ ] ; then - mpi_provider="intel-mpi" - elif [ "${with_intelmpi}" = __DONTUSE__ ] ; then - if [ "${mpi_provider}" = "intel-mpi" ] ; then - mpi_provider="openmpi" - fi - else - echo "ERROR: explicitly requesting a system library or setting a path is not yet supported (for $1)" - exit 1 - fi - ;; - --with-fftw*) - with_fftw=$(parse_with_arg "$1") - if [ "${with_fftw}" = __INSTALL__ ] ; then - fftw_provider="fftw" - elif [ "${with_fftw}" = __DONTUSE__ ] ; then - if [ "${fftw_provider}" = "fftw" ] ; then - echo "ERROR: an FFTW library is required to build CP2K, please use --math-mode to switch the provider." - exit 1 - fi - else - echo "ERROR: explicitly requesting a system library or setting a path is not yet supported (for $1)" - exit 1 - fi - ;; - --with-reflapack*) - with_reflapack=$(parse_with_arg "$1") - if [ "${with_reflapack}" = __INSTALL__ ] ; then - lapack_provider="netlib-lapack" - elif [ "${with_reflapack}" = __DONTUSE__ ] ; then - if [ "${lapack_provider}" = "netlib-lapack" ] ; then - echo "ERROR: a BLAS/LAPACK implementation is required to build CP2K, please use --math-mode" - echo " or one of the --with-mkl/openblas options to switch the provider." - exit 1 - fi - else - echo "ERROR: explicitly requesting a system library or setting a path is not yet supported (for $1)" - exit 1 - fi - ;; - --with-mkl*) - with_mkl=$(parse_with_arg "$1") - if [ "${with_mkl}" = __INSTALL__ ] ; then - lapack_provider="intel-mkl" - scalapack_provider="intel-mkl" - fftw_provider="intel-mkl" - elif [ "${with_mkl}" = __DONTUSE__ ] ; then - if [ "${lapack_provider}" = "intel-mkl" ] || [ "${fftw_provider}" = "intel-mkl" ] || [ "${scalapack_provider}" = "intel-mkl" ] ; then - echo "ERROR: please use --math-mode to switch to a different math provider (MKL is specified for at least one of LAPACK, FFTW, ScaLAPACK)." - exit 1 - fi - else - echo "ERROR: explicitly requesting a system library or setting a path is not yet supported (for $1)" - exit 1 - fi - ;; - --with-openblas*) - with_openblas=$(parse_with_arg "$1") - if [ "${with_openblas}" = __INSTALL__ ] ; then - lapack_provider="openblas" - elif [ "${with_openblas}" = __DONTUSE__ ] ; then - if [ "${lapack_provider}" = "openblas" ] ; then - echo "ERROR: a BLAS/LAPACK implementation is required to build CP2K, please use --math-mode" - echo " or one of the --with-mkl/reflapack options to switch the provider." - exit 1 - fi - else - echo "ERROR: explicitly requesting a system library or setting a path is not yet supported (for $1)" - exit 1 - fi - ;; - --with-scalapack*) - with_scalapack=$(parse_with_arg "$1") - if [ "${with_scalapack}" = __INSTALL__ ] ; then - scalapack_provider="netlib-scalapack" - elif [ "${with_scalapack}" = __DONTUSE__ ] ; then - if [ "${scalapack_provider}" = "netlib-scalapack" ] && [ "${mpi_provider}" != "none" ] ; then - echo "ERROR: a ScaLAPACK implementation is required to build CP2K with MPI, use --mpi-mode=no" - echo " to disable MPI or the --with-mkl option to switch the provider." - exit 1 - fi - else - echo "ERROR: explicitly requesting a system library or setting a path is not yet supported (for $1)" - exit 1 - fi - ;; - --with-libxsmm*) - with_libxsmm=$(parse_with_arg "$1") - if [ "${with_libxsmm}" = "__DONTUSE__" ] ; then - smm_driver="libxsmm" - elif [ "${with_libxsmm}" = "__INSTALL__" ] ; then - smm_driver="blas" - else - echo "ERROR: explicitly requesting a system library or setting a path is not yet supported (for $1)" - exit 1 - fi - ;; - --with-libint*) - # shellcheck disable=SC2034 - with_libint=$(parse_with_arg "$1") - ;; - --with-libxc*) - # shellcheck disable=SC2034 - with_libxc=$(parse_with_arg "$1") - ;; - --with-elpa*) - # shellcheck disable=SC2034 - with_elpa=$(parse_with_arg "$1") - ;; - --with-pexsi*) - # shellcheck disable=SC2034 - with_pexsi=$(parse_with_arg "$1") - ;; - --with-plumed*) - # shellcheck disable=SC2034 - with_plumed=$(parse_with_arg "$1") - ;; - --with-sirius*) - # shellcheck disable=SC2034 - with_sirius=$(parse_with_arg "$1") - ;; - --with-cosma*) - # shellcheck disable=SC2034 - with_cosma=$(parse_with_arg "$1") - ;; - --verbose) - set -x - ;; - -h|--help|-*) - usage - exit 0 - ;; +while [ "$#" -ge 1 ]; do + case "$1" in + -j | --jobs) + nprocs=$1 + shift + ;; + --no-check-certificate) + no_check_certificates=1 + ;; + --install-all) + # enable (almost) all variants + for variant in ${AVAILABLE_VARIANTS}; do + eval "with_${variant}=__INSTALL__" + done + mpi_provider="mpich" + ;; + --mpi-mode=*) + case "${1#*=}" in + mpich) + mpi_provider="mpich" + ;; + openmpi) + mpi_provider="openmpi" + ;; + intelmpi) + mpi_provider="intel-mpi" + ;; + no) + mpi_provider="none" + ;; *) - break - ;; - # --with-gcc*) # TODO: bootstrapping the compiler (and possibly also the binutils) needs more work - #--with-cmake*) # TODO: implement ignoring installed CMake and manually setting up an external - # TODO: separate tools need additional installation steps: - # --with-valgrind*) - #--enable-cuda*) - #--enable-cray*) - #--with-spglib*) # not a variant for CP2K in spack - #--with-quip*) # not available in Spack - esac - shift + usage_error "'$1' is not supported" + ;; + esac + break + ;; + --math-mode=*) + case "${1#*=}" in + cray) + lapack_provider="cray-libsci" + fftw_provider="cray-libsci" + scalapack_provider="cray-libsci" + ;; + mkl) + lapack_provider="intel-mkl" + fftw_provider="intel-mkl" + scalapack_provider="intel-mkl" + ;; + openblas) + lapack_provider="openblas" + ;; + reflapack) + lapack_provider="netlib-lapack" + ;; + *) + usage_error "'$1' is not supported" + ;; + esac + break + ;; + #--gpu-ver=*) + # case "${1#*=}" in + # K20X) + # gpuver="K20X" + # ;; + # K40) + # gpuver="K40" + # ;; + # K80) + # gpuver="K80" + # ;; + # P100) + # gpuver="P100" + # ;; + # V100) + # gpuver="V100" + # ;; + # no) + # gpuver="no" + # ;; + # *) + # usage_error "'$1' is not supported" + # esac + # ;; + --libint-lmax=*) + libint_lmax="${1#*=}" + ;; + --with-mpich*) + with_mpich=$(parse_with_arg "$1") + if [ "${with_mpich}" != __DONTUSE__ ]; then + mpi_provider="mpich" + fi + ;; + --with-openmpi*) + with_openmpi=$(parse_with_arg "$1") + if [ "${with_openmpi}" = __INSTALL__ ]; then + mpi_provider="openmpi" + elif [ "${with_openmpi}" = __DONTUSE__ ]; then + if [ "${mpi_provider}" = none ] || [ "${mpi_provider}" = openmpi ]; then + echo "ERROR: an MPI library is required to build CP2K since you didn't pass --mpi-mode=no" + mpi_provider="openmpi" + fi + else + echo "ERROR: explicitly requesting a system library or setting a path is not yet supported (for $1)" + exit 1 + fi + ;; + --with-intelmpi*) + with_intelmpi=$(parse_with_arg "$1") + if [ "${with_intelmpi}" = __INSTALL__ ]; then + mpi_provider="intel-mpi" + elif [ "${with_intelmpi}" = __DONTUSE__ ]; then + if [ "${mpi_provider}" = "intel-mpi" ]; then + mpi_provider="openmpi" + fi + else + echo "ERROR: explicitly requesting a system library or setting a path is not yet supported (for $1)" + exit 1 + fi + ;; + --with-fftw*) + with_fftw=$(parse_with_arg "$1") + if [ "${with_fftw}" = __INSTALL__ ]; then + fftw_provider="fftw" + elif [ "${with_fftw}" = __DONTUSE__ ]; then + if [ "${fftw_provider}" = "fftw" ]; then + echo "ERROR: an FFTW library is required to build CP2K, please use --math-mode to switch the provider." + exit 1 + fi + else + echo "ERROR: explicitly requesting a system library or setting a path is not yet supported (for $1)" + exit 1 + fi + ;; + --with-reflapack*) + with_reflapack=$(parse_with_arg "$1") + if [ "${with_reflapack}" = __INSTALL__ ]; then + lapack_provider="netlib-lapack" + elif [ "${with_reflapack}" = __DONTUSE__ ]; then + if [ "${lapack_provider}" = "netlib-lapack" ]; then + echo "ERROR: a BLAS/LAPACK implementation is required to build CP2K, please use --math-mode" + echo " or one of the --with-mkl/openblas options to switch the provider." + exit 1 + fi + else + echo "ERROR: explicitly requesting a system library or setting a path is not yet supported (for $1)" + exit 1 + fi + ;; + --with-mkl*) + with_mkl=$(parse_with_arg "$1") + if [ "${with_mkl}" = __INSTALL__ ]; then + lapack_provider="intel-mkl" + scalapack_provider="intel-mkl" + fftw_provider="intel-mkl" + elif [ "${with_mkl}" = __DONTUSE__ ]; then + if [ "${lapack_provider}" = "intel-mkl" ] || [ "${fftw_provider}" = "intel-mkl" ] || [ "${scalapack_provider}" = "intel-mkl" ]; then + echo "ERROR: please use --math-mode to switch to a different math provider (MKL is specified for at least one of LAPACK, FFTW, ScaLAPACK)." + exit 1 + fi + else + echo "ERROR: explicitly requesting a system library or setting a path is not yet supported (for $1)" + exit 1 + fi + ;; + --with-openblas*) + with_openblas=$(parse_with_arg "$1") + if [ "${with_openblas}" = __INSTALL__ ]; then + lapack_provider="openblas" + elif [ "${with_openblas}" = __DONTUSE__ ]; then + if [ "${lapack_provider}" = "openblas" ]; then + echo "ERROR: a BLAS/LAPACK implementation is required to build CP2K, please use --math-mode" + echo " or one of the --with-mkl/reflapack options to switch the provider." + exit 1 + fi + else + echo "ERROR: explicitly requesting a system library or setting a path is not yet supported (for $1)" + exit 1 + fi + ;; + --with-scalapack*) + with_scalapack=$(parse_with_arg "$1") + if [ "${with_scalapack}" = __INSTALL__ ]; then + scalapack_provider="netlib-scalapack" + elif [ "${with_scalapack}" = __DONTUSE__ ]; then + if [ "${scalapack_provider}" = "netlib-scalapack" ] && [ "${mpi_provider}" != "none" ]; then + echo "ERROR: a ScaLAPACK implementation is required to build CP2K with MPI, use --mpi-mode=no" + echo " to disable MPI or the --with-mkl option to switch the provider." + exit 1 + fi + else + echo "ERROR: explicitly requesting a system library or setting a path is not yet supported (for $1)" + exit 1 + fi + ;; + --with-libxsmm*) + with_libxsmm=$(parse_with_arg "$1") + if [ "${with_libxsmm}" = "__DONTUSE__" ]; then + smm_driver="libxsmm" + elif [ "${with_libxsmm}" = "__INSTALL__" ]; then + smm_driver="blas" + else + echo "ERROR: explicitly requesting a system library or setting a path is not yet supported (for $1)" + exit 1 + fi + ;; + --with-libint*) + # shellcheck disable=SC2034 + with_libint=$(parse_with_arg "$1") + ;; + --with-libxc*) + # shellcheck disable=SC2034 + with_libxc=$(parse_with_arg "$1") + ;; + --with-elpa*) + # shellcheck disable=SC2034 + with_elpa=$(parse_with_arg "$1") + ;; + --with-pexsi*) + # shellcheck disable=SC2034 + with_pexsi=$(parse_with_arg "$1") + ;; + --with-plumed*) + # shellcheck disable=SC2034 + with_plumed=$(parse_with_arg "$1") + ;; + --with-sirius*) + # shellcheck disable=SC2034 + with_sirius=$(parse_with_arg "$1") + ;; + --with-cosma*) + # shellcheck disable=SC2034 + with_cosma=$(parse_with_arg "$1") + ;; + --verbose) + set -x + ;; + -h | --help | -*) + usage + exit 0 + ;; + *) + break + ;; + # --with-gcc*) # TODO: bootstrapping the compiler (and possibly also the binutils) needs more work + #--with-cmake*) # TODO: implement ignoring installed CMake and manually setting up an external + # TODO: separate tools need additional installation steps: + # --with-valgrind*) + #--enable-cuda*) + #--enable-cray*) + #--with-spglib*) # not a variant for CP2K in spack + #--with-quip*) # not available in Spack + esac + shift done cp2k_variants="lmax=${libint_lmax} smm=${smm_driver}" cp2k_variants_mpi_only="" -for variant in ${AVAILABLE_VARIANTS} ; do - val=$(eval "echo \${with_${variant}}") +for variant in ${AVAILABLE_VARIANTS}; do + val=$(eval "echo \${with_${variant}}") - if [ "${val}" = "__INSTALL__" ] ; then - prefix="+" - elif [ "${val}" = "__DONTUSE__" ] ; then - prefix="~" - else - echo "ERROR: explicitly requesting a system library or setting a path is not yet supported (for --with-${variant})" - exit 1 - fi + if [ "${val}" = "__INSTALL__" ]; then + prefix="+" + elif [ "${val}" = "__DONTUSE__" ]; then + prefix="~" + else + echo "ERROR: explicitly requesting a system library or setting a path is not yet supported (for --with-${variant})" + exit 1 + fi - if [ "${VARIANTS_REQUIRING_MPI#*${variant}}" = "${VARIANTS_REQUIRING_MPI}" ] ; then - cp2k_variants="${cp2k_variants} ${prefix}${variant}" - else - cp2k_variants_mpi_only="${cp2k_variants_mpi_only} ${prefix}${variant}" - fi + if [ "${VARIANTS_REQUIRING_MPI#*${variant}}" = "${VARIANTS_REQUIRING_MPI}" ]; then + cp2k_variants="${cp2k_variants} ${prefix}${variant}" + else + cp2k_variants_mpi_only="${cp2k_variants_mpi_only} ${prefix}${variant}" + fi done -if [ "${lapack_provider}" = "netlib-lapack" ] ; then - blas_provider="netlib-xblas" +if [ "${lapack_provider}" = "netlib-lapack" ]; then + blas_provider="netlib-xblas" else - blas_provider="${lapack_provider}" + blas_provider="${lapack_provider}" fi -if [ -d "${SPACKDIR}" ] ; then - echo "Found a Spack installation, updating..." - # -C was introduced in git 1.8.5 (Q4 2013) - git -C "${SPACKDIR}" pull +if [ -d "${SPACKDIR}" ]; then + echo "Found a Spack installation, updating..." + # -C was introduced in git 1.8.5 (Q4 2013) + git -C "${SPACKDIR}" pull else - git clone --depth=1 https://github.com/spack/spack.git "${SPACKDIR}" + git clone --depth=1 https://github.com/spack/spack.git "${SPACKDIR}" fi SPACK=$(PATH="${SPACKDIR}/bin:${PATH}" command -v spack) SPACK_ARGS="" -if [ ${no_check_certificates} -eq 1 ] ; then - SPACK_ARGS="${SPACK_ARGS} --insecure" +if [ ${no_check_certificates} -eq 1 ]; then + SPACK_ARGS="${SPACK_ARGS} --insecure" fi echo "Let 'spack' detect system-packages to be used..." @@ -412,31 +413,31 @@ echo "Let 'spack' detect system-packages to be used..." # also, if there is a user/system-provided Spack, do not run this "${SPACK}" external find --scope site - # workaround Spack issue https://github.com/spack/spack/issues/4635 +# workaround Spack issue https://github.com/spack/spack/issues/4635 "${SPACK}" config --scope site rm packages:cmake # TODO: if there is already a Spack environment/command avvailable, we should setup a chained installation instead echo "Installing non-MPI environment..." -if [ ! -d "${SPACKENVDIR}/ssmp" ] ; then - "${SPACK}" env create -d "${SPACKENVDIR}/ssmp" +if [ ! -d "${SPACKENVDIR}/ssmp" ]; then + "${SPACK}" env create -d "${SPACKENVDIR}/ssmp" else - echo "Existing environment found, reconfiguring..." + echo "Existing environment found, reconfiguring..." fi configure_spack_env "ssmp" \ - "config:build_language:C.UTF-8" \ - "packages:all:providers:fftw-api:[${fftw_provider}]" \ - "packages:all:providers:blas:[${blas_provider}]" \ - "packages:all:providers:lapack:[${lapack_provider}]" \ - "packages:cp2k:variants:${cp2k_variants} ~mpi" \ - "packages:fftw:variants:+openmp" \ - "packages:openblas:variants:threads=openmp" + "config:build_language:C.UTF-8" \ + "packages:all:providers:fftw-api:[${fftw_provider}]" \ + "packages:all:providers:blas:[${blas_provider}]" \ + "packages:all:providers:lapack:[${lapack_provider}]" \ + "packages:cp2k:variants:${cp2k_variants} ~mpi" \ + "packages:fftw:variants:+openmp" \ + "packages:openblas:variants:threads=openmp" -if [ "${mpi_provider}" = none ] ; then - # avoid installing MPI also in the non-MPI environment if fftw is pulled-in - # note: fftw builds 2 sets of libs with +mpi - configure_spack_env "ssmp" \ - "packages:fftw:variants:+openmp ~mpi" +if [ "${mpi_provider}" = none ]; then + # avoid installing MPI also in the non-MPI environment if fftw is pulled-in + # note: fftw builds 2 sets of libs with +mpi + configure_spack_env "ssmp" \ + "packages:fftw:variants:+openmp ~mpi" fi echo "Installing packages..." @@ -444,28 +445,28 @@ echo "Installing packages..." echo "Generating environment setup file..." "${SPACK}" --env-dir "${SPACKENVDIR}/ssmp" build-env --dump "${SPACKENVDIR}/ssmp/setup" cp2k@master -- -if [ "${mpi_provider}" != none ] ; then - echo "Installing MPI environment..." - if [ ! -d "${SPACKENVDIR}/psmp" ] ; then - "${SPACK}" env create -d "${SPACKENVDIR}/psmp" - else - echo "Existing environment found, reconfiguring..." - fi - configure_spack_env "psmp" \ - "config:build_language:C.UTF-8" \ - "packages:all:providers:fftw-api:[${fftw_provider}]" \ - "packages:all:providers:blas:[${lapack_provider}]" \ - "packages:all:providers:lapack:[${blas_provider}]" \ - "packages:all:providers:mpi:[${mpi_provider}]" \ - "packages:all:providers:scalapack:[${scalapack_provider}]" \ - "packages:cp2k:variants:${cp2k_variants} ${cp2k_variants_mpi_only} ${cp2k_variants_mpi_only}" \ - "packages:fftw:variants:+openmp" \ - "packages:openblas:variants:threads=openmp" +if [ "${mpi_provider}" != none ]; then + echo "Installing MPI environment..." + if [ ! -d "${SPACKENVDIR}/psmp" ]; then + "${SPACK}" env create -d "${SPACKENVDIR}/psmp" + else + echo "Existing environment found, reconfiguring..." + fi + configure_spack_env "psmp" \ + "config:build_language:C.UTF-8" \ + "packages:all:providers:fftw-api:[${fftw_provider}]" \ + "packages:all:providers:blas:[${lapack_provider}]" \ + "packages:all:providers:lapack:[${blas_provider}]" \ + "packages:all:providers:mpi:[${mpi_provider}]" \ + "packages:all:providers:scalapack:[${scalapack_provider}]" \ + "packages:cp2k:variants:${cp2k_variants} ${cp2k_variants_mpi_only} ${cp2k_variants_mpi_only}" \ + "packages:fftw:variants:+openmp" \ + "packages:openblas:variants:threads=openmp" - echo "Installing packages..." - "${SPACK}" --env-dir "${SPACKENVDIR}/psmp" dev-build -j "${nprocs}" -d "${CP2KDIR}" --quiet --until edit cp2k@master - echo "Generating environment setup file..." - "${SPACK}" --env-dir "${SPACKENVDIR}/psmp" build-env --dump "${SPACKENVDIR}/psmp/setup" cp2k@master -- + echo "Installing packages..." + "${SPACK}" --env-dir "${SPACKENVDIR}/psmp" dev-build -j "${nprocs}" -d "${CP2KDIR}" --quiet --until edit cp2k@master + echo "Generating environment setup file..." + "${SPACK}" --env-dir "${SPACKENVDIR}/psmp" build-env --dump "${SPACKENVDIR}/psmp/setup" cp2k@master -- fi # shellcheck disable=SC2016 @@ -476,10 +477,10 @@ echo "To build the single-node implementation of CP2K, run:" echo "" echo " source \"${SPACKENVDIR}/ssmp/setup\"" echo " make -j${nprocs} ARCH=${ARCH} VERSION=ssmp" -if [ "${mpi_provider}" != none ] ; then - echo "" - echo "To build the multi-node (MPI) implementation of CP2K, run:" - echo "" - echo " source \"${SPACKENVDIR}/psmp/setup\"" - echo " make -j${nprocs} ARCH=${ARCH} VERSION=psmp" +if [ "${mpi_provider}" != none ]; then + echo "" + echo "To build the multi-node (MPI) implementation of CP2K, run:" + echo "" + echo " source \"${SPACKENVDIR}/psmp/setup\"" + echo " make -j${nprocs} ARCH=${ARCH} VERSION=psmp" fi diff --git a/tools/toolchain/install_cp2k_toolchain.sh b/tools/toolchain/install_cp2k_toolchain.sh index 0aaf43da9d..896ed08f41 100755 --- a/tools/toolchain/install_cp2k_toolchain.sh +++ b/tools/toolchain/install_cp2k_toolchain.sh @@ -44,7 +44,7 @@ source "${SCRIPTDIR}"/tool_kit.sh # Documentation # ------------------------------------------------------------------------ show_help() { - cat<&- 2>&-) ; then - # check if we are dealing with openmpi, mpich or intelmpi - if (mpirun --version 2>&1 | grep -s -q "HYDRA") ; then - echo "MPI is detected and it appears to be MPICH" - export MPI_MODE=mpich - elif (mpirun --version 2>&1 | grep -s -q "Open MPI") ; then - echo "MPI is detected and it appears to be OpenMPI" - export MPI_MODE=openmpi - elif (mpirun --version 2>&1 | grep -s -q "Intel") ; then - echo "MPI is detected and it appears to be Intel MPI" - with_gcc=__DONTUSE__ - export MPI_MODE=intelmpi - else - # default to mpich - export MPI_MODE=mpich - fi +if (command -v mpirun >&- 2>&-); then + # check if we are dealing with openmpi, mpich or intelmpi + if (mpirun --version 2>&1 | grep -s -q "HYDRA"); then + echo "MPI is detected and it appears to be MPICH" + export MPI_MODE=mpich + elif (mpirun --version 2>&1 | grep -s -q "Open MPI"); then + echo "MPI is detected and it appears to be OpenMPI" + export MPI_MODE=openmpi + elif (mpirun --version 2>&1 | grep -s -q "Intel"); then + echo "MPI is detected and it appears to be Intel MPI" + with_gcc=__DONTUSE__ + export MPI_MODE=intelmpi + else + # default to mpich + export MPI_MODE=mpich + fi else - report_warning $LINENO "No MPI installation detected on your system. Ignore this message if you are using Cray Linux Environment" - export MPI_MODE=no + report_warning $LINENO "No MPI installation detected on your system. Ignore this message if you are using Cray Linux Environment" + export MPI_MODE=no fi # number of processors to use @@ -346,295 +346,296 @@ dry_run=__FALSE__ enable_tsan=__FALSE__ enable_gcc_master=__FALSE__ enable_libxsmm_master=__FALSE__ -if (command -v nvcc >&- 2>&-) ; then - echo "nvcc found, enabling CUDA by default" - enable_cuda=__TRUE__ - export GPUVER=no +if (command -v nvcc >&- 2>&-); then + echo "nvcc found, enabling CUDA by default" + enable_cuda=__TRUE__ + export GPUVER=no else - echo "nvcc not found, disabling CUDA by default" - enable_cuda=__FALSE__ - export GPUVER=no + echo "nvcc not found, disabling CUDA by default" + enable_cuda=__FALSE__ + export GPUVER=no fi # default for libint export LIBINT_LMAX=5 # defaults for CRAY Linux Environment -if [ "$CRAY_LD_LIBRARY_PATH" ] ; then - enable_cray=__TRUE__ - export FAST_MATH_MODE=cray - # Default MPI used by CLE is assumed to be MPICH, in any case - # don't use the installers for the MPI libraries - with_mpich="__DONTUSE__" - with_openmpi="__DONTUSE__" - with_intelmpi="__DONTUSE__" - export MPI_MODE=mpich - # set default value for some installers appropriate for CLE - with_gcc="__DONTUSE__" - with_fftw="__SYSTEM__" - with_scalapack="__DONTUSE__" +if [ "$CRAY_LD_LIBRARY_PATH" ]; then + enable_cray=__TRUE__ + export FAST_MATH_MODE=cray + # Default MPI used by CLE is assumed to be MPICH, in any case + # don't use the installers for the MPI libraries + with_mpich="__DONTUSE__" + with_openmpi="__DONTUSE__" + with_intelmpi="__DONTUSE__" + export MPI_MODE=mpich + # set default value for some installers appropriate for CLE + with_gcc="__DONTUSE__" + with_fftw="__SYSTEM__" + with_scalapack="__DONTUSE__" else - enable_cray=__FALSE__ + enable_cray=__FALSE__ fi - # ------------------------------------------------------------------------ # parse user options # ------------------------------------------------------------------------ -while [ $# -ge 1 ] ; do - case $1 in - -j) - shift - export NPROCS=$1 - ;; - --no-check-certificate) - export DOWNLOADER_FLAGS="-n" - ;; - --install-all) - # set all package to __INSTALL__ status - for ii in $package_list ; do - eval with_${ii}=__INSTALL__ - done - # default mpi-mode to MPICH - export MPI_MODE=mpich - ;; - --mpi-mode=*) - user_input="${1#*=}" - case "$user_input" in - mpich) - export MPI_MODE=mpich - ;; - openmpi) - export MPI_MODE=openmpi - ;; - intelmpi) - export MPI_MODE=intelmpi - ;; - no) - export MPI_MODE=no - ;; - *) - report_error ${LINENO} \ - "--mpi-mode currently only supports openmpi, mpich, intelmpi and no as options" - exit 1 - ;; - esac - ;; - --math-mode=*) - user_input="${1#*=}" - case "$user_input" in - cray) - export FAST_MATH_MODE=cray - ;; - mkl) - export FAST_MATH_MODE=mkl - ;; - acml) - export FAST_MATH_MODE=acml - ;; - openblas) - export FAST_MATH_MODE=openblas - ;; - reflapack) - export FAST_MATH_MODE=reflapack - ;; - *) - report_error ${LINENO} \ - "--math-mode currently only supports mkl, acml, openblas and reflapack as options" - esac - ;; - --gpu-ver=*) - user_input="${1#*=}" - case "$user_input" in - K20X) - export GPUVER=K20X - ;; - K40) - export GPUVER=K40 - ;; - K80) - export GPUVER=K80 - ;; - P100) - export GPUVER=P100 - ;; - V100) - export GPUVER=V100 - ;; - no) - export GPUVER=no - ;; - *) - export GPUVER=no - report_error ${LINENO} \ - "--gpu-ver currently only supports K20X, K40, K80, P100, V100 and no as options" - exit 1 - esac - ;; - --libint-lmax=*) - user_input="${1#*=}" - export LIBINT_LMAX="$user_input" - ;; - --dry-run) - dry_run="__TRUE__" - ;; - --enable-tsan*) - enable_tsan=$(read_enable $1) - if [ $enable_tsan = "__INVALID__" ] ; then - report_error "invalid value for --enable-tsan, please use yes or no" - exit 1 - fi - ;; - --enable-gcc-master*) - enable_gcc_master=$(read_enable $1) - if [ $enable_gcc_master = "__INVALID__" ] ; then - report_error "invalid value for --enable-gcc-master, please use yes or no" - exit 1 - fi - ;; - --enable-libxsmm-master*) - enable_libxsmm_master=$(read_enable $1) - if [ $enable_libxsmm_master = "__INVALID__" ] ; then - report_error "invalid value for --enable-libxsmm-master, please use yes or no" - exit 1 - fi - ;; - --enable-cuda*) - enable_cuda=$(read_enable $1) - if [ $enable_cuda = "__INVALID__" ] ; then - report_error "invalid value for --enable-cuda, please use yes or no" - exit 1 - fi - ;; - --enable-cray*) - enable_cray=$(read_enable $1) - if [ $enable_cray = "__INVALID__" ] ; then - report_error "invalid value for --enable-cray, please use yes or no" - exit 1 - fi - ;; - --with-gcc*) - with_gcc=$(read_with $1) - ;; - --with-cmake*) - with_cmake=$(read_with $1) - ;; - --with-valgrind*) - with_valgrind=$(read_with $1) - ;; - --with-mpich*) - with_mpich=$(read_with $1) - if [ $with_mpich != __DONTUSE__ ] ; then - export MPI_MODE=mpich - fi - ;; - --with-openmpi*) - with_openmpi=$(read_with $1) - if [ $with_openmpi != __DONTUSE__ ] ; then - export MPI_MODE=openmpi - fi - ;; - --with-intelmpi*) - with_intelmpi=$(read_with $1) - if [ $with_intelmpi != __DONTUSE__ ] ; then - export MPI_MODE=intelmpi - fi - ;; - --with-libint*) - with_libint=$(read_with $1) - ;; - --with-libxc*) - with_libxc=$(read_with $1) - ;; - --with-fftw*) - with_fftw=$(read_with $1) - ;; - --with-reflapack*) - with_reflapack=$(read_with $1) - ;; - --with-mkl*) - with_mkl=$(read_with $1) - if [ $with_mkl != __DONTUSE__ ] ; then - export FAST_MATH_MODE=mkl - fi - ;; - --with-acml*) - with_acml=$(read_with $1) - if [ $with_acml != __DONTUSE__ ] ; then - export FAST_MATH_MODE=acml - fi - ;; - --with-openblas*) - with_openblas=$(read_with $1) - if [ $with_openblas != __DONTUSE__ ] ; then - export FAST_MATH_MODE=openblas - fi - ;; - --with-scalapack*) - with_scalapack=$(read_with $1) - ;; - --with-libsmm*) - with_libsmm=$(read_with $1) - ;; - --with-libxsmm*) - with_libxsmm=$(read_with $1) - ;; - --with-elpa*) - with_elpa=$(read_with $1) - ;; - --with-ptscotch*) - with_ptscotch=$(read_with $1) - ;; - --with-superlu*) - with_superlu=$(read_with $1) - ;; - --with-pexsi*) - with_pexsi=$(read_with $1) - ;; - --with-quip*) - with_quip=$(read_with $1) - ;; - --with-plumed*) - with_plumed=$(read_with $1) - ;; - --with-sirius*) - with_sirius=$(read_with $1) - ;; - --with-gsl*) - with_gsl=$(read_with $1) - ;; - --with-spglib*) - with_spglib=$(read_with $1) - ;; - --with-hdf5*) - with_hdf5=$(read_with $1) - ;; - --with-libvdwxc*) - with_libvdwxc=$(read_with $1) - ;; - --with-spfft*) - with_spfft=$(read_with $1) - ;; - --with-cosma*) - with_cosma=$(read_with $1) - ;; - --with-libvori*) - with_libvori=$(read_with $1) - ;; - --help*) - show_help - exit 0 - ;; - -h*) - show_help - exit 0 - ;; +while [ $# -ge 1 ]; do + case $1 in + -j) + shift + export NPROCS=$1 + ;; + --no-check-certificate) + export DOWNLOADER_FLAGS="-n" + ;; + --install-all) + # set all package to __INSTALL__ status + for ii in $package_list; do + eval with_${ii}=__INSTALL__ + done + # default mpi-mode to MPICH + export MPI_MODE=mpich + ;; + --mpi-mode=*) + user_input="${1#*=}" + case "$user_input" in + mpich) + export MPI_MODE=mpich + ;; + openmpi) + export MPI_MODE=openmpi + ;; + intelmpi) + export MPI_MODE=intelmpi + ;; + no) + export MPI_MODE=no + ;; *) - report_error "Unknown flag: $1" - exit 1 - ;; - esac - shift + report_error ${LINENO} \ + "--mpi-mode currently only supports openmpi, mpich, intelmpi and no as options" + exit 1 + ;; + esac + ;; + --math-mode=*) + user_input="${1#*=}" + case "$user_input" in + cray) + export FAST_MATH_MODE=cray + ;; + mkl) + export FAST_MATH_MODE=mkl + ;; + acml) + export FAST_MATH_MODE=acml + ;; + openblas) + export FAST_MATH_MODE=openblas + ;; + reflapack) + export FAST_MATH_MODE=reflapack + ;; + *) + report_error ${LINENO} \ + "--math-mode currently only supports mkl, acml, openblas and reflapack as options" + ;; + esac + ;; + --gpu-ver=*) + user_input="${1#*=}" + case "$user_input" in + K20X) + export GPUVER=K20X + ;; + K40) + export GPUVER=K40 + ;; + K80) + export GPUVER=K80 + ;; + P100) + export GPUVER=P100 + ;; + V100) + export GPUVER=V100 + ;; + no) + export GPUVER=no + ;; + *) + export GPUVER=no + report_error ${LINENO} \ + "--gpu-ver currently only supports K20X, K40, K80, P100, V100 and no as options" + exit 1 + ;; + esac + ;; + --libint-lmax=*) + user_input="${1#*=}" + export LIBINT_LMAX="$user_input" + ;; + --dry-run) + dry_run="__TRUE__" + ;; + --enable-tsan*) + enable_tsan=$(read_enable $1) + if [ $enable_tsan = "__INVALID__" ]; then + report_error "invalid value for --enable-tsan, please use yes or no" + exit 1 + fi + ;; + --enable-gcc-master*) + enable_gcc_master=$(read_enable $1) + if [ $enable_gcc_master = "__INVALID__" ]; then + report_error "invalid value for --enable-gcc-master, please use yes or no" + exit 1 + fi + ;; + --enable-libxsmm-master*) + enable_libxsmm_master=$(read_enable $1) + if [ $enable_libxsmm_master = "__INVALID__" ]; then + report_error "invalid value for --enable-libxsmm-master, please use yes or no" + exit 1 + fi + ;; + --enable-cuda*) + enable_cuda=$(read_enable $1) + if [ $enable_cuda = "__INVALID__" ]; then + report_error "invalid value for --enable-cuda, please use yes or no" + exit 1 + fi + ;; + --enable-cray*) + enable_cray=$(read_enable $1) + if [ $enable_cray = "__INVALID__" ]; then + report_error "invalid value for --enable-cray, please use yes or no" + exit 1 + fi + ;; + --with-gcc*) + with_gcc=$(read_with $1) + ;; + --with-cmake*) + with_cmake=$(read_with $1) + ;; + --with-valgrind*) + with_valgrind=$(read_with $1) + ;; + --with-mpich*) + with_mpich=$(read_with $1) + if [ $with_mpich != __DONTUSE__ ]; then + export MPI_MODE=mpich + fi + ;; + --with-openmpi*) + with_openmpi=$(read_with $1) + if [ $with_openmpi != __DONTUSE__ ]; then + export MPI_MODE=openmpi + fi + ;; + --with-intelmpi*) + with_intelmpi=$(read_with $1) + if [ $with_intelmpi != __DONTUSE__ ]; then + export MPI_MODE=intelmpi + fi + ;; + --with-libint*) + with_libint=$(read_with $1) + ;; + --with-libxc*) + with_libxc=$(read_with $1) + ;; + --with-fftw*) + with_fftw=$(read_with $1) + ;; + --with-reflapack*) + with_reflapack=$(read_with $1) + ;; + --with-mkl*) + with_mkl=$(read_with $1) + if [ $with_mkl != __DONTUSE__ ]; then + export FAST_MATH_MODE=mkl + fi + ;; + --with-acml*) + with_acml=$(read_with $1) + if [ $with_acml != __DONTUSE__ ]; then + export FAST_MATH_MODE=acml + fi + ;; + --with-openblas*) + with_openblas=$(read_with $1) + if [ $with_openblas != __DONTUSE__ ]; then + export FAST_MATH_MODE=openblas + fi + ;; + --with-scalapack*) + with_scalapack=$(read_with $1) + ;; + --with-libsmm*) + with_libsmm=$(read_with $1) + ;; + --with-libxsmm*) + with_libxsmm=$(read_with $1) + ;; + --with-elpa*) + with_elpa=$(read_with $1) + ;; + --with-ptscotch*) + with_ptscotch=$(read_with $1) + ;; + --with-superlu*) + with_superlu=$(read_with $1) + ;; + --with-pexsi*) + with_pexsi=$(read_with $1) + ;; + --with-quip*) + with_quip=$(read_with $1) + ;; + --with-plumed*) + with_plumed=$(read_with $1) + ;; + --with-sirius*) + with_sirius=$(read_with $1) + ;; + --with-gsl*) + with_gsl=$(read_with $1) + ;; + --with-spglib*) + with_spglib=$(read_with $1) + ;; + --with-hdf5*) + with_hdf5=$(read_with $1) + ;; + --with-libvdwxc*) + with_libvdwxc=$(read_with $1) + ;; + --with-spfft*) + with_spfft=$(read_with $1) + ;; + --with-cosma*) + with_cosma=$(read_with $1) + ;; + --with-libvori*) + with_libvori=$(read_with $1) + ;; + --help*) + show_help + exit 0 + ;; + -h*) + show_help + exit 0 + ;; + *) + report_error "Unknown flag: $1" + exit 1 + ;; + esac + shift done # consolidate settings after user input @@ -643,123 +644,123 @@ export ENABLE_CUDA=$enable_cuda export ENABLE_CRAY=$enable_cray [ "$enable_gcc_master" = "__TRUE__" ] && export gcc_ver=master [ "$enable_libxsmm_master" = "__TRUE__" ] && export libxsmm_ver=master -[ "$with_valgrind" != "__DONTUSE__" ] && export ENABLE_VALGRIND="__TRUE__" +[ "$with_valgrind" != "__DONTUSE__" ] && export ENABLE_VALGRIND="__TRUE__" # ------------------------------------------------------------------------ # Check and solve known conflicts before installations proceed # ------------------------------------------------------------------------ # GCC thread sanitizer conflicts -if [ $ENABLE_TSAN = "__TRUE__" ] ; then - if [ "$with_openblas" != "__DONTUSE__" ] ; then - echo "TSAN is enabled, cannot use openblas, we will use reflapack instead" - [ "$with_reflapack" = "__DONTUSE__" ] && with_reflapack="__INSTALL__" - export FAST_MATH_MODE=reflapack - fi - echo "TSAN is enabled, cannot use libsmm" - with_libsmm="__DONTUSE__" +if [ $ENABLE_TSAN = "__TRUE__" ]; then + if [ "$with_openblas" != "__DONTUSE__" ]; then + echo "TSAN is enabled, cannot use openblas, we will use reflapack instead" + [ "$with_reflapack" = "__DONTUSE__" ] && with_reflapack="__INSTALL__" + export FAST_MATH_MODE=reflapack + fi + echo "TSAN is enabled, cannot use libsmm" + with_libsmm="__DONTUSE__" fi # valgrind conflicts -if [ "$ENABLE_VALGRIND" = "__TRUE__" ] ; then - if [ "$with_reflapack" = "__DONTUSE__" ] ; then - echo "reflapack is automatically installed when valgrind is enabled" - with_reflapack="__INSTALL__" - fi +if [ "$ENABLE_VALGRIND" = "__TRUE__" ]; then + if [ "$with_reflapack" = "__DONTUSE__" ]; then + echo "reflapack is automatically installed when valgrind is enabled" + with_reflapack="__INSTALL__" + fi fi # mpi library conflicts -if [ $MPI_MODE = no ] ; then - if [ "$with_scalapack" != "__DONTUSE__" ] ; then - echo "Not using MPI, so scalapack is disabled." - with_scalapack="__DONTUSE__" - fi - if [ "$with_elpa" != "__DONTUSE__" ] ; then - echo "Not using MPI, so ELPA is disabled." - with_elpa="__DONTUSE__" - fi - if [ "$with_pexi" != "__DONTUSE__" ] ; then - echo "Not using MPI, so PEXSI is disabled." - with_pexsi="__DONTUSE__" - fi - if [ "$with_sirius" != "__DONTUSE__" ] ; then - echo "Not using MPI, so sirius is disabled" - with_sirius="__DONTUSE__" - fi - if [ "$with_spfft" != "__DONTUSE__" ] ; then - echo "Not using MPI, so spfft is disabled" - with_spfft="__DONTUSE__" - fi - if [ "$with_spla" != "__DONTUSE__" ] ; then - echo "Not using MPI, so spla is disabled" - with_spla="__DONTUSE__" - fi - if [ "$with_cosma" != "__DONTUSE__" ] ; then - echo "Not using MPI, so cosma is disabled" - with_cosma="__DONTUSE__" - fi +if [ $MPI_MODE = no ]; then + if [ "$with_scalapack" != "__DONTUSE__" ]; then + echo "Not using MPI, so scalapack is disabled." + with_scalapack="__DONTUSE__" + fi + if [ "$with_elpa" != "__DONTUSE__" ]; then + echo "Not using MPI, so ELPA is disabled." + with_elpa="__DONTUSE__" + fi + if [ "$with_pexi" != "__DONTUSE__" ]; then + echo "Not using MPI, so PEXSI is disabled." + with_pexsi="__DONTUSE__" + fi + if [ "$with_sirius" != "__DONTUSE__" ]; then + echo "Not using MPI, so sirius is disabled" + with_sirius="__DONTUSE__" + fi + if [ "$with_spfft" != "__DONTUSE__" ]; then + echo "Not using MPI, so spfft is disabled" + with_spfft="__DONTUSE__" + fi + if [ "$with_spla" != "__DONTUSE__" ]; then + echo "Not using MPI, so spla is disabled" + with_spla="__DONTUSE__" + fi + if [ "$with_cosma" != "__DONTUSE__" ]; then + echo "Not using MPI, so cosma is disabled" + with_cosma="__DONTUSE__" + fi else - # if gcc is installed, then mpi needs to be installed too - if [ "$with_gcc" = "__INSTALL__" ] ; then - echo "You have chosen to install GCC, therefore MPI libraries will have to be installed too" - with_openmpi="__INSTALL__" - with_mpich="__INSTALL__" - with_intelmpi="__DONTUSE__" - fi + # if gcc is installed, then mpi needs to be installed too + if [ "$with_gcc" = "__INSTALL__" ]; then + echo "You have chosen to install GCC, therefore MPI libraries will have to be installed too" + with_openmpi="__INSTALL__" + with_mpich="__INSTALL__" + with_intelmpi="__DONTUSE__" + fi fi # If CUDA is enabled, make sure the GPU version has been defined -if [ $ENABLE_CUDA = __TRUE__ ] ; then - if [ "$GPUVER" = no ] ; then - report_error "CUDA enabled, please choose GPU architecture to compile for with --gpu-ver" - exit 1 - fi +if [ $ENABLE_CUDA = __TRUE__ ]; then + if [ "$GPUVER" = no ]; then + report_error "CUDA enabled, please choose GPU architecture to compile for with --gpu-ver" + exit 1 + fi fi # PESXI and its dependencies -if [ "$with_pexsi" = "__DONTUSE__" ] ; then - if [ "$with_ptscotch" != "__DONTUSE__" ] ; then - echo "Not using PEXSI, so PT-Scotch is disabled." - with_ptscotch="__DONTUSE__" - fi - if [ "$with_superlu" != "__DONTUSE__" ] ; then - echo "Not using PEXSI, so SuperLU-DIST is disabled." - with_superlu="__DONTUSE__" - fi -elif [ "$with_pexsi" = "__INSTALL__" ] ; then - [ "$with_ptscotch" = "__DONTUSE__" ] && with_ptscotch="__INSTALL__" - [ "$with_superlu" = "__DONTUSE__" ] && with_superlu="__INSTALL__" +if [ "$with_pexsi" = "__DONTUSE__" ]; then + if [ "$with_ptscotch" != "__DONTUSE__" ]; then + echo "Not using PEXSI, so PT-Scotch is disabled." + with_ptscotch="__DONTUSE__" + fi + if [ "$with_superlu" != "__DONTUSE__" ]; then + echo "Not using PEXSI, so SuperLU-DIST is disabled." + with_superlu="__DONTUSE__" + fi +elif [ "$with_pexsi" = "__INSTALL__" ]; then + [ "$with_ptscotch" = "__DONTUSE__" ] && with_ptscotch="__INSTALL__" + [ "$with_superlu" = "__DONTUSE__" ] && with_superlu="__INSTALL__" else - if [ "$with_ptscotch" = "__DONTUSE__" ] ; then - report_error "For PEXSI to work you need a working PT-Scotch library use --with-ptscotch option to specify if you wish to install the library or specify its location." - exit 1 - fi - if [ "$with_superlu" = "__DONTUSE__" ] ; then - report_error "For PEXSI to work you need a working SuperLU-DIST library use --with-superlu option to specify if you wish to install the library or specify its location." - exit 1 - fi + if [ "$with_ptscotch" = "__DONTUSE__" ]; then + report_error "For PEXSI to work you need a working PT-Scotch library use --with-ptscotch option to specify if you wish to install the library or specify its location." + exit 1 + fi + if [ "$with_superlu" = "__DONTUSE__" ]; then + report_error "For PEXSI to work you need a working SuperLU-DIST library use --with-superlu option to specify if you wish to install the library or specify its location." + exit 1 + fi fi # spglib and libvori require cmake. -if [ "$with_spglib" = "__INSTALL__" ] || [ "$with_libvori" = "__INSTALL__" ] ; then - [ "$with_cmake" = "__DONTUSE__" ] && with_cmake="__INSTALL__" +if [ "$with_spglib" = "__INSTALL__" ] || [ "$with_libvori" = "__INSTALL__" ]; then + [ "$with_cmake" = "__DONTUSE__" ] && with_cmake="__INSTALL__" fi # SIRIUS dependencies. Remove the gsl library from the dependencies if SIRIUS is not activated -if [ "$with_sirius" = "__INSTALL__" ] ; then - [ "$with_spfft" = "__DONTUSE__" ] && with_spfft="__INSTALL__" - [ "$with_gsl" = "__DONTUSE__" ] && with_gsl="__INSTALL__" - [ "$with_libxc" = "__DONTUSE__" ] && with_libxc="__INSTALL__" - [ "$with_fftw" = "__DONTUSE__" ] && with_fftw="__INSTALL__" - [ "$with_spglib" = "__DONTUSE__" ] && with_spglib="__INSTALL__" - [ "$with_hdf5" = "__DONTUSE__" ] && with_hdf5="__INSTALL__" - [ "$with_libvdwxc" = "__DONTUSE__" ] && with_libvdwxc="__INSTALL__" - [ "$with_cosma" = "__DONTUSE__" ] && with_cosma="__INSTALL__" +if [ "$with_sirius" = "__INSTALL__" ]; then + [ "$with_spfft" = "__DONTUSE__" ] && with_spfft="__INSTALL__" + [ "$with_gsl" = "__DONTUSE__" ] && with_gsl="__INSTALL__" + [ "$with_libxc" = "__DONTUSE__" ] && with_libxc="__INSTALL__" + [ "$with_fftw" = "__DONTUSE__" ] && with_fftw="__INSTALL__" + [ "$with_spglib" = "__DONTUSE__" ] && with_spglib="__INSTALL__" + [ "$with_hdf5" = "__DONTUSE__" ] && with_hdf5="__INSTALL__" + [ "$with_libvdwxc" = "__DONTUSE__" ] && with_libvdwxc="__INSTALL__" + [ "$with_cosma" = "__DONTUSE__" ] && with_cosma="__INSTALL__" fi -if [ "$with_plumed" = "__INSTALL__" ] ; then - [ "$with_gsl" = "__DONTUSE__" ] && with_gsl="__INSTALL__" - [ "$with_fftw" = "__DONTUSE__" ] && with_fftw="__INSTALL__" +if [ "$with_plumed" = "__INSTALL__" ]; then + [ "$with_gsl" = "__DONTUSE__" ] && with_gsl="__INSTALL__" + [ "$with_fftw" = "__DONTUSE__" ] && with_fftw="__INSTALL__" fi # ------------------------------------------------------------------------ # Preliminaries @@ -776,7 +777,7 @@ export CP_LDFLAGS="-Wl,--enable-new-dtags" # ------------------------------------------------------------------------ # Start writing setup file # ------------------------------------------------------------------------ -cat < "$SETUPFILE" +cat << EOF > "$SETUPFILE" #!/bin/bash source "${SCRIPTDIR}/tool_kit.sh" export CP2K_TOOLCHAIN_OPTIONS="${TOOLCHAIN_OPTIONS}" @@ -785,79 +786,79 @@ EOF # ------------------------------------------------------------------------ # Special settings for CRAY Linux Environment (CLE) # ------------------------------------------------------------------------ -if [ "$ENABLE_CRAY" = "__TRUE__" ] ; then - echo "------------------------------------------------------------------------" - echo "CRAY Linux Environment (CLE) is detected" - echo "------------------------------------------------------------------------" - # add cray paths to system search path - export LIB_PATHS="CRAY_LD_LIBRARY_PATH ${LIB_PATHS}" - # set compilers to CLE wrappers - check_command cc - check_command ftn - check_command CC - export CC=cc - export FC=ftn - export F77=ftn - export F90=ftn - export CXX=CC - export MPICC=cc - export MPIFC=ftn - export MPIF77=ftn - export MPIF90=ftn - export MPICXX=CC - # CRAY libsci should contains core math libraries, scalapack - # doesn't need LDFLAGS or CFLAGS, nor do the one need to - # explicitly link the math and scalapack libraries, as all is - # taken care of by the cray compiler wrappers. - if [ "$with_scalapack" = "__DONTUSE__" ] ; then - export CP_DFLAGS="${CP_DFLAGS} IF_MPI(-D__SCALAPACK|)" - fi - case $MPI_MODE in - mpich) - if [ "$MPICH_DIR" ] ; then - cray_mpich_include_path="$MPICH_DIR/include" - cray_mpich_lib_path="$MPICH_DIR/lib" - export INCLUDE_PATHS="$INCLUDE_PATHS cray_mpich_include_path" - export LIB_PATHS="$LIB_PATHS cray_mpich_lib_path" - fi - if [ "$with_mpich" = "__DONTUSE__" ] ; then - add_include_from_paths MPI_CFLAGS "mpi.h" $INCLUDE_PATHS - add_include_from_paths MPI_LDFLAGS "libmpi.*" $LIB_PATHS - export MPI_CFLAGS - export MPI_LDFLAGS - export MPI_LIBS=" " - export CP_DFLAGS="${CP_DFLAGS} IF_MPI(-D__parallel -D__MPI_VERSION=3|)" - fi - ;; - openmpi) - if [ "$with_openmpi" = "__DONTUSE__" ] ; then - add_include_from_paths MPI_CFLAGS "mpi.h" $INCLUDE_PATHS - add_include_from_paths MPI_LDFLAGS "libmpi.*" $LIB_PATHS - export MPI_CFLAGS - export MPI_LDFLAGS - export MPI_LIBS="-lmpi -lmpi_cxx" - export CP_DFLAGS="${CP_DFLAGS} IF_MPI(-D__parallel -D__MPI_VERSION=3|)" - fi - ;; - intelmpi) - if [ "$with_intelmpi" = "__DONTUSE__" ] ; then - with_gcc=__DONTUSE__ - add_include_from_paths MPI_CFLAGS "mpi.h" $INCLUDE_PATHS - add_include_from_paths MPI_LDFLAGS "libmpi.*" $LIB_PATHS - export MPI_CFLAGS - export MPI_LDFLAGS - export MPI_LIBS="-lmpi -lmpi_cxx" - export CP_DFLAGS="${CP_DFLAGS} IF_MPI(-D__parallel -D__MPI_VERSION=3|)" - fi - ;; - esac - check_lib -lz - check_lib -ldl - export CRAY_EXTRA_LIBS="-lz -ldl" - # the space is intentional, so that the variable is non-empty and - # can pass require_env checks - export SCALAPACK_LDFLAGS=" " - export SCALAPACK_LIBS=" " +if [ "$ENABLE_CRAY" = "__TRUE__" ]; then + echo "------------------------------------------------------------------------" + echo "CRAY Linux Environment (CLE) is detected" + echo "------------------------------------------------------------------------" + # add cray paths to system search path + export LIB_PATHS="CRAY_LD_LIBRARY_PATH ${LIB_PATHS}" + # set compilers to CLE wrappers + check_command cc + check_command ftn + check_command CC + export CC=cc + export FC=ftn + export F77=ftn + export F90=ftn + export CXX=CC + export MPICC=cc + export MPIFC=ftn + export MPIF77=ftn + export MPIF90=ftn + export MPICXX=CC + # CRAY libsci should contains core math libraries, scalapack + # doesn't need LDFLAGS or CFLAGS, nor do the one need to + # explicitly link the math and scalapack libraries, as all is + # taken care of by the cray compiler wrappers. + if [ "$with_scalapack" = "__DONTUSE__" ]; then + export CP_DFLAGS="${CP_DFLAGS} IF_MPI(-D__SCALAPACK|)" + fi + case $MPI_MODE in + mpich) + if [ "$MPICH_DIR" ]; then + cray_mpich_include_path="$MPICH_DIR/include" + cray_mpich_lib_path="$MPICH_DIR/lib" + export INCLUDE_PATHS="$INCLUDE_PATHS cray_mpich_include_path" + export LIB_PATHS="$LIB_PATHS cray_mpich_lib_path" + fi + if [ "$with_mpich" = "__DONTUSE__" ]; then + add_include_from_paths MPI_CFLAGS "mpi.h" $INCLUDE_PATHS + add_include_from_paths MPI_LDFLAGS "libmpi.*" $LIB_PATHS + export MPI_CFLAGS + export MPI_LDFLAGS + export MPI_LIBS=" " + export CP_DFLAGS="${CP_DFLAGS} IF_MPI(-D__parallel -D__MPI_VERSION=3|)" + fi + ;; + openmpi) + if [ "$with_openmpi" = "__DONTUSE__" ]; then + add_include_from_paths MPI_CFLAGS "mpi.h" $INCLUDE_PATHS + add_include_from_paths MPI_LDFLAGS "libmpi.*" $LIB_PATHS + export MPI_CFLAGS + export MPI_LDFLAGS + export MPI_LIBS="-lmpi -lmpi_cxx" + export CP_DFLAGS="${CP_DFLAGS} IF_MPI(-D__parallel -D__MPI_VERSION=3|)" + fi + ;; + intelmpi) + if [ "$with_intelmpi" = "__DONTUSE__" ]; then + with_gcc=__DONTUSE__ + add_include_from_paths MPI_CFLAGS "mpi.h" $INCLUDE_PATHS + add_include_from_paths MPI_LDFLAGS "libmpi.*" $LIB_PATHS + export MPI_CFLAGS + export MPI_LDFLAGS + export MPI_LIBS="-lmpi -lmpi_cxx" + export CP_DFLAGS="${CP_DFLAGS} IF_MPI(-D__parallel -D__MPI_VERSION=3|)" + fi + ;; + esac + check_lib -lz + check_lib -ldl + export CRAY_EXTRA_LIBS="-lz -ldl" + # the space is intentional, so that the variable is non-empty and + # can pass require_env checks + export SCALAPACK_LDFLAGS=" " + export SCALAPACK_LIBS=" " fi # ------------------------------------------------------------------------ @@ -877,56 +878,56 @@ export CXXFLAGS=${CXXFLAGS:-"-O2 -g -Wno-error"} # Select the correct compute number based on the GPU architecture case $GPUVER in - K20X) - export ARCH_NUM=35 - ;; - K40) - export ARCH_NUM=35 - ;; - K80) - export ARCH_NUM=37 - ;; - P100) - export ARCH_NUM=60 - ;; - V100) - export ARCH_NUM=70 - ;; - no) - export ARCH_NUM=no - ;; - *) - report_error ${LINENO} \ - "--gpu-ver currently only supports K20X, K40, K80, P100, V100 as options" + K20X) + export ARCH_NUM=35 + ;; + K40) + export ARCH_NUM=35 + ;; + K80) + export ARCH_NUM=37 + ;; + P100) + export ARCH_NUM=60 + ;; + V100) + export ARCH_NUM=70 + ;; + no) + export ARCH_NUM=no + ;; + *) + report_error ${LINENO} \ + "--gpu-ver currently only supports K20X, K40, K80, P100, V100 as options" + ;; esac write_toolchain_env "${INSTALLDIR}" # write toolchain config echo "tool_list=\"${tool_list}\"" > "${INSTALLDIR}"/toolchain.conf -for ii in $package_list ; do - install_mode="$(eval echo \${with_${ii}})" - echo "with_${ii}=\"${install_mode}\"" >> "${INSTALLDIR}"/toolchain.conf +for ii in $package_list; do + install_mode="$(eval echo \${with_${ii}})" + echo "with_${ii}=\"${install_mode}\"" >> "${INSTALLDIR}"/toolchain.conf done - # ------------------------------------------------------------------------ # Build packages unless dry-run mode is enabled. # ------------------------------------------------------------------------ -if [ "$dry_run" == "__TRUE__" ] ; then - echo "Wrote only configuration files (--dry-run)." +if [ "$dry_run" == "__TRUE__" ]; then + echo "Wrote only configuration files (--dry-run)." else - ./scripts/stage0/install_stage0.sh - ./scripts/stage1/install_stage1.sh - ./scripts/stage2/install_stage2.sh - ./scripts/stage3/install_stage3.sh - ./scripts/stage4/install_stage4.sh - ./scripts/stage5/install_stage5.sh - ./scripts/stage6/install_stage6.sh - ./scripts/stage7/install_stage7.sh - ./scripts/stage8/install_stage8.sh - # Stage 9 is reserved for DBCSR. - ./scripts/generate_arch_files.sh + ./scripts/stage0/install_stage0.sh + ./scripts/stage1/install_stage1.sh + ./scripts/stage2/install_stage2.sh + ./scripts/stage3/install_stage3.sh + ./scripts/stage4/install_stage4.sh + ./scripts/stage5/install_stage5.sh + ./scripts/stage6/install_stage6.sh + ./scripts/stage7/install_stage7.sh + ./scripts/stage8/install_stage8.sh + # Stage 9 is reserved for DBCSR. + ./scripts/generate_arch_files.sh fi #EOF diff --git a/tools/toolchain/install_requirements.sh b/tools/toolchain/install_requirements.sh index 0a46ff9abd..e3ce685ce4 100755 --- a/tools/toolchain/install_requirements.sh +++ b/tools/toolchain/install_requirements.sh @@ -2,22 +2,22 @@ # author: Ole Schuett -if (( $# != 1 )) ; then - echo "Usage: install_requirements.sh " - exit 1 +if (($# != 1)); then + echo "Usage: install_requirements.sh " + exit 1 fi BASE_IMAGE=$1 -if [[ ${BASE_IMAGE} == ubuntu* ]] ; then - ./install_requirements_ubuntu.sh +if [[ ${BASE_IMAGE} == ubuntu* ]]; then + ./install_requirements_ubuntu.sh -elif [[ ${BASE_IMAGE} == fedora* ]] ; then - ./install_requirements_fedora.sh +elif [[ ${BASE_IMAGE} == fedora* ]]; then + ./install_requirements_fedora.sh else - echo "Unknown base image: ${BASE_IMAGE}" - exit 1 + echo "Unknown base image: ${BASE_IMAGE}" + exit 1 fi #EOF diff --git a/tools/toolchain/install_requirements_fedora.sh b/tools/toolchain/install_requirements_fedora.sh index 7a75d86833..f5dbad097e 100755 --- a/tools/toolchain/install_requirements_fedora.sh +++ b/tools/toolchain/install_requirements_fedora.sh @@ -6,29 +6,29 @@ echo "Installing Fedora packages..." -dnf -qy install \ - autoconf \ - autogen \ - automake \ - bzip2 \ - ca-certificates \ - diffutils \ - g++ \ - git \ - less \ - libtool \ - make \ - nano \ - patch \ - perl-open \ - perl-FindBin \ - pkg-config \ - python3 \ - unzip \ - vim-common \ - wget \ - which \ - zlib-devel +dnf -qy install \ + autoconf \ + autogen \ + automake \ + bzip2 \ + ca-certificates \ + diffutils \ + g++ \ + git \ + less \ + libtool \ + make \ + nano \ + patch \ + perl-open \ + perl-FindBin \ + pkg-config \ + python3 \ + unzip \ + vim-common \ + wget \ + which \ + zlib-devel dnf clean -q all diff --git a/tools/toolchain/install_requirements_ubuntu.sh b/tools/toolchain/install_requirements_ubuntu.sh index 83987407d5..fd6b5cd698 100755 --- a/tools/toolchain/install_requirements_ubuntu.sh +++ b/tools/toolchain/install_requirements_ubuntu.sh @@ -12,26 +12,26 @@ export DEBCONF_NONINTERACTIVE_SEEN=true apt-get update -qq apt-get install -qq --no-install-recommends \ - autoconf \ - autogen \ - automake \ - autotools-dev \ - bzip2 \ - ca-certificates \ - g++ \ - git \ - less \ - libtool \ - libtool-bin \ - make \ - nano \ - patch \ - pkg-config \ - python3 \ - unzip \ - wget \ - xxd \ - zlib1g-dev + autoconf \ + autogen \ + automake \ + autotools-dev \ + bzip2 \ + ca-certificates \ + g++ \ + git \ + less \ + libtool \ + libtool-bin \ + make \ + nano \ + patch \ + pkg-config \ + python3 \ + unzip \ + wget \ + xxd \ + zlib1g-dev rm -rf /var/lib/apt/lists/* diff --git a/tools/toolchain/scripts/generate_arch_files.sh b/tools/toolchain/scripts/generate_arch_files.sh index 4746480028..962475b4b7 100755 --- a/tools/toolchain/scripts/generate_arch_files.sh +++ b/tools/toolchain/scripts/generate_arch_files.sh @@ -60,20 +60,20 @@ IEEE_EXCEPTIONS_DFLAGS="-D__HAS_IEEE_EXCEPTIONS" # check all of the above flags, filter out incompatible flags for the # current version of gcc in use -BASEFLAGS=$(allowed_gfortran_flags $BASEFLAGS) -OPT_FLAGS=$(allowed_gfortran_flags $OPT_FLAGS) -NOOPT_FLAGS=$(allowed_gfortran_flags $NOOPT_FLAGS) -FCDEB_FLAGS=$(allowed_gfortran_flags $FCDEB_FLAGS) +BASEFLAGS=$(allowed_gfortran_flags $BASEFLAGS) +OPT_FLAGS=$(allowed_gfortran_flags $OPT_FLAGS) +NOOPT_FLAGS=$(allowed_gfortran_flags $NOOPT_FLAGS) +FCDEB_FLAGS=$(allowed_gfortran_flags $FCDEB_FLAGS) FCDEB_FLAGS_DEBUG=$(allowed_gfortran_flags $FCDEB_FLAGS_DEBUG) -COVERAGE_FLAGS=$(allowed_gfortran_flags $COVERAGE_FLAGS) -WFLAGS_ERROR=$(allowed_gfortran_flags $WFLAGS_ERROR) -WFLAGS_WARN=$(allowed_gfortran_flags $WFLAGS_WARN) -WFLAGS_WARNALL=$(allowed_gfortran_flags $WFLAGS_WARNALL) +COVERAGE_FLAGS=$(allowed_gfortran_flags $COVERAGE_FLAGS) +WFLAGS_ERROR=$(allowed_gfortran_flags $WFLAGS_ERROR) +WFLAGS_WARN=$(allowed_gfortran_flags $WFLAGS_WARN) +WFLAGS_WARNALL=$(allowed_gfortran_flags $WFLAGS_WARNALL) # check if ieee_exeptions module is available for the current version # of gfortran being used -if ! (check_gfortran_module ieee_exceptions) ; then - IEEE_EXCEPTIONS_DFLAGS="" +if ! (check_gfortran_module ieee_exceptions); then + IEEE_EXCEPTIONS_DFLAGS="" fi # concatenate the above flags into WFLAGS, FCDEBFLAGS, DFLAGS and @@ -102,32 +102,32 @@ LIBS="${CP_LIBS} -lstdc++" # CUDA handling CUDA_LIBS="-lcudart -lnvrtc -lcuda -lcufft -lcublas -lrt IF_DEBUG(-lnvToolsExt|)" CUDA_DFLAGS="-D__GRID_CUDA -D__ACC -D__DBCSR_ACC -D__PW_CUDA IF_DEBUG(-D__CUDA_PROFILING|)" -if [ "${ENABLE_CUDA}" = __TRUE__ ] && [ "${GPUVER}" != no ] ; then - LIBS="${LIBS} IF_CUDA(${CUDA_LIBS}|)" - DFLAGS="IF_CUDA(${CUDA_DFLAGS}|) ${DFLAGS}" - NVFLAGS="-arch sm_${ARCH_NUM} -O3 -Xcompiler='-fopenmp' --std=c++11 \$(DFLAGS)" - check_command nvcc "cuda" - check_lib -lcudart "cuda" - check_lib -lnvrtc "cuda" - check_lib -lcuda "cuda" - check_lib -lcufft "cuda" - check_lib -lcublas "cuda" +if [ "${ENABLE_CUDA}" = __TRUE__ ] && [ "${GPUVER}" != no ]; then + LIBS="${LIBS} IF_CUDA(${CUDA_LIBS}|)" + DFLAGS="IF_CUDA(${CUDA_DFLAGS}|) ${DFLAGS}" + NVFLAGS="-arch sm_${ARCH_NUM} -O3 -Xcompiler='-fopenmp' --std=c++11 \$(DFLAGS)" + check_command nvcc "cuda" + check_lib -lcudart "cuda" + check_lib -lnvrtc "cuda" + check_lib -lcuda "cuda" + check_lib -lcufft "cuda" + check_lib -lcublas "cuda" - # Set include flags - CUDA_CFLAGS='' - add_include_from_paths CUDA_CFLAGS "cuda.h" $INCLUDE_PATHS - export CUDA_CFLAGS="${CUDA_CFLAGS}" - CFLAGS+=" ${CUDA_CFLAGS}" + # Set include flags + CUDA_CFLAGS='' + add_include_from_paths CUDA_CFLAGS "cuda.h" $INCLUDE_PATHS + export CUDA_CFLAGS="${CUDA_CFLAGS}" + CFLAGS+=" ${CUDA_CFLAGS}" - # Set LD-flags - CUDA_LDFLAGS='' - add_lib_from_paths CUDA_LDFLAGS "libcudart.*" $LIB_PATHS - add_lib_from_paths CUDA_LDFLAGS "libnvrtc.*" $LIB_PATHS - add_lib_from_paths CUDA_LDFLAGS "libcuda.*" $LIB_PATHS - add_lib_from_paths CUDA_LDFLAGS "libcufft.*" $LIB_PATHS - add_lib_from_paths CUDA_LDFLAGS "libcublas.*" $LIB_PATHS - export CUDA_LDFLAGS="${CUDA_LDFLAGS}" - LDFLAGS+=" ${CUDA_LDFLAGS}" + # Set LD-flags + CUDA_LDFLAGS='' + add_lib_from_paths CUDA_LDFLAGS "libcudart.*" $LIB_PATHS + add_lib_from_paths CUDA_LDFLAGS "libnvrtc.*" $LIB_PATHS + add_lib_from_paths CUDA_LDFLAGS "libcuda.*" $LIB_PATHS + add_lib_from_paths CUDA_LDFLAGS "libcufft.*" $LIB_PATHS + add_lib_from_paths CUDA_LDFLAGS "libcublas.*" $LIB_PATHS + export CUDA_LDFLAGS="${CUDA_LDFLAGS}" + LDFLAGS+=" ${CUDA_LDFLAGS}" fi # ------------------------- @@ -136,27 +136,27 @@ fi # generator for CP2K ARCH files gen_arch_file() { - # usage: gen_arch_file file_name flags - # - # If the flags are present they are assumed to be on, otherwise - # they switched off - require_env ARCH_FILE_TEMPLATE - local __filename=$1 - shift - local __flags=$@ - local __full_flag_list="MPI DEBUG CUDA WARNALL VALGRIND COVERAGE" - local __flag='' - for __flag in $__full_flag_list ; do - eval "local __${__flag}=off" - done - for __flag in $__flags ; do - eval "__${__flag}=on" - done - # generate initial arch file - cat $ARCH_FILE_TEMPLATE > $__filename - # add additional parts - if [ "$__CUDA" = "on" ] ; then - cat <> $__filename + # usage: gen_arch_file file_name flags + # + # If the flags are present they are assumed to be on, otherwise + # they switched off + require_env ARCH_FILE_TEMPLATE + local __filename=$1 + shift + local __flags=$@ + local __full_flag_list="MPI DEBUG CUDA WARNALL VALGRIND COVERAGE" + local __flag='' + for __flag in $__full_flag_list; do + eval "local __${__flag}=off" + done + for __flag in $__flags; do + eval "__${__flag}=on" + done + # generate initial arch file + cat $ARCH_FILE_TEMPLATE > $__filename + # add additional parts + if [ "$__CUDA" = "on" ]; then + cat << EOF >> $__filename # CXX = \${CC} CXXFLAGS = \${CXXFLAGS} -I\\\${CUDA_PATH}/include -std=c++11 -fopenmp @@ -165,25 +165,25 @@ GPUVER = \${GPUVER} NVCC = \${NVCC} NVFLAGS = \${NVFLAGS} EOF - fi - if [ "$__WARNALL" = "on" ] ; then - cat <> $__filename + fi + if [ "$__WARNALL" = "on" ]; then + cat << EOF >> $__filename # FCLOGPIPE = 2>&1 | tee \\\$(notdir \\\$<).warn EOF - fi - if [ "$with_gcc" != "__DONTUSE__" ] ; then - cat <> $__filename + fi + if [ "$with_gcc" != "__DONTUSE__" ]; then + cat << EOF >> $__filename # FYPPFLAGS = -n --line-marker-format=gfortran5 EOF - fi - # replace variable values in output file using eval - local __TMPL=$(cat $__filename) - eval "printf \"${__TMPL}\n\"" > $__filename - # pass this to parsers to replace all of the IF_XYZ statements - "${SCRIPTDIR}/parse_if.py" -i -f "${__filename}" $__flags - echo "Wrote ${INSTALLDIR}/arch/$__filename" + fi + # replace variable values in output file using eval + local __TMPL=$(cat $__filename) + eval "printf \"${__TMPL}\n\"" > $__filename + # pass this to parsers to replace all of the IF_XYZ statements + "${SCRIPTDIR}/parse_if.py" -i -f "${__filename}" $__flags + echo "Wrote ${INSTALLDIR}/arch/$__filename" } rm -f ${INSTALLDIR}/arch/local* @@ -192,32 +192,32 @@ gen_arch_file "local.ssmp" gen_arch_file "local.sdbg" DEBUG arch_vers="ssmp sdbg" -if [ "$MPI_MODE" != no ] ; then - gen_arch_file "local.psmp" MPI - gen_arch_file "local.pdbg" MPI DEBUG - gen_arch_file "local_warn.psmp" MPI WARNALL - gen_arch_file "local_coverage.pdbg" MPI COVERAGE - arch_vers="${arch_vers} psmp pdbg" +if [ "$MPI_MODE" != no ]; then + gen_arch_file "local.psmp" MPI + gen_arch_file "local.pdbg" MPI DEBUG + gen_arch_file "local_warn.psmp" MPI WARNALL + gen_arch_file "local_coverage.pdbg" MPI COVERAGE + arch_vers="${arch_vers} psmp pdbg" fi # cuda enabled arch files -if [ "$ENABLE_CUDA" = __TRUE__ ] ; then - gen_arch_file "local_cuda.ssmp" CUDA - gen_arch_file "local_cuda.sdbg" CUDA DEBUG - if [ "$MPI_MODE" != no ] ; then - gen_arch_file "local_cuda.psmp" CUDA MPI - gen_arch_file "local_cuda.pdbg" CUDA MPI DEBUG - gen_arch_file "local_cuda_warn.psmp" CUDA MPI WARNALL - gen_arch_file "local_coverage_cuda.pdbg" CUDA MPI COVERAGE - fi +if [ "$ENABLE_CUDA" = __TRUE__ ]; then + gen_arch_file "local_cuda.ssmp" CUDA + gen_arch_file "local_cuda.sdbg" CUDA DEBUG + if [ "$MPI_MODE" != no ]; then + gen_arch_file "local_cuda.psmp" CUDA MPI + gen_arch_file "local_cuda.pdbg" CUDA MPI DEBUG + gen_arch_file "local_cuda_warn.psmp" CUDA MPI WARNALL + gen_arch_file "local_coverage_cuda.pdbg" CUDA MPI COVERAGE + fi fi # valgrind enabled arch files -if [ "$ENABLE_VALGRIND" = __TRUE__ ] ; then - gen_arch_file "local_valgrind.ssmp" VALGRIND - if [ "$MPI_MODE" != no ] ; then - gen_arch_file "local_valgrind.psmp" VALGRIND MPI - fi +if [ "$ENABLE_VALGRIND" = __TRUE__ ]; then + gen_arch_file "local_valgrind.ssmp" VALGRIND + if [ "$MPI_MODE" != no ]; then + gen_arch_file "local_valgrind.psmp" VALGRIND MPI + fi fi cd "${ROOTDIR}" @@ -226,7 +226,7 @@ cd "${ROOTDIR}" # print out user instructions # ------------------------- -cat < "${BUILDDIR}/openblas_arch" +cat << EOF > "${BUILDDIR}/openblas_arch" export OPENBLAS_LIBCORE="${OPENBLAS_LIBCORE}" export OPENBLAS_ARCH="${OPENBLAS_ARCH}" EOF diff --git a/tools/toolchain/scripts/stage0/install_cmake.sh b/tools/toolchain/scripts/stage0/install_cmake.sh index fd43453ca4..eb0c221e83 100755 --- a/tools/toolchain/scripts/stage0/install_cmake.sh +++ b/tools/toolchain/scripts/stage0/install_cmake.sh @@ -16,57 +16,57 @@ source "${INSTALLDIR}"/toolchain.env cd "${BUILDDIR}" case "$with_cmake" in - __INSTALL__) - echo "==================== Installing CMake ====================" - pkg_install_dir="${INSTALLDIR}/cmake-${cmake_ver}" - install_lock_file="$pkg_install_dir/install_successful" - if verify_checksums "${install_lock_file}" ; then - echo "cmake-${cmake_ver} is already installed, skipping it." - else - if [ -f cmake-${cmake_ver}.tar.gz ] ; then - echo "cmake-${cmake_ver}.tar.gz is found" - else - download_pkg ${DOWNLOADER_FLAGS} ${cmake_sha256} \ - https://github.com/Kitware/CMake/releases/download/v${cmake_ver}/cmake-${cmake_ver}.tar.gz - fi - echo "Installing from scratch into ${pkg_install_dir}" - [ -d cmake-${cmake_ver} ] && rm -rf cmake-${cmake_ver} - tar -xzf cmake-${cmake_ver}.tar.gz - cd cmake-${cmake_ver} - # on ARCHER (cray system), ccmake cannot compile without - # -ldl, but was not sure how to link -ldl in the CMake - # bootstrap scripts. As GUI are not really needed, we just - # disable it here - if [ "$ENABLE_CRAY" = "__TRUE__" ] ; then - cp CMakeLists.txt CMakeLists.txt.orig - sed -i 's/option(BUILD_CursesDialog "Build the CMake Curses Dialog ccmake" ON)/option(BUILD_CursesDialog "Build the CMake Curses Dialog ccmake" OFF)/g' CMakeLists.txt - fi - ./bootstrap --prefix="${pkg_install_dir}" --parallel="${NPROCS}" -- -DCMAKE_USE_OPENSSL=OFF > configure.log 2>&1 - make -j $NPROCS > make.log 2>&1 - make install > install.log 2>&1 - cd .. - write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage0/$(basename ${SCRIPT_NAME})" - fi - ;; - __SYSTEM__) - echo "==================== Finding CMake from system paths ====================" - check_command cmake "cmake" - ;; - __DONTUSE__) - ;; - *) - echo "==================== Linking CMake to user paths ====================" - pkg_install_dir="$with_cmake" - check_dir "${with_cmake}/bin" - ;; + __INSTALL__) + echo "==================== Installing CMake ====================" + pkg_install_dir="${INSTALLDIR}/cmake-${cmake_ver}" + install_lock_file="$pkg_install_dir/install_successful" + if verify_checksums "${install_lock_file}"; then + echo "cmake-${cmake_ver} is already installed, skipping it." + else + if [ -f cmake-${cmake_ver}.tar.gz ]; then + echo "cmake-${cmake_ver}.tar.gz is found" + else + download_pkg ${DOWNLOADER_FLAGS} ${cmake_sha256} \ + https://github.com/Kitware/CMake/releases/download/v${cmake_ver}/cmake-${cmake_ver}.tar.gz + fi + echo "Installing from scratch into ${pkg_install_dir}" + [ -d cmake-${cmake_ver} ] && rm -rf cmake-${cmake_ver} + tar -xzf cmake-${cmake_ver}.tar.gz + cd cmake-${cmake_ver} + # on ARCHER (cray system), ccmake cannot compile without + # -ldl, but was not sure how to link -ldl in the CMake + # bootstrap scripts. As GUI are not really needed, we just + # disable it here + if [ "$ENABLE_CRAY" = "__TRUE__" ]; then + cp CMakeLists.txt CMakeLists.txt.orig + sed -i 's/option(BUILD_CursesDialog "Build the CMake Curses Dialog ccmake" ON)/option(BUILD_CursesDialog "Build the CMake Curses Dialog ccmake" OFF)/g' CMakeLists.txt + fi + ./bootstrap --prefix="${pkg_install_dir}" --parallel="${NPROCS}" -- -DCMAKE_USE_OPENSSL=OFF > configure.log 2>&1 + make -j $NPROCS > make.log 2>&1 + make install > install.log 2>&1 + cd .. + write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage0/$(basename ${SCRIPT_NAME})" + fi + ;; + __SYSTEM__) + echo "==================== Finding CMake from system paths ====================" + check_command cmake "cmake" + ;; + __DONTUSE__) ;; + + *) + echo "==================== Linking CMake to user paths ====================" + pkg_install_dir="$with_cmake" + check_dir "${with_cmake}/bin" + ;; esac -if [ "$with_cmake" != "__DONTUSE__" ] ; then - if [ "$with_cmake" != "__SYSTEM__" ] ; then - cat < "${BUILDDIR}/setup_cmake" +if [ "$with_cmake" != "__DONTUSE__" ]; then + if [ "$with_cmake" != "__SYSTEM__" ]; then + cat << EOF > "${BUILDDIR}/setup_cmake" prepend_path PATH "$pkg_install_dir/bin" EOF - cat "${BUILDDIR}/setup_cmake" >> $SETUPFILE - fi + cat "${BUILDDIR}/setup_cmake" >> $SETUPFILE + fi fi load "${BUILDDIR}/setup_cmake" diff --git a/tools/toolchain/scripts/stage0/install_gcc.sh b/tools/toolchain/scripts/stage0/install_gcc.sh index b35e168712..7138eaa6c0 100755 --- a/tools/toolchain/scripts/stage0/install_gcc.sh +++ b/tools/toolchain/scripts/stage0/install_gcc.sh @@ -6,8 +6,8 @@ gcc_ver="10.2.0" gcc_sha256="27e879dccc639cd7b0cc08ed575c1669492579529b53c9ff27b0b96265fa867d" patches=( - "${SCRIPT_DIR}/stage0/gcc-${gcc_ver}-cpp-__has_include.patch" - ) + "${SCRIPT_DIR}/stage0/gcc-${gcc_ver}-cpp-__has_include.patch" +) source "${SCRIPT_DIR}"/common_vars.sh source "${SCRIPT_DIR}"/tool_kit.sh @@ -24,113 +24,113 @@ TSANFLAGS="" cd "${BUILDDIR}" case "$with_gcc" in - __INSTALL__) - echo "==================== Installing GCC ====================" - pkg_install_dir="${INSTALLDIR}/gcc-${gcc_ver}" - install_lock_file="$pkg_install_dir/install_successful" - if verify_checksums "${install_lock_file}" ; then - echo "gcc-${gcc_ver} is already installed, skipping it." + __INSTALL__) + echo "==================== Installing GCC ====================" + pkg_install_dir="${INSTALLDIR}/gcc-${gcc_ver}" + install_lock_file="$pkg_install_dir/install_successful" + if verify_checksums "${install_lock_file}"; then + echo "gcc-${gcc_ver} is already installed, skipping it." + else + if [ "${gcc_ver}" == "master" ]; then + [ -d gcc-master ] && rm -rf gcc-master + svn checkout svn://gcc.gnu.org/svn/gcc/trunk gcc-master > svn-gcc.log 2>&1 + else + if [ -f gcc-${gcc_ver}.tar.gz ]; then + echo "gcc-${gcc_ver}.tar.gz is found" else - if [ "${gcc_ver}" == "master" ]; then - [ -d gcc-master ] && rm -rf gcc-master - svn checkout svn://gcc.gnu.org/svn/gcc/trunk gcc-master > svn-gcc.log 2>&1 - else - if [ -f gcc-${gcc_ver}.tar.gz ] ; then - echo "gcc-${gcc_ver}.tar.gz is found" - else - download_pkg ${DOWNLOADER_FLAGS} ${gcc_sha256} \ - "https://www.cp2k.org/static/downloads/gcc-${gcc_ver}.tar.gz" - fi - [ -d gcc-${gcc_ver} ] && rm -rf gcc-${gcc_ver} - tar -xzf gcc-${gcc_ver}.tar.gz - fi - echo "Installing GCC from scratch into ${pkg_install_dir}" - cd gcc-${gcc_ver} - - for patch in "${patches[@]}" ; do - patch -p1 < "${patch}" - done - - ./contrib/download_prerequisites > prereq.log 2>&1 - GCCROOT=${PWD} - mkdir obj - cd obj - ${GCCROOT}/configure --prefix="${pkg_install_dir}" \ - --libdir="${pkg_install_dir}/lib" \ - --enable-languages=c,c++,fortran \ - --disable-multilib --disable-bootstrap \ - --enable-lto \ - --enable-plugins \ - > configure.log 2>&1 - make -j $NPROCS \ - CFLAGS="-fPIC $CFLAGS"\ - CXXFLAGS="-fPIC $CXXFLAGS"\ - > make.log 2>&1 - make -j $NPROCS install > install.log 2>&1 - # thread sanitizer - if [ $ENABLE_TSAN = "__TRUE__" ] ; then - # now the tricky bit... we need to recompile in particular - # libgomp with -fsanitize=thread.. there is not configure - # option for this (as far as I know). we need to go in - # the build tree and recompile / reinstall with proper - # options... this is likely to break for later version of - # gcc, tested with 5.1.0 based on - # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55374#c10 - cd x86_64*/libgfortran - make clean > clean.log 2>&1 - make -j $NPROCS \ - CFLAGS="-std=gnu99 -g -O2 -fsanitize=thread " \ - FCFLAGS="-g -O2 -fsanitize=thread" \ - CXXFLAGS="-std=gnu99 -g -O2 -fsanitize=thread " \ - LDFLAGS="-B`pwd`/../libsanitizer/tsan/.libs/ -Wl,-rpath,`pwd`/../libsanitizer/tsan/.libs/ -fsanitize=thread" \ - > make.log 2>&1 - make install > install.log 2>&1 - cd ../libgomp - make clean > clean.log 2>&1 - make -j $NPROCS \ - CFLAGS="-std=gnu99 -g -O2 -fsanitize=thread " \ - FCFLAGS="-g -O2 -fsanitize=thread" \ - CXXFLAGS="-std=gnu99 -g -O2 -fsanitize=thread " \ - LDFLAGS="-B`pwd`/../libsanitizer/tsan/.libs/ -Wl,-rpath,`pwd`/../libsanitizer/tsan/.libs/ -fsanitize=thread" \ - > make.log 2>&1 - make install > install.log 2>&1 - cd $GCCROOT/obj/ - fi - cd ../.. - write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage0/$(basename ${SCRIPT_NAME})" + download_pkg ${DOWNLOADER_FLAGS} ${gcc_sha256} \ + "https://www.cp2k.org/static/downloads/gcc-${gcc_ver}.tar.gz" fi - GCC_CFLAGS="-I'${pkg_install_dir}/include'" - GCC_LDFLAGS="-L'${pkg_install_dir}/lib64' -L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib64' -Wl,-rpath='${pkg_install_dir}/lib64'" - ;; - __SYSTEM__) - echo "==================== Finding GCC from system paths ====================" - check_command gcc "gcc" - check_command g++ "gcc" - check_command gfortran "gcc" - add_include_from_paths -p GCC_CFLAGS "c++" $INCLUDE_PATHS - add_lib_from_paths GCC_LDFLAGS "libgfortran.*" $LIB_PATHS - ;; - __DONTUSE__) - ;; - *) - echo "==================== Linking GCC to user paths ====================" - pkg_install_dir="$with_gcc" - check_dir "${pkg_install_dir}/bin" - check_dir "${pkg_install_dir}/lib" - check_dir "${pkg_install_dir}/lib64" - check_dir "${pkg_install_dir}/include" - GCC_CFLAGS="-I'${pkg_install_dir}/include'" - GCC_LDFLAGS="-L'${pkg_install_dir}/lib64' -L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib64' -Wl,-rpath='${pkg_install_dir}/lib64'" - ;; + [ -d gcc-${gcc_ver} ] && rm -rf gcc-${gcc_ver} + tar -xzf gcc-${gcc_ver}.tar.gz + fi + echo "Installing GCC from scratch into ${pkg_install_dir}" + cd gcc-${gcc_ver} + + for patch in "${patches[@]}"; do + patch -p1 < "${patch}" + done + + ./contrib/download_prerequisites > prereq.log 2>&1 + GCCROOT=${PWD} + mkdir obj + cd obj + ${GCCROOT}/configure --prefix="${pkg_install_dir}" \ + --libdir="${pkg_install_dir}/lib" \ + --enable-languages=c,c++,fortran \ + --disable-multilib --disable-bootstrap \ + --enable-lto \ + --enable-plugins \ + > configure.log 2>&1 + make -j $NPROCS \ + CFLAGS="-fPIC $CFLAGS" \ + CXXFLAGS="-fPIC $CXXFLAGS" \ + > make.log 2>&1 + make -j $NPROCS install > install.log 2>&1 + # thread sanitizer + if [ $ENABLE_TSAN = "__TRUE__" ]; then + # now the tricky bit... we need to recompile in particular + # libgomp with -fsanitize=thread.. there is not configure + # option for this (as far as I know). we need to go in + # the build tree and recompile / reinstall with proper + # options... this is likely to break for later version of + # gcc, tested with 5.1.0 based on + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55374#c10 + cd x86_64*/libgfortran + make clean > clean.log 2>&1 + make -j $NPROCS \ + CFLAGS="-std=gnu99 -g -O2 -fsanitize=thread " \ + FCFLAGS="-g -O2 -fsanitize=thread" \ + CXXFLAGS="-std=gnu99 -g -O2 -fsanitize=thread " \ + LDFLAGS="-B$(pwd)/../libsanitizer/tsan/.libs/ -Wl,-rpath,$(pwd)/../libsanitizer/tsan/.libs/ -fsanitize=thread" \ + > make.log 2>&1 + make install > install.log 2>&1 + cd ../libgomp + make clean > clean.log 2>&1 + make -j $NPROCS \ + CFLAGS="-std=gnu99 -g -O2 -fsanitize=thread " \ + FCFLAGS="-g -O2 -fsanitize=thread" \ + CXXFLAGS="-std=gnu99 -g -O2 -fsanitize=thread " \ + LDFLAGS="-B$(pwd)/../libsanitizer/tsan/.libs/ -Wl,-rpath,$(pwd)/../libsanitizer/tsan/.libs/ -fsanitize=thread" \ + > make.log 2>&1 + make install > install.log 2>&1 + cd $GCCROOT/obj/ + fi + cd ../.. + write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage0/$(basename ${SCRIPT_NAME})" + fi + GCC_CFLAGS="-I'${pkg_install_dir}/include'" + GCC_LDFLAGS="-L'${pkg_install_dir}/lib64' -L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib64' -Wl,-rpath='${pkg_install_dir}/lib64'" + ;; + __SYSTEM__) + echo "==================== Finding GCC from system paths ====================" + check_command gcc "gcc" + check_command g++ "gcc" + check_command gfortran "gcc" + add_include_from_paths -p GCC_CFLAGS "c++" $INCLUDE_PATHS + add_lib_from_paths GCC_LDFLAGS "libgfortran.*" $LIB_PATHS + ;; + __DONTUSE__) ;; + + *) + echo "==================== Linking GCC to user paths ====================" + pkg_install_dir="$with_gcc" + check_dir "${pkg_install_dir}/bin" + check_dir "${pkg_install_dir}/lib" + check_dir "${pkg_install_dir}/lib64" + check_dir "${pkg_install_dir}/include" + GCC_CFLAGS="-I'${pkg_install_dir}/include'" + GCC_LDFLAGS="-L'${pkg_install_dir}/lib64' -L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib64' -Wl,-rpath='${pkg_install_dir}/lib64'" + ;; esac -if [ "$ENABLE_TSAN" = "__TRUE__" ] ; then - TSANFLAGS="-fsanitize=thread" +if [ "$ENABLE_TSAN" = "__TRUE__" ]; then + TSANFLAGS="-fsanitize=thread" else - TSANFLAGS="" + TSANFLAGS="" fi -if [ "$with_gcc" != "__DONTUSE__" ] ; then - if [ "$with_gcc" != "__SYSTEM__" ] ; then - cat < "${BUILDDIR}/setup_gcc" +if [ "$with_gcc" != "__DONTUSE__" ]; then + if [ "$with_gcc" != "__SYSTEM__" ]; then + cat << EOF > "${BUILDDIR}/setup_gcc" # needs full path for mpich/openmpi builds, triggers openblas bug export CC="${pkg_install_dir}/bin/gcc" export CXX="${pkg_install_dir}/bin/g++" @@ -146,9 +146,9 @@ prepend_path LIBRARY_PATH "${pkg_install_dir}/lib" prepend_path LIBRARY_PATH "${pkg_install_dir}/lib64" prepend_path CPATH "${pkg_install_dir}/include" EOF - cat "${BUILDDIR}/setup_gcc" >> $SETUPFILE - fi - cat <> "${BUILDDIR}/setup_gcc" + cat "${BUILDDIR}/setup_gcc" >> $SETUPFILE + fi + cat << EOF >> "${BUILDDIR}/setup_gcc" export GCC_CFLAGS="${GCC_CFLAGS}" export GCC_LDFLAGS="${GCC_LDFLAGS}" export TSANFLAGS="${TSANFLAGS}" @@ -162,7 +162,7 @@ cd "${ROOTDIR}" # this might need to be adjusted for the versions of the software # employed -cat <> ${INSTALLDIR}/lsan.supp +cat << EOF >> ${INSTALLDIR}/lsan.supp # known leak either related to mpi or scalapack (e.g. showing randomly for Fist/regtest-7-2/UO2-2x2x2-genpot_units.inp) leak:__cp_fm_types_MOD_cp_fm_write_unformatted # leak related to mpi or scalapack triggers sometimes for regtest-kp-2/cc2.inp @@ -188,7 +188,7 @@ race:__dbcsr_transformations_MOD_dbcsr_make_untransposed_blocks EOF # need to also link to the .supp file in setup file -cat <> ${SETUPFILE} +cat << EOF >> ${SETUPFILE} export LSAN_OPTIONS=suppressions=${INSTALLDIR}/lsan.supp export TSAN_OPTIONS=suppressions=${INSTALLDIR}/tsan.supp EOF diff --git a/tools/toolchain/scripts/stage0/setup_buildtools.sh b/tools/toolchain/scripts/stage0/setup_buildtools.sh index bc25239fe5..d53173b0fd 100755 --- a/tools/toolchain/scripts/stage0/setup_buildtools.sh +++ b/tools/toolchain/scripts/stage0/setup_buildtools.sh @@ -9,8 +9,8 @@ source "${SCRIPT_DIR}"/signal_trap.sh source "${INSTALLDIR}"/toolchain.conf source "${INSTALLDIR}"/toolchain.env -for ii in $tool_list ; do - load "${BUILDDIR}/setup_${ii}" +for ii in $tool_list; do + load "${BUILDDIR}/setup_${ii}" done # ------------------------------------------------------------------------ @@ -35,7 +35,8 @@ export CXXFLAGS=$(allowed_gxx_flags ${CXXFLAGS}) export LDFLAGS="${TSANFLAGS}" # get system arch information using OpenBLAS prebuild -"${SCRIPTDIR}"/get_openblas_arch.sh; load "${BUILDDIR}/openblas_arch" +"${SCRIPTDIR}"/get_openblas_arch.sh +load "${BUILDDIR}/openblas_arch" write_toolchain_env "${INSTALLDIR}" diff --git a/tools/toolchain/scripts/stage1/install_intelmpi.sh b/tools/toolchain/scripts/stage1/install_intelmpi.sh index f3d0c00064..467aa695a7 100755 --- a/tools/toolchain/scripts/stage1/install_intelmpi.sh +++ b/tools/toolchain/scripts/stage1/install_intelmpi.sh @@ -18,49 +18,49 @@ mkdir -p "${BUILDDIR}" cd "${BUILDDIR}" case "$with_intelmpi" in - __INSTALL__) - echo '__INSTALL__ is not supported; please manually install Intel MPI' - exit 1 - ;; - __SYSTEM__) - echo "==================== Finding Intel MPI from system paths ====================" - check_command mpirun "intelmpi" - check_command mpiicc "intelmpi" - check_command mpiifort "intelmpi" - check_command mpiicpc "intelmpi" - add_include_from_paths INTELMPI_CFLAGS "mpi.h" $INCLUDE_PATHS - add_lib_from_paths INTELMPI_LDFLAGS "libmpi.*" $LIB_PATHS - check_lib -lmpi "intelmpi" - check_lib -lmpicxx "intelmpi" - ;; - __DONTUSE__) - ;; - *) - echo "==================== Linking INTELMPI to user paths ====================" - pkg_install_dir="$with_intelmpi" - check_dir "${pkg_install_dir}/bin" - check_dir "${pkg_install_dir}/lib" - check_dir "${pkg_install_dir}/include" - INTELMPI_CFLAGS="-I'${pkg_install_dir}/include'" - INTELMPI_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; + __INSTALL__) + echo '__INSTALL__ is not supported; please manually install Intel MPI' + exit 1 + ;; + __SYSTEM__) + echo "==================== Finding Intel MPI from system paths ====================" + check_command mpirun "intelmpi" + check_command mpiicc "intelmpi" + check_command mpiifort "intelmpi" + check_command mpiicpc "intelmpi" + add_include_from_paths INTELMPI_CFLAGS "mpi.h" $INCLUDE_PATHS + add_lib_from_paths INTELMPI_LDFLAGS "libmpi.*" $LIB_PATHS + check_lib -lmpi "intelmpi" + check_lib -lmpicxx "intelmpi" + ;; + __DONTUSE__) ;; + + *) + echo "==================== Linking INTELMPI to user paths ====================" + pkg_install_dir="$with_intelmpi" + check_dir "${pkg_install_dir}/bin" + check_dir "${pkg_install_dir}/lib" + check_dir "${pkg_install_dir}/include" + INTELMPI_CFLAGS="-I'${pkg_install_dir}/include'" + INTELMPI_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; esac -if [ "$with_intelmpi" != "__DONTUSE__" ] ; then - INTELMPI_LIBS="-lmpi -lmpicxx" - if [ "$with_intelmpi" != "__SYSTEM__" ] ; then - cat < "${BUILDDIR}/setup_intelmpi" +if [ "$with_intelmpi" != "__DONTUSE__" ]; then + INTELMPI_LIBS="-lmpi -lmpicxx" + if [ "$with_intelmpi" != "__SYSTEM__" ]; then + cat << EOF > "${BUILDDIR}/setup_intelmpi" prepend_path PATH "$pkg_install_dir/bin" prepend_path LD_LIBRARY_PATH "$pkg_install_dir/lib" prepend_path LD_RUN_PATH "$pkg_install_dir/lib" prepend_path LIBRARY_PATH "$pkg_install_dir/lib" prepend_path CPATH "$pkg_install_dir/include" EOF - cat "${BUILDDIR}/setup_intelmpi" >> $SETUPFILE - mpi_bin="$pkg_install_dir/bin/mpirun" - else - mpi_bin=mpirun - fi - cat <> "${BUILDDIR}/setup_intelmpi" + cat "${BUILDDIR}/setup_intelmpi" >> $SETUPFILE + mpi_bin="$pkg_install_dir/bin/mpirun" + else + mpi_bin=mpirun + fi + cat << EOF >> "${BUILDDIR}/setup_intelmpi" export MPI_MODE="${MPI_MODE}" export INTELMPI_CFLAGS="${INTELMPI_CFLAGS}" export INTELMPI_LDFLAGS="${INTELMPI_LDFLAGS}" diff --git a/tools/toolchain/scripts/stage1/install_mpich.sh b/tools/toolchain/scripts/stage1/install_mpich.sh index 1bc217f109..885e32a921 100755 --- a/tools/toolchain/scripts/stage1/install_mpich.sh +++ b/tools/toolchain/scripts/stage1/install_mpich.sh @@ -22,87 +22,87 @@ MPICH_LIBS='' cd "${BUILDDIR}" case "$with_mpich" in - __INSTALL__) - echo "==================== Installing MPICH ====================" - pkg_install_dir="${INSTALLDIR}/mpich-${mpich_ver}" - install_lock_file="$pkg_install_dir/install_successful" - if verify_checksums "${install_lock_file}" ; then - echo "mpich-${mpich_ver} is already installed, skipping it." - else - if [ -f ${mpich_pkg} ] ; then - echo "${mpich_pkg} is found" - else - download_pkg ${DOWNLOADER_FLAGS} ${mpich_sha256}\ - https://www.cp2k.org/static/downloads/${mpich_pkg} - fi - echo "Installing from scratch into ${pkg_install_dir}" - [ -d mpich-${mpich_ver} ] && rm -rf mpich-${mpich_ver} - tar -xzf ${mpich_pkg} - cd mpich-${mpich_ver} - unset F90 - unset F90FLAGS + __INSTALL__) + echo "==================== Installing MPICH ====================" + pkg_install_dir="${INSTALLDIR}/mpich-${mpich_ver}" + install_lock_file="$pkg_install_dir/install_successful" + if verify_checksums "${install_lock_file}"; then + echo "mpich-${mpich_ver} is already installed, skipping it." + else + if [ -f ${mpich_pkg} ]; then + echo "${mpich_pkg} is found" + else + download_pkg ${DOWNLOADER_FLAGS} ${mpich_sha256} \ + https://www.cp2k.org/static/downloads/${mpich_pkg} + fi + echo "Installing from scratch into ${pkg_install_dir}" + [ -d mpich-${mpich_ver} ] && rm -rf mpich-${mpich_ver} + tar -xzf ${mpich_pkg} + cd mpich-${mpich_ver} + unset F90 + unset F90FLAGS - # workaround for compilation with GCC-10, until properly fixed: - # https://github.com/pmodels/mpich/issues/4300 - ( "${FC}" --version | grep -Eq 'GNU.+\s10\.') && compat_flag="-fallow-argument-mismatch" || compat_flag="" - ./configure --prefix="${pkg_install_dir}" --libdir="${pkg_install_dir}/lib" MPICC="" FFLAGS="${FCFLAGS} ${compat_flag}" FCFLAGS="${FCFLAGS} ${compat_flag}" --without-x --enable-gl=no > configure.log 2>&1 - make -j $NPROCS > make.log 2>&1 - make install > install.log 2>&1 - cd .. - write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage1/$(basename ${SCRIPT_NAME})" - fi - MPICH_CFLAGS="-I'${pkg_install_dir}/include'" - MPICH_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; - __SYSTEM__) - echo "==================== Finding MPICH from system paths ====================" - check_command mpirun "mpich" - check_command mpicc "mpich" - check_command mpif90 "mpich" - check_command mpic++ "mpich" - check_lib -lmpi "mpich" - check_lib -lmpicxx "mpich" - add_include_from_paths MPICH_CFLAGS "mpi.h" $INCLUDE_PATHS - add_lib_from_paths MPICH_LDFLAGS "libmpi.*" $LIB_PATHS - ;; - __DONTUSE__) - ;; - *) - echo "==================== Linking MPICH to user paths ====================" - pkg_install_dir="$with_mpich" - check_dir "${pkg_install_dir}/bin" - check_dir "${pkg_install_dir}/lib" - check_dir "${pkg_install_dir}/include" - MPICH_CFLAGS="-I'${pkg_install_dir}/include'" - MPICH_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; + # workaround for compilation with GCC-10, until properly fixed: + # https://github.com/pmodels/mpich/issues/4300 + ("${FC}" --version | grep -Eq 'GNU.+\s10\.') && compat_flag="-fallow-argument-mismatch" || compat_flag="" + ./configure --prefix="${pkg_install_dir}" --libdir="${pkg_install_dir}/lib" MPICC="" FFLAGS="${FCFLAGS} ${compat_flag}" FCFLAGS="${FCFLAGS} ${compat_flag}" --without-x --enable-gl=no > configure.log 2>&1 + make -j $NPROCS > make.log 2>&1 + make install > install.log 2>&1 + cd .. + write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage1/$(basename ${SCRIPT_NAME})" + fi + MPICH_CFLAGS="-I'${pkg_install_dir}/include'" + MPICH_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; + __SYSTEM__) + echo "==================== Finding MPICH from system paths ====================" + check_command mpirun "mpich" + check_command mpicc "mpich" + check_command mpif90 "mpich" + check_command mpic++ "mpich" + check_lib -lmpi "mpich" + check_lib -lmpicxx "mpich" + add_include_from_paths MPICH_CFLAGS "mpi.h" $INCLUDE_PATHS + add_lib_from_paths MPICH_LDFLAGS "libmpi.*" $LIB_PATHS + ;; + __DONTUSE__) ;; + + *) + echo "==================== Linking MPICH to user paths ====================" + pkg_install_dir="$with_mpich" + check_dir "${pkg_install_dir}/bin" + check_dir "${pkg_install_dir}/lib" + check_dir "${pkg_install_dir}/include" + MPICH_CFLAGS="-I'${pkg_install_dir}/include'" + MPICH_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; esac -if [ "$with_mpich" != "__DONTUSE__" ] ; then - MPICH_LIBS="-lmpi -lmpicxx" - if [ "$with_mpich" != "__SYSTEM__" ] ; then - cat < "${BUILDDIR}/setup_mpich" +if [ "$with_mpich" != "__DONTUSE__" ]; then + MPICH_LIBS="-lmpi -lmpicxx" + if [ "$with_mpich" != "__SYSTEM__" ]; then + cat << EOF > "${BUILDDIR}/setup_mpich" prepend_path PATH "$pkg_install_dir/bin" prepend_path LD_LIBRARY_PATH "$pkg_install_dir/lib" prepend_path LD_RUN_PATH "$pkg_install_dir/lib" prepend_path LIBRARY_PATH "$pkg_install_dir/lib" prepend_path CPATH "$pkg_install_dir/include" EOF - cat "${BUILDDIR}/setup_mpich" >> $SETUPFILE - mpi_bin="$pkg_install_dir/bin/mpirun" - else - mpi_bin=mpirun - fi - # check MPICH version, versions less than 3.0 will get -D__MPI_VERSION=2 flag - raw_version=$($mpi_bin --version | \ - grep "Version:" | awk '{print $2}') - major_version=$(echo $raw_version | cut -d '.' -f 1) - minor_version=$(echo $raw_version | cut -d '.' -f 2) - if [ $major_version -lt 3 ] ; then - mpi2_dflags="-D__MPI_VERSION=2" - else - mpi2_dflags='' - fi - cat <> "${BUILDDIR}/setup_mpich" + cat "${BUILDDIR}/setup_mpich" >> $SETUPFILE + mpi_bin="$pkg_install_dir/bin/mpirun" + else + mpi_bin=mpirun + fi + # check MPICH version, versions less than 3.0 will get -D__MPI_VERSION=2 flag + raw_version=$($mpi_bin --version | + grep "Version:" | awk '{print $2}') + major_version=$(echo $raw_version | cut -d '.' -f 1) + minor_version=$(echo $raw_version | cut -d '.' -f 2) + if [ $major_version -lt 3 ]; then + mpi2_dflags="-D__MPI_VERSION=2" + else + mpi2_dflags='' + fi + cat << EOF >> "${BUILDDIR}/setup_mpich" export MPI_MODE="${MPI_MODE}" export MPICH_CFLAGS="${MPICH_CFLAGS}" export MPICH_LDFLAGS="${MPICH_LDFLAGS}" diff --git a/tools/toolchain/scripts/stage1/install_openmpi.sh b/tools/toolchain/scripts/stage1/install_openmpi.sh index 7cb13e783a..14766da191 100755 --- a/tools/toolchain/scripts/stage1/install_openmpi.sh +++ b/tools/toolchain/scripts/stage1/install_openmpi.sh @@ -22,102 +22,102 @@ OPENMPI_LIBS='' cd "${BUILDDIR}" case "$with_openmpi" in - __INSTALL__) - echo "==================== Installing OpenMPI ====================" - pkg_install_dir="${INSTALLDIR}/openmpi-${openmpi_ver}" - install_lock_file="$pkg_install_dir/install_successful" - if verify_checksums "${install_lock_file}" ; then - echo "openmpi-${openmpi_ver} is already installed, skipping it." - else - if [ -f ${openmpi_pkg} ] ; then - echo "${openmpi_pkg} is found" - else - download_pkg ${DOWNLOADER_FLAGS} ${openmpi_sha256} \ - "https://www.cp2k.org/static/downloads/${openmpi_pkg}" - fi - echo "Installing from scratch into ${pkg_install_dir}" - [ -d openmpi-${openmpi_ver} ] && rm -rf openmpi-${openmpi_ver} - tar -xzf ${openmpi_pkg} - cd openmpi-${openmpi_ver} - # 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 - # glibc package - glibc_version=$(ldd --version | awk '/ldd/{print $NF}') - glibc_major_ver=${glibc_version%%.*} - glibc_minor_ver=${glibc_version##*.} - if [ $glibc_major_ver -lt 2 ] || \ - [ $glibc_major_ver -eq 2 -a $glibc_minor_ver -lt 12 ] ; then - CFLAGS="${CFLAGS} -fgnu89-inline" - fi - ./configure --prefix=${pkg_install_dir} --libdir="${pkg_install_dir}/lib" --enable-mpi1-compatibility CFLAGS="${CFLAGS}" > configure.log 2>&1 - make -j $NPROCS > make.log 2>&1 - make -j $NPROCS install > install.log 2>&1 - cd .. - write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage1/$(basename ${SCRIPT_NAME})" - fi - OPENMPI_CFLAGS="-I'${pkg_install_dir}/include'" - OPENMPI_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; - __SYSTEM__) - echo "==================== Finding OpenMPI from system paths ====================" - check_command mpirun "openmpi" - check_command mpicc "openmpi" - check_command mpif90 "openmpi" - check_command mpic++ "openmpi" - # Fortran code in CP2K is built via the mpifort wrapper, but we may need additional - # libraries and linker flags for C/C++-based MPI codepaths, pull them in at this point. - OPENMPI_CFLAGS="$(mpicxx --showme:compile)" - OPENMPI_LDFLAGS="$(mpicxx --showme:link)" - ;; - __DONTUSE__) - ;; - *) - echo "==================== Linking OpenMPI to user paths ====================" - pkg_install_dir="$with_openmpi" - check_dir "${pkg_install_dir}/bin" - check_dir "${pkg_install_dir}/lib" - check_dir "${pkg_install_dir}/include" - OPENMPI_CFLAGS="-I'${pkg_install_dir}/include'" - OPENMPI_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; + __INSTALL__) + echo "==================== Installing OpenMPI ====================" + pkg_install_dir="${INSTALLDIR}/openmpi-${openmpi_ver}" + install_lock_file="$pkg_install_dir/install_successful" + if verify_checksums "${install_lock_file}"; then + echo "openmpi-${openmpi_ver} is already installed, skipping it." + else + if [ -f ${openmpi_pkg} ]; then + echo "${openmpi_pkg} is found" + else + download_pkg ${DOWNLOADER_FLAGS} ${openmpi_sha256} \ + "https://www.cp2k.org/static/downloads/${openmpi_pkg}" + fi + echo "Installing from scratch into ${pkg_install_dir}" + [ -d openmpi-${openmpi_ver} ] && rm -rf openmpi-${openmpi_ver} + tar -xzf ${openmpi_pkg} + cd openmpi-${openmpi_ver} + # 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 + # glibc package + glibc_version=$(ldd --version | awk '/ldd/{print $NF}') + glibc_major_ver=${glibc_version%%.*} + glibc_minor_ver=${glibc_version##*.} + if [ $glibc_major_ver -lt 2 ] || + [ $glibc_major_ver -eq 2 -a $glibc_minor_ver -lt 12 ]; then + CFLAGS="${CFLAGS} -fgnu89-inline" + fi + ./configure --prefix=${pkg_install_dir} --libdir="${pkg_install_dir}/lib" --enable-mpi1-compatibility CFLAGS="${CFLAGS}" > configure.log 2>&1 + make -j $NPROCS > make.log 2>&1 + make -j $NPROCS install > install.log 2>&1 + cd .. + write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage1/$(basename ${SCRIPT_NAME})" + fi + OPENMPI_CFLAGS="-I'${pkg_install_dir}/include'" + OPENMPI_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; + __SYSTEM__) + echo "==================== Finding OpenMPI from system paths ====================" + check_command mpirun "openmpi" + check_command mpicc "openmpi" + check_command mpif90 "openmpi" + check_command mpic++ "openmpi" + # Fortran code in CP2K is built via the mpifort wrapper, but we may need additional + # libraries and linker flags for C/C++-based MPI codepaths, pull them in at this point. + OPENMPI_CFLAGS="$(mpicxx --showme:compile)" + OPENMPI_LDFLAGS="$(mpicxx --showme:link)" + ;; + __DONTUSE__) ;; + + *) + echo "==================== Linking OpenMPI to user paths ====================" + pkg_install_dir="$with_openmpi" + check_dir "${pkg_install_dir}/bin" + check_dir "${pkg_install_dir}/lib" + check_dir "${pkg_install_dir}/include" + OPENMPI_CFLAGS="-I'${pkg_install_dir}/include'" + OPENMPI_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; esac -if [ "$with_openmpi" != "__DONTUSE__" ] ; then - if [ "$with_openmpi" != "__SYSTEM__" ] ; then - cat < "${BUILDDIR}/setup_openmpi" +if [ "$with_openmpi" != "__DONTUSE__" ]; then + if [ "$with_openmpi" != "__SYSTEM__" ]; then + cat << EOF > "${BUILDDIR}/setup_openmpi" prepend_path PATH "$pkg_install_dir/bin" prepend_path LD_LIBRARY_PATH "$pkg_install_dir/lib" prepend_path LD_RUN_PATH "$pkg_install_dir/lib" prepend_path LIBRARY_PATH "$pkg_install_dir/lib" prepend_path CPATH "$pkg_install_dir/include" EOF - cat "${BUILDDIR}/setup_openmpi" >> $SETUPFILE - mpi_bin="$pkg_install_dir/bin/mpirun" - mpicxx_bin="$pkg_install_dir/bin/mpicxx" - else - mpi_bin=mpirun - mpicxx_bin=mpicxx - fi - # check openmpi version as reported by mpirun - raw_version=$($mpi_bin --version 2>&1 | \ - 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_LIBS="" - # grab additional runtime libs (for C/C++) from the mpicxx wrapper, - # and remove them from the LDFLAGS if present - for lib in $("${mpicxx_bin}" --showme:libs) ; do - OPENMPI_LIBS+=" -l${lib}" - OPENMPI_LDFLAGS="${OPENMPI_LDFLAGS//-l${lib}}" - done - # old versions didn't support MPI 3, so adjust __MPI_VERSION accordingly (needed e.g. for pexsi) - if [[ "$major_version" =~ ^[0-9]+$ ]] && ( [ $major_version -lt 1 ] || \ - [ $major_version -eq 1 -a $minor_version -lt 7 ] ) ; then - mpi2_dflags="-D__MPI_VERSION=2" - else - mpi2_dflags='' - fi - cat <> "${BUILDDIR}/setup_openmpi" + cat "${BUILDDIR}/setup_openmpi" >> $SETUPFILE + mpi_bin="$pkg_install_dir/bin/mpirun" + mpicxx_bin="$pkg_install_dir/bin/mpicxx" + else + mpi_bin=mpirun + mpicxx_bin=mpicxx + fi + # check openmpi version as reported by mpirun + raw_version=$($mpi_bin --version 2>&1 | + 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_LIBS="" + # grab additional runtime libs (for C/C++) from the mpicxx wrapper, + # and remove them from the LDFLAGS if present + for lib in $("${mpicxx_bin}" --showme:libs); do + OPENMPI_LIBS+=" -l${lib}" + OPENMPI_LDFLAGS="${OPENMPI_LDFLAGS//-l${lib}/}" + done + # old versions didn't support MPI 3, so adjust __MPI_VERSION accordingly (needed e.g. for pexsi) + if [[ "$major_version" =~ ^[0-9]+$ ]] && ([ $major_version -lt 1 ] || + [ $major_version -eq 1 -a $minor_version -lt 7 ]); then + mpi2_dflags="-D__MPI_VERSION=2" + else + mpi2_dflags='' + fi + cat << EOF >> "${BUILDDIR}/setup_openmpi" export OPENMPI_CFLAGS="${OPENMPI_CFLAGS}" export OPENMPI_LDFLAGS="${OPENMPI_LDFLAGS}" export OPENMPI_LIBS="${OPENMPI_LIBS}" @@ -132,11 +132,10 @@ EOF fi cd "${ROOTDIR}" - # ---------------------------------------------------------------------- # Suppress reporting of known leaks # ---------------------------------------------------------------------- -cat <> ${INSTALLDIR}/valgrind.supp +cat << EOF >> ${INSTALLDIR}/valgrind.supp { Memcheck:Leak @@ -183,7 +182,7 @@ cat <> ${INSTALLDIR}/valgrind.supp fun:ompi_comm_activate } EOF -cat <> ${INSTALLDIR}/lsan.supp +cat << EOF >> ${INSTALLDIR}/lsan.supp # leaks related to OpenMPI leak:query_2_0_0 leak:ompi_init_f diff --git a/tools/toolchain/scripts/stage1/install_valgrind.sh b/tools/toolchain/scripts/stage1/install_valgrind.sh index 965da45a29..904d2fb1f5 100755 --- a/tools/toolchain/scripts/stage1/install_valgrind.sh +++ b/tools/toolchain/scripts/stage1/install_valgrind.sh @@ -16,60 +16,60 @@ source "${INSTALLDIR}"/toolchain.env cd "${BUILDDIR}" case "$with_valgrind" in - __INSTALL__) - echo "==================== Installing Valgrind ====================" - pkg_install_dir="${INSTALLDIR}/valgrind-${valgrind_ver}" - install_lock_file="$pkg_install_dir/install_successful" - if verify_checksums "${install_lock_file}" ; then - echo "valgrind-${valgrind_ver} is already installed, skipping it." - else - if [ -f valgrind-${valgrind_ver}.tar.bz2 ] ; then - echo "valgrind-${valgrind_ver}.tar.bz2 is found" - else - download_pkg ${DOWNLOADER_FLAGS} ${valgrind_sha256} \ - https://www.cp2k.org/static/downloads/valgrind-${valgrind_ver}.tar.bz2 - fi - echo "Installing from scratch into ${pkg_install_dir}" - [ -d valgrind-${valgrind_ver} ] && rm -rf valgrind-${valgrind_ver} - tar -xjf valgrind-${valgrind_ver}.tar.bz2 - cd valgrind-${valgrind_ver} - ./configure --prefix="${pkg_install_dir}" --libdir="${pkg_install_dir}/lib" > configure.log 2>&1 - make -j $NPROCS > make.log 2>&1 - make -j $NPROCS install > install.log 2>&1 - cd .. - write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage1/$(basename ${SCRIPT_NAME})" - fi - ;; - __SYSTEM__) - echo "==================== Finding Valgrind from system paths ====================" - check_command valgrind "valgrind" - ;; - __DONTUSE__) - ;; - *) - echo "==================== Linking Valgrind to user paths ====================" - pkg_install_dir="$with_valgrind" - check_dir "${with_valgrind}/bin" - check_dir "${with_valgrind}/lib" - check_dir "${with_valgrind}/include" - ;; + __INSTALL__) + echo "==================== Installing Valgrind ====================" + pkg_install_dir="${INSTALLDIR}/valgrind-${valgrind_ver}" + install_lock_file="$pkg_install_dir/install_successful" + if verify_checksums "${install_lock_file}"; then + echo "valgrind-${valgrind_ver} is already installed, skipping it." + else + if [ -f valgrind-${valgrind_ver}.tar.bz2 ]; then + echo "valgrind-${valgrind_ver}.tar.bz2 is found" + else + download_pkg ${DOWNLOADER_FLAGS} ${valgrind_sha256} \ + https://www.cp2k.org/static/downloads/valgrind-${valgrind_ver}.tar.bz2 + fi + echo "Installing from scratch into ${pkg_install_dir}" + [ -d valgrind-${valgrind_ver} ] && rm -rf valgrind-${valgrind_ver} + tar -xjf valgrind-${valgrind_ver}.tar.bz2 + cd valgrind-${valgrind_ver} + ./configure --prefix="${pkg_install_dir}" --libdir="${pkg_install_dir}/lib" > configure.log 2>&1 + make -j $NPROCS > make.log 2>&1 + make -j $NPROCS install > install.log 2>&1 + cd .. + write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage1/$(basename ${SCRIPT_NAME})" + fi + ;; + __SYSTEM__) + echo "==================== Finding Valgrind from system paths ====================" + check_command valgrind "valgrind" + ;; + __DONTUSE__) ;; + + *) + echo "==================== Linking Valgrind to user paths ====================" + pkg_install_dir="$with_valgrind" + check_dir "${with_valgrind}/bin" + check_dir "${with_valgrind}/lib" + check_dir "${with_valgrind}/include" + ;; esac -if [ "$with_valgrind" != "__DONTUSE__" ] ; then - if [ "$with_valgrind" != "__SYSTEM__" ] ; then - cat < "${BUILDDIR}/setup_valgrind" +if [ "$with_valgrind" != "__DONTUSE__" ]; then + if [ "$with_valgrind" != "__SYSTEM__" ]; then + cat << EOF > "${BUILDDIR}/setup_valgrind" prepend_path PATH "$pkg_install_dir/bin" prepend_path PATH "$pkg_install_dir/lib" prepend_path PATH "$pkg_install_dir/include" EOF - cat "${BUILDDIR}/setup_valgrind" >> ${SETUPFILE} - fi + cat "${BUILDDIR}/setup_valgrind" >> ${SETUPFILE} + fi fi cd "${ROOTDIR}" # ---------------------------------------------------------------------- # Suppress reporting of known leaks # ---------------------------------------------------------------------- -cat <> ${INSTALLDIR}/valgrind.supp +cat << EOF >> ${INSTALLDIR}/valgrind.supp { BuggySUPERLU Memcheck:Cond @@ -90,7 +90,7 @@ cat <> ${INSTALLDIR}/valgrind.supp } EOF # also need to give links to the .supp file in setup file -cat <> ${SETUPFILE} +cat << EOF >> ${SETUPFILE} export VALGRIND_OPTIONS="--suppressions=${INSTALLDIR}/valgrind.supp --max-stackframe=2168152 --error-exitcode=42" EOF diff --git a/tools/toolchain/scripts/stage2/install_acml.sh b/tools/toolchain/scripts/stage2/install_acml.sh index 27cdfdffa2..02e995f587 100755 --- a/tools/toolchain/scripts/stage2/install_acml.sh +++ b/tools/toolchain/scripts/stage2/install_acml.sh @@ -17,39 +17,39 @@ ACML_LIBS='' cd "${BUILDDIR}" case "$with_acml" in - __INSTALL__) - echo "==================== Installing ACML ====================" - report_error $LINENO "To install ACML you should either contact your system administrator or go to https://developer.amd.com/tools-and-sdks/archive/amd-core-math-library-acml/acml-downloads-resources/ and download the correct version for your system." - exit 1 - ;; - __SYSTEM__) - echo "==================== Finding ACML from system paths ====================" - check_lib -lacml "ACML" - add_include_from_paths ACML_CFLAGS "acml.h" $INCLUDE_PATHS - add_lib_from_paths ACML_LDFLAGS "libacml.*" $LIB_PATHS - ;; - __DONTUSE__) - ;; - *) - echo "==================== Linking ACML to user paths ====================" - pkg_install_dir="$with_acml" - check_dir "${pkg_install_dir}/lib" - ACML_CFLAGS="-I'${pkg_install_dir}/include'" - ACML_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; + __INSTALL__) + echo "==================== Installing ACML ====================" + report_error $LINENO "To install ACML you should either contact your system administrator or go to https://developer.amd.com/tools-and-sdks/archive/amd-core-math-library-acml/acml-downloads-resources/ and download the correct version for your system." + exit 1 + ;; + __SYSTEM__) + echo "==================== Finding ACML from system paths ====================" + check_lib -lacml "ACML" + add_include_from_paths ACML_CFLAGS "acml.h" $INCLUDE_PATHS + add_lib_from_paths ACML_LDFLAGS "libacml.*" $LIB_PATHS + ;; + __DONTUSE__) ;; + + *) + echo "==================== Linking ACML to user paths ====================" + pkg_install_dir="$with_acml" + check_dir "${pkg_install_dir}/lib" + ACML_CFLAGS="-I'${pkg_install_dir}/include'" + ACML_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; esac -if [ "$with_acml" != "__DONTUSE__" ] ; then - ACML_LIBS="-lacml" - if [ "$with_acml" != "__SYSTEM__" ] ; then - cat < "${BUILDDIR}/setup_acml" +if [ "$with_acml" != "__DONTUSE__" ]; then + ACML_LIBS="-lacml" + if [ "$with_acml" != "__SYSTEM__" ]; then + cat << EOF > "${BUILDDIR}/setup_acml" prepend_path LD_LIBRARY_PATH "$pkg_install_dir/lib" prepend_path LD_RUN_PATH "$pkg_install_dir/lib" prepend_path LIBRARY_PATH "$pkg_install_dir/lib" prepend_path CPATH "$pkg_install_dir/include" EOF - cat "${BUILDDIR}/setup_acml" >> $SETUPFILE - fi - cat <> "${BUILDDIR}/setup_acml" + cat "${BUILDDIR}/setup_acml" >> $SETUPFILE + fi + cat << EOF >> "${BUILDDIR}/setup_acml" export ACML_CFLAGS="${ACML_CFLAGS}" export ACML_LDFLAGS="${ACML_LDFLAGS}" export ACML_LIBS="${ACML_LIBS}" diff --git a/tools/toolchain/scripts/stage2/install_fftw.sh b/tools/toolchain/scripts/stage2/install_fftw.sh index 33a8a0b5fb..f60f6c9f91 100755 --- a/tools/toolchain/scripts/stage2/install_fftw.sh +++ b/tools/toolchain/scripts/stage2/install_fftw.sh @@ -21,72 +21,72 @@ FFTW_LIBS='' cd "${BUILDDIR}" case "$with_fftw" in - __INSTALL__) - require_env MPI_LIBS - echo "==================== Installing FFTW ====================" - pkg_install_dir="${INSTALLDIR}/fftw-${fftw_ver}" - install_lock_file="$pkg_install_dir/install_successful" + __INSTALL__) + require_env MPI_LIBS + echo "==================== Installing FFTW ====================" + pkg_install_dir="${INSTALLDIR}/fftw-${fftw_ver}" + install_lock_file="$pkg_install_dir/install_successful" - if verify_checksums "${install_lock_file}" ; then - echo "fftw-${fftw_ver} is already installed, skipping it." - else - if [ -f ${fftw_pkg} ] ; then - echo "${fftw_pkg} is found" - else - download_pkg ${DOWNLOADER_FLAGS} ${fftw_sha256} \ - "https://www.cp2k.org/static/downloads/${fftw_pkg}" - fi - echo "Installing from scratch into ${pkg_install_dir}" - [ -d fftw-${fftw_ver} ] && rm -rf fftw-${fftw_ver} - tar -xzf ${fftw_pkg} - cd fftw-${fftw_ver} - FFTW_FLAGS="--enable-openmp --enable-shared --enable-static" - # fftw has mpi support but not compiled by default. so compile it if we build with mpi. - # it will create a second library to link with if needed - [ "$MPI_MODE" != "no" ] && FFTW_FLAGS="--enable-mpi ${FFTW_FLAGS}" - grep '\bavx\b' /proc/cpuinfo 1>/dev/null && FFTW_FLAGS="${FFTW_FLAGS} --enable-avx" - grep '\bavx2\b' /proc/cpuinfo 1>/dev/null && FFTW_FLAGS="${FFTW_FLAGS} --enable-avx2" - grep '\bavx512f\b' /proc/cpuinfo 1>/dev/null && FFTW_FLAGS="${FFTW_FLAGS} --enable-avx512" - ./configure --prefix=${pkg_install_dir} --libdir="${pkg_install_dir}/lib" ${FFTW_FLAGS} > configure.log 2>&1 - make -j $NPROCS > make.log 2>&1 - make install > install.log 2>&1 - cd .. - write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage2/$(basename ${SCRIPT_NAME})" - fi - FFTW_CFLAGS="-I'${pkg_install_dir}/include'" - FFTW_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; - __SYSTEM__) - echo "==================== Finding FFTW from system paths ====================" - check_lib -lfftw3 "FFTW" - check_lib -lfftw3_omp "FFTW" - [ "$MPI_MODE" != "no" ] && check_lib -lfftw3_mpi "FFTW" - add_include_from_paths FFTW_CFLAGS "fftw3.h" $INCLUDE_PATHS - add_lib_from_paths FFTW_LDFLAGS "libfftw3.*" $LIB_PATHS - ;; - __DONTUSE__) - ;; - *) - echo "==================== Linking FFTW to user paths ====================" - pkg_install_dir="$with_fftw" - check_dir "${pkg_install_dir}/lib" - check_dir "${pkg_install_dir}/include" - FFTW_CFLAGS="-I'${pkg_install_dir}/include'" - FFTW_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; + if verify_checksums "${install_lock_file}"; then + echo "fftw-${fftw_ver} is already installed, skipping it." + else + if [ -f ${fftw_pkg} ]; then + echo "${fftw_pkg} is found" + else + download_pkg ${DOWNLOADER_FLAGS} ${fftw_sha256} \ + "https://www.cp2k.org/static/downloads/${fftw_pkg}" + fi + echo "Installing from scratch into ${pkg_install_dir}" + [ -d fftw-${fftw_ver} ] && rm -rf fftw-${fftw_ver} + tar -xzf ${fftw_pkg} + cd fftw-${fftw_ver} + FFTW_FLAGS="--enable-openmp --enable-shared --enable-static" + # fftw has mpi support but not compiled by default. so compile it if we build with mpi. + # it will create a second library to link with if needed + [ "$MPI_MODE" != "no" ] && FFTW_FLAGS="--enable-mpi ${FFTW_FLAGS}" + grep '\bavx\b' /proc/cpuinfo 1> /dev/null && FFTW_FLAGS="${FFTW_FLAGS} --enable-avx" + grep '\bavx2\b' /proc/cpuinfo 1> /dev/null && FFTW_FLAGS="${FFTW_FLAGS} --enable-avx2" + grep '\bavx512f\b' /proc/cpuinfo 1> /dev/null && FFTW_FLAGS="${FFTW_FLAGS} --enable-avx512" + ./configure --prefix=${pkg_install_dir} --libdir="${pkg_install_dir}/lib" ${FFTW_FLAGS} > configure.log 2>&1 + make -j $NPROCS > make.log 2>&1 + make install > install.log 2>&1 + cd .. + write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage2/$(basename ${SCRIPT_NAME})" + fi + FFTW_CFLAGS="-I'${pkg_install_dir}/include'" + FFTW_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; + __SYSTEM__) + echo "==================== Finding FFTW from system paths ====================" + check_lib -lfftw3 "FFTW" + check_lib -lfftw3_omp "FFTW" + [ "$MPI_MODE" != "no" ] && check_lib -lfftw3_mpi "FFTW" + add_include_from_paths FFTW_CFLAGS "fftw3.h" $INCLUDE_PATHS + add_lib_from_paths FFTW_LDFLAGS "libfftw3.*" $LIB_PATHS + ;; + __DONTUSE__) ;; + + *) + echo "==================== Linking FFTW to user paths ====================" + pkg_install_dir="$with_fftw" + check_dir "${pkg_install_dir}/lib" + check_dir "${pkg_install_dir}/include" + FFTW_CFLAGS="-I'${pkg_install_dir}/include'" + FFTW_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; esac -if [ "$with_fftw" != "__DONTUSE__" ] ; then - FFTW_LIBS="-lfftw3 -lfftw3_omp" - if [ "$with_fftw" != "__SYSTEM__" ] ; then - cat < "${BUILDDIR}/setup_fftw" +if [ "$with_fftw" != "__DONTUSE__" ]; then + FFTW_LIBS="-lfftw3 -lfftw3_omp" + if [ "$with_fftw" != "__SYSTEM__" ]; then + cat << EOF > "${BUILDDIR}/setup_fftw" prepend_path LD_LIBRARY_PATH "$pkg_install_dir/lib" prepend_path LD_RUN_PATH "$pkg_install_dir/lib" prepend_path LIBRARY_PATH "$pkg_install_dir/lib" prepend_path CPATH "$pkg_install_dir/include" EOF - fi - # we may also want to cover FFT_SG - cat <> "${BUILDDIR}/setup_fftw" + fi + # we may also want to cover FFT_SG + cat << EOF >> "${BUILDDIR}/setup_fftw" export FFTW_CFLAGS="${FFTW_CFLAGS}" export FFTW_LDFLAGS="${FFTW_LDFLAGS}" export FFTW_LIBS="${FFTW_LIBS}" @@ -98,15 +98,14 @@ prepend_path PKG_CONFIG_PATH "$pkg_install_dir/lib/pkgconfig" export FFTW_ROOT="$pkg_install_dir" EOF - cat "${BUILDDIR}/setup_fftw" >> $SETUPFILE + cat "${BUILDDIR}/setup_fftw" >> $SETUPFILE fi cd "${ROOTDIR}" - # ---------------------------------------------------------------------- # Suppress reporting of known leaks # ---------------------------------------------------------------------- -cat <> ${INSTALLDIR}/valgrind.supp +cat << EOF >> ${INSTALLDIR}/valgrind.supp { Memcheck:Addr32 diff --git a/tools/toolchain/scripts/stage2/install_mathlibs.sh b/tools/toolchain/scripts/stage2/install_mathlibs.sh index ede0f3ae29..233987e31f 100755 --- a/tools/toolchain/scripts/stage2/install_mathlibs.sh +++ b/tools/toolchain/scripts/stage2/install_mathlibs.sh @@ -20,42 +20,46 @@ export FAST_MATH_LIBS='' write_toolchain_env "${INSTALLDIR}" -"${SCRIPTDIR}"/stage2/install_reflapack.sh "${with_reflapack}"; load "${BUILDDIR}/setup_reflapack" +"${SCRIPTDIR}"/stage2/install_reflapack.sh "${with_reflapack}" +load "${BUILDDIR}/setup_reflapack" case "$FAST_MATH_MODE" in - mkl) - "${SCRIPTDIR}"/stage2/install_mkl.sh "${with_mkl}"; load "${BUILDDIR}/setup_mkl" - ;; - acml) - "${SCRIPTDIR}"/stage2/install_acml.sh "${with_acml}"; load "${BUILDDIR}/setup_acml" - ;; - openblas) - "${SCRIPTDIR}"/stage2/install_openblas.sh "${with_openblas}"; load "${BUILDDIR}/setup_openblas" - ;; - cray) - # note the space is intentional so that the variable is - # non-empty and can pass require_env checks - export FAST_MATH_LDFLAGS="${FAST_MATH_LDFLAGS} " - export FAST_MATH_LIBS="${FAST_MATH_LIBS} ${CRAY_EXTRA_LIBS}" - ;; + mkl) + "${SCRIPTDIR}"/stage2/install_mkl.sh "${with_mkl}" + load "${BUILDDIR}/setup_mkl" + ;; + acml) + "${SCRIPTDIR}"/stage2/install_acml.sh "${with_acml}" + load "${BUILDDIR}/setup_acml" + ;; + openblas) + "${SCRIPTDIR}"/stage2/install_openblas.sh "${with_openblas}" + load "${BUILDDIR}/setup_openblas" + ;; + cray) + # note the space is intentional so that the variable is + # non-empty and can pass require_env checks + export FAST_MATH_LDFLAGS="${FAST_MATH_LDFLAGS} " + export FAST_MATH_LIBS="${FAST_MATH_LIBS} ${CRAY_EXTRA_LIBS}" + ;; esac -if [ "$with_reflapack" = "__DONTUSE__" ] ; then - # if we don't build the refereence blas/lapack implementations, - # make sure we still link against a BLAS/LAPACK implementation in *dbg profiles - export REF_MATH_CFLAGS="${FAST_MATH_CFLAGS}" - export REF_MATH_LDFLAGS="${FAST_MATH_LDFLAGS}" - export REF_MATH_LIBS="${FAST_MATH_LIBS}" +if [ "$with_reflapack" = "__DONTUSE__" ]; then + # if we don't build the refereence blas/lapack implementations, + # make sure we still link against a BLAS/LAPACK implementation in *dbg profiles + export REF_MATH_CFLAGS="${FAST_MATH_CFLAGS}" + export REF_MATH_LDFLAGS="${FAST_MATH_LDFLAGS}" + export REF_MATH_LIBS="${FAST_MATH_LIBS}" fi -if [ $ENABLE_VALGRIND = "__TRUE__" ] ; then - export MATH_CFLAGS="${REF_MATH_CFLAGS}" - export MATH_LDFLAGS="${REF_MATH_LDFLAGS}" - export MATH_LIBS="${REF_MATH_LIBS}" +if [ $ENABLE_VALGRIND = "__TRUE__" ]; then + export MATH_CFLAGS="${REF_MATH_CFLAGS}" + export MATH_LDFLAGS="${REF_MATH_LDFLAGS}" + export MATH_LIBS="${REF_MATH_LIBS}" else - export MATH_CFLAGS="${FAST_MATH_CFLAGS}" - export MATH_LDFLAGS="${FAST_MATH_LDFLAGS}" - export MATH_LIBS="${FAST_MATH_LIBS}" + export MATH_CFLAGS="${FAST_MATH_CFLAGS}" + export MATH_LDFLAGS="${FAST_MATH_LDFLAGS}" + export MATH_LIBS="${FAST_MATH_LIBS}" fi export CP_CFLAGS="${CP_CFLAGS} IF_DEBUG(${REF_MATH_CFLAGS}|IF_VALGRIND(${REF_MATH_CFLAGS}|${FAST_MATH_CFLAGS}))" diff --git a/tools/toolchain/scripts/stage2/install_mkl.sh b/tools/toolchain/scripts/stage2/install_mkl.sh index c73962bef4..1fcf072e2a 100755 --- a/tools/toolchain/scripts/stage2/install_mkl.sh +++ b/tools/toolchain/scripts/stage2/install_mkl.sh @@ -17,96 +17,96 @@ MKL_LIBS='' cd "${BUILDDIR}" case "$with_mkl" in - __INSTALL__) - echo "==================== Installing MKL ====================" - report_error ${LINENO} "To install MKL you should contact your system administrator." - exit 1 - ;; - __SYSTEM__) - echo "==================== Finding MKL from system paths ====================" - if ! [ -z "${MKLROOT}" ] ; then - echo "MKLROOT is found to be ${MKLROOT}" - else - report_error ${LINENO} "Cannot find env variable MKLROOT, the script relies on it being set. Please check in MKL installation and use --with-mkl= to pass the path to MKL root directory to this script." - exit 1 - fi - check_lib -lm - check_lib -ldl - ;; - __DONTUSE__) - ;; - *) - echo "==================== Linking MKL to user paths ====================" - check_dir "$with_mkl" - MKLROOT="$with_mkl" - ;; + __INSTALL__) + echo "==================== Installing MKL ====================" + report_error ${LINENO} "To install MKL you should contact your system administrator." + exit 1 + ;; + __SYSTEM__) + echo "==================== Finding MKL from system paths ====================" + if ! [ -z "${MKLROOT}" ]; then + echo "MKLROOT is found to be ${MKLROOT}" + else + report_error ${LINENO} "Cannot find env variable MKLROOT, the script relies on it being set. Please check in MKL installation and use --with-mkl= to pass the path to MKL root directory to this script." + exit 1 + fi + check_lib -lm + check_lib -ldl + ;; + __DONTUSE__) ;; + + *) + echo "==================== Linking MKL to user paths ====================" + check_dir "$with_mkl" + MKLROOT="$with_mkl" + ;; esac -if [ "$with_mkl" != "__DONTUSE__" ] ; then - case $OPENBLAS_ARCH in - x86_64) - mkl_arch_dir=intel64 - MKL_CFLAGS="-m64" - ;; - i386) - mkl_arch_dir=ia32 - 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" - exit 1 - ;; - esac - mkl_lib_dir="${MKLROOT}/lib/${mkl_arch_dir}" - # check we have required libraries - mkl_required_libs="libmkl_gf_lp64.so libmkl_sequential.so libmkl_core.so" - for ii in $mkl_required_libs ; do - if [ ! -f "$mkl_lib_dir/${ii}" ] ; then - report_error $LINENO "missing MKL library ${ii}" - exit 1 - fi - done +if [ "$with_mkl" != "__DONTUSE__" ]; then + case $OPENBLAS_ARCH in + x86_64) + mkl_arch_dir=intel64 + MKL_CFLAGS="-m64" + ;; + i386) + mkl_arch_dir=ia32 + 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" + exit 1 + ;; + esac + mkl_lib_dir="${MKLROOT}/lib/${mkl_arch_dir}" + # check we have required libraries + mkl_required_libs="libmkl_gf_lp64.so libmkl_sequential.so libmkl_core.so" + for ii in $mkl_required_libs; do + if [ ! -f "$mkl_lib_dir/${ii}" ]; then + report_error $LINENO "missing MKL library ${ii}" + exit 1 + fi + done - case $MPI_MODE in - mpich) - mkl_scalapack_lib="-lmkl_scalapack_lp64" - mkl_blacs_lib="-lmkl_blacs_intelmpi_lp64" - ;; - openmpi) - mkl_scalapack_lib="-lmkl_scalapack_lp64" - mkl_blacs_lib="-lmkl_blacs_openmpi_lp64" - ;; - *) - echo "Not using MKL provided ScaLAPACK and BLACS" - mkl_scalapack_lib="" - mkl_blacs_lib="" - ;; - esac + case $MPI_MODE in + mpich) + mkl_scalapack_lib="-lmkl_scalapack_lp64" + mkl_blacs_lib="-lmkl_blacs_intelmpi_lp64" + ;; + openmpi) + mkl_scalapack_lib="-lmkl_scalapack_lp64" + mkl_blacs_lib="-lmkl_blacs_openmpi_lp64" + ;; + *) + echo "Not using MKL provided ScaLAPACK and BLACS" + mkl_scalapack_lib="" + mkl_blacs_lib="" + ;; + esac - # set the correct lib flags from MLK link adviser - MKL_LIBS="-L${mkl_lib_dir} -Wl,-rpath=${mkl_lib_dir} ${mkl_scalapack_lib}" - MKL_LIBS+=" -Wl,--start-group -lmkl_gf_lp64 -lmkl_sequential -lmkl_core" - MKL_LIBS+=" ${mkl_blacs_lib} -Wl,--end-group -lpthread -lm -ldl" + # set the correct lib flags from MLK link adviser + MKL_LIBS="-L${mkl_lib_dir} -Wl,-rpath=${mkl_lib_dir} ${mkl_scalapack_lib}" + MKL_LIBS+=" -Wl,--start-group -lmkl_gf_lp64 -lmkl_sequential -lmkl_core" + MKL_LIBS+=" ${mkl_blacs_lib} -Wl,--end-group -lpthread -lm -ldl" - MKL_CFLAGS="${MKL_CFLAGS} -I${MKLROOT}/include -I${MKLROOT}/include/fftw" + MKL_CFLAGS="${MKL_CFLAGS} -I${MKLROOT}/include -I${MKLROOT}/include/fftw" - # write setup files - cat < "${BUILDDIR}/setup_mkl" + # write setup files + cat << EOF > "${BUILDDIR}/setup_mkl" export MKLROOT="${MKLROOT}" EOF - cat "${BUILDDIR}/setup_mkl" >> ${SETUPFILE} - cat <> "${BUILDDIR}/setup_mkl" + cat "${BUILDDIR}/setup_mkl" >> ${SETUPFILE} + cat << EOF >> "${BUILDDIR}/setup_mkl" export MKL_CFLAGS="${MKL_CFLAGS}" export MKL_LIBS="${MKL_LIBS}" export FAST_MATH_CFLAGS="\${FAST_MATH_CFLAGS} ${MKL_CFLAGS}" export FAST_MATH_LIBS="\${FAST_MATH_LIBS} ${MKL_LIBS}" export CP_DFLAGS="\${CP_DFLAGS} -D__MKL" EOF - if [ -n "${mkl_scalapack_lib}" ] ; then - cat <> "${BUILDDIR}/setup_mkl" + if [ -n "${mkl_scalapack_lib}" ]; then + cat << EOF >> "${BUILDDIR}/setup_mkl" export CP_DFLAGS="\${CP_DFLAGS} IF_MPI(-D__SCALAPACK|)" export with_scalapack="__DONTUSE__" EOF - fi + fi fi load "${BUILDDIR}/setup_mkl" diff --git a/tools/toolchain/scripts/stage2/install_openblas.sh b/tools/toolchain/scripts/stage2/install_openblas.sh index cf4520eb57..4a5f75cb38 100755 --- a/tools/toolchain/scripts/stage2/install_openblas.sh +++ b/tools/toolchain/scripts/stage2/install_openblas.sh @@ -22,109 +22,110 @@ OPENBLASROOT="" cd "${BUILDDIR}" case "$with_openblas" in - __INSTALL__) - echo "==================== Installing OpenBLAS ====================" - pkg_install_dir="${INSTALLDIR}/openblas-${openblas_ver}" - install_lock_file="$pkg_install_dir/install_successful" - if verify_checksums "${install_lock_file}" ; then - echo "openblas-${openblas_ver} is already installed, skipping it." - else - if [ -f ${openblas_pkg} ] ; then - echo "${openblas_pkg} is found" - else - download_pkg ${DOWNLOADER_FLAGS} ${openblas_sha256} \ - https://www.cp2k.org/static/downloads/${openblas_pkg} - fi + __INSTALL__) + echo "==================== Installing OpenBLAS ====================" + pkg_install_dir="${INSTALLDIR}/openblas-${openblas_ver}" + install_lock_file="$pkg_install_dir/install_successful" + if verify_checksums "${install_lock_file}"; then + echo "openblas-${openblas_ver} is already installed, skipping it." + else + if [ -f ${openblas_pkg} ]; then + echo "${openblas_pkg} is found" + else + download_pkg ${DOWNLOADER_FLAGS} ${openblas_sha256} \ + https://www.cp2k.org/static/downloads/${openblas_pkg} + fi - echo "Installing from scratch into ${pkg_install_dir}" - [ -d OpenBLAS-${openblas_ver} ] && rm -rf OpenBLAS-${openblas_ver} - tar -zxf ${openblas_pkg} - cd OpenBLAS-${openblas_ver} + echo "Installing from scratch into ${pkg_install_dir}" + [ -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 - # - # 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 - ( make -j $NPROCS \ - MAKE_NB_JOBS=0 \ - NUM_THREADS=64 \ - USE_THREAD=1 \ - USE_OPENMP=1 \ - CC="${CC}" \ - FC="${FC}" \ - PREFIX="${pkg_install_dir}" \ - > make.log 2>&1 \ - ) || ( \ - make -j $NPROCS \ - MAKE_NB_JOBS=0 \ - TARGET=NEHALEM \ - NUM_THREADS=64 \ - USE_THREAD=1 \ - USE_OPENMP=1 \ - CC="${CC}" \ - FC="${FC}" \ - PREFIX="${pkg_install_dir}" \ - > make.nehalem.log 2>&1 \ - ) - make -j $NPROCS \ - MAKE_NB_JOBS=0 \ - NUM_THREADS=64 \ - USE_THREAD=1 \ - USE_OPENMP=1 \ - CC="${CC}" \ - FC="${FC}" \ - PREFIX="${pkg_install_dir}" \ - install > install.log 2>&1 - cd .. - write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage2/$(basename ${SCRIPT_NAME})" - fi - OPENBLAS_CFLAGS="-I'${pkg_install_dir}/include'" - OPENBLAS_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - OPENBLASROOT='${pkg_install_dir}' - OPENBLAS_LIBS="-lopenblas" - ;; - __SYSTEM__) - echo "==================== Finding LAPACK from system paths ====================" - # assume that system openblas is threaded - check_lib -lopenblas "OpenBLAS" - OPENBLAS_LIBS="-lopenblas" - # detect separate omp builds - check_lib -lopenblas_openmp 2>/dev/null && OPENBLAS_LIBS="-lopenblas_openmp" - check_lib -lopenblas_omp 2>/dev/null && OPENBLAS_LIBS="-lopenblas_omp" - add_include_from_paths OPENBLAS_CFLAGS "openblas_config.h" $INCLUDE_PATHS - add_lib_from_paths OPENBLAS_LDFLAGS "libopenblas.*" $LIB_PATHS - ;; - __DONTUSE__) - ;; - *) - echo "==================== Linking LAPACK to user paths ====================" - pkg_install_dir="$with_openblas" - check_dir "${pkg_install_dir}/include" - check_dir "${pkg_install_dir}/lib" - OPENBLAS_CFLAGS="-I'${pkg_install_dir}/include'" - OPENBLAS_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - OPENBLAS_LIBS="-lopenblas" - # detect separate omp builds - (__libdir="${pkg_install_dir}/lib" LIB_PATHS="__libdir" check_lib -lopenblas_openmp 2>/dev/null) && \ - OPENBLAS_LIBS="-lopenblas_openmp" - (__libdir="${pkg_install_dir}/lib" LIB_PATHS="__libdir" check_lib -lopenblas_omp 2>/dev/null) && \ - OPENBLAS_LIBS="-lopenblas_omp" - ;; + # First attempt to make openblas using auto detected + # TARGET, if this fails, then make with forced + # TARGET=NEHALEM + # + # 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 + ( + make -j $NPROCS \ + MAKE_NB_JOBS=0 \ + NUM_THREADS=64 \ + USE_THREAD=1 \ + USE_OPENMP=1 \ + CC="${CC}" \ + FC="${FC}" \ + PREFIX="${pkg_install_dir}" \ + > make.log 2>&1 + ) || ( + make -j $NPROCS \ + MAKE_NB_JOBS=0 \ + TARGET=NEHALEM \ + NUM_THREADS=64 \ + USE_THREAD=1 \ + USE_OPENMP=1 \ + CC="${CC}" \ + FC="${FC}" \ + PREFIX="${pkg_install_dir}" \ + > make.nehalem.log 2>&1 + ) + make -j $NPROCS \ + MAKE_NB_JOBS=0 \ + NUM_THREADS=64 \ + USE_THREAD=1 \ + USE_OPENMP=1 \ + CC="${CC}" \ + FC="${FC}" \ + PREFIX="${pkg_install_dir}" \ + install > install.log 2>&1 + cd .. + write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage2/$(basename ${SCRIPT_NAME})" + fi + OPENBLAS_CFLAGS="-I'${pkg_install_dir}/include'" + OPENBLAS_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + OPENBLASROOT='${pkg_install_dir}' + OPENBLAS_LIBS="-lopenblas" + ;; + __SYSTEM__) + echo "==================== Finding LAPACK from system paths ====================" + # assume that system openblas is threaded + check_lib -lopenblas "OpenBLAS" + OPENBLAS_LIBS="-lopenblas" + # detect separate omp builds + check_lib -lopenblas_openmp 2> /dev/null && OPENBLAS_LIBS="-lopenblas_openmp" + check_lib -lopenblas_omp 2> /dev/null && OPENBLAS_LIBS="-lopenblas_omp" + add_include_from_paths OPENBLAS_CFLAGS "openblas_config.h" $INCLUDE_PATHS + add_lib_from_paths OPENBLAS_LDFLAGS "libopenblas.*" $LIB_PATHS + ;; + __DONTUSE__) ;; + + *) + echo "==================== Linking LAPACK to user paths ====================" + pkg_install_dir="$with_openblas" + check_dir "${pkg_install_dir}/include" + check_dir "${pkg_install_dir}/lib" + OPENBLAS_CFLAGS="-I'${pkg_install_dir}/include'" + OPENBLAS_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + OPENBLAS_LIBS="-lopenblas" + # detect separate omp builds + (__libdir="${pkg_install_dir}/lib" LIB_PATHS="__libdir" check_lib -lopenblas_openmp 2> /dev/null) && + OPENBLAS_LIBS="-lopenblas_openmp" + (__libdir="${pkg_install_dir}/lib" LIB_PATHS="__libdir" check_lib -lopenblas_omp 2> /dev/null) && + OPENBLAS_LIBS="-lopenblas_omp" + ;; esac -if [ "$with_openblas" != "__DONTUSE__" ] ; then - if [ "$with_openblas" != "__SYSTEM__" ] ; then - cat < "${BUILDDIR}/setup_openblas" +if [ "$with_openblas" != "__DONTUSE__" ]; then + if [ "$with_openblas" != "__SYSTEM__" ]; then + cat << EOF > "${BUILDDIR}/setup_openblas" prepend_path LD_LIBRARY_PATH "$pkg_install_dir/lib" prepend_path LD_RUN_PATH "$pkg_install_dir/lib" prepend_path LIBRARY_PATH "$pkg_install_dir/lib" prepend_path CPATH "$pkg_install_dir/include" export OPENBLASROOT=${pkg_install_dir} EOF - cat "${BUILDDIR}/setup_openblas" >> $SETUPFILE - fi - cat <> "${BUILDDIR}/setup_openblas" + cat "${BUILDDIR}/setup_openblas" >> $SETUPFILE + fi + cat << EOF >> "${BUILDDIR}/setup_openblas" export OPENBLASROOT="${pkg_install_dir}" export OPENBLAS_CFLAGS="${OPENBLAS_CFLAGS}" export OPENBLAS_LDFLAGS="${OPENBLAS_LDFLAGS}" diff --git a/tools/toolchain/scripts/stage2/install_reflapack.sh b/tools/toolchain/scripts/stage2/install_reflapack.sh index 7a0695aff0..d173108d99 100755 --- a/tools/toolchain/scripts/stage2/install_reflapack.sh +++ b/tools/toolchain/scripts/stage2/install_reflapack.sh @@ -19,24 +19,24 @@ REFLAPACK_LIBS='' cd "${BUILDDIR}" case "$with_reflapack" in - __INSTALL__) - echo "==================== Installing LAPACK ====================" - pkg_install_dir="${INSTALLDIR}/lapack-${reflapack_ver}" - install_lock_file="$pkg_install_dir/install_successful" - if verify_checksums "${install_lock_file}" ; then - echo "lapack-${reflapack_ver} is already installed, skipping it." - else - if [ -f lapack-${reflapack_ver}.tgz ] ; then - echo "reflapack-${reflapack_ver}.tgz is found" - else - download_pkg ${DOWNLOADER_FLAGS} ${reflapack_sha256} \ - https://www.cp2k.org/static/downloads/lapack-${reflapack_ver}.tgz - fi - echo "Installing from scratch into ${pkg_install_dir}" - [ -d lapack-${reflapack_ver} ] && rm -rf lapack-${reflapack_ver} - tar -xzf lapack-${reflapack_ver}.tgz - cd lapack-${reflapack_ver} - cat < make.inc + __INSTALL__) + echo "==================== Installing LAPACK ====================" + pkg_install_dir="${INSTALLDIR}/lapack-${reflapack_ver}" + install_lock_file="$pkg_install_dir/install_successful" + if verify_checksums "${install_lock_file}"; then + echo "lapack-${reflapack_ver} is already installed, skipping it." + else + if [ -f lapack-${reflapack_ver}.tgz ]; then + echo "reflapack-${reflapack_ver}.tgz is found" + else + download_pkg ${DOWNLOADER_FLAGS} ${reflapack_sha256} \ + https://www.cp2k.org/static/downloads/lapack-${reflapack_ver}.tgz + fi + echo "Installing from scratch into ${pkg_install_dir}" + [ -d lapack-${reflapack_ver} ] && rm -rf lapack-${reflapack_ver} + tar -xzf lapack-${reflapack_ver}.tgz + cd lapack-${reflapack_ver} + cat << EOF > make.inc SHELL = /bin/sh FORTRAN = $FC OPTS = $FFLAGS -frecursive @@ -56,56 +56,56 @@ LAPACKLIB = liblapack.a TMGLIB = libtmglib.a LAPACKELIB = liblapacke.a EOF - # lapack/blas build is *not* parallel safe (updates to the archive race) - # Run first in parallel which will result most likely in an incomplete library - make -j $NPROCS lib blaslib > make.log 2>&1 - # Complete library in non-parallel mode - make -j 1 lib blaslib > make1.log 2>&1 - # no make install, so have to do this manually - ! [ -d "${pkg_install_dir}/lib" ] && mkdir -p "${pkg_install_dir}/lib" - cp libblas.a SRC/liblapack.a "${pkg_install_dir}/lib" - cd .. - write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage2/$(basename ${SCRIPT_NAME})" - fi - REFLAPACK_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; - __SYSTEM__) - echo "==================== Finding LAPACK from system paths ====================" - check_lib -lblas "lapack" - check_lib -llapack "lapack" - add_lib_from_paths REFLAPACK_LDFLAGS "liblapack.*" $LIB_PATHS - ;; - __DONTUSE__) - ;; - *) - echo "==================== Linking LAPACK to user paths ====================" - pkg_install_dir="$with_reflapack" - check_dir "${pkg_install_dir}/lib" - REFLAPACK_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; + # lapack/blas build is *not* parallel safe (updates to the archive race) + # Run first in parallel which will result most likely in an incomplete library + make -j $NPROCS lib blaslib > make.log 2>&1 + # Complete library in non-parallel mode + make -j 1 lib blaslib > make1.log 2>&1 + # no make install, so have to do this manually + ! [ -d "${pkg_install_dir}/lib" ] && mkdir -p "${pkg_install_dir}/lib" + cp libblas.a SRC/liblapack.a "${pkg_install_dir}/lib" + cd .. + write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage2/$(basename ${SCRIPT_NAME})" + fi + REFLAPACK_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; + __SYSTEM__) + echo "==================== Finding LAPACK from system paths ====================" + check_lib -lblas "lapack" + check_lib -llapack "lapack" + add_lib_from_paths REFLAPACK_LDFLAGS "liblapack.*" $LIB_PATHS + ;; + __DONTUSE__) ;; + + *) + echo "==================== Linking LAPACK to user paths ====================" + pkg_install_dir="$with_reflapack" + check_dir "${pkg_install_dir}/lib" + REFLAPACK_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; esac -if [ "$with_reflapack" != "__DONTUSE__" ] ; then - REFLAPACK_LIBS="-llapack -lblas" - if [ "$with_reflapack" != "__SYSTEM__" ] ; then - cat < "${BUILDDIR}/setup_reflapack" +if [ "$with_reflapack" != "__DONTUSE__" ]; then + REFLAPACK_LIBS="-llapack -lblas" + if [ "$with_reflapack" != "__SYSTEM__" ]; then + cat << EOF > "${BUILDDIR}/setup_reflapack" prepend_path LD_LIBRARY_PATH "$pkg_install_dir/lib" prepend_path LD_RUN_PATH "$pkg_install_dir/lib" prepend_path LIBRARY_PATH "$pkg_install_dir/lib" EOF - cat "${BUILDDIR}/setup_reflapack" >> $SETUPFILE - fi - cat <> "${BUILDDIR}/setup_reflapack" + cat "${BUILDDIR}/setup_reflapack" >> $SETUPFILE + fi + cat << EOF >> "${BUILDDIR}/setup_reflapack" export REFLAPACK_LDFLAGS="${REFLAPACK_LDFLAGS}" export REFLAPACK_LIBS="${REFLAPACK_LIBS}" export REF_MATH_LDFLAGS="\${REF_MATH_LDFLAGS} ${REFLAPACK_LDFLAGS}" export REF_MATH_LIBS="\${REF_MATH_LIBS} ${REFLAPACK_LIBS}" EOF - if [ "$FAST_MATH_MODE" = reflapack ] ; then - cat <> setup_reflapack + if [ "$FAST_MATH_MODE" = reflapack ]; then + cat << EOF >> setup_reflapack export FAST_MATH_LDFLAGS="\${FAST_MATH_LDFLAGS} ${REFLAPACK_LDFLAGS}" export FAST_MATH_LIBS="\${FAST_MATH_LIBS} ${REFLAPACK_LIBS}" EOF - fi + fi fi load "${BUILDDIR}/setup_reflapack" diff --git a/tools/toolchain/scripts/stage3/install_libint.sh b/tools/toolchain/scripts/stage3/install_libint.sh index aa5995a5ce..17c948a6dd 100755 --- a/tools/toolchain/scripts/stage3/install_libint.sh +++ b/tools/toolchain/scripts/stage3/install_libint.sh @@ -12,22 +12,22 @@ libint_ver="2.6.0" libint_pkg="libint-v${libint_ver}-cp2k-lmax-${LIBINT_LMAX}.tgz" case "$LIBINT_LMAX" in - 4) - libint_sha256="7c8d28bfb03920936231228b79686ba0fd87ea922c267199789bc131cf21ac08" - ;; - 5) - libint_sha256="1cd72206afddb232bcf2179c6229fbf6e42e4ba8440e701e6aa57ff1e871e9db" - ;; - 6) - libint_sha256="bea76a433cd32bde280879f73b5fc8228c78b62e3ea57ace4c6d74b65910b8af" - ;; - 7) - libint_sha256="3bcdcc55e1dbafe38a785d4af171df8e300bb8b7775894b57186cdf35807c334" - ;; - *) - report_error "Unsupported value --libint-lmax=${LIBINT_LMAX}." - exit 1 - ;; + 4) + libint_sha256="7c8d28bfb03920936231228b79686ba0fd87ea922c267199789bc131cf21ac08" + ;; + 5) + libint_sha256="1cd72206afddb232bcf2179c6229fbf6e42e4ba8440e701e6aa57ff1e871e9db" + ;; + 6) + libint_sha256="bea76a433cd32bde280879f73b5fc8228c78b62e3ea57ace4c6d74b65910b8af" + ;; + 7) + libint_sha256="3bcdcc55e1dbafe38a785d4af171df8e300bb8b7775894b57186cdf35807c334" + ;; + *) + report_error "Unsupported value --libint-lmax=${LIBINT_LMAX}." + exit 1 + ;; esac [ -f "${BUILDDIR}/setup_libint" ] && rm "${BUILDDIR}/setup_libint" @@ -39,85 +39,85 @@ LIBINT_LIBS='' cd "${BUILDDIR}" case "$with_libint" in - __INSTALL__) - echo "==================== Installing LIBINT ====================" - pkg_install_dir="${INSTALLDIR}/libint-v${libint_ver}-cp2k-lmax-${LIBINT_LMAX}" - install_lock_file="$pkg_install_dir/install_successful" - if verify_checksums "${install_lock_file}" ; then - echo "libint-${libint_ver} is already installed, skipping it." - else - if [ -f ${libint_pkg} ] ; then - echo "${libint_pkg} is found" - else - download_pkg ${DOWNLOADER_FLAGS} ${libint_sha256} \ - https://github.com/cp2k/libint-cp2k/releases/download/v${libint_ver}/${libint_pkg} - fi + __INSTALL__) + echo "==================== Installing LIBINT ====================" + pkg_install_dir="${INSTALLDIR}/libint-v${libint_ver}-cp2k-lmax-${LIBINT_LMAX}" + install_lock_file="$pkg_install_dir/install_successful" + if verify_checksums "${install_lock_file}"; then + echo "libint-${libint_ver} is already installed, skipping it." + else + if [ -f ${libint_pkg} ]; then + echo "${libint_pkg} is found" + else + download_pkg ${DOWNLOADER_FLAGS} ${libint_sha256} \ + https://github.com/cp2k/libint-cp2k/releases/download/v${libint_ver}/${libint_pkg} + fi - [ -d libint-v${libint_ver}-cp2k-lmax-${LIBINT_LMAX} ] && rm -rf libint-v${libint_ver}-cp2k-lmax-${LIBINT_LMAX} - tar -xzf ${libint_pkg} + [ -d libint-v${libint_ver}-cp2k-lmax-${LIBINT_LMAX} ] && rm -rf libint-v${libint_ver}-cp2k-lmax-${LIBINT_LMAX} + tar -xzf ${libint_pkg} - echo "Installing from scratch into ${pkg_install_dir}" - cd libint-v${libint_ver}-cp2k-lmax-${LIBINT_LMAX} + echo "Installing from scratch into ${pkg_install_dir}" + cd libint-v${libint_ver}-cp2k-lmax-${LIBINT_LMAX} - # reduce debug information to level 1 since - # level 2 (default for -g flag) leads to very large binary size - LIBINT_CXXFLAGS="$CXXFLAGS -g1" + # reduce debug information to level 1 since + # level 2 (default for -g flag) leads to very large binary size + LIBINT_CXXFLAGS="$CXXFLAGS -g1" - # cmake build broken with libint 2.6, uncomment for libint 2.7 and above - #cmake . -DCMAKE_INSTALL_PREFIX=${pkg_install_dir} \ - # -DCMAKE_CXX_COMPILER="$CXX" \ - # -DLIBINT2_INSTALL_LIBDIR="${pkg_install_dir}/lib" \ - # -DENABLE_FORTRAN=ON \ - # -DCXXFLAGS="$LIBINT_CXXFLAGS" > configure.log 2>&1 - #cmake --build . > cmake.log 2>&1 - #cmake --build . --target install > install.log 2>&1 + # cmake build broken with libint 2.6, uncomment for libint 2.7 and above + #cmake . -DCMAKE_INSTALL_PREFIX=${pkg_install_dir} \ + # -DCMAKE_CXX_COMPILER="$CXX" \ + # -DLIBINT2_INSTALL_LIBDIR="${pkg_install_dir}/lib" \ + # -DENABLE_FORTRAN=ON \ + # -DCXXFLAGS="$LIBINT_CXXFLAGS" > configure.log 2>&1 + #cmake --build . > cmake.log 2>&1 + #cmake --build . --target install > install.log 2>&1 - ./configure --prefix=${pkg_install_dir} \ - --with-cxx="$CXX $LIBINT_CXXFLAGS" \ - --with-cxx-optflags="$LIBINT_CXXFLAGS" \ - --enable-fortran \ - --libdir="${pkg_install_dir}/lib" \ - > configure.log 2>&1 + ./configure --prefix=${pkg_install_dir} \ + --with-cxx="$CXX $LIBINT_CXXFLAGS" \ + --with-cxx-optflags="$LIBINT_CXXFLAGS" \ + --enable-fortran \ + --libdir="${pkg_install_dir}/lib" \ + > configure.log 2>&1 - make -j $NPROCS > make.log 2>&1 - make install > install.log 2>&1 + make -j $NPROCS > make.log 2>&1 + make install > install.log 2>&1 - cd .. - write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage3/$(basename ${SCRIPT_NAME})" - fi + cd .. + write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage3/$(basename ${SCRIPT_NAME})" + fi - LIBINT_CFLAGS="-I'${pkg_install_dir}/include'" - LIBINT_LDFLAGS="-L'${pkg_install_dir}/lib'" - ;; - __SYSTEM__) - echo "==================== Finding LIBINT from system paths ====================" - check_lib -lint2 "libint" - add_include_from_paths -p LIBINT_CFLAGS "libint" $INCLUDE_PATHS - add_lib_from_paths LIBINT_LDFLAGS "libint2.*" $LIB_PATHS - ;; - __DONTUSE__) - ;; - *) - echo "==================== Linking LIBINT to user paths ====================" - pkg_install_dir="$with_libint" - check_dir "${pkg_install_dir}/lib" - check_dir "${pkg_install_dir}/include" - LIBINT_CFLAGS="-I'${pkg_install_dir}/include'" - LIBINT_LDFLAGS="-L'${pkg_install_dir}/lib'" - ;; + LIBINT_CFLAGS="-I'${pkg_install_dir}/include'" + LIBINT_LDFLAGS="-L'${pkg_install_dir}/lib'" + ;; + __SYSTEM__) + echo "==================== Finding LIBINT from system paths ====================" + check_lib -lint2 "libint" + add_include_from_paths -p LIBINT_CFLAGS "libint" $INCLUDE_PATHS + add_lib_from_paths LIBINT_LDFLAGS "libint2.*" $LIB_PATHS + ;; + __DONTUSE__) ;; + + *) + echo "==================== Linking LIBINT to user paths ====================" + pkg_install_dir="$with_libint" + check_dir "${pkg_install_dir}/lib" + check_dir "${pkg_install_dir}/include" + LIBINT_CFLAGS="-I'${pkg_install_dir}/include'" + LIBINT_LDFLAGS="-L'${pkg_install_dir}/lib'" + ;; esac -if [ "$with_libint" != "__DONTUSE__" ] ; then - LIBINT_LIBS="-lint2" - if [ "$with_libint" != "__SYSTEM__" ] ; then - cat < "${BUILDDIR}/setup_libint" +if [ "$with_libint" != "__DONTUSE__" ]; then + LIBINT_LIBS="-lint2" + if [ "$with_libint" != "__SYSTEM__" ]; then + cat << EOF > "${BUILDDIR}/setup_libint" prepend_path LD_LIBRARY_PATH "$pkg_install_dir/lib" prepend_path LD_RUN_PATH "$pkg_install_dir/lib" prepend_path LIBRARY_PATH "$pkg_install_dir/lib" prepend_path CPATH "$pkg_install_dir/include" EOF - cat "${BUILDDIR}/setup_libint" >> $SETUPFILE - fi - cat <> "${BUILDDIR}/setup_libint" + cat "${BUILDDIR}/setup_libint" >> $SETUPFILE + fi + cat << EOF >> "${BUILDDIR}/setup_libint" export LIBINT_CFLAGS="${LIBINT_CFLAGS}" export LIBINT_LDFLAGS="${LIBINT_LDFLAGS}" export LIBINT_LIBS="${LIBINT_LIBS}" diff --git a/tools/toolchain/scripts/stage3/install_libxc.sh b/tools/toolchain/scripts/stage3/install_libxc.sh index ce431229d6..2b885d2cf2 100755 --- a/tools/toolchain/scripts/stage3/install_libxc.sh +++ b/tools/toolchain/scripts/stage3/install_libxc.sh @@ -19,62 +19,62 @@ LIBXC_LIBS='' cd "${BUILDDIR}" case "$with_libxc" in - __INSTALL__) - echo "==================== Installing LIBXC ====================" - pkg_install_dir="${INSTALLDIR}/libxc-${libxc_ver}" - install_lock_file="$pkg_install_dir/install_successful" - if verify_checksums "${install_lock_file}" ; then - echo "libxc-${libxc_ver} is already installed, skipping it." - else - if [ -f libxc-${libxc_ver}.tar.gz ] ; then - echo "libxc-${libxc_ver}.tar.gz is found" - else - download_pkg ${DOWNLOADER_FLAGS} ${libxc_sha256} \ - https://www.cp2k.org/static/downloads/libxc-${libxc_ver}.tar.gz - fi - echo "Installing from scratch into ${pkg_install_dir}" - [ -d libxc-${libxc_ver} ] && rm -rf libxc-${libxc_ver} - tar -xzf libxc-${libxc_ver}.tar.gz - cd libxc-${libxc_ver} - ./configure --prefix="${pkg_install_dir}" --libdir="${pkg_install_dir}/lib" > configure.log 2>&1 - make -j $NPROCS > make.log 2>&1 - make install > install.log 2>&1 - cd .. - write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage3/$(basename ${SCRIPT_NAME})" - fi - LIBXC_CFLAGS="-I'${pkg_install_dir}/include'" - LIBXC_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; - __SYSTEM__) - echo "==================== Finding LIBXC from system paths ====================" - check_lib -lxcf03 "libxc" - check_lib -lxc "libxc" - add_include_from_paths LIBXC_CFLAGS "xc.h" $INCLUDE_PATHS - add_lib_from_paths LIBXC_LDFLAGS "libxc.*" $LIB_PATHS - ;; - __DONTUSE__) - ;; - *) - echo "==================== Linking LIBXC to user paths ====================" - pkg_install_dir="$with_libxc" - check_dir "${pkg_install_dir}/lib" - check_dir "${pkg_install_dir}/include" - LIBXC_CFLAGS="-I'${pkg_install_dir}/include'" - LIBXC_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; + __INSTALL__) + echo "==================== Installing LIBXC ====================" + pkg_install_dir="${INSTALLDIR}/libxc-${libxc_ver}" + install_lock_file="$pkg_install_dir/install_successful" + if verify_checksums "${install_lock_file}"; then + echo "libxc-${libxc_ver} is already installed, skipping it." + else + if [ -f libxc-${libxc_ver}.tar.gz ]; then + echo "libxc-${libxc_ver}.tar.gz is found" + else + download_pkg ${DOWNLOADER_FLAGS} ${libxc_sha256} \ + https://www.cp2k.org/static/downloads/libxc-${libxc_ver}.tar.gz + fi + echo "Installing from scratch into ${pkg_install_dir}" + [ -d libxc-${libxc_ver} ] && rm -rf libxc-${libxc_ver} + tar -xzf libxc-${libxc_ver}.tar.gz + cd libxc-${libxc_ver} + ./configure --prefix="${pkg_install_dir}" --libdir="${pkg_install_dir}/lib" > configure.log 2>&1 + make -j $NPROCS > make.log 2>&1 + make install > install.log 2>&1 + cd .. + write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage3/$(basename ${SCRIPT_NAME})" + fi + LIBXC_CFLAGS="-I'${pkg_install_dir}/include'" + LIBXC_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; + __SYSTEM__) + echo "==================== Finding LIBXC from system paths ====================" + check_lib -lxcf03 "libxc" + check_lib -lxc "libxc" + add_include_from_paths LIBXC_CFLAGS "xc.h" $INCLUDE_PATHS + add_lib_from_paths LIBXC_LDFLAGS "libxc.*" $LIB_PATHS + ;; + __DONTUSE__) ;; + + *) + echo "==================== Linking LIBXC to user paths ====================" + pkg_install_dir="$with_libxc" + check_dir "${pkg_install_dir}/lib" + check_dir "${pkg_install_dir}/include" + LIBXC_CFLAGS="-I'${pkg_install_dir}/include'" + LIBXC_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; esac -if [ "$with_libxc" != "__DONTUSE__" ] ; then - LIBXC_LIBS="-lxcf03 -lxc" - if [ "$with_libxc" != "__SYSTEM__" ] ; then - cat < "${BUILDDIR}/setup_libxc" +if [ "$with_libxc" != "__DONTUSE__" ]; then + LIBXC_LIBS="-lxcf03 -lxc" + if [ "$with_libxc" != "__SYSTEM__" ]; then + cat << EOF > "${BUILDDIR}/setup_libxc" prepend_path LD_LIBRARY_PATH "$pkg_install_dir/lib" prepend_path LD_RUN_PATH "$pkg_install_dir/lib" prepend_path LIBRARY_PATH "$pkg_install_dir/lib" prepend_path CPATH "$pkg_install_dir/include" EOF - cat "${BUILDDIR}/setup_libxc" >> $SETUPFILE - fi - cat <> "${BUILDDIR}/setup_libxc" + cat "${BUILDDIR}/setup_libxc" >> $SETUPFILE + fi + cat << EOF >> "${BUILDDIR}/setup_libxc" export LIBXC_CFLAGS="${LIBXC_CFLAGS}" export LIBXC_LDFLAGS="${LIBXC_LDFLAGS}" export LIBXC_LIBS="${LIBXC_LIBS}" diff --git a/tools/toolchain/scripts/stage4/install_cosma.sh b/tools/toolchain/scripts/stage4/install_cosma.sh index f7bfe53229..f9939410f3 100755 --- a/tools/toolchain/scripts/stage4/install_cosma.sh +++ b/tools/toolchain/scripts/stage4/install_cosma.sh @@ -16,130 +16,130 @@ source "${INSTALLDIR}"/toolchain.env cd "${BUILDDIR}" case "$with_cosma" in - __INSTALL__) - require_env OPENBLASROOT - require_env SCALAPACKROOT + __INSTALL__) + require_env OPENBLASROOT + require_env SCALAPACKROOT - echo "==================== Installing cosma ====================" - pkg_install_dir="${INSTALLDIR}/cosma-${cosma_ver}" - install_lock_file="$pkg_install_dir/install_successful" + echo "==================== Installing cosma ====================" + pkg_install_dir="${INSTALLDIR}/cosma-${cosma_ver}" + install_lock_file="$pkg_install_dir/install_successful" - if verify_checksums "${install_lock_file}" ; then - echo "cosma-${cosma_ver} is already installed, skipping it." - else - if [ -f cosma-${cosma_ver}.tar.gz ] ; then - echo "cosma-${cosma_ver}.tar.gz is found" - else - download_pkg ${DOWNLOADER_FLAGS} ${cosma_sha256} \ - "https://github.com/eth-cscs/COSMA/releases/download/v${cosma_ver}/cosma.tar.gz" \ - -o cosma-${cosma_ver}.tar.gz + if verify_checksums "${install_lock_file}"; then + echo "cosma-${cosma_ver} is already installed, skipping it." + else + if [ -f cosma-${cosma_ver}.tar.gz ]; then + echo "cosma-${cosma_ver}.tar.gz is found" + else + download_pkg ${DOWNLOADER_FLAGS} ${cosma_sha256} \ + "https://github.com/eth-cscs/COSMA/releases/download/v${cosma_ver}/cosma.tar.gz" \ + -o cosma-${cosma_ver}.tar.gz - fi - echo "Installing from scratch into ${pkg_install_dir}" - [ -d cosma-${cosma_ver} ] && rm -rf cosma-${cosma_ver} - tar -xzf cosma-${cosma_ver}.tar.gz - mv cosma cosma-${cosma_ver} - cd cosma-${cosma_ver} - mkdir build-cpu - cd build-cpu - case "$FAST_MATH_MODE" in - mkl) - cmake \ - -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \ - -DCMAKE_INSTALL_LIBDIR=lib \ - -DCOSMA_BLAS=MKL \ - -DCOSMA_SCALAPACK=MKL \ - -DCOSMA_WITH_TESTS=NO \ - -DCOSMA_WITH_APPS=NO \ - -DCOSMA_WITH_BENCHMARKS=NO .. > cmake.log 2>&1 - ;; - *) - cmake \ - -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \ - -DCMAKE_INSTALL_LIBDIR=lib \ - -DCOSMA_BLAS=OPENBLAS \ - -DCOSMA_SCALAPACK=CUSTOM \ - -DCOSMA_WITH_TESTS=NO \ - -DCOSMA_WITH_APPS=NO \ - -DCMAKE_WITH_BENCHMARKS=NO .. > cmake.log 2>&1 - ;; - esac + fi + echo "Installing from scratch into ${pkg_install_dir}" + [ -d cosma-${cosma_ver} ] && rm -rf cosma-${cosma_ver} + tar -xzf cosma-${cosma_ver}.tar.gz + mv cosma cosma-${cosma_ver} + cd cosma-${cosma_ver} + mkdir build-cpu + cd build-cpu + case "$FAST_MATH_MODE" in + mkl) + cmake \ + -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \ + -DCMAKE_INSTALL_LIBDIR=lib \ + -DCOSMA_BLAS=MKL \ + -DCOSMA_SCALAPACK=MKL \ + -DCOSMA_WITH_TESTS=NO \ + -DCOSMA_WITH_APPS=NO \ + -DCOSMA_WITH_BENCHMARKS=NO .. > cmake.log 2>&1 + ;; + *) + cmake \ + -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \ + -DCMAKE_INSTALL_LIBDIR=lib \ + -DCOSMA_BLAS=OPENBLAS \ + -DCOSMA_SCALAPACK=CUSTOM \ + -DCOSMA_WITH_TESTS=NO \ + -DCOSMA_WITH_APPS=NO \ + -DCMAKE_WITH_BENCHMARKS=NO .. > cmake.log 2>&1 + ;; + esac - make -j $NPROCS > make.log 2>&1 - make -j $NPROCS install > install.log 2>&1 - cd .. + make -j $NPROCS > make.log 2>&1 + make -j $NPROCS install > install.log 2>&1 + cd .. - if [ "$ENABLE_CUDA" = "__TRUE__" ] ; then - [ -d build-cuda ] && rm -rf "build-cuda" - mkdir build-cuda - cd build-cuda - case "$FAST_MATH_MODE" in - mkl) - cmake \ - -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \ - -DCMAKE_INSTALL_LIBDIR=lib \ - -DCOSMA_BLAS=CUDA \ - -DCOSMA_SCALAPACK=MKL \ - -DCOSMA_WITH_TESTS=NO \ - -DCOSMA_WITH_BENCHMARKS=NO \ - -DCOSMA_WITH_APPS=NO .. > cmake.log 2>&1 - ;; - *) - cmake \ - -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \ - -DCMAKE_INSTALL_LIBDIR=lib \ - -DCOSMA_BLAS=CUDA \ - -DCOSMA_SCALAPACK=CUSTOM \ - -DCOSMA_WITH_TESTS=NO \ - -DCOSMA_WITH_BENCHMARKS=NO \ - -DCOSMA_WITH_APPS=NO .. > cmake.log 2>&1 - ;; - esac - make -j $NPROCS > make.log 2>&1 - install -d ${pkg_install_dir}/lib/cuda - [ -f libs/grid2grid/src/grid2grid/*.a ] && install -m 644 libs/grid2grid/src/grid2grid/*.a ${pkg_install_dir}/lib/cuda >> install.log 2>&1 - [ -f libs/options/*.so ] && install -m 644 libs/options/*.so ${pkg_install_dir}/lib/cuda >> install.log 2>&1 - install -m 644 src/cosma/*.a ${pkg_install_dir}/lib/cuda >> install.log 2>&1 - [ -f libs/Tiled-MM/src/Tiled-MM/*.a ] && install -m 644 libs/Tiled-MM/src/Tiled-MM/*.a ${pkg_install_dir}/lib/cuda >> install.log 2>&1 - fi + if [ "$ENABLE_CUDA" = "__TRUE__" ]; then + [ -d build-cuda ] && rm -rf "build-cuda" + mkdir build-cuda + cd build-cuda + case "$FAST_MATH_MODE" in + mkl) + cmake \ + -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \ + -DCMAKE_INSTALL_LIBDIR=lib \ + -DCOSMA_BLAS=CUDA \ + -DCOSMA_SCALAPACK=MKL \ + -DCOSMA_WITH_TESTS=NO \ + -DCOSMA_WITH_BENCHMARKS=NO \ + -DCOSMA_WITH_APPS=NO .. > cmake.log 2>&1 + ;; + *) + cmake \ + -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \ + -DCMAKE_INSTALL_LIBDIR=lib \ + -DCOSMA_BLAS=CUDA \ + -DCOSMA_SCALAPACK=CUSTOM \ + -DCOSMA_WITH_TESTS=NO \ + -DCOSMA_WITH_BENCHMARKS=NO \ + -DCOSMA_WITH_APPS=NO .. > cmake.log 2>&1 + ;; + esac + make -j $NPROCS > make.log 2>&1 + install -d ${pkg_install_dir}/lib/cuda + [ -f libs/grid2grid/src/grid2grid/*.a ] && install -m 644 libs/grid2grid/src/grid2grid/*.a ${pkg_install_dir}/lib/cuda >> install.log 2>&1 + [ -f libs/options/*.so ] && install -m 644 libs/options/*.so ${pkg_install_dir}/lib/cuda >> install.log 2>&1 + install -m 644 src/cosma/*.a ${pkg_install_dir}/lib/cuda >> install.log 2>&1 + [ -f libs/Tiled-MM/src/Tiled-MM/*.a ] && install -m 644 libs/Tiled-MM/src/Tiled-MM/*.a ${pkg_install_dir}/lib/cuda >> install.log 2>&1 + fi - write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage4/$(basename ${SCRIPT_NAME})" - fi - COSMA_ROOT="${pkg_install_dir}" - COSMA_CFLAGS="-I'${pkg_install_dir}/include'" + write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage4/$(basename ${SCRIPT_NAME})" + fi + COSMA_ROOT="${pkg_install_dir}" + COSMA_CFLAGS="-I'${pkg_install_dir}/include'" - # check if cosma is compiled with 64bits and set up COSMA_LIBDIR accordingly - COSMA_LIBDIR="${pkg_install_dir}/lib" - COSMA_LDFLAGS="-L'${COSMA_LIBDIR}' -Wl,-rpath='${COSMA_LIBDIR}'" - COSMA_CUDA_LDFLAGS="-L'${COSMA_LIBDIR}/cuda' -Wl,-rpath='${COSMA_LIBDIR}/cuda'" - ;; - __SYSTEM__) - echo "==================== Finding cosma from system paths ====================" - check_command pkg-config --modversion cosma - add_include_from_paths COSMA_CFLAGS "cosma.h" $INCLUDE_PATHS - add_lib_from_paths COSMA_LDFLAGS "libcosma.*" $LIB_PATHS - ;; - __DONTUSE__) - ;; - *) - echo "==================== Linking cosma to user paths ====================" - pkg_install_dir="$with_cosma" + # check if cosma is compiled with 64bits and set up COSMA_LIBDIR accordingly + COSMA_LIBDIR="${pkg_install_dir}/lib" + COSMA_LDFLAGS="-L'${COSMA_LIBDIR}' -Wl,-rpath='${COSMA_LIBDIR}'" + COSMA_CUDA_LDFLAGS="-L'${COSMA_LIBDIR}/cuda' -Wl,-rpath='${COSMA_LIBDIR}/cuda'" + ;; + __SYSTEM__) + echo "==================== Finding cosma from system paths ====================" + check_command pkg-config --modversion cosma + add_include_from_paths COSMA_CFLAGS "cosma.h" $INCLUDE_PATHS + add_lib_from_paths COSMA_LDFLAGS "libcosma.*" $LIB_PATHS + ;; + __DONTUSE__) ;; - # use the lib64 directory if present (multi-abi distros may link lib/ to lib32/ instead) - COSMA_LIBDIR="${pkg_install_dir}/lib" - [ -d "${pkg_install_dir}/lib64" ] && COSMA_LIBDIR="${pkg_install_dir}/lib64" + *) + echo "==================== Linking cosma to user paths ====================" + pkg_install_dir="$with_cosma" - check_dir "$pkg_install_dir/lib" - check_dir "$pkg_install_dir/include" + # use the lib64 directory if present (multi-abi distros may link lib/ to lib32/ instead) + COSMA_LIBDIR="${pkg_install_dir}/lib" + [ -d "${pkg_install_dir}/lib64" ] && COSMA_LIBDIR="${pkg_install_dir}/lib64" - COSMA_CFLAGS="-I'${pkg_install_dir}/include'" - COSMA_LDFLAGS="-L'${COSMA_LIBDIR}' -Wl,-rpath='${COSMA_LIBDIR}'" - ;; + check_dir "$pkg_install_dir/lib" + check_dir "$pkg_install_dir/include" + + COSMA_CFLAGS="-I'${pkg_install_dir}/include'" + COSMA_LDFLAGS="-L'${COSMA_LIBDIR}' -Wl,-rpath='${COSMA_LIBDIR}'" + ;; esac -if [ "$with_cosma" != "__DONTUSE__" ] ; then - COSMA_LIBS="-lcosma_pxgemm -lcosma -lgrid2grid IF_CUDA(-lTiled-MM|)" - if [ "$with_cosma" != "__SYSTEM__" ] ; then - cat << EOF > "${BUILDDIR}/setup_cosma" +if [ "$with_cosma" != "__DONTUSE__" ]; then + COSMA_LIBS="-lcosma_pxgemm -lcosma -lgrid2grid IF_CUDA(-lTiled-MM|)" + if [ "$with_cosma" != "__SYSTEM__" ]; then + cat << EOF > "${BUILDDIR}/setup_cosma" prepend_path LD_LIBRARY_PATH "${COSMA_LIBDIR}" prepend_path LD_RUN_PATH "${COSMA_LIBDIR}" prepend_path LIBRARY_PATH "${COSMA_LIBDIR}" @@ -148,8 +148,8 @@ export COSMA_INCLUDE_DIR="$pkg_install_dir/include" export COSMA_ROOT="${pkg_install_dir}" export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:${COSMA_LIBDIR}/pkgconfig" EOF - fi - cat << EOF >> "${BUILDDIR}/setup_cosma" + fi + cat << EOF >> "${BUILDDIR}/setup_cosma" export COSMA_CFLAGS="${COSMA_CFLAGS}" export COSMA_LDFLAGS="${COSMA_LDFLAGS}" export COSMA_CUDA_LDFLAGS="${COSMA_CUDA_LDFLAGS}" @@ -163,7 +163,7 @@ export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:${COSMA_LIBDIR}/pkgconfig" export COSMA_VERSION=${cosma_ver} export CP_LIBS="IF_MPI(${COSMA_LIBS}|) \${CP_LIBS}" EOF - cat "${BUILDDIR}/setup_cosma" >> $SETUPFILE + cat "${BUILDDIR}/setup_cosma" >> $SETUPFILE fi load "${BUILDDIR}/setup_cosma" diff --git a/tools/toolchain/scripts/stage4/install_libsmm.sh b/tools/toolchain/scripts/stage4/install_libsmm.sh index 8084c45c2b..b8660381f9 100755 --- a/tools/toolchain/scripts/stage4/install_libsmm.sh +++ b/tools/toolchain/scripts/stage4/install_libsmm.sh @@ -17,101 +17,101 @@ LIBSMM_LIBS='' cd "${BUILDDIR}" case "$with_libsmm" in - __INSTALL__) - echo "==================== Installing libsmm ====================" - pkg_install_dir="${INSTALLDIR}/libsmm" - install_lock_file="$pkg_install_dir/install_successful" - if verify_checksums "${install_lock_file}" ; then - echo "libsmm is already installed, skipping it." + __INSTALL__) + echo "==================== Installing libsmm ====================" + pkg_install_dir="${INSTALLDIR}/libsmm" + install_lock_file="$pkg_install_dir/install_successful" + if verify_checksums "${install_lock_file}"; then + echo "libsmm is already installed, skipping it." + else + # Here we attempt to determine which precompiled libsmm binary + # to download, and do that if such binary exists on CP2K web + # repository. The binary is determined by the arch and + # libcore values obtained via OpenBLAS prebuild. + echo "Searching for an optimised libsmm binary from CP2K website" + case ${OPENBLAS_LIBCORE} in + haswell) + libsmm="libsmm_dnn_haswell-2015-11-10.a" + libsmm_sha256="a1cf9eb1bfb1bd3467024e47173a6e85881c3908961b7bb29f3348af9837018b" + echo "An optimized libsmm $libsmm is available" + ;; + ivybridge) + libsmm="libsmm_dnn_ivybridge-2015-07-02.a" + libsmm_sha256="ef74fb7339979545f9583d9ecab52c640c4f98f9dd49f98d2b4580304d5fcf60" + echo "An optimized libsmm $libsmm is available" + ;; + nehalem) + libsmm="libsmm_dnn_nehalem-2015-07-02.a" + libsmm_sha256="cc7e8c6623055fc6bc032dfda2d08b2201a8d86577ab72c3f66bee9b86cbebe9" + echo "An optimized libsmm $libsmm is available" + ;; + sandybridge) + libsmm="libsmm_dnn_sandybridge-2015-11-10.a" + libsmm_sha256="56ffdafa715554ec87f20ff1e0150450209a7635b47b8a5b81970e88ec67687c" + echo "An optimized libsmm $libsmm is available" + ;; + *) + echo "No optimised binary found ..." + echo "Searching for a generic libsmm binary from CP2K website" + if [ "${OPENBLAS_ARCH}" == "x86_64" ]; then + libsmm="libsmm_dnn_x86_64-latest.a" + libsmm_sha256="dd58aee2bc5505e23b0761835bf2b9a90e5f050c6708ef68c5028373970673f8" + echo "A generic libsmm $libsmm is available." + echo "Consider building and contributing to CP2K an optimized" + echo "libsmm for your $OPENBLAS_ARCH $OPENBLAS_LIBCORE using" + echo "the toolkit in tools/build_libsmm provided in cp2k package" + fi + ;; + esac + # we know what to get, proceed with install + if [ "x$libsmm" != "x" ]; then + if [ -f $libsmm ]; then + echo "$libsmm has already been downloaded." else - # Here we attempt to determine which precompiled libsmm binary - # to download, and do that if such binary exists on CP2K web - # repository. The binary is determined by the arch and - # libcore values obtained via OpenBLAS prebuild. - echo "Searching for an optimised libsmm binary from CP2K website" - case ${OPENBLAS_LIBCORE} in - haswell) - libsmm="libsmm_dnn_haswell-2015-11-10.a" - libsmm_sha256="a1cf9eb1bfb1bd3467024e47173a6e85881c3908961b7bb29f3348af9837018b" - echo "An optimized libsmm $libsmm is available" - ;; - ivybridge) - libsmm="libsmm_dnn_ivybridge-2015-07-02.a" - libsmm_sha256="ef74fb7339979545f9583d9ecab52c640c4f98f9dd49f98d2b4580304d5fcf60" - echo "An optimized libsmm $libsmm is available" - ;; - nehalem) - libsmm="libsmm_dnn_nehalem-2015-07-02.a" - libsmm_sha256="cc7e8c6623055fc6bc032dfda2d08b2201a8d86577ab72c3f66bee9b86cbebe9" - echo "An optimized libsmm $libsmm is available" - ;; - sandybridge) - libsmm="libsmm_dnn_sandybridge-2015-11-10.a" - libsmm_sha256="56ffdafa715554ec87f20ff1e0150450209a7635b47b8a5b81970e88ec67687c" - echo "An optimized libsmm $libsmm is available" - ;; - *) - echo "No optimised binary found ..." - echo "Searching for a generic libsmm binary from CP2K website" - if [ "${OPENBLAS_ARCH}" == "x86_64" ] ; then - libsmm="libsmm_dnn_x86_64-latest.a" - libsmm_sha256="dd58aee2bc5505e23b0761835bf2b9a90e5f050c6708ef68c5028373970673f8" - echo "A generic libsmm $libsmm is available." - echo "Consider building and contributing to CP2K an optimized" - echo "libsmm for your $OPENBLAS_ARCH $OPENBLAS_LIBCORE using" - echo "the toolkit in tools/build_libsmm provided in cp2k package" - fi - esac - # we know what to get, proceed with install - if [ "x$libsmm" != "x" ]; then - if [ -f $libsmm ]; then - echo "$libsmm has already been downloaded." - else - download_pkg ${DOWNLOADER_FLAGS} $libsmm_sha256\ - https://www.cp2k.org/static/downloads/libsmm/$libsmm - fi - # install manually - ! [ -d "${pkg_install_dir}/lib" ] && mkdir -p "${pkg_install_dir}/lib" - cp $libsmm "${pkg_install_dir}/lib" - ln -sf "${pkg_install_dir}/lib/$libsmm" "${pkg_install_dir}/lib/libsmm_dnn.a" - else - echo "No libsmm is available" - echo "Consider building an optimized libsmm on your system yourself" - echo "using the toolkid in tools/build_libsmm provided in cp2k package" - cat < "${BUILDDIR}/setup_libsmm" + download_pkg ${DOWNLOADER_FLAGS} $libsmm_sha256 https://www.cp2k.org/static/downloads/libsmm/$libsmm + fi + # install manually + ! [ -d "${pkg_install_dir}/lib" ] && mkdir -p "${pkg_install_dir}/lib" + cp $libsmm "${pkg_install_dir}/lib" + ln -sf "${pkg_install_dir}/lib/$libsmm" "${pkg_install_dir}/lib/libsmm_dnn.a" + else + echo "No libsmm is available" + echo "Consider building an optimized libsmm on your system yourself" + echo "using the toolkid in tools/build_libsmm provided in cp2k package" + cat << EOF > "${BUILDDIR}/setup_libsmm" with_libsmm="__DONTUSE__" EOF - exit 0 - fi - write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage4/$(basename ${SCRIPT_NAME})" - fi - LIBSMM_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; - __SYSTEM__) - echo "==================== Finding Libsmm from system paths ====================" - check_lib -lsmm_dnn "libsmm" - add_lib_from_paths LIBSMM_LDFLAGS "libsmm_dnn.*" $LIB_PATHS - ;; - __DONTUSE__) - ;; - *) - echo "==================== Linking Libsmm to user paths ====================" - pkg_install_dir="$with_libsmm" - check_dir "${pkg_install_dir}/lib" - LIBSMM_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; + exit 0 + fi + write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage4/$(basename ${SCRIPT_NAME})" + fi + LIBSMM_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; + __SYSTEM__) + echo "==================== Finding Libsmm from system paths ====================" + check_lib -lsmm_dnn "libsmm" + add_lib_from_paths LIBSMM_LDFLAGS "libsmm_dnn.*" $LIB_PATHS + ;; + __DONTUSE__) ;; + + *) + echo "==================== Linking Libsmm to user paths ====================" + pkg_install_dir="$with_libsmm" + check_dir "${pkg_install_dir}/lib" + LIBSMM_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; esac -if [ "$with_libsmm" != "__DONTUSE__" ] ; then - LIBSMM_LIBS="-lsmm_dnn" - if [ "$with_libsmm" != "__SYSTEM__" ] ; then - cat < "${BUILDDIR}/setup_libsmm" +if [ "$with_libsmm" != "__DONTUSE__" ]; then + LIBSMM_LIBS="-lsmm_dnn" + if [ "$with_libsmm" != "__SYSTEM__" ]; then + cat << EOF > "${BUILDDIR}/setup_libsmm" prepend_path LD_LIBRARY_PATH "${pkg_install_dir}/lib" prepend_path LD_RUN_PATH "${pkg_install_dir}/lib" prepend_path LIBRARY_PATH "${pkg_install_dir}/lib" EOF - cat "${BUILDDIR}/setup_libsmm" >> $SETUPFILE - fi - cat <> "${BUILDDIR}/setup_libsmm" + cat "${BUILDDIR}/setup_libsmm" >> $SETUPFILE + fi + cat << EOF >> "${BUILDDIR}/setup_libsmm" export LIBSMM_LDFLAGS="${LIBSMM_LDFLAGS}" export LIBSMM_LIBS="${LIBSMM_LIBS}" export CP_DFLAGS="\${CP_DFLAGS} IF_VALGRIND(|-D__HAS_smm_dnn)" diff --git a/tools/toolchain/scripts/stage4/install_libxsmm.sh b/tools/toolchain/scripts/stage4/install_libxsmm.sh index 702f02ca9f..b5b1a34b00 100755 --- a/tools/toolchain/scripts/stage4/install_libxsmm.sh +++ b/tools/toolchain/scripts/stage4/install_libxsmm.sh @@ -19,98 +19,98 @@ LIBXSMM_LIBS='' cd "${BUILDDIR}" case "$with_libxsmm" in - __INSTALL__) - echo "==================== Installing Libxsmm ====================" - if [ "$OPENBLAS_ARCH" != "x86_64" ] ; then - report_warning $LINENO "libxsmm is not supported on arch ${OPENBLAS_ARCH}" - cat < "${BUILDDIR}/setup_libxsmm" + __INSTALL__) + echo "==================== Installing Libxsmm ====================" + if [ "$OPENBLAS_ARCH" != "x86_64" ]; then + report_warning $LINENO "libxsmm is not supported on arch ${OPENBLAS_ARCH}" + cat << EOF > "${BUILDDIR}/setup_libxsmm" with_libxsmm="__DONTUSE__" EOF - exit 0 - fi - pkg_install_dir="${INSTALLDIR}/libxsmm-${libxsmm_ver}" - install_lock_file="$pkg_install_dir/install_successful" - if verify_checksums "${install_lock_file}" ; then - echo "libxsmm-${libxsmm_ver} is already installed, skipping it." + exit 0 + fi + pkg_install_dir="${INSTALLDIR}/libxsmm-${libxsmm_ver}" + install_lock_file="$pkg_install_dir/install_successful" + if verify_checksums "${install_lock_file}"; then + echo "libxsmm-${libxsmm_ver} is already installed, skipping it." + else + if [ "$libxsmm_ver" = "master" ]; then + download_pkg_no_checksum ${DOWNLOADER_FLAGS} \ + -o libxsmm-master.zip \ + https://github.com/hfp/libxsmm/archive/master.zip + [ -d libxsmm-master ] && rm -rf libxsmm-master + unzip -q -o libxsmm-master.zip + else + if [ -f libxsmm-${libxsmm_ver}.tar.gz ]; then + echo "libxsmm-${libxsmm_ver}.tar.gz is found" else - if [ "$libxsmm_ver" = "master" ] ; then - download_pkg_no_checksum ${DOWNLOADER_FLAGS} \ - -o libxsmm-master.zip \ - https://github.com/hfp/libxsmm/archive/master.zip - [ -d libxsmm-master ] && rm -rf libxsmm-master - unzip -q -o libxsmm-master.zip - else - if [ -f libxsmm-${libxsmm_ver}.tar.gz ] ; then - echo "libxsmm-${libxsmm_ver}.tar.gz is found" - else - download_pkg ${DOWNLOADER_FLAGS} ${libxsmm_sha256} \ - https://www.cp2k.org/static/downloads/libxsmm-${libxsmm_ver}.tar.gz - fi - [ -d libxsmm-${libxsmm_ver} ] && rm -rf libxsmm-${libxsmm_ver} - tar -xzf libxsmm-${libxsmm_ver}.tar.gz - fi - echo "Installing from scratch into ${pkg_install_dir}" - # note that we do not have to set -L flags to ld for the - # linked math libraries for the libxsmm build, as for a - # library this is not required, you just have to provide - # the appropriate -L flags (LDFLAGS) during the linking - # stage of building an executable that uses the libxsmm - # library - cd libxsmm-${libxsmm_ver} - make -j $NPROCS \ - MALLOC=0 \ - INTRINSICS=1 \ - CXX=$CXX \ - CC=$CC \ - FC=$FC \ - PREFIX=${pkg_install_dir} \ - > make.log 2>&1 - make -j $NPROCS \ - MALLOC=0 \ - INTRINSICS=1 \ - CXX=$CXX \ - CC=$CC \ - FC=$FC \ - PREFIX=${pkg_install_dir} \ - install > install.log 2>&1 - cd .. - write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage4/$(basename ${SCRIPT_NAME})" + download_pkg ${DOWNLOADER_FLAGS} ${libxsmm_sha256} \ + https://www.cp2k.org/static/downloads/libxsmm-${libxsmm_ver}.tar.gz fi - LIBXSMM_CFLAGS="-I'${pkg_install_dir}/include'" - LIBXSMM_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; - __SYSTEM__) - echo "==================== Finding Libxsmm from system paths ====================" - check_command libxsmm_generator "libxsmm" - check_lib -lxsmm "libxsmm" - check_lib -lxsmmf "libxsmm" - add_include_from_paths LIBXSMM_CFLAGS "libxsmm.h" $INCLUDE_PATHS - add_lib_from_paths LIBXSMM_LDFLAGS "libxsmm.*" $LIB_PATHS - ;; - __DONTUSE__) - ;; - *) - echo "==================== Linking Libxsmm to user paths ====================" - pkg_install_dir="$with_libxsmm" - check_dir "${pkg_install_dir}/bin" - check_dir "${pkg_install_dir}/include" - check_dir "${pkg_install_dir}/lib" - LIBXSMM_CFLAGS="-I'${pkg_install_dir}/include'" - LIBXSMM_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; + [ -d libxsmm-${libxsmm_ver} ] && rm -rf libxsmm-${libxsmm_ver} + tar -xzf libxsmm-${libxsmm_ver}.tar.gz + fi + echo "Installing from scratch into ${pkg_install_dir}" + # note that we do not have to set -L flags to ld for the + # linked math libraries for the libxsmm build, as for a + # library this is not required, you just have to provide + # the appropriate -L flags (LDFLAGS) during the linking + # stage of building an executable that uses the libxsmm + # library + cd libxsmm-${libxsmm_ver} + make -j $NPROCS \ + MALLOC=0 \ + INTRINSICS=1 \ + CXX=$CXX \ + CC=$CC \ + FC=$FC \ + PREFIX=${pkg_install_dir} \ + > make.log 2>&1 + make -j $NPROCS \ + MALLOC=0 \ + INTRINSICS=1 \ + CXX=$CXX \ + CC=$CC \ + FC=$FC \ + PREFIX=${pkg_install_dir} \ + install > install.log 2>&1 + cd .. + write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage4/$(basename ${SCRIPT_NAME})" + fi + LIBXSMM_CFLAGS="-I'${pkg_install_dir}/include'" + LIBXSMM_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; + __SYSTEM__) + echo "==================== Finding Libxsmm from system paths ====================" + check_command libxsmm_generator "libxsmm" + check_lib -lxsmm "libxsmm" + check_lib -lxsmmf "libxsmm" + add_include_from_paths LIBXSMM_CFLAGS "libxsmm.h" $INCLUDE_PATHS + add_lib_from_paths LIBXSMM_LDFLAGS "libxsmm.*" $LIB_PATHS + ;; + __DONTUSE__) ;; + + *) + echo "==================== Linking Libxsmm to user paths ====================" + pkg_install_dir="$with_libxsmm" + check_dir "${pkg_install_dir}/bin" + check_dir "${pkg_install_dir}/include" + check_dir "${pkg_install_dir}/lib" + LIBXSMM_CFLAGS="-I'${pkg_install_dir}/include'" + LIBXSMM_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; esac -if [ "$with_libxsmm" != "__DONTUSE__" ] ; then - LIBXSMM_LIBS="-lxsmmf -lxsmm -ldl -lpthread" - if [ "$with_libxsmm" != "__SYSTEM__" ] ; then - cat < "${BUILDDIR}/setup_libxsmm" +if [ "$with_libxsmm" != "__DONTUSE__" ]; then + LIBXSMM_LIBS="-lxsmmf -lxsmm -ldl -lpthread" + if [ "$with_libxsmm" != "__SYSTEM__" ]; then + cat << EOF > "${BUILDDIR}/setup_libxsmm" prepend_path PATH "${pkg_install_dir}/bin" prepend_path LD_LIBRARY_PATH "${pkg_install_dir}/lib" prepend_path LD_RUN_PATH "${pkg_install_dir}/lib" prepend_path LIBRARY_PATH "${pkg_install_dir}/lib" EOF - cat "${BUILDDIR}/setup_libxsmm" >> $SETUPFILE - fi - cat <> "${BUILDDIR}/setup_libxsmm" + cat "${BUILDDIR}/setup_libxsmm" >> $SETUPFILE + fi + cat << EOF >> "${BUILDDIR}/setup_libxsmm" export LIBXSMM_CFLAGS="${LIBXSMM_CFLAGS}" export LIBXSMM_LDFLAGS="${LIBXSMM_LDFLAGS}" export LIBXSMM_LIBS="${LIBXSMM_LIBS}" diff --git a/tools/toolchain/scripts/stage4/install_scalapack.sh b/tools/toolchain/scripts/stage4/install_scalapack.sh index 0140cb2c33..0c50099e79 100755 --- a/tools/toolchain/scripts/stage4/install_scalapack.sh +++ b/tools/toolchain/scripts/stage4/install_scalapack.sh @@ -6,8 +6,8 @@ scalapack_ver="2.1.0" scalapack_sha256="61d9216cf81d246944720cfce96255878a3f85dec13b9351f1fa0fd6768220a6" scalapack_pkg="scalapack-${scalapack_ver}.tgz" patches=( - "${SCRIPT_DIR}/stage4/scalapack-${scalapack_ver}-gcc10.patch" - ) + "${SCRIPT_DIR}/stage4/scalapack-${scalapack_ver}-gcc10.patch" +) source "${SCRIPT_DIR}"/common_vars.sh source "${SCRIPT_DIR}"/tool_kit.sh @@ -24,70 +24,70 @@ SCALAPACK_LIBS='' cd "${BUILDDIR}" case "$with_scalapack" in - __INSTALL__) - echo "==================== Installing ScaLAPACK ====================" - pkg_install_dir="${INSTALLDIR}/scalapack-${scalapack_ver}" - install_lock_file="$pkg_install_dir/install_successful" - if verify_checksums "${install_lock_file}" ; then - echo "scalapack-${scalapack_ver} is already installed, skipping it." - else - require_env MATH_LIBS - if [ -f ${scalapack_pkg} ] ; then - echo "${scalapack_pkg} is found" - else - download_pkg ${DOWNLOADER_FLAGS} ${scalapack_sha256} \ - https://www.cp2k.org/static/downloads/${scalapack_pkg} - fi - echo "Installing from scratch into ${pkg_install_dir}" - [ -d scalapack-${scalapack_ver} ] && rm -rf scalapack-${scalapack_ver} - tar -xzf ${scalapack_pkg} + __INSTALL__) + echo "==================== Installing ScaLAPACK ====================" + pkg_install_dir="${INSTALLDIR}/scalapack-${scalapack_ver}" + install_lock_file="$pkg_install_dir/install_successful" + if verify_checksums "${install_lock_file}"; then + echo "scalapack-${scalapack_ver} is already installed, skipping it." + else + require_env MATH_LIBS + if [ -f ${scalapack_pkg} ]; then + echo "${scalapack_pkg} is found" + else + download_pkg ${DOWNLOADER_FLAGS} ${scalapack_sha256} \ + https://www.cp2k.org/static/downloads/${scalapack_pkg} + fi + echo "Installing from scratch into ${pkg_install_dir}" + [ -d scalapack-${scalapack_ver} ] && rm -rf scalapack-${scalapack_ver} + tar -xzf ${scalapack_pkg} - pushd "scalapack-${scalapack_ver}" >/dev/null - for patch in "${patches[@]}" ; do - patch -p1 < "${patch}" - done - popd >/dev/null + pushd "scalapack-${scalapack_ver}" > /dev/null + for patch in "${patches[@]}"; do + patch -p1 < "${patch}" + done + popd > /dev/null - mkdir -p "scalapack-${scalapack_ver}/build" - pushd "scalapack-${scalapack_ver}/build" >/dev/null + mkdir -p "scalapack-${scalapack_ver}/build" + pushd "scalapack-${scalapack_ver}/build" > /dev/null - cmake -DCMAKE_FIND_ROOT_PATH="$ROOTDIR" \ - -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \ - -DCMAKE_INSTALL_LIBDIR="lib" \ - -DCMAKE_BUILD_TYPE=Release .. > configure.log 2>&1 - make -j $NPROCS > make.log 2>&1 - make install >> make.log 2>&1 + cmake -DCMAKE_FIND_ROOT_PATH="$ROOTDIR" \ + -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \ + -DCMAKE_INSTALL_LIBDIR="lib" \ + -DCMAKE_BUILD_TYPE=Release .. > configure.log 2>&1 + make -j $NPROCS > make.log 2>&1 + make install >> make.log 2>&1 - popd >/dev/null - write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage4/$(basename ${SCRIPT_NAME})" - fi - SCALAPACK_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; - __SYSTEM__) - echo "==================== Finding ScaLAPACK from system paths ====================" - check_lib -lscalapack "ScaLAPACK" - add_lib_from_paths SCALAPACK_LDFLAGS "libscalapack.*" $LIB_PATHS - ;; - __DONTUSE__) - ;; - *) - echo "==================== Linking ScaLAPACK to user paths ====================" - pkg_install_dir="$with_scalapack" - check_dir "${pkg_install_dir}/lib" - SCALAPACK_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; + popd > /dev/null + write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage4/$(basename ${SCRIPT_NAME})" + fi + SCALAPACK_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; + __SYSTEM__) + echo "==================== Finding ScaLAPACK from system paths ====================" + check_lib -lscalapack "ScaLAPACK" + add_lib_from_paths SCALAPACK_LDFLAGS "libscalapack.*" $LIB_PATHS + ;; + __DONTUSE__) ;; + + *) + echo "==================== Linking ScaLAPACK to user paths ====================" + pkg_install_dir="$with_scalapack" + check_dir "${pkg_install_dir}/lib" + SCALAPACK_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; esac -if [ "$with_scalapack" != "__DONTUSE__" ] ; then - SCALAPACK_LIBS="-lscalapack" - if [ "$with_scalapack" != "__SYSTEM__" ] ; then - cat < "${BUILDDIR}/setup_scalapack" +if [ "$with_scalapack" != "__DONTUSE__" ]; then + SCALAPACK_LIBS="-lscalapack" + if [ "$with_scalapack" != "__SYSTEM__" ]; then + cat << EOF > "${BUILDDIR}/setup_scalapack" prepend_path LD_LIBRARY_PATH "${pkg_install_dir}/lib" prepend_path LD_RUN_PATH "${pkg_install_dir}/lib" prepend_path LIBRARY_PATH "${pkg_install_dir}/lib" EOF - cat "${BUILDDIR}/setup_scalapack" >> $SETUPFILE - fi - cat <> "${BUILDDIR}/setup_scalapack" + cat "${BUILDDIR}/setup_scalapack" >> $SETUPFILE + fi + cat << EOF >> "${BUILDDIR}/setup_scalapack" export SCALAPACK_LDFLAGS="${SCALAPACK_LDFLAGS}" export SCALAPACK_LIBS="${SCALAPACK_LIBS}" export SCALAPACKROOT="${pkg_install_dir}" @@ -101,7 +101,7 @@ cd "${ROOTDIR}" # ---------------------------------------------------------------------- # Suppress reporting of known leaks # ---------------------------------------------------------------------- -cat <> ${INSTALLDIR}/lsan.supp +cat << EOF >> ${INSTALLDIR}/lsan.supp # leaks related to SCALAPACK leak:pdpotrf_ EOF diff --git a/tools/toolchain/scripts/stage5/install_elpa.sh b/tools/toolchain/scripts/stage5/install_elpa.sh index 71e984cbfa..cfffbab925 100755 --- a/tools/toolchain/scripts/stage5/install_elpa.sh +++ b/tools/toolchain/scripts/stage5/install_elpa.sh @@ -5,8 +5,8 @@ SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_NAME")/.." && pwd -P)" elpa_ver="2020.11.001" elpa_sha256="15591f142eeaa98ab3201d27ca9ac328e21beabf0803b011a04183fcaf6efdde" patches=( - "${SCRIPT_DIR}/stage5/elpa-${elpa_ver}-fix_nvcc_wrap.patch" - ) + "${SCRIPT_DIR}/stage5/elpa-${elpa_ver}-fix_nvcc_wrap.patch" +) source "${SCRIPT_DIR}"/common_vars.sh source "${SCRIPT_DIR}"/tool_kit.sh @@ -26,157 +26,158 @@ ELPA_MAKEOPTS='-j1' cd "${BUILDDIR}" # elpa only works with MPI switched on -if [ $MPI_MODE = no ] ; then - report_warning $LINENO "MPI is disabled, skipping elpa installation" -cat < "${BUILDDIR}/setup_elpa" +if [ $MPI_MODE = no ]; then + report_warning $LINENO "MPI is disabled, skipping elpa installation" + cat << EOF > "${BUILDDIR}/setup_elpa" with_elpa="__FALSE__" EOF - exit 0 + exit 0 fi case "$with_elpa" in - __INSTALL__) - echo "==================== Installing ELPA ====================" - pkg_install_dir="${INSTALLDIR}/elpa-${elpa_ver}" - install_lock_file="$pkg_install_dir/install_successful" - if verify_checksums "${install_lock_file}" ; then - echo "elpa-${elpa_ver} is already installed, skipping it." - else - require_env MATH_LIBS - if [ -f elpa-${elpa_ver}.tar.gz ] ; then - echo "elpa-${elpa_ver}.tar.gz is found" - else - download_pkg ${DOWNLOADER_FLAGS} ${elpa_sha256} \ - https://www.cp2k.org/static/downloads/elpa-${elpa_ver}.tar.gz - fi - [ -d elpa-${elpa_ver} ] && rm -rf elpa-${elpa_ver} - tar -xzf elpa-${elpa_ver}.tar.gz + __INSTALL__) + echo "==================== Installing ELPA ====================" + pkg_install_dir="${INSTALLDIR}/elpa-${elpa_ver}" + install_lock_file="$pkg_install_dir/install_successful" + if verify_checksums "${install_lock_file}"; then + echo "elpa-${elpa_ver} is already installed, skipping it." + else + require_env MATH_LIBS + if [ -f elpa-${elpa_ver}.tar.gz ]; then + echo "elpa-${elpa_ver}.tar.gz is found" + else + download_pkg ${DOWNLOADER_FLAGS} ${elpa_sha256} \ + https://www.cp2k.org/static/downloads/elpa-${elpa_ver}.tar.gz + fi + [ -d elpa-${elpa_ver} ] && rm -rf elpa-${elpa_ver} + tar -xzf elpa-${elpa_ver}.tar.gz - # fix wrong dependency order (at least in elpa 2016.05.003) - # sed -i "s/build_lib = libelpa@SUFFIX@.la libelpatest@SUFFIX@.la/build_lib = libelpatest@SUFFIX@.la libelpa@SUFFIX@.la/g" elpa-${elpa_ver}/Makefile.in - # sed -i "s/build_lib = libelpa@SUFFIX@.la libelpatest@SUFFIX@.la/build_lib = libelpatest@SUFFIX@.la libelpa@SUFFIX@.la/g" elpa-${elpa_ver}/Makefile.am + # fix wrong dependency order (at least in elpa 2016.05.003) + # sed -i "s/build_lib = libelpa@SUFFIX@.la libelpatest@SUFFIX@.la/build_lib = libelpatest@SUFFIX@.la libelpa@SUFFIX@.la/g" elpa-${elpa_ver}/Makefile.in + # sed -i "s/build_lib = libelpa@SUFFIX@.la libelpatest@SUFFIX@.la/build_lib = libelpatest@SUFFIX@.la libelpa@SUFFIX@.la/g" elpa-${elpa_ver}/Makefile.am - # need both flavors ? + # need both flavors ? - # elpa expect FC to be an mpi fortran compiler that is happy - # with long lines, and that a bunch of libs can be found - cd elpa-${elpa_ver} + # elpa expect FC to be an mpi fortran compiler that is happy + # with long lines, and that a bunch of libs can be found + cd elpa-${elpa_ver} - for patch in "${patches[@]}" ; do - patch -p1 < "${patch}" - done + for patch in "${patches[@]}"; do + patch -p1 < "${patch}" + done - # specific settings needed on CRAY Linux Environment - if [ "$ENABLE_CRAY" = "__TRUE__" ] ; then - # extra LDFLAGS needed - cray_ldflags="-dynamic" - fi + # specific settings needed on CRAY Linux Environment + if [ "$ENABLE_CRAY" = "__TRUE__" ]; then + # extra LDFLAGS needed + cray_ldflags="-dynamic" + fi - # ELPA-2017xxxx enables AVX2 by default, switch off if machine doesn't support it. - 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'` - [ "${has_AVX2}" == "yes" ] && AVX_flag="-mavx2" - has_AVX512=`grep '\bavx512f\b' /proc/cpuinfo 1>/dev/null && echo 'yes' || echo 'no'` - [ "${has_AVX512}" == "yes" ] && AVX512_flags="-mavx512f" - if [ "$OPENBLAS_ARCH" == "x86_64" ] ; then - FMA_flag=`grep '\bfma\b' /proc/cpuinfo 1>/dev/null && echo '-mfma' || echo '-mno-fma'` - SSE4_flag=`grep '\bsse4_1\b' /proc/cpuinfo 1>/dev/null && echo '-msse4' || echo '-mno-sse4'` - grep '\bavx512dq\b' /proc/cpuinfo 1>/dev/null && AVX512_flags+=" -mavx512dq" - grep '\bavx512cd\b' /proc/cpuinfo 1>/dev/null && AVX512_flags+=" -mavx512cd" - grep '\bavx512bw\b' /proc/cpuinfo 1>/dev/null && AVX512_flags+=" -mavx512bw" - grep '\bavx512v1\b' /proc/cpuinfo 1>/dev/null && AVX512_flags+=" -mavx512v1" - config_flags="--enable-avx=${has_AVX} --enable-avx2=${has_AVX2} --enable-avx512=${has_AVX512}" - else - AVX_flag="" - AVX512_flags="" - FMA_flag="" - SSE4_flag="" - config_flags="--disable-avx --disable-avx2 --disable-avx512 --disable-sse --disable-sse-assembly" - fi - for TARGET in "cpu" "gpu" ; do - [ "$TARGET" == "gpu" ] && [ "$ENABLE_CUDA" != "__TRUE__" ] && continue - echo "Installing from scratch into ${pkg_install_dir}/${TARGET}" + # ELPA-2017xxxx enables AVX2 by default, switch off if machine doesn't support it. + 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') + [ "${has_AVX2}" == "yes" ] && AVX_flag="-mavx2" + has_AVX512=$(grep '\bavx512f\b' /proc/cpuinfo 1> /dev/null && echo 'yes' || echo 'no') + [ "${has_AVX512}" == "yes" ] && AVX512_flags="-mavx512f" + if [ "$OPENBLAS_ARCH" == "x86_64" ]; then + FMA_flag=$(grep '\bfma\b' /proc/cpuinfo 1> /dev/null && echo '-mfma' || echo '-mno-fma') + SSE4_flag=$(grep '\bsse4_1\b' /proc/cpuinfo 1> /dev/null && echo '-msse4' || echo '-mno-sse4') + grep '\bavx512dq\b' /proc/cpuinfo 1> /dev/null && AVX512_flags+=" -mavx512dq" + grep '\bavx512cd\b' /proc/cpuinfo 1> /dev/null && AVX512_flags+=" -mavx512cd" + grep '\bavx512bw\b' /proc/cpuinfo 1> /dev/null && AVX512_flags+=" -mavx512bw" + grep '\bavx512v1\b' /proc/cpuinfo 1> /dev/null && AVX512_flags+=" -mavx512v1" + config_flags="--enable-avx=${has_AVX} --enable-avx2=${has_AVX2} --enable-avx512=${has_AVX512}" + else + AVX_flag="" + AVX512_flags="" + FMA_flag="" + SSE4_flag="" + config_flags="--disable-avx --disable-avx2 --disable-avx512 --disable-sse --disable-sse-assembly" + fi + for TARGET in "cpu" "gpu"; do + [ "$TARGET" == "gpu" ] && [ "$ENABLE_CUDA" != "__TRUE__" ] && continue + echo "Installing from scratch into ${pkg_install_dir}/${TARGET}" - mkdir -p "build_${TARGET}"; cd "build_${TARGET}" - ../configure --prefix="${pkg_install_dir}/${TARGET}/" \ - --libdir="${pkg_install_dir}/${TARGET}/lib" \ - --enable-openmp=yes \ - --enable-shared=no \ - --enable-static=yes \ - ${config_flags} \ - --enable-gpu=$([ "$TARGET" == "gpu" ] && echo "yes" || echo "no") \ - --with-cuda-path=${CUDA_PATH} \ - FC=${MPIFC} \ - CC=${MPICC} \ - CXX=${MPICXX} \ - FCFLAGS="${FCFLAGS} ${MATH_CFLAGS} ${SCALAPACK_CFLAGS} -ffree-line-length-none ${AVX_flag} ${FMA_flag} ${SSE4_flag} ${AVX512_flags}" \ - CFLAGS="${CFLAGS} ${MATH_CFLAGS} ${SCALAPACK_CFLAGS} ${AVX_flag} ${FMA_flag} ${SSE4_flag} ${AVX512_flags}" \ - CXXFLAGS="${CXXFLAGS} ${MATH_CFLAGS} ${SCALAPACK_CFLAGS} ${AVX_flag} ${FMA_flag} ${SSE4_flag} ${AVX512_flags}" \ - LDFLAGS="-Wl,--enable-new-dtags ${MATH_LDFLAGS} ${SCALAPACK_LDFLAGS} ${cray_ldflags}" \ - LIBS="${SCALAPACK_LIBS} ${MATH_LIBS}" \ - >configure.log 2>&1 - make -j $NPROCS ${ELPA_MAKEOPTS} >make.log 2>&1 - make install >install.log 2>&1 - cd .. - done - cd .. - write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage5/$(basename ${SCRIPT_NAME})" - fi - ELPA_CFLAGS="-I'${pkg_install_dir}/IF_CUDA(gpu|cpu)/include/elpa_openmp-${elpa_ver}/modules' -I'${pkg_install_dir}/IF_CUDA(gpu|cpu)/include/elpa_openmp-${elpa_ver}/elpa'" - ELPA_LDFLAGS="-L'${pkg_install_dir}/IF_CUDA(gpu|cpu)/lib' -Wl,-rpath='${pkg_install_dir}/IF_CUDA(gpu|cpu)/lib'" - ;; - __SYSTEM__) - echo "==================== Finding ELPA from system paths ====================" - check_lib -lelpa_openmp "ELPA" - # get the include paths - elpa_include="$(find_in_paths "elpa_openmp-*" $INCLUDE_PATHS)" - if [ "$elpa_include" != "__FALSE__" ] ; then - echo "ELPA include directory threaded version is found to be $elpa_include" - ELPA_CFLAGS="-I'$elpa_include/modules' -I'$elpa_include/elpa'" - else - echo "Cannot find elpa_openmp-${elpa_ver} from paths $INCLUDE_PATHS" - exit 1 - fi - # get the lib paths - add_lib_from_paths ELPA_LDFLAGS "libelpa.*" $LIB_PATHS - ;; - __DONTUSE__) - ;; - *) - echo "==================== Linking ELPA to user paths ====================" - pkg_install_dir="$with_elpa" - check_dir "${pkg_install_dir}/include" - check_dir "${pkg_install_dir}/lib" - user_include_path="$pkg_install_dir/include" - elpa_include="$(find_in_paths "elpa_openmp-*" user_include_path)" - if [ "$elpa_include" != "__FALSE__" ] ; then - echo "ELPA include directory threaded version is found to be $elpa_include/modules" - check_dir "$elpa_include/modules" - ELPA_CFLAGS="-I'$elpa_include/modules' -I'$elpa_include/elpa'" - else - echo "Cannot find elpa_openmp-* from path $user_include_path" - exit 1 - fi - ELPA_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; + mkdir -p "build_${TARGET}" + cd "build_${TARGET}" + ../configure --prefix="${pkg_install_dir}/${TARGET}/" \ + --libdir="${pkg_install_dir}/${TARGET}/lib" \ + --enable-openmp=yes \ + --enable-shared=no \ + --enable-static=yes \ + ${config_flags} \ + --enable-gpu=$([ "$TARGET" == "gpu" ] && echo "yes" || echo "no") \ + --with-cuda-path=${CUDA_PATH} \ + FC=${MPIFC} \ + CC=${MPICC} \ + CXX=${MPICXX} \ + FCFLAGS="${FCFLAGS} ${MATH_CFLAGS} ${SCALAPACK_CFLAGS} -ffree-line-length-none ${AVX_flag} ${FMA_flag} ${SSE4_flag} ${AVX512_flags}" \ + CFLAGS="${CFLAGS} ${MATH_CFLAGS} ${SCALAPACK_CFLAGS} ${AVX_flag} ${FMA_flag} ${SSE4_flag} ${AVX512_flags}" \ + CXXFLAGS="${CXXFLAGS} ${MATH_CFLAGS} ${SCALAPACK_CFLAGS} ${AVX_flag} ${FMA_flag} ${SSE4_flag} ${AVX512_flags}" \ + LDFLAGS="-Wl,--enable-new-dtags ${MATH_LDFLAGS} ${SCALAPACK_LDFLAGS} ${cray_ldflags}" \ + LIBS="${SCALAPACK_LIBS} ${MATH_LIBS}" \ + > configure.log 2>&1 + make -j $NPROCS ${ELPA_MAKEOPTS} > make.log 2>&1 + make install > install.log 2>&1 + cd .. + done + cd .. + write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage5/$(basename ${SCRIPT_NAME})" + fi + ELPA_CFLAGS="-I'${pkg_install_dir}/IF_CUDA(gpu|cpu)/include/elpa_openmp-${elpa_ver}/modules' -I'${pkg_install_dir}/IF_CUDA(gpu|cpu)/include/elpa_openmp-${elpa_ver}/elpa'" + ELPA_LDFLAGS="-L'${pkg_install_dir}/IF_CUDA(gpu|cpu)/lib' -Wl,-rpath='${pkg_install_dir}/IF_CUDA(gpu|cpu)/lib'" + ;; + __SYSTEM__) + echo "==================== Finding ELPA from system paths ====================" + check_lib -lelpa_openmp "ELPA" + # get the include paths + elpa_include="$(find_in_paths "elpa_openmp-*" $INCLUDE_PATHS)" + if [ "$elpa_include" != "__FALSE__" ]; then + echo "ELPA include directory threaded version is found to be $elpa_include" + ELPA_CFLAGS="-I'$elpa_include/modules' -I'$elpa_include/elpa'" + else + echo "Cannot find elpa_openmp-${elpa_ver} from paths $INCLUDE_PATHS" + exit 1 + fi + # get the lib paths + add_lib_from_paths ELPA_LDFLAGS "libelpa.*" $LIB_PATHS + ;; + __DONTUSE__) ;; + + *) + echo "==================== Linking ELPA to user paths ====================" + pkg_install_dir="$with_elpa" + check_dir "${pkg_install_dir}/include" + check_dir "${pkg_install_dir}/lib" + user_include_path="$pkg_install_dir/include" + elpa_include="$(find_in_paths "elpa_openmp-*" user_include_path)" + if [ "$elpa_include" != "__FALSE__" ]; then + echo "ELPA include directory threaded version is found to be $elpa_include/modules" + check_dir "$elpa_include/modules" + ELPA_CFLAGS="-I'$elpa_include/modules' -I'$elpa_include/elpa'" + else + echo "Cannot find elpa_openmp-* from path $user_include_path" + exit 1 + fi + ELPA_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; esac -if [ "$with_elpa" != "__DONTUSE__" ] ; then - ELPA_LIBS="-lelpa_openmp" - cat < "${BUILDDIR}/setup_elpa" +if [ "$with_elpa" != "__DONTUSE__" ]; then + ELPA_LIBS="-lelpa_openmp" + cat << EOF > "${BUILDDIR}/setup_elpa" prepend_path CPATH "$elpa_include" EOF - if [ "$with_elpa" != "__SYSTEM__" ] ; then - cat <> "${BUILDDIR}/setup_elpa" + if [ "$with_elpa" != "__SYSTEM__" ]; then + cat << EOF >> "${BUILDDIR}/setup_elpa" prepend_path PATH "$pkg_install_dir/bin" prepend_path LD_LIBRARY_PATH "$pkg_install_dir/lib" prepend_path LD_RUN_PATH "$pkg_install_dir/lib" prepend_path LIBRARY_PATH "$pkg_install_dir/lib" export ELPAROOT="$pkg_install_dir" EOF - fi - cat "${BUILDDIR}/setup_elpa" >> $SETUPFILE - cat <> "${BUILDDIR}/setup_elpa" + fi + cat "${BUILDDIR}/setup_elpa" >> $SETUPFILE + cat << EOF >> "${BUILDDIR}/setup_elpa" export ELPA_CFLAGS="${ELPA_CFLAGS}" export ELPA_LDFLAGS="${ELPA_LDFLAGS}" export ELPA_LIBS="${ELPA_LIBS}" @@ -189,7 +190,7 @@ export ELPAROOT="$pkg_install_dir" export ELPAVERSION="${elpa_ver}" EOF -cat <> ${INSTALLDIR}/lsan.supp + cat << EOF >> ${INSTALLDIR}/lsan.supp # leaks related to ELPA leak:cublasXtDeviceSelect EOF diff --git a/tools/toolchain/scripts/stage5/install_pexsi.sh b/tools/toolchain/scripts/stage5/install_pexsi.sh index bb818561a3..01cf36d737 100755 --- a/tools/toolchain/scripts/stage5/install_pexsi.sh +++ b/tools/toolchain/scripts/stage5/install_pexsi.sh @@ -19,101 +19,101 @@ PEXSI_LIBS='' cd "${BUILDDIR}" case "$with_pexsi" in - __INSTALL__) - echo "==================== Installing PEXSI ====================" - require_env SUPERLU_LDFLAGS - require_env SUPERLU_LIBS - require_env MATH_LIBS - require_env MPI_LDFLAGS - require_env MPI_LIBS - pkg_install_dir="${INSTALLDIR}/pexsi-${pexsi_ver}" - install_lock_file="$pkg_install_dir/install_successful" - if verify_checksums "${install_lock_file}" ; then - echo "pexsi_dist-${pexsi_ver} is already installed, skipping it." - else - if [ -f pexsi_v${pexsi_ver}.tar.gz ] ; then - echo "pexsi_v${pexsi_ver}.tar.gz is found" - else - download_pkg ${DOWNLOADER_FLAGS} ${pexsi_sha256} \ - https://www.cp2k.org/static/downloads/pexsi_v${pexsi_ver}.tar.gz - fi - echo "Installing from scratch into ${pkg_install_dir}" - [ -d pexsi_v${pexsi_ver} ] && rm -rf pexsi_v${pexsi_ver} - tar -xzf pexsi_v${pexsi_ver}.tar.gz - cd pexsi_v${pexsi_ver} - cat config/make.inc.linux.gnu | \ - sed -e "s|\(CC *=\).*|\1 ${MPICC}|g" \ - -e "s|\(CXX *=\).*|\1 ${MPICXX}|g" \ - -e "s|\(FC *=\).*|\1 ${MPIFC}|g" \ - -e "s|\(LOADER *=\).*|\1 ${MPICXX}|g" \ - -e "s|\(USE_SYMPACK *=\).*|\1 0|g" \ - -e "s|\(PEXSI_DIR *=\).*|\1 ${PWD}|g" \ - -e "s|\(PEXSI_BUILD_DIR *=\).*|\1 ${pkg_install_dir}|g" \ - -e "s|\(CPP_LIB *=\).*|\1 -lstdc++ ${MPI_LDFLAGS} ${MPI_LIBS} |g" \ - -e "s|\(LAPACK_LIB *=\).*|\1 ${MATH_LDFLAGS} $(resolve_string "${MATH_LIBS}")|g" \ - -e "s|\(BLAS_LIB *=\).*|\1|g" \ - -e "s|\(\bMETIS_LIB *=\).*|\1 ${METIS_LDFLAGS} ${METIS_LIBS}|g" \ - -e "s|\(PARMETIS_LIB *=\).*|\1 |g" \ - -e "s|\(DSUPERLU_LIB *=\).*|\1 ${SUPERLU_LDFLAGS} -lsuperlu_dist|g" \ - -e "s|\(SCOTCH_LIB *=\).*|\1 ${SCOTCH_LDFLAGS} -lscotchmetis -lscotch -lscotcherr|g" \ - -e "s|\(PTSCOTCH_LIB *=\).*|\1 ${SCOTCH_LDFLAGS} -lptscotchparmetis -lptscotch -lptscotcherr -lscotch|g" \ - -e "s|\(DSUPERLU_INCLUDE *=\).*|\1 ${SUPERLU_CFLAGS}|g" \ - -e "s|\(INCLUDES *=\).*|\1 ${MATH_CFLAGS} \${DSUPERLU_INCLUDE} \${PEXSI_INCLUDE}|g" \ - -e "s|\(COMPILE_FLAG *=\).*|\1 ${CFLAGS}|g" \ - -e "s|\(SUFFIX *=\).*|\1 ${OPENBLAS_ARCH}|g" \ - -e "s|\(DSUPERLU_DIR *=\).*|\1|g" \ - -e "s|\(METIS_DIR *=\).*|\1|g" \ - -e "s|\(PARMETIS_DIR *=\).*|\1|g" \ - -e "s|\(PTSCOTCH_DIR *=\).*|\1|g" \ - -e "s|\(LAPACK_DIR *=\).*|\1|g" \ - -e "s|\(BLAS_DIR *=\).*|\1|g" \ - -e "s|-DCOREDUMPER||g" \ - -e "s|\(COREDUMPER_LIB *=\).*||g" \ - -e "s|\(GFORTRAN_LIB *=\).*|\1 -lgfortran|g" > make.inc + __INSTALL__) + echo "==================== Installing PEXSI ====================" + require_env SUPERLU_LDFLAGS + require_env SUPERLU_LIBS + require_env MATH_LIBS + require_env MPI_LDFLAGS + require_env MPI_LIBS + pkg_install_dir="${INSTALLDIR}/pexsi-${pexsi_ver}" + install_lock_file="$pkg_install_dir/install_successful" + if verify_checksums "${install_lock_file}"; then + echo "pexsi_dist-${pexsi_ver} is already installed, skipping it." + else + if [ -f pexsi_v${pexsi_ver}.tar.gz ]; then + echo "pexsi_v${pexsi_ver}.tar.gz is found" + else + download_pkg ${DOWNLOADER_FLAGS} ${pexsi_sha256} \ + https://www.cp2k.org/static/downloads/pexsi_v${pexsi_ver}.tar.gz + fi + echo "Installing from scratch into ${pkg_install_dir}" + [ -d pexsi_v${pexsi_ver} ] && rm -rf pexsi_v${pexsi_ver} + tar -xzf pexsi_v${pexsi_ver}.tar.gz + cd pexsi_v${pexsi_ver} + cat config/make.inc.linux.gnu | + sed -e "s|\(CC *=\).*|\1 ${MPICC}|g" \ + -e "s|\(CXX *=\).*|\1 ${MPICXX}|g" \ + -e "s|\(FC *=\).*|\1 ${MPIFC}|g" \ + -e "s|\(LOADER *=\).*|\1 ${MPICXX}|g" \ + -e "s|\(USE_SYMPACK *=\).*|\1 0|g" \ + -e "s|\(PEXSI_DIR *=\).*|\1 ${PWD}|g" \ + -e "s|\(PEXSI_BUILD_DIR *=\).*|\1 ${pkg_install_dir}|g" \ + -e "s|\(CPP_LIB *=\).*|\1 -lstdc++ ${MPI_LDFLAGS} ${MPI_LIBS} |g" \ + -e "s|\(LAPACK_LIB *=\).*|\1 ${MATH_LDFLAGS} $(resolve_string "${MATH_LIBS}")|g" \ + -e "s|\(BLAS_LIB *=\).*|\1|g" \ + -e "s|\(\bMETIS_LIB *=\).*|\1 ${METIS_LDFLAGS} ${METIS_LIBS}|g" \ + -e "s|\(PARMETIS_LIB *=\).*|\1 |g" \ + -e "s|\(DSUPERLU_LIB *=\).*|\1 ${SUPERLU_LDFLAGS} -lsuperlu_dist|g" \ + -e "s|\(SCOTCH_LIB *=\).*|\1 ${SCOTCH_LDFLAGS} -lscotchmetis -lscotch -lscotcherr|g" \ + -e "s|\(PTSCOTCH_LIB *=\).*|\1 ${SCOTCH_LDFLAGS} -lptscotchparmetis -lptscotch -lptscotcherr -lscotch|g" \ + -e "s|\(DSUPERLU_INCLUDE *=\).*|\1 ${SUPERLU_CFLAGS}|g" \ + -e "s|\(INCLUDES *=\).*|\1 ${MATH_CFLAGS} \${DSUPERLU_INCLUDE} \${PEXSI_INCLUDE}|g" \ + -e "s|\(COMPILE_FLAG *=\).*|\1 ${CFLAGS}|g" \ + -e "s|\(SUFFIX *=\).*|\1 ${OPENBLAS_ARCH}|g" \ + -e "s|\(DSUPERLU_DIR *=\).*|\1|g" \ + -e "s|\(METIS_DIR *=\).*|\1|g" \ + -e "s|\(PARMETIS_DIR *=\).*|\1|g" \ + -e "s|\(PTSCOTCH_DIR *=\).*|\1|g" \ + -e "s|\(LAPACK_DIR *=\).*|\1|g" \ + -e "s|\(BLAS_DIR *=\).*|\1|g" \ + -e "s|-DCOREDUMPER||g" \ + -e "s|\(COREDUMPER_LIB *=\).*||g" \ + -e "s|\(GFORTRAN_LIB *=\).*|\1 -lgfortran|g" > make.inc - # Seemingly this should've been moved together with the other fortran files. - mv ./src/f_interface.f90 ./fortran/ + # Seemingly this should've been moved together with the other fortran files. + mv ./src/f_interface.f90 ./fortran/ - make finstall > make.log 2>&1 # still issues with parallel make (fortran_examples target) + make finstall > make.log 2>&1 # still issues with parallel make (fortran_examples target) - ln -sf "${pkg_install_dir}/lib/libpexsi_${OPENBLAS_ARCH}.a" \ - "${pkg_install_dir}/lib/libpexsi.a" + ln -sf "${pkg_install_dir}/lib/libpexsi_${OPENBLAS_ARCH}.a" \ + "${pkg_install_dir}/lib/libpexsi.a" - cp -r ./include/* ${pkg_install_dir}/include/ # bug: make install neglects most header files + cp -r ./include/* ${pkg_install_dir}/include/ # bug: make install neglects most header files - write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage5/$(basename ${SCRIPT_NAME})" - fi - PEXSI_CFLAGS="-I'${pkg_install_dir}/include'" + write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage5/$(basename ${SCRIPT_NAME})" + fi + PEXSI_CFLAGS="-I'${pkg_install_dir}/include'" - PEXSI_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; - __SYSTEM__) - echo "==================== Finding Pexsi_DIST from system paths ====================" - check_lib -lpexsi "PEXSI" - # add_include_from_paths PEXSI_CFLAGS "pexsi*" $INCLUDE_PATHS - add_lib_from_paths PEXSI_LDFLAGS "libpexsi.*" $LIB_PATHS - ;; - __DONTUSE__) - ;; - *) - echo "==================== Linking Pexsi_Dist to user paths ====================" - pkg_install_dir="$with_pexsi" - check_dir "${pkg_install_dir}/lib" - check_dir "${pkg_install_dir}/include" - ;; + PEXSI_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; + __SYSTEM__) + echo "==================== Finding Pexsi_DIST from system paths ====================" + check_lib -lpexsi "PEXSI" + # add_include_from_paths PEXSI_CFLAGS "pexsi*" $INCLUDE_PATHS + add_lib_from_paths PEXSI_LDFLAGS "libpexsi.*" $LIB_PATHS + ;; + __DONTUSE__) ;; + + *) + echo "==================== Linking Pexsi_Dist to user paths ====================" + pkg_install_dir="$with_pexsi" + check_dir "${pkg_install_dir}/lib" + check_dir "${pkg_install_dir}/include" + ;; esac -if [ "$with_pexsi" != "__DONTUSE__" ] ; then - PEXSI_LIBS="-lpexsi" - if [ "$with_pexsi" != "__SYSTEM__" ] ; then - cat < "${BUILDDIR}/setup_pexsi" +if [ "$with_pexsi" != "__DONTUSE__" ]; then + PEXSI_LIBS="-lpexsi" + if [ "$with_pexsi" != "__SYSTEM__" ]; then + cat << EOF > "${BUILDDIR}/setup_pexsi" prepend_path LD_LIBRARY_PATH "$pkg_install_dir/lib" prepend_path LD_RUN_PATH "$pkg_install_dir/lib" prepend_path LIBRARY_PATH "$pkg_install_dir/lib" prepend_path CPATH "$pkg_install_dir/include" EOF - cat "${BUILDDIR}/setup_pexsi" >> $SETUPFILE - fi - cat <> "${BUILDDIR}/setup_pexsi" + cat "${BUILDDIR}/setup_pexsi" >> $SETUPFILE + fi + cat << EOF >> "${BUILDDIR}/setup_pexsi" export PEXSI_CFLAGS="${PEXSI_CFLAGS}" export PEXSI_LDFLAGS="${PEXSI_LDFLAGS}" export PEXSI_LIBS="${PEXSI_LIBS}" diff --git a/tools/toolchain/scripts/stage5/install_ptscotch.sh b/tools/toolchain/scripts/stage5/install_ptscotch.sh index ed285f36ba..ee72a04401 100755 --- a/tools/toolchain/scripts/stage5/install_ptscotch.sh +++ b/tools/toolchain/scripts/stage5/install_ptscotch.sh @@ -19,82 +19,82 @@ SCOTCH_LIBS='' cd "${BUILDDIR}" case "$with_ptscotch" in - __INSTALL__) - echo "==================== Installing PT-Scotch ====================" - pkg_install_dir="${INSTALLDIR}/scotch-${scotch_ver}" - install_lock_file="$pkg_install_dir/install_successful" - if verify_checksums "${install_lock_file}" ; then - echo "scotch-${scotch_ver} is already installed, skipping it." - else - if [ -f scotch_${scotch_ver}.tar.gz ] ; then - echo "scotch_${scotch_ver}.tar.gz is found" - else - download_pkg ${DOWNLOADER_FLAGS} ${scotch_sha256} \ - https://www.cp2k.org/static/downloads/scotch_${scotch_ver}.tar.gz - fi - echo "Installing from scratch into ${pkg_install_dir}" - [ -d scotch_${scotch_ver} ] && rm -rf scotch_${scotch_ver} - tar -xzf scotch_${scotch_ver}.tar.gz - cd scotch_${scotch_ver}/src - cat Make.inc/Makefile.inc.x86-64_pc_linux2 | \ - sed -e "s|\(^CCS\).*|\1 = $MPICC|g" \ - -e "s|\(^CCP\).*|\1 = $MPICC|g" \ - -e "s|\(^CCD\).*|\1 = $MPICC|g" \ - -e "s|\(^CFLAGS\).*|\1 = $CFLAGS -DCOMMON_RANDOM_FIXED_SEED -DSCOTCH_RENAME -Drestrict=__restrict -DIDXSIZE64 ${MPI_CFLAGS}|g" \ - > Makefile.inc - make scotch -j $NPROCS > make.log 2>&1 - make ptscotch -j $NROCS > make.log 2>&1 - # PT-scotch make install is buggy in that it cannot create - # intermediate directories - ! [ -d "${pkg_install_dir}" ] && mkdir -p "${pkg_install_dir}" - make install prefix=${pkg_install_dir} > install.log 2>&1 - cd .. + __INSTALL__) + echo "==================== Installing PT-Scotch ====================" + pkg_install_dir="${INSTALLDIR}/scotch-${scotch_ver}" + install_lock_file="$pkg_install_dir/install_successful" + if verify_checksums "${install_lock_file}"; then + echo "scotch-${scotch_ver} is already installed, skipping it." + else + if [ -f scotch_${scotch_ver}.tar.gz ]; then + echo "scotch_${scotch_ver}.tar.gz is found" + else + download_pkg ${DOWNLOADER_FLAGS} ${scotch_sha256} \ + https://www.cp2k.org/static/downloads/scotch_${scotch_ver}.tar.gz + fi + echo "Installing from scratch into ${pkg_install_dir}" + [ -d scotch_${scotch_ver} ] && rm -rf scotch_${scotch_ver} + tar -xzf scotch_${scotch_ver}.tar.gz + cd scotch_${scotch_ver}/src + cat Make.inc/Makefile.inc.x86-64_pc_linux2 | + sed -e "s|\(^CCS\).*|\1 = $MPICC|g" \ + -e "s|\(^CCP\).*|\1 = $MPICC|g" \ + -e "s|\(^CCD\).*|\1 = $MPICC|g" \ + -e "s|\(^CFLAGS\).*|\1 = $CFLAGS -DCOMMON_RANDOM_FIXED_SEED -DSCOTCH_RENAME -Drestrict=__restrict -DIDXSIZE64 ${MPI_CFLAGS}|g" \ + > Makefile.inc + make scotch -j $NPROCS > make.log 2>&1 + make ptscotch -j $NROCS > make.log 2>&1 + # PT-scotch make install is buggy in that it cannot create + # intermediate directories + ! [ -d "${pkg_install_dir}" ] && mkdir -p "${pkg_install_dir}" + make install prefix=${pkg_install_dir} > install.log 2>&1 + cd .. - # PEXSI also needs parmetis.h - cp ./include/parmetis.h "${pkg_install_dir}/include/" - sed -i "s|SCOTCH_Num|int|g" "${pkg_install_dir}/include/parmetis.h" + # PEXSI also needs parmetis.h + cp ./include/parmetis.h "${pkg_install_dir}/include/" + sed -i "s|SCOTCH_Num|int|g" "${pkg_install_dir}/include/parmetis.h" - write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage5/$(basename ${SCRIPT_NAME})" - fi - SCOTCH_CFLAGS="-I'${pkg_install_dir}/include'" - SCOTCH_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; - __SYSTEM__) - echo "==================== Finding PT-Scotch from system paths ====================" - check_lib -lptscotchparmetis "PT-Scotch" - check_lib -lptscotch "PT-Scotch" - check_lib -lptscotcherr "PT-Scotch" - check_lib -lscotchmetis "PT-Scotch" - check_lib -lscotch "PT-Scotch" - check_lib -lscotcherr "PT-Scotch" - check_lib -lptscotchparmetis "PT-Scotch" - add_include_from_paths SCOTCH_CFLAGS "ptscotch.h" $INCLUDE_PATHS - add_lib_from_paths SCOTCH_LDFLAGS "libptscotch.*" $LIB_PATHS - ;; - __DONTUSE__) - ;; - *) - echo "==================== Linking PT-Scotch to user paths ====================" - pkg_install_dir="$with_ptscotch" - check_dir "${pkg_install_dir}/lib" - check_dir "${pkg_install_dir}/include" - SCOTCH_CFLAGS="-I'${pkg_install_dir}/include'" - SCOTCH_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; + write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage5/$(basename ${SCRIPT_NAME})" + fi + SCOTCH_CFLAGS="-I'${pkg_install_dir}/include'" + SCOTCH_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; + __SYSTEM__) + echo "==================== Finding PT-Scotch from system paths ====================" + check_lib -lptscotchparmetis "PT-Scotch" + check_lib -lptscotch "PT-Scotch" + check_lib -lptscotcherr "PT-Scotch" + check_lib -lscotchmetis "PT-Scotch" + check_lib -lscotch "PT-Scotch" + check_lib -lscotcherr "PT-Scotch" + check_lib -lptscotchparmetis "PT-Scotch" + add_include_from_paths SCOTCH_CFLAGS "ptscotch.h" $INCLUDE_PATHS + add_lib_from_paths SCOTCH_LDFLAGS "libptscotch.*" $LIB_PATHS + ;; + __DONTUSE__) ;; + + *) + echo "==================== Linking PT-Scotch to user paths ====================" + pkg_install_dir="$with_ptscotch" + check_dir "${pkg_install_dir}/lib" + check_dir "${pkg_install_dir}/include" + SCOTCH_CFLAGS="-I'${pkg_install_dir}/include'" + SCOTCH_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; esac -if [ "$with_ptscotch" != "__DONTUSE__" ] ; then - SCOTCH_LIBS="-lptscotchparmetis -lptscotch -lptscotcherr -lscotchmetis -lscotch -lscotcherr" - if [ "$with_ptscotch" != "__SYSTEM__" ] ; then - cat < "${BUILDDIR}/setup_ptscotch" +if [ "$with_ptscotch" != "__DONTUSE__" ]; then + SCOTCH_LIBS="-lptscotchparmetis -lptscotch -lptscotcherr -lscotchmetis -lscotch -lscotcherr" + if [ "$with_ptscotch" != "__SYSTEM__" ]; then + cat << EOF > "${BUILDDIR}/setup_ptscotch" prepend_path PATH "$pkg_install_dir/bin" prepend_path LD_LIBRARY_PATH "$pkg_install_dir/lib" prepend_path LD_RUN_PATH "$pkg_install_dir/lib" prepend_path LIBRARY_PATH "$pkg_install_dir/lib" prepend_path CPATH "$pkg_install_dir/include" EOF - cat "${BUILDDIR}/setup_ptscotch" >> $SETUPFILE - fi - cat <> "${BUILDDIR}/setup_ptscotch" + cat "${BUILDDIR}/setup_ptscotch" >> $SETUPFILE + fi + cat << EOF >> "${BUILDDIR}/setup_ptscotch" export SCOTCH_CFLAGS="${SCOTCH_CFLAGS}" export SCOTCH_LDFLAGS="${SCOTCH_LDFLAGS}" export SCOTCH_LIBS="${SCOTCH_LIBS}" diff --git a/tools/toolchain/scripts/stage5/install_superlu.sh b/tools/toolchain/scripts/stage5/install_superlu.sh index 42817eb108..5065308cfa 100755 --- a/tools/toolchain/scripts/stage5/install_superlu.sh +++ b/tools/toolchain/scripts/stage5/install_superlu.sh @@ -2,7 +2,7 @@ [ "${BASH_SOURCE[0]}" ] && SCRIPT_NAME="${BASH_SOURCE[0]}" || SCRIPT_NAME=$0 SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_NAME")/.." && pwd -P)" -superlu_ver="6.1.0" # Newer versions don't work with PEXSI 1.2.0. +superlu_ver="6.1.0" # Newer versions don't work with PEXSI 1.2.0. superlu_sha256="92c6d1424dd830ee2d1e7396a418a5f6645160aea8472e558c4e4bfe006593c4" source "${SCRIPT_DIR}"/common_vars.sh @@ -20,71 +20,71 @@ SUPERLU_LIBS='' cd "${BUILDDIR}" case "$with_superlu" in - __INSTALL__) - echo "==================== Installing SuperLU_DIST ====================" - require_env MATH_LIBS - pkg_install_dir="${INSTALLDIR}/superlu_dist-${superlu_ver}" - install_lock_file="$pkg_install_dir/install_successful" - if verify_checksums "${install_lock_file}" ; then - echo "superlu_dist-${superlu_ver} is already installed, skipping it." - else - if [ -f superlu_dist_${superlu_ver}.tar.gz ] ; then - echo "superlu_dist_${superlu_ver}.tar.gz is found" - else - download_pkg ${DOWNLOADER_FLAGS} ${superlu_sha256} \ - https://www.cp2k.org/static/downloads/superlu_dist_${superlu_ver}.tar.gz - fi - echo "Installing from scratch into ${pkg_install_dir}" - [ -d SuperLU_DIST_${superlu_ver} ] && rm -rf SuperLU_DIST_${superlu_ver} - tar -xzf superlu_dist_${superlu_ver}.tar.gz - cd superlu_dist-${superlu_ver} - cd build - # Explicitly set LIBDIR to "lib", otherwise it sometimes defaults to "lib64". - cmake -DTPL_ENABLE_PARMETISLIB=FALSE \ - -DCMAKE_INSTALL_PREFIX=${pkg_install_dir} \ - -DCMAKE_INSTALL_LIBDIR=${pkg_install_dir}/lib \ - .. > cmake.log 2>&1 - make -j $NPROCS > make.log 2>&1 - make install > install.log 2>&1 - cd .. + __INSTALL__) + echo "==================== Installing SuperLU_DIST ====================" + require_env MATH_LIBS + pkg_install_dir="${INSTALLDIR}/superlu_dist-${superlu_ver}" + install_lock_file="$pkg_install_dir/install_successful" + if verify_checksums "${install_lock_file}"; then + echo "superlu_dist-${superlu_ver} is already installed, skipping it." + else + if [ -f superlu_dist_${superlu_ver}.tar.gz ]; then + echo "superlu_dist_${superlu_ver}.tar.gz is found" + else + download_pkg ${DOWNLOADER_FLAGS} ${superlu_sha256} \ + https://www.cp2k.org/static/downloads/superlu_dist_${superlu_ver}.tar.gz + fi + echo "Installing from scratch into ${pkg_install_dir}" + [ -d SuperLU_DIST_${superlu_ver} ] && rm -rf SuperLU_DIST_${superlu_ver} + tar -xzf superlu_dist_${superlu_ver}.tar.gz + cd superlu_dist-${superlu_ver} + cd build + # Explicitly set LIBDIR to "lib", otherwise it sometimes defaults to "lib64". + cmake -DTPL_ENABLE_PARMETISLIB=FALSE \ + -DCMAKE_INSTALL_PREFIX=${pkg_install_dir} \ + -DCMAKE_INSTALL_LIBDIR=${pkg_install_dir}/lib \ + .. > cmake.log 2>&1 + make -j $NPROCS > make.log 2>&1 + make install > install.log 2>&1 + cd .. - # PEXSI needs some more headers. - cp SRC/*.h "${pkg_install_dir}/include" + # PEXSI needs some more headers. + cp SRC/*.h "${pkg_install_dir}/include" - write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage5/$(basename ${SCRIPT_NAME})" - fi - SUPERLU_CFLAGS="-I'${pkg_install_dir}/include'" - SUPERLU_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; - __SYSTEM__) - echo "==================== Finding SuperLU_DIST from system paths ====================" - check_lib -lsuperlu_dist "SuperLU_DIST" - add_include_from_paths SUPERLU_CFLAGS "superlu*" $INCLUDE_PATHS - add_lib_from_paths SUPERLU_LDFLAGS "libsuperlu*" $LIB_PATHS - ;; - __DONTUSE__) - ;; - *) - echo "==================== Linking Superlu_Dist to user paths ====================" - pkg_install_dir="$with_superlu" - check_dir "${pkg_install_dir}/lib" - check_dir "${pkg_install_dir}/include" - SUPERLU_CFLAGS="-I'${pkg_install_dir}/include'" - SUPERLU_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; + write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage5/$(basename ${SCRIPT_NAME})" + fi + SUPERLU_CFLAGS="-I'${pkg_install_dir}/include'" + SUPERLU_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; + __SYSTEM__) + echo "==================== Finding SuperLU_DIST from system paths ====================" + check_lib -lsuperlu_dist "SuperLU_DIST" + add_include_from_paths SUPERLU_CFLAGS "superlu*" $INCLUDE_PATHS + add_lib_from_paths SUPERLU_LDFLAGS "libsuperlu*" $LIB_PATHS + ;; + __DONTUSE__) ;; + + *) + echo "==================== Linking Superlu_Dist to user paths ====================" + pkg_install_dir="$with_superlu" + check_dir "${pkg_install_dir}/lib" + check_dir "${pkg_install_dir}/include" + SUPERLU_CFLAGS="-I'${pkg_install_dir}/include'" + SUPERLU_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; esac -if [ "$with_superlu" != "__DONTUSE__" ] ; then - SUPERLU_LIBS="-lsuperlu_dist" - if [ "$with_superlu" != "__SYSTEM__" ] ; then - cat < "${BUILDDIR}/setup_superlu" +if [ "$with_superlu" != "__DONTUSE__" ]; then + SUPERLU_LIBS="-lsuperlu_dist" + if [ "$with_superlu" != "__SYSTEM__" ]; then + cat << EOF > "${BUILDDIR}/setup_superlu" prepend_path LD_LIBRARY_PATH "$pkg_install_dir/lib" prepend_path LD_RUN_PATH "$pkg_install_dir/lib" prepend_path LIBRARY_PATH "$pkg_install_dir/lib" prepend_path CPATH "$pkg_install_dir/include" EOF - cat "${BUILDDIR}/setup_superlu" >> $SETUPFILE - fi - cat <> "${BUILDDIR}/setup_superlu" + cat "${BUILDDIR}/setup_superlu" >> $SETUPFILE + fi + cat << EOF >> "${BUILDDIR}/setup_superlu" export SUPERLU_CFLAGS="${SUPERLU_CFLAGS}" export SUPERLU_LDFLAGS="${SUPERLU_LDFLAGS}" export SUPERLU_LIBS="${SUPERLU_LIBS}" diff --git a/tools/toolchain/scripts/stage6/install_gsl.sh b/tools/toolchain/scripts/stage6/install_gsl.sh index d611cef4c4..402f0169f1 100755 --- a/tools/toolchain/scripts/stage6/install_gsl.sh +++ b/tools/toolchain/scripts/stage6/install_gsl.sh @@ -16,57 +16,57 @@ source "${INSTALLDIR}"/toolchain.env cd "${BUILDDIR}" case "$with_gsl" in - __INSTALL__) - echo "==================== Installing gsl ====================" - pkg_install_dir="${INSTALLDIR}/gsl-${gsl_ver}" - install_lock_file="$pkg_install_dir/install_successful" - if verify_checksums "${install_lock_file}" ; then - echo "gsl-${gsl_ver} is already installed, skipping it." - else - if [ -f gsl-${gsl_ver}.tar.gz ] ; then - echo "gsl-${gsl_ver}.tar.gz is found" - else - download_pkg ${DOWNLOADER_FLAGS} ${gls_sha256} \ - "https://www.cp2k.org/static/downloads/gsl-${gsl_ver}.tar.gz" - fi - echo "Installing from scratch into ${pkg_install_dir}" - [ -d gsl-${gsl_ver} ] && rm -rf gsl-${gsl_ver} - tar -xzf gsl-${gsl_ver}.tar.gz - cd gsl-${gsl_ver} - ./configure --prefix="${pkg_install_dir}" \ - --libdir="${pkg_install_dir}/lib" \ - --enable-shared \ - --enable-static > configure.log 2>&1 - make -j $NPROCS > make.log 2>&1 - make -j $NPROCS install > install.log 2>&1 - cd .. - write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage6/$(basename ${SCRIPT_NAME})" - fi + __INSTALL__) + echo "==================== Installing gsl ====================" + pkg_install_dir="${INSTALLDIR}/gsl-${gsl_ver}" + install_lock_file="$pkg_install_dir/install_successful" + if verify_checksums "${install_lock_file}"; then + echo "gsl-${gsl_ver} is already installed, skipping it." + else + if [ -f gsl-${gsl_ver}.tar.gz ]; then + echo "gsl-${gsl_ver}.tar.gz is found" + else + download_pkg ${DOWNLOADER_FLAGS} ${gls_sha256} \ + "https://www.cp2k.org/static/downloads/gsl-${gsl_ver}.tar.gz" + fi + echo "Installing from scratch into ${pkg_install_dir}" + [ -d gsl-${gsl_ver} ] && rm -rf gsl-${gsl_ver} + tar -xzf gsl-${gsl_ver}.tar.gz + cd gsl-${gsl_ver} + ./configure --prefix="${pkg_install_dir}" \ + --libdir="${pkg_install_dir}/lib" \ + --enable-shared \ + --enable-static > configure.log 2>&1 + make -j $NPROCS > make.log 2>&1 + make -j $NPROCS install > install.log 2>&1 + cd .. + write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage6/$(basename ${SCRIPT_NAME})" + fi - GSL_CFLAGS="-I'${pkg_install_dir}/include'" - GSL_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; - __SYSTEM__) - echo "==================== Finding gsl from system paths ====================" - check_command pkg-config --modversion gsl - add_include_from_paths GSL_CFLAGS "gsl.h" $INCLUDE_PATHS - add_lib_from_paths GSL_LDFLAGS "libgsl.*" $LIB_PATHS - ;; - __DONTUSE__) - ;; - *) - echo "==================== Linking gsl to user paths ====================" - pkg_install_dir="$with_gsl" - check_dir "$pkg_install_dir/lib" - check_dir "$pkg_install_dir/include" - GSL_CFLAGS="-I'${pkg_install_dir}/include'" - GSL_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; + GSL_CFLAGS="-I'${pkg_install_dir}/include'" + GSL_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; + __SYSTEM__) + echo "==================== Finding gsl from system paths ====================" + check_command pkg-config --modversion gsl + add_include_from_paths GSL_CFLAGS "gsl.h" $INCLUDE_PATHS + add_lib_from_paths GSL_LDFLAGS "libgsl.*" $LIB_PATHS + ;; + __DONTUSE__) ;; + + *) + echo "==================== Linking gsl to user paths ====================" + pkg_install_dir="$with_gsl" + check_dir "$pkg_install_dir/lib" + check_dir "$pkg_install_dir/include" + GSL_CFLAGS="-I'${pkg_install_dir}/include'" + GSL_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; esac -if [ "$with_gsl" != "__DONTUSE__" ] ; then - GSL_LIBS="-lgsl -lgslcblas" - if [ "$with_gsl" != "__SYSTEM__" ] ; then - cat << EOF > "${BUILDDIR}/setup_gsl" +if [ "$with_gsl" != "__DONTUSE__" ]; then + GSL_LIBS="-lgsl -lgslcblas" + if [ "$with_gsl" != "__SYSTEM__" ]; then + cat << EOF > "${BUILDDIR}/setup_gsl" prepend_path LD_LIBRARY_PATH "$pkg_install_dir/lib" prepend_path LD_RUN_PATH "$pkg_install_dir/lib" prepend_path LIBRARY_PATH "$pkg_install_dir/lib" @@ -76,8 +76,8 @@ export GSL_LIBRARY="-lgsl" export GSL_CBLAS_LIBRARY="-lgslcblas" export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$pkg_install_dir/lib64/pkgconfig:$pkg_install_dir/lib/pkgconfig" EOF - fi - cat << EOF >> "${BUILDDIR}/setup_gsl" + fi + cat << EOF >> "${BUILDDIR}/setup_gsl" export GSL_CFLAGS="${GSL_CFLAGS}" export GSL_LDFLAGS="${GSL_LDFLAGS}" export CP_DFLAGS="\${CP_DFLAGS} IF_MPI(-D__GSL|)" @@ -99,7 +99,7 @@ export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$pkg_install_dir/lib64/pkgconfig:$pkg_i export CP_LIBS="IF_MPI(${GSL_LIBS}|) \${CP_LIBS}" EOF - cat "${BUILDDIR}/setup_gsl" >> $SETUPFILE + cat "${BUILDDIR}/setup_gsl" >> $SETUPFILE fi load "${BUILDDIR}/setup_gsl" diff --git a/tools/toolchain/scripts/stage6/install_plumed.sh b/tools/toolchain/scripts/stage6/install_plumed.sh index f5bf74b876..9a0fdba916 100755 --- a/tools/toolchain/scripts/stage6/install_plumed.sh +++ b/tools/toolchain/scripts/stage6/install_plumed.sh @@ -21,72 +21,72 @@ PLUMED_LIBS='' cd "${BUILDDIR}" case "$with_plumed" in - __INSTALL__) - echo "==================== Installing PLUMED ====================" - pkg_install_dir="${INSTALLDIR}/plumed-${plumed_ver}" - install_lock_file="$pkg_install_dir/install_successful" - if verify_checksums "${install_lock_file}" ; then - echo "plumed-${plumed_ver} is already installed, skipping it." - else - if [ -f ${plumed_pkg} ] ; then - echo "${plumed_pkg} is found" - else - download_pkg ${DOWNLOADER_FLAGS} ${plumed_sha256} \ - "https://www.cp2k.org/static/downloads/${plumed_pkg}" - fi + __INSTALL__) + echo "==================== Installing PLUMED ====================" + pkg_install_dir="${INSTALLDIR}/plumed-${plumed_ver}" + install_lock_file="$pkg_install_dir/install_successful" + if verify_checksums "${install_lock_file}"; then + echo "plumed-${plumed_ver} is already installed, skipping it." + else + if [ -f ${plumed_pkg} ]; then + echo "${plumed_pkg} is found" + else + download_pkg ${DOWNLOADER_FLAGS} ${plumed_sha256} \ + "https://www.cp2k.org/static/downloads/${plumed_pkg}" + fi - [ -d plumed-${plumed_ver} ] && rm -rf plumed-${plumed_ver} - tar -xzf ${plumed_pkg} + [ -d plumed-${plumed_ver} ] && rm -rf plumed-${plumed_ver} + tar -xzf ${plumed_pkg} - echo "Installing from scratch into ${pkg_install_dir}" - cd plumed-${plumed_ver} - # disable generating debugging infos for now to work around an issue in gcc-10.2: - # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96354 - # note: some MPI wrappers carry a -g forward, thus stripping is not enough + echo "Installing from scratch into ${pkg_install_dir}" + cd plumed-${plumed_ver} + # disable generating debugging infos for now to work around an issue in gcc-10.2: + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96354 + # note: some MPI wrappers carry a -g forward, thus stripping is not enough - libs="" - [ -n "${MKL_LIBS}" ] && libs+="${MKL_LIBS}" + libs="" + [ -n "${MKL_LIBS}" ] && libs+="${MKL_LIBS}" - ./configure \ - CXX="${MPICXX}" \ - CXXFLAGS="${CXXFLAGS//-g/-g0} ${GSL_CFLAGS}" \ - LDFLAGS="${LDFLAGS} ${GSL_LDFLAGS}" \ - LIBS="${libs}" \ - --prefix=${pkg_install_dir} \ - --libdir="${pkg_install_dir}/lib" > configure.log 2>&1 - make VERBOSE=1 -j $NPROCS > make.log 2>&1 - make install > install.log 2>&1 - write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage6/$(basename ${SCRIPT_NAME})" - fi - PLUMED_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; - __SYSTEM__) - echo "==================== Finding PLUMED from system paths ====================" - check_lib -lplumed "PLUMED" - add_lib_from_paths PLUMED_LDFLAGS "libplumed*" $LIB_PATHS - ;; - __DONTUSE__) - ;; - *) - echo "==================== Linking PLUMED to user paths ====================" - pkg_install_dir="$with_plumed" - check_dir "${pkg_install_dir}/lib" - PLUMED_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; + ./configure \ + CXX="${MPICXX}" \ + CXXFLAGS="${CXXFLAGS//-g/-g0} ${GSL_CFLAGS}" \ + LDFLAGS="${LDFLAGS} ${GSL_LDFLAGS}" \ + LIBS="${libs}" \ + --prefix=${pkg_install_dir} \ + --libdir="${pkg_install_dir}/lib" > configure.log 2>&1 + make VERBOSE=1 -j $NPROCS > make.log 2>&1 + make install > install.log 2>&1 + write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage6/$(basename ${SCRIPT_NAME})" + fi + PLUMED_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; + __SYSTEM__) + echo "==================== Finding PLUMED from system paths ====================" + check_lib -lplumed "PLUMED" + add_lib_from_paths PLUMED_LDFLAGS "libplumed*" $LIB_PATHS + ;; + __DONTUSE__) ;; + + *) + echo "==================== Linking PLUMED to user paths ====================" + pkg_install_dir="$with_plumed" + check_dir "${pkg_install_dir}/lib" + PLUMED_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; esac -if [ "$with_plumed" != "__DONTUSE__" ] ; then - PLUMED_LIBS='-lplumed -ldl -lstdc++ -lz -ldl' - if [ "$with_plumed" != "__SYSTEM__" ] ; then - cat < "${BUILDDIR}/setup_plumed" +if [ "$with_plumed" != "__DONTUSE__" ]; then + PLUMED_LIBS='-lplumed -ldl -lstdc++ -lz -ldl' + if [ "$with_plumed" != "__SYSTEM__" ]; then + cat << EOF > "${BUILDDIR}/setup_plumed" prepend_path LD_LIBRARY_PATH "$pkg_install_dir/lib" prepend_path LD_RUN_PATH "$pkg_install_dir/lib" prepend_path LIBRARY_PATH "$pkg_install_dir/lib" EOF - cat "${BUILDDIR}/setup_plumed" >> $SETUPFILE - fi + cat "${BUILDDIR}/setup_plumed" >> $SETUPFILE + fi - cat <> "${BUILDDIR}/setup_plumed" + cat << EOF >> "${BUILDDIR}/setup_plumed" export PLUMED_LDFLAGS="${PLUMED_LDFLAGS}" export PLUMED_LIBS="${PLUMED_LIBS}" export CP_DFLAGS="\${CP_DFLAGS} -D__PLUMED2" diff --git a/tools/toolchain/scripts/stage6/install_quip.sh b/tools/toolchain/scripts/stage6/install_quip.sh index 4b62940214..b6ae3975b7 100755 --- a/tools/toolchain/scripts/stage6/install_quip.sh +++ b/tools/toolchain/scripts/stage6/install_quip.sh @@ -13,12 +13,12 @@ source "${INSTALLDIR}"/toolchain.env [ -f "${BUILDDIR}/setup_quip" ] && rm "${BUILDDIR}/setup_quip" -if [ "${ENABLE_TSAN}" = "__TRUE__" ] ; then - report_warning "QUIP is not combatiable with thread sanitizer, not installing..." -cat < setup_quip +if [ "${ENABLE_TSAN}" = "__TRUE__" ]; then + report_warning "QUIP is not combatiable with thread sanitizer, not installing..." + cat << EOF > setup_quip with_quip=__DONTUSE__ EOF - exit 0 + exit 0 fi QUIP_CFLAGS='' @@ -28,124 +28,124 @@ QUIP_LIBS='' cd "${BUILDDIR}" case "$with_quip" in - __INSTALL__) - echo "==================== Installing QUIP ====================" - require_env MATH_LIBS - pkg_install_dir="${INSTALLDIR}/quip-${quip_ver}" - install_lock_file="$pkg_install_dir/install_successful" - if verify_checksums "${install_lock_file}" ; then - echo "quip_dist-${quip_ver} is already installed, skipping it." - else - if [ -f QUIP-${quip_ver}.tar.gz ] ; then - echo "QUIP-${quip_ver}.tar.gz is found" - else - download_pkg ${DOWNLOADER_FLAGS} ${quip_sha256} \ - https://www.cp2k.org/static/downloads/QUIP-${quip_ver}.tar.gz - fi - [ -d QUIP-${quip_ver} ] && rm -rf QUIP-${quip_ver} - echo "Installing from scratch into ${pkg_install_dir}" - tar -xzf QUIP-${quip_ver}.tar.gz - cd QUIP-${quip_ver} - # translate OPENBLAS_ARCH - case $OPENBLAS_ARCH in - x86_64) - quip_arch=x86_64 - ;; - i386) - quip_arch=x86_32 - ;; - arm) - quip_arch=x86_64 - ;; - *) - report_error $LINENO "arch $OPENBLAS_ARCH is currently unsupported" - exit 1 - ;; - esac - # The ARCHER cd has a very annoying habbit of printing out - # dir names to stdout for any target directories that are - # more than one level deep, and one cannot seem to disable - # it. This unfortunately messes up the installation script - # for QUIP. So this hack will help to resolve the issue - if [ "$ENABLE_CRAY" = "__TRUE__" ] ; then - sed -i \ - -e "s|\(cd build/.*\)|\1 >&- 2>&-|g" \ - bin/find_sizeof_fortran_t - fi - sed -i \ - -e "s|\(F77 *=\).*|\1 ${FC}|g" \ - -e "s|\(F90 *=\).*|\1 ${FC}|g" \ - -e "s|\(F95 *=\).*|\1 ${FC}|g" \ - -e "s|\(CC *=\).*|\1 ${CC}|g" \ - -e "s|\(CPLUSPLUS *=\).*|\1 ${CXX}|g" \ - -e "s|\(LINKER *=\).*|\1 ${FC}|g" \ - -e "s|\(FPP *=\).*|\1 ${FC} -E -x f95-cpp-input|g" \ - -e "s|\(QUIPPY_FCOMPILER *=\).*|\1 ${FC}|g" \ - -e "s|\(QUIPPY_CPP *=\).*|\1 ${FC} -E -x f95-cpp-input|g" \ - arch/Makefile.linux_${quip_arch}_gfortran + __INSTALL__) + echo "==================== Installing QUIP ====================" + require_env MATH_LIBS + pkg_install_dir="${INSTALLDIR}/quip-${quip_ver}" + install_lock_file="$pkg_install_dir/install_successful" + if verify_checksums "${install_lock_file}"; then + echo "quip_dist-${quip_ver} is already installed, skipping it." + else + if [ -f QUIP-${quip_ver}.tar.gz ]; then + echo "QUIP-${quip_ver}.tar.gz is found" + else + download_pkg ${DOWNLOADER_FLAGS} ${quip_sha256} \ + https://www.cp2k.org/static/downloads/QUIP-${quip_ver}.tar.gz + fi + [ -d QUIP-${quip_ver} ] && rm -rf QUIP-${quip_ver} + echo "Installing from scratch into ${pkg_install_dir}" + tar -xzf QUIP-${quip_ver}.tar.gz + cd QUIP-${quip_ver} + # translate OPENBLAS_ARCH + case $OPENBLAS_ARCH in + x86_64) + quip_arch=x86_64 + ;; + i386) + quip_arch=x86_32 + ;; + arm) + quip_arch=x86_64 + ;; + *) + report_error $LINENO "arch $OPENBLAS_ARCH is currently unsupported" + exit 1 + ;; + esac + # The ARCHER cd has a very annoying habbit of printing out + # dir names to stdout for any target directories that are + # more than one level deep, and one cannot seem to disable + # it. This unfortunately messes up the installation script + # for QUIP. So this hack will help to resolve the issue + if [ "$ENABLE_CRAY" = "__TRUE__" ]; then + sed -i \ + -e "s|\(cd build/.*\)|\1 >&- 2>&-|g" \ + bin/find_sizeof_fortran_t + fi + sed -i \ + -e "s|\(F77 *=\).*|\1 ${FC}|g" \ + -e "s|\(F90 *=\).*|\1 ${FC}|g" \ + -e "s|\(F95 *=\).*|\1 ${FC}|g" \ + -e "s|\(CC *=\).*|\1 ${CC}|g" \ + -e "s|\(CPLUSPLUS *=\).*|\1 ${CXX}|g" \ + -e "s|\(LINKER *=\).*|\1 ${FC}|g" \ + -e "s|\(FPP *=\).*|\1 ${FC} -E -x f95-cpp-input|g" \ + -e "s|\(QUIPPY_FCOMPILER *=\).*|\1 ${FC}|g" \ + -e "s|\(QUIPPY_CPP *=\).*|\1 ${FC} -E -x f95-cpp-input|g" \ + arch/Makefile.linux_${quip_arch}_gfortran - # workaround for compilation with GCC-10, until properly fixed: - # https://github.com/libAtoms/QUIP/issues/209 - ( "${FC}" --version | grep -Eq 'GNU.+\s10\.') && compat_flag="-fallow-argument-mismatch" || compat_flag="" + # workaround for compilation with GCC-10, until properly fixed: + # https://github.com/libAtoms/QUIP/issues/209 + ("${FC}" --version | grep -Eq 'GNU.+\s10\.') && compat_flag="-fallow-argument-mismatch" || compat_flag="" - # enable debug symbols - echo "F95FLAGS += -g ${compat_flag}" >> arch/Makefile.linux_${quip_arch}_gfortran - echo "F77FLAGS += -g ${compat_flag}" >> arch/Makefile.linux_${quip_arch}_gfortran - echo "CFLAGS += -g" >> arch/Makefile.linux_${quip_arch}_gfortran - echo "CPLUSPLUSFLAGS += -g" >> arch/Makefile.linux_${quip_arch}_gfortran - export QUIP_ARCH=linux_${quip_arch}_gfortran - # hit enter a few times to accept defaults - echo -e "${MATH_LDFLAGS} $(resolve_string "${MATH_LIBS}") \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" | make config > configure.log - # make -j does not work :-( - make > make.log 2>&1 - ! [ -d "${pkg_install_dir}/include" ] && mkdir -p "${pkg_install_dir}/include" - ! [ -d "${pkg_install_dir}/lib" ] && mkdir -p "${pkg_install_dir}/lib" - cp build/linux_x86_64_gfortran/quip_unified_wrapper_module.mod \ - "${pkg_install_dir}/include/" - cp build/linux_x86_64_gfortran/*.a \ - "${pkg_install_dir}/lib/" - cp src/fox/objs.linux_${quip_arch}_gfortran/lib/*.a \ - "${pkg_install_dir}/lib/" - cd .. - write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage6/$(basename ${SCRIPT_NAME})" - fi - QUIP_CFLAGS="-I'${pkg_install_dir}/include'" - QUIP_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; - __SYSTEM__) - echo "==================== Finding Quip_DIST from system paths ====================" - check_lib -lquip_core "QUIP" - check_lib -latoms "QUIP" - check_lib -lFoX_sax "QUIP" - check_lib -lFoX_common "QUIP" - check_lib -lFoX_utils "QUIP" - check_lib -lFoX_fsys "QUIP" - add_include_from_paths QUIP_CFLAGS "quip*" $INCLUDE_PATHS - add_lib_from_paths QUIP_LDFLAGS "libquip_core*" $LIB_PATHS - ;; - __DONTUSE__) - ;; - *) - echo "==================== Linking Quip_Dist to user paths ====================" - pkg_install_dir="$with_quip" - check_dir "${pkg_install_dir}/lib" - check_dir "${pkg_install_dir}/include" - QUIP_CFLAGS="-I'${pkg_install_dir}/include'" - QUIP_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; + # enable debug symbols + echo "F95FLAGS += -g ${compat_flag}" >> arch/Makefile.linux_${quip_arch}_gfortran + echo "F77FLAGS += -g ${compat_flag}" >> arch/Makefile.linux_${quip_arch}_gfortran + echo "CFLAGS += -g" >> arch/Makefile.linux_${quip_arch}_gfortran + echo "CPLUSPLUSFLAGS += -g" >> arch/Makefile.linux_${quip_arch}_gfortran + export QUIP_ARCH=linux_${quip_arch}_gfortran + # hit enter a few times to accept defaults + echo -e "${MATH_LDFLAGS} $(resolve_string "${MATH_LIBS}") \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" | make config > configure.log + # make -j does not work :-( + make > make.log 2>&1 + ! [ -d "${pkg_install_dir}/include" ] && mkdir -p "${pkg_install_dir}/include" + ! [ -d "${pkg_install_dir}/lib" ] && mkdir -p "${pkg_install_dir}/lib" + cp build/linux_x86_64_gfortran/quip_unified_wrapper_module.mod \ + "${pkg_install_dir}/include/" + cp build/linux_x86_64_gfortran/*.a \ + "${pkg_install_dir}/lib/" + cp src/fox/objs.linux_${quip_arch}_gfortran/lib/*.a \ + "${pkg_install_dir}/lib/" + cd .. + write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage6/$(basename ${SCRIPT_NAME})" + fi + QUIP_CFLAGS="-I'${pkg_install_dir}/include'" + QUIP_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; + __SYSTEM__) + echo "==================== Finding Quip_DIST from system paths ====================" + check_lib -lquip_core "QUIP" + check_lib -latoms "QUIP" + check_lib -lFoX_sax "QUIP" + check_lib -lFoX_common "QUIP" + check_lib -lFoX_utils "QUIP" + check_lib -lFoX_fsys "QUIP" + add_include_from_paths QUIP_CFLAGS "quip*" $INCLUDE_PATHS + add_lib_from_paths QUIP_LDFLAGS "libquip_core*" $LIB_PATHS + ;; + __DONTUSE__) ;; + + *) + echo "==================== Linking Quip_Dist to user paths ====================" + pkg_install_dir="$with_quip" + check_dir "${pkg_install_dir}/lib" + check_dir "${pkg_install_dir}/include" + QUIP_CFLAGS="-I'${pkg_install_dir}/include'" + QUIP_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; esac -if [ "$with_quip" != "__DONTUSE__" ] ; then - QUIP_LIBS="-lquip_core -latoms -lFoX_sax -lFoX_common -lFoX_utils -lFoX_fsys" - if [ "$with_quip" != "__SYSTEM__" ] ; then - cat < "${BUILDDIR}/setup_quip" +if [ "$with_quip" != "__DONTUSE__" ]; then + QUIP_LIBS="-lquip_core -latoms -lFoX_sax -lFoX_common -lFoX_utils -lFoX_fsys" + if [ "$with_quip" != "__SYSTEM__" ]; then + cat << EOF > "${BUILDDIR}/setup_quip" prepend_path LD_LIBRARY_PATH "$pkg_install_dir/lib" prepend_path LD_RUN_PATH "$pkg_install_dir/lib" prepend_path LIBRARY_PATH "$pkg_install_dir/lib" prepend_path CPATH "$pkg_install_dir/include" EOF - cat "${BUILDDIR}/setup_quip" >> $SETUPFILE - fi - cat <> "${BUILDDIR}/setup_quip" + cat "${BUILDDIR}/setup_quip" >> $SETUPFILE + fi + cat << EOF >> "${BUILDDIR}/setup_quip" export QUIP_CFLAGS="${QUIP_CFLAGS}" export QUIP_LDFLAGS="${QUIP_LDFLAGS}" export QUIP_LIBS="${QUIP_LIBS}" diff --git a/tools/toolchain/scripts/stage7/install_hdf5.sh b/tools/toolchain/scripts/stage7/install_hdf5.sh index c80ebfa932..eeb03e9646 100755 --- a/tools/toolchain/scripts/stage7/install_hdf5.sh +++ b/tools/toolchain/scripts/stage7/install_hdf5.sh @@ -17,59 +17,59 @@ source "${INSTALLDIR}"/toolchain.env cd "${BUILDDIR}" case "$with_hdf5" in - __INSTALL__) - echo "==================== Installing hdf5 ====================" - pkg_install_dir="${INSTALLDIR}/hdf5-${hdf5_ver}" - install_lock_file="$pkg_install_dir/install_successful" - if verify_checksums "${install_lock_file}" ; then - echo "hdf5-${hdf5_ver} is already installed, skipping it." - else - if [ -f hdf5-${hdf5_ver}.tar.bz2 ] ; then - echo "hdf5-${hdf5_ver}.tar.bz2 is found" - else - download_pkg ${DOWNLOADER_FLAGS} ${hdf5_sha256} \ - https://www.cp2k.org/static/downloads/hdf5-${hdf5_ver}.tar.bz2 - fi - echo "Installing from scratch into ${pkg_install_dir}" - [ -d hdf5-${hdf5_ver} ] && rm -rf hdf5-${hdf5_ver} - tar xf hdf5-${hdf5_ver}.tar.bz2 - cd hdf5-${hdf5_ver} - ./configure \ - --prefix="${pkg_install_dir}" \ - --libdir="${pkg_install_dir}/lib" \ - --enable-shared \ - > configure.log 2>&1 - make -j $NPROCS > make.log 2>&1 - make -j $NPROCS install > install.log 2>&1 - cd .. - write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage7/$(basename ${SCRIPT_NAME})" - fi + __INSTALL__) + echo "==================== Installing hdf5 ====================" + pkg_install_dir="${INSTALLDIR}/hdf5-${hdf5_ver}" + install_lock_file="$pkg_install_dir/install_successful" + if verify_checksums "${install_lock_file}"; then + echo "hdf5-${hdf5_ver} is already installed, skipping it." + else + if [ -f hdf5-${hdf5_ver}.tar.bz2 ]; then + echo "hdf5-${hdf5_ver}.tar.bz2 is found" + else + download_pkg ${DOWNLOADER_FLAGS} ${hdf5_sha256} \ + https://www.cp2k.org/static/downloads/hdf5-${hdf5_ver}.tar.bz2 + fi + echo "Installing from scratch into ${pkg_install_dir}" + [ -d hdf5-${hdf5_ver} ] && rm -rf hdf5-${hdf5_ver} + tar xf hdf5-${hdf5_ver}.tar.bz2 + cd hdf5-${hdf5_ver} + ./configure \ + --prefix="${pkg_install_dir}" \ + --libdir="${pkg_install_dir}/lib" \ + --enable-shared \ + > configure.log 2>&1 + make -j $NPROCS > make.log 2>&1 + make -j $NPROCS install > install.log 2>&1 + cd .. + write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage7/$(basename ${SCRIPT_NAME})" + fi + + HDF5_CFLAGS="-I${pkg_install_dir}/include" + HDF5_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; + __SYSTEM__) + echo "==================== Finding hdf5 from system paths ====================" + check_command pkg-config --modversion hdf5 + add_include_from_paths HDF5_CFLAGS "hdf5.h" $INCLUDE_PATHS + add_lib_from_paths HDF5_LDFLAGS "libhdf5.*" $LIB_PATHS + ;; + __DONTUSE__) ;; + + *) ;; - HDF5_CFLAGS="-I${pkg_install_dir}/include" - HDF5_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; - __SYSTEM__) - echo "==================== Finding hdf5 from system paths ====================" - check_command pkg-config --modversion hdf5 - add_include_from_paths HDF5_CFLAGS "hdf5.h" $INCLUDE_PATHS - add_lib_from_paths HDF5_LDFLAGS "libhdf5.*" $LIB_PATHS - ;; - __DONTUSE__) - ;; - *) - ;; esac -if [ "$with_hdf5" != "__DONTUSE__" ] ; then - HDF5_LIBS="-lhdf5 -lhdf5_hl" - if [ "$with_hdf5" != "__SYSTEM__" ] ; then - cat < "${BUILDDIR}/setup_hdf5" +if [ "$with_hdf5" != "__DONTUSE__" ]; then + HDF5_LIBS="-lhdf5 -lhdf5_hl" + if [ "$with_hdf5" != "__SYSTEM__" ]; then + cat << EOF > "${BUILDDIR}/setup_hdf5" prepend_path LD_LIBRARY_PATH "$pkg_install_dir/lib" prepend_path LD_RUN_PATH "$pkg_install_dir/lib" prepend_path LIBRARY_PATH "$pkg_install_dir/lib" prepend_path CPATH "$pkg_install_dir/include" EOF - fi - cat <> "${BUILDDIR}/setup_hdf5" + fi + cat << EOF >> "${BUILDDIR}/setup_hdf5" export HDF5_CFLAGS="${HDF5_CFLAGS}" export HDF5_LDFLAGS="${HDF5_LDFLAGS}" export CP_DFLAGS="\${CP_DFLAGS} IF_MPI(-D__HDF5|)" @@ -89,7 +89,7 @@ export HDF5_HL_LIBRARIES="$HDF5_LIBS" export HDF5_INCLUDE_DIRS="$pkg_install_dir/include" EOF - cat "${BUILDDIR}/setup_hdf5" >> $SETUPFILE + cat "${BUILDDIR}/setup_hdf5" >> $SETUPFILE fi load "${BUILDDIR}/setup_hdf5" diff --git a/tools/toolchain/scripts/stage7/install_libvdwxc.sh b/tools/toolchain/scripts/stage7/install_libvdwxc.sh index debfb0b040..a052fe67bf 100755 --- a/tools/toolchain/scripts/stage7/install_libvdwxc.sh +++ b/tools/toolchain/scripts/stage7/install_libvdwxc.sh @@ -12,111 +12,111 @@ source "${INSTALLDIR}"/toolchain.env [ -f "${BUILDDIR}/setup_libvdwxc" ] && rm "${BUILDDIR}/setup_libvdwxc" -if [ "$MPI_MODE" = "no" ] && [ $with_sirius ="__FALSE__" ] ; then - report_warning $LINENO "MPI and SIRIUS are disabled, skipping libvdwxc installation" - exit 0 +if [ "$MPI_MODE" = "no" ] && [ $with_sirius ="__FALSE__" ]; then + report_warning $LINENO "MPI and SIRIUS are disabled, skipping libvdwxc installation" + exit 0 fi ! [ -d "${BUILDDIR}" ] && mkdir -p "${BUILDDIR}" cd "${BUILDDIR}" case "$with_libvdwxc" in - __INSTALL__) - require_env MPI_CFLAGS - require_env MPI_LDFLAGS - require_env MPI_LIBS - require_env FFTW_ROOT - require_env FFTW_LDFLAGS - require_env FFTW_LIBS - require_env FFTW_CFLAGS + __INSTALL__) + require_env MPI_CFLAGS + require_env MPI_LDFLAGS + require_env MPI_LIBS + require_env FFTW_ROOT + require_env FFTW_LDFLAGS + require_env FFTW_LIBS + require_env FFTW_CFLAGS - echo "==================== Installing libvdwxc ====================" - pkg_install_dir="${INSTALLDIR}/libvdwxc-${libvdwxc_ver}" - install_lock_file="$pkg_install_dir/install_successful" - if verify_checksums "${install_lock_file}" ; then - echo "libvdwxc-${libvdwxc_ver} is already installed, skipping it." + echo "==================== Installing libvdwxc ====================" + pkg_install_dir="${INSTALLDIR}/libvdwxc-${libvdwxc_ver}" + install_lock_file="$pkg_install_dir/install_successful" + if verify_checksums "${install_lock_file}"; then + echo "libvdwxc-${libvdwxc_ver} is already installed, skipping it." + else + if [ -f libvdwxc-${libvdwxc_ver}.tar.gz ]; then + echo "libvdwxc-${libvdwxc_ver}.tar.gz is found" + else + # do not remove this. They do not publish official version often + download_pkg ${DOWNLOADER_FLAGS} ${libvdwxc_sha256} \ + "https://www.cp2k.org/static/downloads/libvdwxc-${libvdwxc_ver}.tar.gz" + fi + + for patch in "${patches[@]}"; do + fname="${patch##*/}" + if [ -f "${fname}" ]; then + echo "${fname} is found" else - if [ -f libvdwxc-${libvdwxc_ver}.tar.gz ] ; then - echo "libvdwxc-${libvdwxc_ver}.tar.gz is found" - else - # do not remove this. They do not publish official version often - download_pkg ${DOWNLOADER_FLAGS} ${libvdwxc_sha256} \ - "https://www.cp2k.org/static/downloads/libvdwxc-${libvdwxc_ver}.tar.gz" - fi - - for patch in "${patches[@]}" ; do - fname="${patch##*/}" - if [ -f "${fname}" ] ; then - echo "${fname} is found" - else - # parallel build patch - download_pkg ${DOWNLOADER_FLAGS} "${patch}" - fi - done - - echo "Installing from scratch into ${pkg_install_dir}" - [ -d libvdwxc-${libvdwxc_ver} ] && rm -rf libvdwxc-${libvdwxc_ver} - tar -xzf libvdwxc-${libvdwxc_ver}.tar.gz - cd libvdwxc-${libvdwxc_ver} - - for patch in "${patches[@]}" ; do - patch -p1 < ../"${patch##*/}" - done - unset MPICC MPICXX MPIF90 MPIFC MPIF77 - if [ "$MPI_MODE" = "no" ]; then - # compile libvdwxc without mpi support since fftw (or mkl) do not have mpi support activated - ./configure \ - --prefix="${pkg_install_dir}" \ - --libdir="${pkg_install_dir}/lib" \ - --with-fftw3=${FFTW_ROOT} \ - --disable-shared \ - --without-mpi \ - >> configure.log 2>&1 - else - CC="${MPICC}" FC="${MPIFC}" ./configure \ - --prefix="${pkg_install_dir}" \ - --libdir="${pkg_install_dir}/lib" \ - --with-fftw3=${FFTW_ROOT} \ - --disable-shared \ - --with-mpi \ - >> configure.log 2>&1 - fi - make -j $NPROCS > compile.log 2>&1 - make install > compile.log 2>&1 - write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage7/$(basename ${SCRIPT_NAME})" + # parallel build patch + download_pkg ${DOWNLOADER_FLAGS} "${patch}" fi + done - LIBVDWXC_CFLAGS="-I${pkg_install_dir}/include" - LIBVDWXC_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; - __SYSTEM__) - echo "==================== Finding libvdwxc from system paths ====================" - check_command pkg-config --modversion libvdwxc - add_include_from_paths LIBVDWXC_CFLAGS "vdwxc.h" $INCLUDE_PATHS - add_lib_from_paths LIBVDWXC_LDFLAGS "libvdwxc*" $LIB_PATHS - ;; - __DONTUSE__) - ;; - *) - echo "==================== Linking libvdwxc to user paths ====================" - pkg_install_dir="$with_libvdwxc" - check_dir "$pkg_install_dir/lib" - check_dir "$pkg_install_dir/include" - LIBVDWXC_CFLAGS="-I'${pkg_install_dir}/include'" - LIBVDWXC_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; + echo "Installing from scratch into ${pkg_install_dir}" + [ -d libvdwxc-${libvdwxc_ver} ] && rm -rf libvdwxc-${libvdwxc_ver} + tar -xzf libvdwxc-${libvdwxc_ver}.tar.gz + cd libvdwxc-${libvdwxc_ver} + + for patch in "${patches[@]}"; do + patch -p1 < ../"${patch##*/}" + done + unset MPICC MPICXX MPIF90 MPIFC MPIF77 + if [ "$MPI_MODE" = "no" ]; then + # compile libvdwxc without mpi support since fftw (or mkl) do not have mpi support activated + ./configure \ + --prefix="${pkg_install_dir}" \ + --libdir="${pkg_install_dir}/lib" \ + --with-fftw3=${FFTW_ROOT} \ + --disable-shared \ + --without-mpi \ + >> configure.log 2>&1 + else + CC="${MPICC}" FC="${MPIFC}" ./configure \ + --prefix="${pkg_install_dir}" \ + --libdir="${pkg_install_dir}/lib" \ + --with-fftw3=${FFTW_ROOT} \ + --disable-shared \ + --with-mpi \ + >> configure.log 2>&1 + fi + make -j $NPROCS > compile.log 2>&1 + make install > compile.log 2>&1 + write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage7/$(basename ${SCRIPT_NAME})" + fi + + LIBVDWXC_CFLAGS="-I${pkg_install_dir}/include" + LIBVDWXC_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; + __SYSTEM__) + echo "==================== Finding libvdwxc from system paths ====================" + check_command pkg-config --modversion libvdwxc + add_include_from_paths LIBVDWXC_CFLAGS "vdwxc.h" $INCLUDE_PATHS + add_lib_from_paths LIBVDWXC_LDFLAGS "libvdwxc*" $LIB_PATHS + ;; + __DONTUSE__) ;; + + *) + echo "==================== Linking libvdwxc to user paths ====================" + pkg_install_dir="$with_libvdwxc" + check_dir "$pkg_install_dir/lib" + check_dir "$pkg_install_dir/include" + LIBVDWXC_CFLAGS="-I'${pkg_install_dir}/include'" + LIBVDWXC_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; esac -if [ "$with_libvdwxc" != "__DONTUSE__" ] ; then - LIBVDWXC_LIBS="-lvdwxc" - if [ "$with_libvdwxc" != "__SYSTEM__" ] ; then - cat < "${BUILDDIR}/setup_libvdwxc" +if [ "$with_libvdwxc" != "__DONTUSE__" ]; then + LIBVDWXC_LIBS="-lvdwxc" + if [ "$with_libvdwxc" != "__SYSTEM__" ]; then + cat << EOF > "${BUILDDIR}/setup_libvdwxc" prepend_path LD_LIBRARY_PATH "$pkg_install_dir/lib" prepend_path LD_RUN_PATH "$pkg_install_dir/lib" prepend_path LIBRARY_PATH "$pkg_install_dir/lib" prepend_path CPATH "$pkg_install_dir/include" EOF - fi - cat <> "${BUILDDIR}/setup_libvdwxc" + fi + cat << EOF >> "${BUILDDIR}/setup_libvdwxc" export LIBVDWXC_CFLAGS="-I$pkg_install_dir/include ${LIBVDWXC_CFLAGS}" export LIBVDWXC_LDFLAGS="${LIBVDWXC_LDFLAGS}" export LIBVDWXC_LIBS="${LIBVDWXC_LIBS}" @@ -127,7 +127,7 @@ export CP_LIBS="IF_MPI(${LIBVDWXC_LIBS}|) \${CP_LIBS}" export PKG_CONFIG_PATH="$pkg_install_dir/lib/pkgconfig:$PKG_CONFIG_PATH" export VDWXC_DIR="$pkg_install_dir" EOF - cat "${BUILDDIR}/setup_libvdwxc" >> $SETUPFILE + cat "${BUILDDIR}/setup_libvdwxc" >> $SETUPFILE fi load "${BUILDDIR}/setup_libvdwxc" diff --git a/tools/toolchain/scripts/stage7/install_libvori.sh b/tools/toolchain/scripts/stage7/install_libvori.sh index 0110e75079..2d198dd2a0 100755 --- a/tools/toolchain/scripts/stage7/install_libvori.sh +++ b/tools/toolchain/scripts/stage7/install_libvori.sh @@ -20,73 +20,73 @@ source "${INSTALLDIR}"/toolchain.env cd "${BUILDDIR}" case "${with_libvori:=__INSTALL__}" in - __INSTALL__) - echo "==================== Installing libvori ====================" - pkg_install_dir="${INSTALLDIR}/libvori-${libvori_ver}" - install_lock_file="${pkg_install_dir}/install_successful" - if verify_checksums "${install_lock_file}" ; then - echo "libvori-${libvori_ver} is already installed, skipping it." - else - if [ -f libvori-${libvori_ver}.tar.gz ] ; then - echo "libvori-${libvori_ver}.tar.gz is found" - else - # shellcheck disable=SC2086 - download_pkg ${DOWNLOADER_FLAGS} ${libvori_sha256} \ - "https://www.cp2k.org/static/downloads/libvori-${libvori_ver}.tar.gz" - fi + __INSTALL__) + echo "==================== Installing libvori ====================" + pkg_install_dir="${INSTALLDIR}/libvori-${libvori_ver}" + install_lock_file="${pkg_install_dir}/install_successful" + if verify_checksums "${install_lock_file}"; then + echo "libvori-${libvori_ver} is already installed, skipping it." + else + if [ -f libvori-${libvori_ver}.tar.gz ]; then + echo "libvori-${libvori_ver}.tar.gz is found" + else + # shellcheck disable=SC2086 + download_pkg ${DOWNLOADER_FLAGS} ${libvori_sha256} \ + "https://www.cp2k.org/static/downloads/libvori-${libvori_ver}.tar.gz" + fi - echo "Installing from scratch into ${pkg_install_dir}" - [ -d libvori-${libvori_ver} ] && rm -rf libvori-${libvori_ver} - tar -xzf libvori-${libvori_ver}.tar.gz + echo "Installing from scratch into ${pkg_install_dir}" + [ -d libvori-${libvori_ver} ] && rm -rf libvori-${libvori_ver} + tar -xzf libvori-${libvori_ver}.tar.gz - mkdir "libvori-${libvori_ver}/build" - cd "libvori-${libvori_ver}/build" - cmake \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \ - -DCMAKE_INSTALL_LIBDIR=lib \ - -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE \ - .. > cmake.log 2>&1 - CMAKE_BUILD_PARALLEL_LEVEL="${NPROCS}" cmake --build . > build.log 2>&1 - CMAKE_BUILD_PARALLEL_LEVEL="${NPROCS}" cmake --build . --target test > test.log 2>&1 - CMAKE_BUILD_PARALLEL_LEVEL="${NPROCS}" cmake --build . --target install > install.log 2>&1 + mkdir "libvori-${libvori_ver}/build" + cd "libvori-${libvori_ver}/build" + cmake \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \ + -DCMAKE_INSTALL_LIBDIR=lib \ + -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE \ + .. > cmake.log 2>&1 + CMAKE_BUILD_PARALLEL_LEVEL="${NPROCS}" cmake --build . > build.log 2>&1 + CMAKE_BUILD_PARALLEL_LEVEL="${NPROCS}" cmake --build . --target test > test.log 2>&1 + CMAKE_BUILD_PARALLEL_LEVEL="${NPROCS}" cmake --build . --target install > install.log 2>&1 - write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage7/$(basename "${SCRIPT_NAME}")" - fi - LIBVORI_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; - __SYSTEM__) - echo "==================== Finding libvori from system paths ====================" - check_lib -lvori "libvori" - add_lib_from_paths LIBVORI_LDFLAGS "libvori.*" "$LIB_PATHS" - ;; - __DONTUSE__) - ;; - *) - echo "==================== Linking libvori to user paths ====================" - pkg_install_dir="${with_libvori}" + write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage7/$(basename "${SCRIPT_NAME}")" + fi + LIBVORI_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; + __SYSTEM__) + echo "==================== Finding libvori from system paths ====================" + check_lib -lvori "libvori" + add_lib_from_paths LIBVORI_LDFLAGS "libvori.*" "$LIB_PATHS" + ;; + __DONTUSE__) ;; - # use the lib64 directory if present (multi-abi distros may link lib/ to lib32/ instead) - LIBVORI_LIBDIR="${pkg_install_dir}/lib" - [ -d "${pkg_install_dir}/lib64" ] && LIBVORI_LIBDIR="${pkg_install_dir}/lib64" + *) + echo "==================== Linking libvori to user paths ====================" + pkg_install_dir="${with_libvori}" - check_dir "${LIBVORI_LIBDIR}" - LIBVORI_LDFLAGS="-L'${LIBVORI_LIBDIR}' -Wl,-rpath='${LIBVORI_LIBDIR}'" - ;; + # use the lib64 directory if present (multi-abi distros may link lib/ to lib32/ instead) + LIBVORI_LIBDIR="${pkg_install_dir}/lib" + [ -d "${pkg_install_dir}/lib64" ] && LIBVORI_LIBDIR="${pkg_install_dir}/lib64" + + check_dir "${LIBVORI_LIBDIR}" + LIBVORI_LDFLAGS="-L'${LIBVORI_LIBDIR}' -Wl,-rpath='${LIBVORI_LIBDIR}'" + ;; esac -if [ "$with_libvori" != "__DONTUSE__" ] ; then - LIBVORI_LIBS="-lvori -lstdc++" - if [ "$with_libvori" != "__SYSTEM__" ] ; then - cat << EOF > "${BUILDDIR}/setup_libvori" +if [ "$with_libvori" != "__DONTUSE__" ]; then + LIBVORI_LIBS="-lvori -lstdc++" + if [ "$with_libvori" != "__SYSTEM__" ]; then + cat << EOF > "${BUILDDIR}/setup_libvori" prepend_path LD_LIBRARY_PATH "${pkg_install_dir}/lib" prepend_path LD_RUN_PATH "${pkg_install_dir}/lib" prepend_path LIBRARY_PATH "${pkg_install_dir}/lib" export LIBVORI_LIBS="${LIBVORI_LIBS}" export LIBVORI_ROOT="${pkg_install_dir}" EOF - fi - cat << EOF >> "${BUILDDIR}/setup_libvori" + fi + cat << EOF >> "${BUILDDIR}/setup_libvori" export LIBVORI_ROOT="${pkg_install_dir}" export LIBVORI_VERSION=${libvori_ver} export LIBVORI_LDFLAGS="${LIBVORI_LDFLAGS}" @@ -95,7 +95,7 @@ export CP_DFLAGS="\${CP_DFLAGS} -D__LIBVORI" export CP_LDFLAGS="\${CP_LDFLAGS} ${LIBVORI_LDFLAGS}" export CP_LIBS="\${CP_LIBS} ${LIBVORI_LIBS}" EOF - cat "${BUILDDIR}/setup_libvori" >> "${SETUPFILE}" + cat "${BUILDDIR}/setup_libvori" >> "${SETUPFILE}" fi load "${BUILDDIR}/setup_libvori" diff --git a/tools/toolchain/scripts/stage7/install_spglib.sh b/tools/toolchain/scripts/stage7/install_spglib.sh index f2660ba80c..7e79597845 100755 --- a/tools/toolchain/scripts/stage7/install_spglib.sh +++ b/tools/toolchain/scripts/stage7/install_spglib.sh @@ -16,72 +16,72 @@ source "${INSTALLDIR}"/toolchain.env cd "${BUILDDIR}" case "$with_spglib" in - __INSTALL__) - echo "==================== Installing spglib ====================" - pkg_install_dir="${INSTALLDIR}/spglib-${spglib_ver}" - install_lock_file="$pkg_install_dir/install_successful" - if verify_checksums "${install_lock_file}" ; then - echo "spglib-${spglib_ver} is already installed, skipping it." - else - if [ -f spglib-${spglib_ver}.tar.gz ] ; then - echo "spglib-${spglib_ver}.tar.gz is found" - else - download_pkg ${DOWNLOADER_FLAGS} ${spglib_sha256} \ - https://github.com/atztogo/spglib/archive/v${spglib_ver}.tar.gz \ - -o spglib-${spglib_ver}.tar.gz - fi + __INSTALL__) + echo "==================== Installing spglib ====================" + pkg_install_dir="${INSTALLDIR}/spglib-${spglib_ver}" + install_lock_file="$pkg_install_dir/install_successful" + if verify_checksums "${install_lock_file}"; then + echo "spglib-${spglib_ver} is already installed, skipping it." + else + if [ -f spglib-${spglib_ver}.tar.gz ]; then + echo "spglib-${spglib_ver}.tar.gz is found" + else + download_pkg ${DOWNLOADER_FLAGS} ${spglib_sha256} \ + https://github.com/atztogo/spglib/archive/v${spglib_ver}.tar.gz \ + -o spglib-${spglib_ver}.tar.gz + fi - echo "Installing from scratch into ${pkg_install_dir}" - rm -rf spglib-${spglib_ver} "${pkg_install_dir}" - tar -xzf spglib-${spglib_ver}.tar.gz - cd spglib-${spglib_ver} + echo "Installing from scratch into ${pkg_install_dir}" + rm -rf spglib-${spglib_ver} "${pkg_install_dir}" + tar -xzf spglib-${spglib_ver}.tar.gz + cd spglib-${spglib_ver} - mkdir build - cd build - cmake -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" -DCMAKE_BUILD_TYPE=Release .. > configure.log 2>&1 - make -j $NPROCS > make.log 2>&1 - make install >> make.log 2>&1 - mkdir ${pkg_install_dir}/include/spglib - cp ${pkg_install_dir}/include/{,spglib/}spglib.h - cd .. - write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage7/$(basename ${SCRIPT_NAME})" - fi + mkdir build + cd build + cmake -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" -DCMAKE_BUILD_TYPE=Release .. > configure.log 2>&1 + make -j $NPROCS > make.log 2>&1 + make install >> make.log 2>&1 + mkdir ${pkg_install_dir}/include/spglib + cp ${pkg_install_dir}/include/{,spglib/}spglib.h + cd .. + write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage7/$(basename ${SCRIPT_NAME})" + fi - SPGLIB_CFLAGS="-I${pkg_install_dir}/include" - SPGLIB_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - if [ -d "${pkg_install_dir}/lib64" ]; then - ln -sf lib64 ${pkg_install_dir}/lib - cd ${pkg_install_dir} - fi - ;; - __SYSTEM__) - echo "==================== Finding spglib from system paths ====================" - check_command pkg-config --modversion spglib - add_include_from_paths SPGLIB_CFLAGS "spglib.h" $INCLUDE_PATHS - add_lib_from_paths SPGLIB_LDFLAGS "libspglib.*" $LIB_PATHS - ;; - __DONTUSE__) - ;; - *) - echo "==================== Linking spglib to user paths ====================" - pkg_install_dir="$with_spglib" - check_dir "$pkg_install_dir/lib" - check_dir "$pkg_install_dir/include" - SPGLIB_CFLAGS="-I'${pkg_install_dir}/include'" - SPGLIB_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - ;; + SPGLIB_CFLAGS="-I${pkg_install_dir}/include" + SPGLIB_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + if [ -d "${pkg_install_dir}/lib64" ]; then + ln -sf lib64 ${pkg_install_dir}/lib + cd ${pkg_install_dir} + fi + ;; + __SYSTEM__) + echo "==================== Finding spglib from system paths ====================" + check_command pkg-config --modversion spglib + add_include_from_paths SPGLIB_CFLAGS "spglib.h" $INCLUDE_PATHS + add_lib_from_paths SPGLIB_LDFLAGS "libspglib.*" $LIB_PATHS + ;; + __DONTUSE__) ;; + + *) + echo "==================== Linking spglib to user paths ====================" + pkg_install_dir="$with_spglib" + check_dir "$pkg_install_dir/lib" + check_dir "$pkg_install_dir/include" + SPGLIB_CFLAGS="-I'${pkg_install_dir}/include'" + SPGLIB_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + ;; esac -if [ "$with_spglib" != "__DONTUSE__" ] ; then - SPGLIB_LIBS="-lsymspg" - if [ "$with_spglib" != "__SYSTEM__" ] ; then - cat < "${BUILDDIR}/setup_spglib" +if [ "$with_spglib" != "__DONTUSE__" ]; then + SPGLIB_LIBS="-lsymspg" + if [ "$with_spglib" != "__SYSTEM__" ]; then + cat << EOF > "${BUILDDIR}/setup_spglib" prepend_path LD_LIBRARY_PATH "$pkg_install_dir/lib" prepend_path LD_RUN_PATH "$pkg_install_dir/lib" prepend_path LIBRARY_PATH "$pkg_install_dir/lib" prepend_path CPATH "$pkg_install_dir/include" EOF - fi - cat <> "${BUILDDIR}/setup_spglib" + fi + cat << EOF >> "${BUILDDIR}/setup_spglib" export SPGLIB_CFLAGS="-I$pkg_install_dir/include ${SPGLIB_CFLAGS}" export SPGLIB_LDFLAGS="${SPGLIB_LDFLAGS}" export CP_DFLAGS="\${CP_DFLAGS} -D__SPGLIB" @@ -91,7 +91,7 @@ export CP_LIBS="${SPGLIB_LIBS} \${CP_LIBS}" export LIBSPGROOT="$pkg_install_dir" export LIBSPG_INCLUDE_DIR="$pkg_install_dir/include" EOF - cat "${BUILDDIR}/setup_spglib" >> $SETUPFILE + cat "${BUILDDIR}/setup_spglib" >> $SETUPFILE fi load "${BUILDDIR}/setup_spglib" diff --git a/tools/toolchain/scripts/stage8/install_sirius.sh b/tools/toolchain/scripts/stage8/install_sirius.sh index a5cf960e1e..e3bd33df0d 100755 --- a/tools/toolchain/scripts/stage8/install_sirius.sh +++ b/tools/toolchain/scripts/stage8/install_sirius.sh @@ -11,10 +11,10 @@ source "${SCRIPT_DIR}"/signal_trap.sh source "${INSTALLDIR}"/toolchain.conf source "${INSTALLDIR}"/toolchain.env -if [ "$MPI_MODE" = "no" ] ; then - report_warning $LINENO "MPI is disabled, skipping sirius installation" - echo 'with_sirius="__FALSE__"' >> ${BUILDDIR}/setup_sirius - exit 0 +if [ "$MPI_MODE" = "no" ]; then + report_warning $LINENO "MPI is disabled, skipping sirius installation" + echo 'with_sirius="__FALSE__"' >> ${BUILDDIR}/setup_sirius + exit 0 fi [ -f "${BUILDDIR}/setup_sirius" ] && rm "${BUILDDIR}/setup_sirius" @@ -26,214 +26,213 @@ SIRIUS_LIBS='' cd "${BUILDDIR}" case "$with_sirius" in - __DONTUSE__) - ;; - __INSTALL__) - echo "==================== Installing SIRIUS ====================" - require_env FFTW_LDFLAGS - require_env FFTW_LIBS - require_env FFTW_CFLAGS - require_env ELPAROOT - require_env ELPA_LDFLAGS - require_env ELPA_LIBS - require_env ELPA_CFLAGS - require_env GSL_LDFLAGS - require_env GSL_CFLAGS - require_env GSL_LIBS - require_env MATH_LIBS - require_env MPI_LDFLAGS - require_env MPI_LIBS - require_env SCALAPACKROOT - require_env SCALAPACK_LDFLAGS - require_env SCALAPACK_CFLAGS - require_env SCALAPACK_LIBS - require_env LIBXC_LIBS - require_env LIBXC_CFLAGS - require_env LIBXC_LDFLAGS - require_env SPGLIB_LIBS - require_env SPGLIB_CFLAGS - require_env SPGLIB_LDFLAGS - require_env HDF5_LIBS - require_env HDF5_CFLAGS - require_env HDF5_LDFLAGS - require_env LIBVDWXC_CFLAGS - require_env LIBVDWXC_LIBS - require_env LIBVDWXC_LDFLAGS - require_env GSL_INCLUDE_DIR - require_env GSL_LIBRARY - require_env GSL_CBLAS_LIBRARY - require_env SPFFT_ROOT - require_env SPFFT_CFLAGS - require_env SPFFT_LDFLAGS - require_env SPFFT_LIBS - require_env SPLA_ROOT - require_env SPLA_CFLAGS - require_env SPLA_LDFLAGS - require_env SPLA_LIBS - ARCH=`uname -m` - SIRIUS_OPT="-O3 -DNDEBUG -mtune=native -ftree-loop-vectorize ${MATH_CFLAGS}" - if [ "$ARCH" = "ppc64le" ]; then - SIRIUS_OPT="-O3 -DNDEBUG -mcpu=power8 -mtune=power8 -funroll-loops -ftree-vectorize -mvsx -maltivec -mpopcntd -mveclibabi=mass -fvect-cost-model -fpeel-loops -mcmodel=medium ${MATH_CFLAGS}" - SIRIUS_DBG="-O2 -g -mcpu=power8 -mtune=power8 -funroll-loops -ftree-vectorize -mvsx -maltivec -mpopcntd -mveclibabi=mass -fvect-cost-model -fpeel-loops -mcmodel=medium ${MATH_CFLAGS}" - fi + __DONTUSE__) ;; - if [ "$ARCH" = "x86_64" ]; then - SIRIUS_OPT="-O3 -DNDEBUG -mtune=native -ftree-loop-vectorize ${MATH_CFLAGS}" - SIRIUS_DBG="-O2 -g -mtune=native -ftree-loop-vectorize ${MATH_CFLAGS}" - fi + __INSTALL__) + echo "==================== Installing SIRIUS ====================" + require_env FFTW_LDFLAGS + require_env FFTW_LIBS + require_env FFTW_CFLAGS + require_env ELPAROOT + require_env ELPA_LDFLAGS + require_env ELPA_LIBS + require_env ELPA_CFLAGS + require_env GSL_LDFLAGS + require_env GSL_CFLAGS + require_env GSL_LIBS + require_env MATH_LIBS + require_env MPI_LDFLAGS + require_env MPI_LIBS + require_env SCALAPACKROOT + require_env SCALAPACK_LDFLAGS + require_env SCALAPACK_CFLAGS + require_env SCALAPACK_LIBS + require_env LIBXC_LIBS + require_env LIBXC_CFLAGS + require_env LIBXC_LDFLAGS + require_env SPGLIB_LIBS + require_env SPGLIB_CFLAGS + require_env SPGLIB_LDFLAGS + require_env HDF5_LIBS + require_env HDF5_CFLAGS + require_env HDF5_LDFLAGS + require_env LIBVDWXC_CFLAGS + require_env LIBVDWXC_LIBS + require_env LIBVDWXC_LDFLAGS + require_env GSL_INCLUDE_DIR + require_env GSL_LIBRARY + require_env GSL_CBLAS_LIBRARY + require_env SPFFT_ROOT + require_env SPFFT_CFLAGS + require_env SPFFT_LDFLAGS + require_env SPFFT_LIBS + require_env SPLA_ROOT + require_env SPLA_CFLAGS + require_env SPLA_LDFLAGS + require_env SPLA_LIBS + ARCH=$(uname -m) + SIRIUS_OPT="-O3 -DNDEBUG -mtune=native -ftree-loop-vectorize ${MATH_CFLAGS}" + if [ "$ARCH" = "ppc64le" ]; then + SIRIUS_OPT="-O3 -DNDEBUG -mcpu=power8 -mtune=power8 -funroll-loops -ftree-vectorize -mvsx -maltivec -mpopcntd -mveclibabi=mass -fvect-cost-model -fpeel-loops -mcmodel=medium ${MATH_CFLAGS}" + SIRIUS_DBG="-O2 -g -mcpu=power8 -mtune=power8 -funroll-loops -ftree-vectorize -mvsx -maltivec -mpopcntd -mveclibabi=mass -fvect-cost-model -fpeel-loops -mcmodel=medium ${MATH_CFLAGS}" + fi - pkg_install_dir="${INSTALLDIR}/sirius-${sirius_ver}" - install_lock_file="${pkg_install_dir}/install_successful" - if verify_checksums "${install_lock_file}" ; then - echo "sirius_dist-${sirius_ver} is already installed, skipping it." - else - if [ -f SIRIUS-${sirius_ver}.tar.gz ] ; then - echo "sirius_${sirius_ver}.tar.gz is found" - else - download_pkg ${DOWNLOADER_FLAGS} ${sirius_sha256} \ - "https://github.com/electronic-structure/SIRIUS/archive/v${sirius_ver}.tar.gz" \ - -o SIRIUS-${sirius_ver}.tar.gz - fi + if [ "$ARCH" = "x86_64" ]; then + SIRIUS_OPT="-O3 -DNDEBUG -mtune=native -ftree-loop-vectorize ${MATH_CFLAGS}" + SIRIUS_DBG="-O2 -g -mtune=native -ftree-loop-vectorize ${MATH_CFLAGS}" + fi - echo "Installing from scratch into ${pkg_install_dir}" - [ -d sirius-${sirius_ver} ] && rm -rf sirius-${sirius_ver} - tar -xzf SIRIUS-${sirius_ver}.tar.gz - cd SIRIUS-${sirius_ver} - rm -Rf build - mkdir build - cd build - COMPILATION_OPTIONS="-DHDF5_DIR=${HDF5_DIR}" - #if [ -n "$ELPA_LIBS" ] ; then - # if [ -s "$ELPAROOT" ] ; then - # export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$ELPAROOT/lib/pkgconfig:$ELPAROOT/lib64/pkgconfig - # fi - # COMPILATION_OPTIONS="-DUSE_ELPA=ON -DELPA_INCLUDE_DIR=${ELPAROOT}/include/elpa-${ELPAVERSION} $COMPILATION_OPTIONS" - #fi + pkg_install_dir="${INSTALLDIR}/sirius-${sirius_ver}" + install_lock_file="${pkg_install_dir}/install_successful" + if verify_checksums "${install_lock_file}"; then + echo "sirius_dist-${sirius_ver} is already installed, skipping it." + else + if [ -f SIRIUS-${sirius_ver}.tar.gz ]; then + echo "sirius_${sirius_ver}.tar.gz is found" + else + download_pkg ${DOWNLOADER_FLAGS} ${sirius_sha256} \ + "https://github.com/electronic-structure/SIRIUS/archive/v${sirius_ver}.tar.gz" \ + -o SIRIUS-${sirius_ver}.tar.gz + fi - if [ -n "$SCALAPACK_LIBS" ] ; then - export SCALAPACK_LIB="$SCALAPACK_LIBS" - if [ -s "$SCALAPACKROOT" ] ; then - COMPILATION_OPTIONS="-DUSE_SCALAPACK=ON -DSCALAPACK_INCLUDE_DIR=${SCALAPACKROOT}/include ${COMPILATION_OPTIONS}" - else - COMPILATION_OPTIONS="-DUSE_SCALAPACK=ON ${COMPILATION_OPTIONS}" - fi - fi - if [ -n "$HDF5_LIBS" ] ; then - COMPILATION_OPTIONS="-DUSE_HDF5=ON $COMPILATION_OPTIONS" - fi - if [ -n "$LIBVDWXC_LIBS" ] ; then - COMPILATION_OPTIONS="-DUSE_VDWXC=ON $COMPILATION_OPTIONS" - fi - if [ -n "$MKL_LIBS" ] ; then - COMPILATION_OPTIONS="-DUSE_MKL=ON -DUSE_SCALAPACK=ON $COMPILATION_OPTIONS" - fi + echo "Installing from scratch into ${pkg_install_dir}" + [ -d sirius-${sirius_ver} ] && rm -rf sirius-${sirius_ver} + tar -xzf SIRIUS-${sirius_ver}.tar.gz + cd SIRIUS-${sirius_ver} + rm -Rf build + mkdir build + cd build + COMPILATION_OPTIONS="-DHDF5_DIR=${HDF5_DIR}" + #if [ -n "$ELPA_LIBS" ] ; then + # if [ -s "$ELPAROOT" ] ; then + # export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$ELPAROOT/lib/pkgconfig:$ELPAROOT/lib64/pkgconfig + # fi + # COMPILATION_OPTIONS="-DUSE_ELPA=ON -DELPA_INCLUDE_DIR=${ELPAROOT}/include/elpa-${ELPAVERSION} $COMPILATION_OPTIONS" + #fi + if [ -n "$SCALAPACK_LIBS" ]; then + export SCALAPACK_LIB="$SCALAPACK_LIBS" + if [ -s "$SCALAPACKROOT" ]; then + COMPILATION_OPTIONS="-DUSE_SCALAPACK=ON -DSCALAPACK_INCLUDE_DIR=${SCALAPACKROOT}/include ${COMPILATION_OPTIONS}" + else + COMPILATION_OPTIONS="-DUSE_SCALAPACK=ON ${COMPILATION_OPTIONS}" + fi + fi + if [ -n "$HDF5_LIBS" ]; then + COMPILATION_OPTIONS="-DUSE_HDF5=ON $COMPILATION_OPTIONS" + fi + if [ -n "$LIBVDWXC_LIBS" ]; then + COMPILATION_OPTIONS="-DUSE_VDWXC=ON $COMPILATION_OPTIONS" + fi + if [ -n "$MKL_LIBS" ]; then + COMPILATION_OPTIONS="-DUSE_MKL=ON -DUSE_SCALAPACK=ON $COMPILATION_OPTIONS" + fi - CMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}:${SPFFT_ROOT}/lib/cmake:${SPFFT_ROOT}/lib64/cmake" \ - cmake -DCMAKE_INSTALL_PREFIX=${pkg_install_dir} \ - -DCMAKE_CXXFLAGS_RELEASE="${SIRIUS_OPT}" \ - -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="${SIRIUS_DBG}" \ - -DCMAKE_CXX_COMPILER="${MPICXX}" \ - -DCMAKE_C_COMPILER="${MPICC}" \ - -DBUILD_SHARED_LIBS=OFF \ - -DUSE_ELPA=OFF \ - ${COMPILATION_OPTIONS} .. > compile.log 2>&1 + CMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}:${SPFFT_ROOT}/lib/cmake:${SPFFT_ROOT}/lib64/cmake" \ + cmake -DCMAKE_INSTALL_PREFIX=${pkg_install_dir} \ + -DCMAKE_CXXFLAGS_RELEASE="${SIRIUS_OPT}" \ + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="${SIRIUS_DBG}" \ + -DCMAKE_CXX_COMPILER="${MPICXX}" \ + -DCMAKE_C_COMPILER="${MPICC}" \ + -DBUILD_SHARED_LIBS=OFF \ + -DUSE_ELPA=OFF \ + ${COMPILATION_OPTIONS} .. > compile.log 2>&1 - make -j $NPROCS -C src >> compile.log 2>&1 + make -j $NPROCS -C src >> compile.log 2>&1 - install -d ${pkg_install_dir}/include >> install.log 2>&1 - install -d ${pkg_install_dir}/lib >> install.log 2>&1 - cp -R ../src/* ${pkg_install_dir}/include >> install.log 2>&1 - install -m 644 src/*.a ${pkg_install_dir}/lib >> install.log 2>&1 - install -m 644 src/mod_files/*.mod ${pkg_install_dir}/include >> install.log 2>&1 - cd .. + install -d ${pkg_install_dir}/include >> install.log 2>&1 + install -d ${pkg_install_dir}/lib >> install.log 2>&1 + cp -R ../src/* ${pkg_install_dir}/include >> install.log 2>&1 + install -m 644 src/*.a ${pkg_install_dir}/lib >> install.log 2>&1 + install -m 644 src/mod_files/*.mod ${pkg_install_dir}/include >> install.log 2>&1 + cd .. - # now do we have cuda as well + # now do we have cuda as well - if [ "$ENABLE_CUDA" = "__TRUE__" ] ; then - [ -d build-cuda ] && rm -rf "build-cuda" - mkdir build-cuda - cd build-cuda - CMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}:${SPFFT_ROOT}/lib/cmake:${SPFFT_ROOT}/lib64/cmake" \ - cmake -DCMAKE_INSTALL_PREFIX=${pkg_install_dir} \ - -DCMAKE_CXXFLAGS_RELEASE="${SIRIUS_OPT}" \ - -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="${SIRIUS_DBG}" \ - -DUSE_CUDA=ON \ - -DUSE_ELPA=OFF \ - -DGPU_MODEL=P100 \ - -DBUILD_SHARED_LIBS=OFF \ - -DCMAKE_CXX_COMPILER="${MPICXX}" \ - -DCMAKE_C_COMPILER="${MPICC}" ${COMPILATION_OPTIONS} .. >> compile.log 2>&1 - make -j $NPROCS -C src >> compile.log 2>&1 - install -d ${pkg_install_dir}/lib/cuda - install -d ${pkg_install_dir}/include/cuda - install -m 644 src/*.a ${pkg_install_dir}/lib/cuda >> install.log 2>&1 - install -m 644 src/mod_files/*.mod ${pkg_install_dir}/include/cuda >> install.log 2>&1 - SIRIUS_CUDA_LDFLAGS="-L'${pkg_install_dir}/lib/cuda' -Wl,-rpath='${pkg_install_dir}/lib/cuda'" - cd .. - fi - SIRIUS_CFLAGS="-I'${pkg_install_dir}/include/cuda'" - SIRIUS_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage8/$(basename ${SCRIPT_NAME})" - fi - ;; - __SYSTEM__) - require_env FFTW_LDFLAGS - require_env FFTW_LIBS - require_env FFTW_CFLAGS - require_env ELPAROOT - require_env ELPA_LDFLAGS - require_env ELPA_LIBS - require_env ELPA_CFLAGS - require_env GSL_LDFLAGS - require_env GSL_CFLAGS - require_env GSL_LIBS - require_env MATH_LIBS - require_env MPI_LDFLAGS - require_env MPI_LIBS - require_env SCALAPACKROOT - require_env SCALAPACK_LDFLAGS - require_env SCALAPACK_CFLAGS - require_env SCALAPACK_LIBS - require_env LIBXC_LIBS - require_env LIBXC_CFLAGS - require_env LIBXC_LDFLAGS - require_env SPGLIB_LIBS - require_env SPGLIB_CFLAGS - require_env SPGLIB_LDFLAGS - require_env HDF5_LIBS - require_env HDF5_CFLAGS - require_env HDF5_LDFLAGS - require_env LIBVDWXC_CFLAGS - require_env LIBVDWXC_LDFLAGS - require_env LIBVDWXC_LIBS - require_env SPFFT_ROOT - require_env SPFFT_CFLAGS - require_env SPFFT_LDFLAGS - require_env SPFFT_LIBS - require_env SPLA_ROOT - require_env SPLA_CFLAGS - require_env SPLA_LDFLAGS - require_env SPLA_LIBS - check_lib -lsirius "sirius" - add_include_from_paths SIRIUS_CFLAGS "sirius*" $INCLUDE_PATHS - add_lib_from_paths SIRIUS_LDFLAGS "libsirius.*" $LIB_PATHS - ;; - *) - echo "==================== Linking SIRIUS_Dist to user paths ====================" - pkg_install_dir="$with_sirius" - check_dir "${pkg_install_dir}/lib" - check_dir "${pkg_install_dir}/lib64" - check_dir "${pkg_install_dir}/include" - ;; + if [ "$ENABLE_CUDA" = "__TRUE__" ]; then + [ -d build-cuda ] && rm -rf "build-cuda" + mkdir build-cuda + cd build-cuda + CMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}:${SPFFT_ROOT}/lib/cmake:${SPFFT_ROOT}/lib64/cmake" \ + cmake -DCMAKE_INSTALL_PREFIX=${pkg_install_dir} \ + -DCMAKE_CXXFLAGS_RELEASE="${SIRIUS_OPT}" \ + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="${SIRIUS_DBG}" \ + -DUSE_CUDA=ON \ + -DUSE_ELPA=OFF \ + -DGPU_MODEL=P100 \ + -DBUILD_SHARED_LIBS=OFF \ + -DCMAKE_CXX_COMPILER="${MPICXX}" \ + -DCMAKE_C_COMPILER="${MPICC}" ${COMPILATION_OPTIONS} .. >> compile.log 2>&1 + make -j $NPROCS -C src >> compile.log 2>&1 + install -d ${pkg_install_dir}/lib/cuda + install -d ${pkg_install_dir}/include/cuda + install -m 644 src/*.a ${pkg_install_dir}/lib/cuda >> install.log 2>&1 + install -m 644 src/mod_files/*.mod ${pkg_install_dir}/include/cuda >> install.log 2>&1 + SIRIUS_CUDA_LDFLAGS="-L'${pkg_install_dir}/lib/cuda' -Wl,-rpath='${pkg_install_dir}/lib/cuda'" + cd .. + fi + SIRIUS_CFLAGS="-I'${pkg_install_dir}/include/cuda'" + SIRIUS_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage8/$(basename ${SCRIPT_NAME})" + fi + ;; + __SYSTEM__) + require_env FFTW_LDFLAGS + require_env FFTW_LIBS + require_env FFTW_CFLAGS + require_env ELPAROOT + require_env ELPA_LDFLAGS + require_env ELPA_LIBS + require_env ELPA_CFLAGS + require_env GSL_LDFLAGS + require_env GSL_CFLAGS + require_env GSL_LIBS + require_env MATH_LIBS + require_env MPI_LDFLAGS + require_env MPI_LIBS + require_env SCALAPACKROOT + require_env SCALAPACK_LDFLAGS + require_env SCALAPACK_CFLAGS + require_env SCALAPACK_LIBS + require_env LIBXC_LIBS + require_env LIBXC_CFLAGS + require_env LIBXC_LDFLAGS + require_env SPGLIB_LIBS + require_env SPGLIB_CFLAGS + require_env SPGLIB_LDFLAGS + require_env HDF5_LIBS + require_env HDF5_CFLAGS + require_env HDF5_LDFLAGS + require_env LIBVDWXC_CFLAGS + require_env LIBVDWXC_LDFLAGS + require_env LIBVDWXC_LIBS + require_env SPFFT_ROOT + require_env SPFFT_CFLAGS + require_env SPFFT_LDFLAGS + require_env SPFFT_LIBS + require_env SPLA_ROOT + require_env SPLA_CFLAGS + require_env SPLA_LDFLAGS + require_env SPLA_LIBS + check_lib -lsirius "sirius" + add_include_from_paths SIRIUS_CFLAGS "sirius*" $INCLUDE_PATHS + add_lib_from_paths SIRIUS_LDFLAGS "libsirius.*" $LIB_PATHS + ;; + *) + echo "==================== Linking SIRIUS_Dist to user paths ====================" + pkg_install_dir="$with_sirius" + check_dir "${pkg_install_dir}/lib" + check_dir "${pkg_install_dir}/lib64" + check_dir "${pkg_install_dir}/include" + ;; esac -if [ "$with_sirius" != "__DONTUSE__" ] ; then - SIRIUS_LIBS="-lsirius IF_CUDA(-lcusolver|)" - SIRIUS_CUDA_LDFLAGS="-L'${pkg_install_dir}/lib/cuda' -Wl,-rpath='${pkg_install_dir}/lib/cuda'" - SIRIUS_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - SIRIUS_CFLAGS="-I'${pkg_install_dir}/include'" - if [ "$with_sirius" != "__SYSTEM__" ] ; then - cat < "${BUILDDIR}/setup_sirius" +if [ "$with_sirius" != "__DONTUSE__" ]; then + SIRIUS_LIBS="-lsirius IF_CUDA(-lcusolver|)" + SIRIUS_CUDA_LDFLAGS="-L'${pkg_install_dir}/lib/cuda' -Wl,-rpath='${pkg_install_dir}/lib/cuda'" + SIRIUS_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + SIRIUS_CFLAGS="-I'${pkg_install_dir}/include'" + if [ "$with_sirius" != "__SYSTEM__" ]; then + cat << EOF > "${BUILDDIR}/setup_sirius" prepend_path LD_LIBRARY_PATH "$pkg_install_dir/lib" prepend_path LD_LIBRARY_PATH "$pkg_install_dir/lib/cuda" prepend_path LD_RUN_PATH "$pkg_install_dir/lib" @@ -242,9 +241,9 @@ prepend_path LIBRARY_PATH "$pkg_install_dir/lib" prepend_path LIBRARY_PATH "$pkg_install_dir/lib/cuda" prepend_path CPATH "$pkg_install_dir/include" EOF - cat "${BUILDDIR}/setup_sirius" >> $SETUPFILE - fi - cat <> "${BUILDDIR}/setup_sirius" + cat "${BUILDDIR}/setup_sirius" >> $SETUPFILE + fi + cat << EOF >> "${BUILDDIR}/setup_sirius" export SIRIUS_CFLAGS="IF_CUDA(-I${pkg_install_dir}/include/cuda|-I${pkg_install_dir}/include)" export SIRIUS_FFLAGS="IF_CUDA(-I${pkg_install_dir}/include/cuda|-I${pkg_install_dir}/include)" export SIRIUS_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" diff --git a/tools/toolchain/scripts/stage8/install_spfft.sh b/tools/toolchain/scripts/stage8/install_spfft.sh index 3054d3a2cf..f3be9c5729 100755 --- a/tools/toolchain/scripts/stage8/install_spfft.sh +++ b/tools/toolchain/scripts/stage8/install_spfft.sh @@ -16,90 +16,90 @@ source "${INSTALLDIR}"/toolchain.env cd "${BUILDDIR}" case "$with_spfft" in - __INSTALL__) - echo "==================== Installing spfft ====================" - pkg_install_dir="${INSTALLDIR}/SpFFT-${spfft_ver}" - install_lock_file="$pkg_install_dir/install_successful" - if verify_checksums "${install_lock_file}" ; then - echo "SpFFT-${spfft_ver} is already installed, skipping it." - else - if [ -f SpFFT-${spfft_ver}.tar.gz ] ; then - echo "SpFFT-${spfft_ver}.tar.gz is found" - else - download_pkg ${DOWNLOADER_FLAGS} ${spfft_sha256} \ - "https://github.com/eth-cscs/SpFFT/archive/v${spfft_ver}.tar.gz" \ - -o SpFFT-${spfft_ver}.tar.gz + __INSTALL__) + echo "==================== Installing spfft ====================" + pkg_install_dir="${INSTALLDIR}/SpFFT-${spfft_ver}" + install_lock_file="$pkg_install_dir/install_successful" + if verify_checksums "${install_lock_file}"; then + echo "SpFFT-${spfft_ver} is already installed, skipping it." + else + if [ -f SpFFT-${spfft_ver}.tar.gz ]; then + echo "SpFFT-${spfft_ver}.tar.gz is found" + else + download_pkg ${DOWNLOADER_FLAGS} ${spfft_sha256} \ + "https://github.com/eth-cscs/SpFFT/archive/v${spfft_ver}.tar.gz" \ + -o SpFFT-${spfft_ver}.tar.gz - fi - echo "Installing from scratch into ${pkg_install_dir}" - [ -d SpFFT-${spfft_ver} ] && rm -rf SpFFT-${spfft_ver} - tar -xzf SpFFT-${spfft_ver}.tar.gz - cd SpFFT-${spfft_ver} - mkdir build-cpu - cd build-cpu - cmake \ - -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \ - -DCMAKE_INSTALL_LIBDIR=lib \ - -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE \ - -DSPFFT_OMP=ON \ - -DSPFFT_MPI=ON \ - -DSPFFT_INSTALL=ON \ - .. > cmake.log 2>&1 - make -j $NPROCS > make.log 2>&1 - make -j $NPROCS install > install.log 2>&1 - cd .. + fi + echo "Installing from scratch into ${pkg_install_dir}" + [ -d SpFFT-${spfft_ver} ] && rm -rf SpFFT-${spfft_ver} + tar -xzf SpFFT-${spfft_ver}.tar.gz + cd SpFFT-${spfft_ver} + mkdir build-cpu + cd build-cpu + cmake \ + -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \ + -DCMAKE_INSTALL_LIBDIR=lib \ + -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE \ + -DSPFFT_OMP=ON \ + -DSPFFT_MPI=ON \ + -DSPFFT_INSTALL=ON \ + .. > cmake.log 2>&1 + make -j $NPROCS > make.log 2>&1 + make -j $NPROCS install > install.log 2>&1 + cd .. - if [ "$ENABLE_CUDA" = "__TRUE__" ] ; then - [ -d build-cuda ] && rm -rf "build-cuda" - mkdir build-cuda - cd build-cuda - cmake \ - -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \ - -DCMAKE_INSTALL_LIBDIR=lib \ - -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE \ - -DSPFFT_OMP=ON \ - -DSPFFT_MPI=ON \ - -DSPFFT_INSTALL=ON \ - -DSPFFT_GPU_BACKEND=CUDA \ - .. > cmake.log 2>&1 - make -j $NPROCS > make.log 2>&1 - install -d ${pkg_install_dir}/lib/cuda - [ -f src/libspfft.a ] && install -m 644 src/*.a ${pkg_install_dir}/lib/cuda >> install.log 2>&1 - [ -f src/libspfft.so ] && install -m 644 src/*.so ${pkg_install_dir}/lib/cuda >> install.log 2>&1 - fi - write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage8/$(basename ${SCRIPT_NAME})" - fi - SPFFT_ROOT="${pkg_install_dir}" - SPFFT_CFLAGS="-I'${pkg_install_dir}/include'" - SPFFT_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - SPFFT_CUDA_LDFLAGS="-L'${pkg_install_dir}/lib/cuda' -Wl,-rpath='${pkg_install_dir}/lib/cuda'" - ;; - __SYSTEM__) - echo "==================== Finding spfft from system paths ====================" - check_command pkg-config --modversion spfft - add_include_from_paths SPFFT_CFLAGS "spfft.h" $INCLUDE_PATHS - add_lib_from_paths SPFFT_LDFLAGS "libspfft.*" $LIB_PATHS - ;; - __DONTUSE__) - ;; - *) - echo "==================== Linking spfft to user paths ====================" - pkg_install_dir="$with_spfft" + if [ "$ENABLE_CUDA" = "__TRUE__" ]; then + [ -d build-cuda ] && rm -rf "build-cuda" + mkdir build-cuda + cd build-cuda + cmake \ + -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \ + -DCMAKE_INSTALL_LIBDIR=lib \ + -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE \ + -DSPFFT_OMP=ON \ + -DSPFFT_MPI=ON \ + -DSPFFT_INSTALL=ON \ + -DSPFFT_GPU_BACKEND=CUDA \ + .. > cmake.log 2>&1 + make -j $NPROCS > make.log 2>&1 + install -d ${pkg_install_dir}/lib/cuda + [ -f src/libspfft.a ] && install -m 644 src/*.a ${pkg_install_dir}/lib/cuda >> install.log 2>&1 + [ -f src/libspfft.so ] && install -m 644 src/*.so ${pkg_install_dir}/lib/cuda >> install.log 2>&1 + fi + write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage8/$(basename ${SCRIPT_NAME})" + fi + SPFFT_ROOT="${pkg_install_dir}" + SPFFT_CFLAGS="-I'${pkg_install_dir}/include'" + SPFFT_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + SPFFT_CUDA_LDFLAGS="-L'${pkg_install_dir}/lib/cuda' -Wl,-rpath='${pkg_install_dir}/lib/cuda'" + ;; + __SYSTEM__) + echo "==================== Finding spfft from system paths ====================" + check_command pkg-config --modversion spfft + add_include_from_paths SPFFT_CFLAGS "spfft.h" $INCLUDE_PATHS + add_lib_from_paths SPFFT_LDFLAGS "libspfft.*" $LIB_PATHS + ;; + __DONTUSE__) ;; - # use the lib64 directory if present (multi-abi distros may link lib/ to lib32/ instead) - SPFFT_LIBDIR="${pkg_install_dir}/lib" - [ -d "${pkg_install_dir}/lib64" ] && SPFFT_LIBDIR="${pkg_install_dir}/lib64" + *) + echo "==================== Linking spfft to user paths ====================" + pkg_install_dir="$with_spfft" - check_dir "${SPFFT_LIBDIR}" - check_dir "${pkg_install_dir}/include" - SPFFT_CFLAGS="-I'${pkg_install_dir}/include'" - SPFFT_LDFLAGS="-L'${SPFFT_LIBDIR}' -Wl,-rpath='${SPFFT_LIBDIR}'" - ;; + # use the lib64 directory if present (multi-abi distros may link lib/ to lib32/ instead) + SPFFT_LIBDIR="${pkg_install_dir}/lib" + [ -d "${pkg_install_dir}/lib64" ] && SPFFT_LIBDIR="${pkg_install_dir}/lib64" + + check_dir "${SPFFT_LIBDIR}" + check_dir "${pkg_install_dir}/include" + SPFFT_CFLAGS="-I'${pkg_install_dir}/include'" + SPFFT_LDFLAGS="-L'${SPFFT_LIBDIR}' -Wl,-rpath='${SPFFT_LIBDIR}'" + ;; esac -if [ "$with_spfft" != "__DONTUSE__" ] ; then - SPFFT_LIBS="-lspfft" - if [ "$with_spfft" != "__SYSTEM__" ] ; then - cat << EOF > "${BUILDDIR}/setup_spfft" +if [ "$with_spfft" != "__DONTUSE__" ]; then + SPFFT_LIBS="-lspfft" + if [ "$with_spfft" != "__SYSTEM__" ]; then + cat << EOF > "${BUILDDIR}/setup_spfft" prepend_path LD_LIBRARY_PATH "$pkg_install_dir/lib" prepend_path LD_RUN_PATH "$pkg_install_dir/lib" prepend_path LIBRARY_PATH "$pkg_install_dir/lib" @@ -109,8 +109,8 @@ export SPFFT_LIBS="-lspfft" export SPFFT_ROOT="${pkg_install_dir}" export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$pkg_install_dir/lib64/pkgconfig:$pkg_install_dir/lib/pkgconfig" EOF - fi - cat << EOF >> "${BUILDDIR}/setup_spfft" + fi + cat << EOF >> "${BUILDDIR}/setup_spfft" export SPFFT_CFLAGS="${SPFFT_CFLAGS}" export SPFFT_LDFLAGS="${SPFFT_LDFLAGS}" export SPFFT_CUDA_LDFLAGS="${SPFFT_CUDA_LDFLAGS}" @@ -124,7 +124,7 @@ export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$pkg_install_dir/lib64/pkgconfig:$pkg_i export SPFFT_VERSION=${spfft-ver} export CP_LIBS="IF_MPI(${SPFFT_LIBS}|) \${CP_LIBS}" EOF - cat "${BUILDDIR}/setup_spfft" >> $SETUPFILE + cat "${BUILDDIR}/setup_spfft" >> $SETUPFILE fi load "${BUILDDIR}/setup_spfft" diff --git a/tools/toolchain/scripts/stage8/install_spla.sh b/tools/toolchain/scripts/stage8/install_spla.sh index 7b578e90c1..78cf047385 100755 --- a/tools/toolchain/scripts/stage8/install_spla.sh +++ b/tools/toolchain/scripts/stage8/install_spla.sh @@ -16,92 +16,92 @@ source "${INSTALLDIR}"/toolchain.env cd "${BUILDDIR}" case "$with_spla" in - __INSTALL__) - echo "==================== Installing spla ====================" - pkg_install_dir="${INSTALLDIR}/SpLA-${spla_ver}" - install_lock_file="$pkg_install_dir/install_successful" - if verify_checksums "${install_lock_file}" ; then - echo "SpLA-${spla_ver} is already installed, skipping it." - else - if [ -f SpLA-${spla_ver}.tar.gz ] ; then - echo "SpLA-${spla_ver}.tar.gz is found" - else - download_pkg ${DOWNLOADER_FLAGS} ${spla_sha256} \ - "https://github.com/eth-cscs/Spla/archive/v${spla_ver}.tar.gz" \ - -o SpLA-${spla_ver}.tar.gz + __INSTALL__) + echo "==================== Installing spla ====================" + pkg_install_dir="${INSTALLDIR}/SpLA-${spla_ver}" + install_lock_file="$pkg_install_dir/install_successful" + if verify_checksums "${install_lock_file}"; then + echo "SpLA-${spla_ver} is already installed, skipping it." + else + if [ -f SpLA-${spla_ver}.tar.gz ]; then + echo "SpLA-${spla_ver}.tar.gz is found" + else + download_pkg ${DOWNLOADER_FLAGS} ${spla_sha256} \ + "https://github.com/eth-cscs/Spla/archive/v${spla_ver}.tar.gz" \ + -o SpLA-${spla_ver}.tar.gz - fi - echo "Installing from scratch into ${pkg_install_dir}" - [ -d SpLA-${spla_ver} ] && rm -rf SpLA-${spla_ver} - tar -xzf SpLA-${spla_ver}.tar.gz - cd spla-${spla_ver} - mkdir build-cpu - cd build-cpu - cmake \ - -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \ - -DCMAKE_INSTALL_LIBDIR=lib \ - -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE \ - -DSPLA_OMP=ON \ - -DSPLA_MPI=ON \ - -DSPLA_INSTALL=ON \ - -DSPLA_STATIC=OM \ - .. > cmake.log 2>&1 - make -j $NPROCS > make.log 2>&1 - make -j $NPROCS install > install.log 2>&1 - cd .. + fi + echo "Installing from scratch into ${pkg_install_dir}" + [ -d SpLA-${spla_ver} ] && rm -rf SpLA-${spla_ver} + tar -xzf SpLA-${spla_ver}.tar.gz + cd spla-${spla_ver} + mkdir build-cpu + cd build-cpu + cmake \ + -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \ + -DCMAKE_INSTALL_LIBDIR=lib \ + -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE \ + -DSPLA_OMP=ON \ + -DSPLA_MPI=ON \ + -DSPLA_INSTALL=ON \ + -DSPLA_STATIC=OM \ + .. > cmake.log 2>&1 + make -j $NPROCS > make.log 2>&1 + make -j $NPROCS install > install.log 2>&1 + cd .. - if [ "$ENABLE_CUDA" = "__TRUE__" ] ; then - [ -d build-cuda ] && rm -rf "build-cuda" - mkdir build-cuda - cd build-cuda - cmake \ - -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \ - -DCMAKE_INSTALL_LIBDIR=lib \ - -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE \ - -DSPLA_OMP=ON \ - -DSPLA_MPI=ON \ - -DSPLA_STATIC=OM \ - -DSPLA_INSTALL=ON \ - -DSPLA_GPU_BACKEND=CUDA \ - .. > cmake.log 2>&1 - make -j $NPROCS > make.log 2>&1 - install -d ${pkg_install_dir}/lib/cuda - [ -f src/libspla.a ] && install -m 644 src/*.a ${pkg_install_dir}/lib/cuda >> install.log 2>&1 - [ -f src/libspla.so ] && install -m 644 src/*.so ${pkg_install_dir}/lib/cuda >> install.log 2>&1 - fi - write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage8/$(basename ${SCRIPT_NAME})" - fi - SPLA_ROOT="${pkg_install_dir}" - SPLA_CFLAGS="-I'${pkg_install_dir}/include'" - SPLA_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" - SPLA_CUDA_LDFLAGS="-L'${pkg_install_dir}/lib/cuda' -Wl,-rpath='${pkg_install_dir}/lib/cuda'" - ;; - __SYSTEM__) - echo "==================== Finding spla from system paths ====================" - check_command pkg-config --modversion spla - add_include_from_paths SPLA_CFLAGS "spla.h" $INCLUDE_PATHS - add_lib_from_paths SPLA_LDFLAGS "libspla.*" $LIB_PATHS - ;; - __DONTUSE__) - ;; - *) - echo "==================== Linking spla to user paths ====================" - pkg_install_dir="$with_spla" + if [ "$ENABLE_CUDA" = "__TRUE__" ]; then + [ -d build-cuda ] && rm -rf "build-cuda" + mkdir build-cuda + cd build-cuda + cmake \ + -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \ + -DCMAKE_INSTALL_LIBDIR=lib \ + -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE \ + -DSPLA_OMP=ON \ + -DSPLA_MPI=ON \ + -DSPLA_STATIC=OM \ + -DSPLA_INSTALL=ON \ + -DSPLA_GPU_BACKEND=CUDA \ + .. > cmake.log 2>&1 + make -j $NPROCS > make.log 2>&1 + install -d ${pkg_install_dir}/lib/cuda + [ -f src/libspla.a ] && install -m 644 src/*.a ${pkg_install_dir}/lib/cuda >> install.log 2>&1 + [ -f src/libspla.so ] && install -m 644 src/*.so ${pkg_install_dir}/lib/cuda >> install.log 2>&1 + fi + write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage8/$(basename ${SCRIPT_NAME})" + fi + SPLA_ROOT="${pkg_install_dir}" + SPLA_CFLAGS="-I'${pkg_install_dir}/include'" + SPLA_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'" + SPLA_CUDA_LDFLAGS="-L'${pkg_install_dir}/lib/cuda' -Wl,-rpath='${pkg_install_dir}/lib/cuda'" + ;; + __SYSTEM__) + echo "==================== Finding spla from system paths ====================" + check_command pkg-config --modversion spla + add_include_from_paths SPLA_CFLAGS "spla.h" $INCLUDE_PATHS + add_lib_from_paths SPLA_LDFLAGS "libspla.*" $LIB_PATHS + ;; + __DONTUSE__) ;; - # use the lib64 directory if present (multi-abi distros may link lib/ to lib32/ instead) - SPLA_LIBDIR="${pkg_install_dir}/lib" - [ -d "${pkg_install_dir}/lib64" ] && SPLA_LIBDIR="${pkg_install_dir}/lib64" + *) + echo "==================== Linking spla to user paths ====================" + pkg_install_dir="$with_spla" - check_dir "${SPLA_LIBDIR}" - check_dir "${pkg_install_dir}/include" - SPLA_CFLAGS="-I'${pkg_install_dir}/include'" - SPLA_LDFLAGS="-L'${SPLA_LIBDIR}' -Wl,-rpath='${SPLA_LIBDIR}'" - ;; + # use the lib64 directory if present (multi-abi distros may link lib/ to lib32/ instead) + SPLA_LIBDIR="${pkg_install_dir}/lib" + [ -d "${pkg_install_dir}/lib64" ] && SPLA_LIBDIR="${pkg_install_dir}/lib64" + + check_dir "${SPLA_LIBDIR}" + check_dir "${pkg_install_dir}/include" + SPLA_CFLAGS="-I'${pkg_install_dir}/include'" + SPLA_LDFLAGS="-L'${SPLA_LIBDIR}' -Wl,-rpath='${SPLA_LIBDIR}'" + ;; esac -if [ "$with_spla" != "__DONTUSE__" ] ; then - SPLA_LIBS="-lspla" - if [ "$with_spla" != "__SYSTEM__" ] ; then - cat << EOF > "${BUILDDIR}/setup_spla" +if [ "$with_spla" != "__DONTUSE__" ]; then + SPLA_LIBS="-lspla" + if [ "$with_spla" != "__SYSTEM__" ]; then + cat << EOF > "${BUILDDIR}/setup_spla" prepend_path LD_LIBRARY_PATH "$pkg_install_dir/lib" prepend_path LD_RUN_PATH "$pkg_install_dir/lib" prepend_path LIBRARY_PATH "$pkg_install_dir/lib" @@ -111,8 +111,8 @@ export SPLA_LIBS="-lspla" export SPLA_ROOT="${pkg_install_dir}" export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$pkg_install_dir/lib64/pkgconfig:$pkg_install_dir/lib/pkgconfig" EOF - fi - cat << EOF >> "${BUILDDIR}/setup_spla" + fi + cat << EOF >> "${BUILDDIR}/setup_spla" export SPLA_CFLAGS="${SPLA_CFLAGS}" export SPLA_LDFLAGS="${SPLA_LDFLAGS}" export SPLA_CUDA_LDFLAGS="${SPLA_CUDA_LDFLAGS}" @@ -126,7 +126,7 @@ export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$pkg_install_dir/lib64/pkgconfig:$pkg_i export SPLA_VERSION=${spla-ver} export CP_LIBS="IF_MPI(${SPLA_LIBS}|) \${CP_LIBS}" EOF - cat "${BUILDDIR}/setup_spla" >> $SETUPFILE + cat "${BUILDDIR}/setup_spla" >> $SETUPFILE fi load "${BUILDDIR}/setup_spla" diff --git a/tools/toolchain/scripts/tool_kit.sh b/tools/toolchain/scripts/tool_kit.sh index 12884b5a88..c2c166c948 100644 --- a/tools/toolchain/scripts/tool_kit.sh +++ b/tools/toolchain/scripts/tool_kit.sh @@ -5,174 +5,178 @@ SYS_INCLUDE_PATH=${SYS_INCLUDE_PATH:-"/usr/local/include:/usr/include"} SYS_LIB_PATH=${SYS_LIB_PATH:-"/user/local/lib64:/usr/local/lib:/usr/lib64:/usr/lib:/lib64:/lib"} INCLUDE_PATHS=${INCLUDE_PATHS:-"CPATH SYS_INCLUDE_PATH"} LIB_PATHS=${LIB_PATHS:-"LIBRARY_PATH LD_LIBRARY_PATH LD_RUN_PATH SYS_LIB_PATH"} -time_start=`date +%s` +time_start=$(date +%s) # report timing report_timing() { - time_stop=`date +%s` - printf "Step %s took %0.2f seconds.\n" $1 $((time_stop-time_start)) + time_stop=$(date +%s) + printf "Step %s took %0.2f seconds.\n" $1 $((time_stop - time_start)) } # report a warning message with script name and line number report_warning() { - if [ $# -gt 1 ] ; then - local __lineno=", line $1" - local __message="$2" - else - local __lineno='' - local __message="$1" - fi - echo "WARNING: (${SCRIPT_NAME}${__lineno}) $__message" >&2 + if [ $# -gt 1 ]; then + local __lineno=", line $1" + local __message="$2" + else + local __lineno='' + local __message="$1" + fi + echo "WARNING: (${SCRIPT_NAME}${__lineno}) $__message" >&2 } # report an error message with script name and line number report_error() { - if [ $# -gt 1 ] ; then - local __lineno=", line $1" - local __message="$2" - else - local __lineno='' - local __message="$1" - fi - echo "ERROR: (${SCRIPT_NAME}${__lineno}) $__message" >&2 + if [ $# -gt 1 ]; then + local __lineno=", line $1" + local __message="$2" + else + local __lineno='' + local __message="$1" + fi + echo "ERROR: (${SCRIPT_NAME}${__lineno}) $__message" >&2 } # error handler for line trap from set -e error_handler() { - local __lineno="$1" - report_error $1 "Non-zero exit code detected." - exit 1 + local __lineno="$1" + report_error $1 "Non-zero exit code detected." + exit 1 } # source a file if it exists, otherwise do nothing load() { - if [ -f "$1" ] ; then - source "$1" - fi + if [ -f "$1" ]; then + source "$1" + fi } # A more portable command that will give the full path, removing # symlinks, of a given path. This is more portable than readlink -f # which does not work on Mac OS X realpath() { - local __path="$1" - if [ "x$__path" = x ] ; then - return 0 - fi - local __basename=$(basename "$__path") - if [ -e "$__path" ] ; then - echo $(cd "$(dirname "$__path")" ; pwd -P)/"$__basename" - return 0 - else - return 1 - fi + local __path="$1" + if [ "x$__path" = x ]; then + return 0 + fi + local __basename=$(basename "$__path") + if [ -e "$__path" ]; then + echo $( + cd "$(dirname "$__path")" + pwd -P + )/"$__basename" + return 0 + else + return 1 + fi } # given a list, outputs a list with duplicated items filtered out unique() ( - # given a list, outputs a list with duplicated items filtered out. - # If -d option exists, then output the list delimited - # by ; note that this option does not effect the input. - local __result='' - local __delimiter=' ' - local __item='' - if [ "$1" = "-d" ] ; then - shift - __delimiter="$1" - shift - fi - # It is essential that we quote $@, which makes it equivalent to - # "$1" "$2" ... So this works if any of the arguments contains - # space. And we use \n to separate the fields in the - # __result for now, so that fields that contain spaces are - # correctly grepped. - for __item in "$@" ; do - if [ x"$__result" = x ] ; then - __result="${__item}" - # Note that quoting $__result after echo is essential to - # retain the \n in the variable from the output of echo. Also - # remember grep only works on a line by line basis, so if - # items are delimited by newlines, then for grep search it - # should be delimited by ^ and $ (beginning and end of line) - elif ! (echo "$__result" | \ - grep -s -q -e "^$__item\$") ; then - __result="${__result} + # given a list, outputs a list with duplicated items filtered out. + # If -d option exists, then output the list delimited + # by ; note that this option does not effect the input. + local __result='' + local __delimiter=' ' + local __item='' + if [ "$1" = "-d" ]; then + shift + __delimiter="$1" + shift + fi + # It is essential that we quote $@, which makes it equivalent to + # "$1" "$2" ... So this works if any of the arguments contains + # space. And we use \n to separate the fields in the + # __result for now, so that fields that contain spaces are + # correctly grepped. + for __item in "$@"; do + if [ x"$__result" = x ]; then + __result="${__item}" + # Note that quoting $__result after echo is essential to + # retain the \n in the variable from the output of echo. Also + # remember grep only works on a line by line basis, so if + # items are delimited by newlines, then for grep search it + # should be delimited by ^ and $ (beginning and end of line) + elif ! (echo "$__result" | + grep -s -q -e "^$__item\$"); then + __result="${__result} ${__item}" - fi - done - __result="$(echo "$__result" | paste -s -d "$__delimiter" -)" - # quoting $__result below is again essential for correct - # behaviour if IFS is set to be the same $__delimiter in the - # parent shell calling this macro - echo "$__result" + fi + done + __result="$(echo "$__result" | paste -s -d "$__delimiter" -)" + # quoting $__result below is again essential for correct + # behaviour if IFS is set to be the same $__delimiter in the + # parent shell calling this macro + echo "$__result" ) # reverse a list reverse() ( - # given a list, output a list with reversed order. If -d - # option exists, then output the list delimited by - # ; note that this option does not effect the input. - local __result='' - local __delimiter=' ' - local __item='' - if [ "$1" = "-d" ] ; then - shift - __delimiter="$1" - shift + # given a list, output a list with reversed order. If -d + # option exists, then output the list delimited by + # ; note that this option does not effect the input. + local __result='' + local __delimiter=' ' + local __item='' + if [ "$1" = "-d" ]; then + shift + __delimiter="$1" + shift + fi + for __item in "$@"; do + if [ x"$__result" = x ]; then + __result="$__item" + else + __result="${__item}${__delimiter}${__result}" fi - for __item in "$@" ; do - if [ x"$__result" = x ] ; then - __result="$__item" - else - __result="${__item}${__delimiter}${__result}" - fi - done - echo "$__result" + done + echo "$__result" ) # get the number of processes available for compilation get_nprocs() { - if $(command -v nproc >&- 2>&-) ; then - echo $(nproc --all) - else - echo 1 - fi + if $(command -v nproc >&- 2>&-); then + echo $(nproc --all) + else + echo 1 + fi } # convert a list of paths to -L ... used by ld paths_to_ld() { - # need to define the POSIX default IFS values here, cannot just do - # __ifs=$IFS first, because IFS can be unset, and if so __ifs will - # becomes an empty string (null) and NOT unset, so later when IFS - # is set to __ifs it becomes null rather than unset, and thus - # causing wrong behaviour. So if IFS is unset, __ifs should be - # the POSIX default value. Further more, due to shell - # automatically remove the tailing "\n" in a string during - # variable assignment, we need to add x after \n and then remove - # it. - local __paths=$@ - local __name='' - local __raw_path='' - local __dir='' - local __lib_dirs='' - # set default IFS first - local __ifs=$(printf " \t\nx"); __ifs="${__ifs%x}" - [ "$IFS" ] && __ifs="$IFS" - for __name in $__paths ; do - eval __raw_path=\$"$__name" - # change internal field separator to : - IFS=':' - # loop over all dirs in path, and filter out duplications - for __dir in $__raw_path ; do - if ! [ x"$__dir" = x ] ; then - if ! [[ "$__lib_dirs" =~ (^|[[:space:]])"-L'$__dir'"($|[[:space:]]) ]] ; then - __lib_dirs="$__lib_dirs -L'$__dir'" - fi - fi - done - IFS="$__ifs" + # need to define the POSIX default IFS values here, cannot just do + # __ifs=$IFS first, because IFS can be unset, and if so __ifs will + # becomes an empty string (null) and NOT unset, so later when IFS + # is set to __ifs it becomes null rather than unset, and thus + # causing wrong behaviour. So if IFS is unset, __ifs should be + # the POSIX default value. Further more, due to shell + # automatically remove the tailing "\n" in a string during + # variable assignment, we need to add x after \n and then remove + # it. + local __paths=$@ + local __name='' + local __raw_path='' + local __dir='' + local __lib_dirs='' + # set default IFS first + local __ifs=$(printf " \t\nx") + __ifs="${__ifs%x}" + [ "$IFS" ] && __ifs="$IFS" + for __name in $__paths; do + eval __raw_path=\$"$__name" + # change internal field separator to : + IFS=':' + # loop over all dirs in path, and filter out duplications + for __dir in $__raw_path; do + if ! [ x"$__dir" = x ]; then + if ! [[ "$__lib_dirs" =~ (^|[[:space:]])"-L'$__dir'"($|[[:space:]]) ]]; then + __lib_dirs="$__lib_dirs -L'$__dir'" + fi + fi done - echo $__lib_dirs + IFS="$__ifs" + done + echo $__lib_dirs } # Find a file from directories given in a list of paths, each has the @@ -182,37 +186,39 @@ paths_to_ld() { # acceptable for bash, and in that case the full path of the first # matching file will be echoed. find_in_paths() { - local __target=$1 - shift - local __paths=$@ - local __name='' - local __raw_path='' - local __dir='' - local __file='' - local __files='' - # use the IFS variable to take care of possible spaces in file/dir names - local __ifs="$(printf " \t\nx")"; __ifs="${__ifs%x}" - [ "$IFS" ] && __ifs="$IFS" - for __name in $__paths ; do - eval __raw_path=\$"$__name" - # fields in paths are separated by : - IFS=':' - for __dir in $__raw_path ; do - # files in possible glob expansion are to be delimited by "\n\b" - IFS="$(printf "\nx")"; IFS="${IFS%x}" - for __file in $__dir/$__target ; do - if [ -e "$__file" ] ; then - echo $(realpath "$__file") - # must remember to change IFS back when exiting - IFS="$__ifs" - return 0 - fi - done - IFS=':' - done - IFS=$__ifs + local __target=$1 + shift + local __paths=$@ + local __name='' + local __raw_path='' + local __dir='' + local __file='' + local __files='' + # use the IFS variable to take care of possible spaces in file/dir names + local __ifs="$(printf " \t\nx")" + __ifs="${__ifs%x}" + [ "$IFS" ] && __ifs="$IFS" + for __name in $__paths; do + eval __raw_path=\$"$__name" + # fields in paths are separated by : + IFS=':' + for __dir in $__raw_path; do + # files in possible glob expansion are to be delimited by "\n\b" + IFS="$(printf "\nx")" + IFS="${IFS%x}" + for __file in $__dir/$__target; do + if [ -e "$__file" ]; then + echo $(realpath "$__file") + # must remember to change IFS back when exiting + IFS="$__ifs" + return 0 + fi + done + IFS=':' done - echo "__FALSE__" + IFS=$__ifs + done + echo "__FALSE__" } # search through a list of given paths, try to find the required file @@ -224,36 +230,36 @@ find_in_paths() { # instead. The search target accepts bash wildcards, and in this case # the first match will be used. add_include_from_paths() { - local __parent_dir_only=false - if [ $1 = "-p" ] ; then - __parent_dir_only=true - shift - fi - local __cflags_name=$1 + local __parent_dir_only=false + if [ $1 = "-p" ]; then + __parent_dir_only=true shift - local __search_target=$1 - shift - local __paths=$@ - local __found_target="" - local __cflags="" - __found_target="$(find_in_paths "$__search_target" \ - $__paths)" - if [ "$__found_target" != "__FALSE__" ] ; then - if [ -f "$__found_target" ] || $__parent_dir_only ; then - __found_target="$(dirname "$__found_target")" - fi - echo "Found include directory $__found_target" - eval __cflags=\$"${__cflags_name}" - __cflags="${__cflags} -I'${__found_target}'" - # remove possible duplicates - __cflags="$(unique $__cflags)" - # must escape all quotes again before the last eval, as - # otherwise all quotes gets interpreted by the shell when - # assigning to variable because eval will reduce one escape - # level - __cflags="${__cflags//'/\\'}" - eval $__cflags_name=\"$__cflags\" + fi + local __cflags_name=$1 + shift + local __search_target=$1 + shift + local __paths=$@ + local __found_target="" + local __cflags="" + __found_target="$(find_in_paths "$__search_target" \ + $__paths)" + if [ "$__found_target" != "__FALSE__" ]; then + if [ -f "$__found_target" ] || $__parent_dir_only; then + __found_target="$(dirname "$__found_target")" fi + echo "Found include directory $__found_target" + eval __cflags=\$"${__cflags_name}" + __cflags="${__cflags} -I'${__found_target}'" + # remove possible duplicates + __cflags="$(unique $__cflags)" + # must escape all quotes again before the last eval, as + # otherwise all quotes gets interpreted by the shell when + # assigning to variable because eval will reduce one escape + # level + __cflags="${__cflags//'/\\'/}" + eval $__cflags_name=\"$__cflags\" + fi } # search through a list of given paths, try to find the required file @@ -265,130 +271,130 @@ add_include_from_paths() { # directory is used for -L instead. The search target accepts bash # wildcards, and in this case the first match will be used. add_lib_from_paths() { - local __parent_dir_only=false - if [ $1 = "-p" ] ; then - __parent_dir_only=true - shift - fi - local __ldflags_name=$1 + local __parent_dir_only=false + if [ $1 = "-p" ]; then + __parent_dir_only=true shift - local __search_target=$1 - shift - local __paths=$@ - local __found_target="" - local __ldflags="" - __found_target="$(find_in_paths "$__search_target" \ - $__paths)" - if [ "$__found_target" != "__FALSE__" ] ; then - if [ -f "$__found_target" ] || $__parent_dir_only ; then - __found_target="$(dirname "$__found_target")" - fi - echo "Found lib directory $__found_target" - eval __ldflags=\$"${__ldflags_name}" - __ldflags="${__ldflags} -L'${__found_target}' -Wl,-rpath='${__found_target}'" - # remove possible duplicates - __ldflags="$(unique $__ldflags)" - # must escape all quotes again before the last eval, as - # otherwise all quotes gets interpreted by the shell when - # assigning to variable because eval will reduce one escape - # level - __ldflags="${__ldflags//'/\\'}" - eval $__ldflags_name=\"$__ldflags\" + fi + local __ldflags_name=$1 + shift + local __search_target=$1 + shift + local __paths=$@ + local __found_target="" + local __ldflags="" + __found_target="$(find_in_paths "$__search_target" \ + $__paths)" + if [ "$__found_target" != "__FALSE__" ]; then + if [ -f "$__found_target" ] || $__parent_dir_only; then + __found_target="$(dirname "$__found_target")" fi + echo "Found lib directory $__found_target" + eval __ldflags=\$"${__ldflags_name}" + __ldflags="${__ldflags} -L'${__found_target}' -Wl,-rpath='${__found_target}'" + # remove possible duplicates + __ldflags="$(unique $__ldflags)" + # must escape all quotes again before the last eval, as + # otherwise all quotes gets interpreted by the shell when + # assigning to variable because eval will reduce one escape + # level + __ldflags="${__ldflags//'/\\'/}" + eval $__ldflags_name=\"$__ldflags\" + fi } # check if environment variable is assigned and non-empty # https://serverfault.com/questions/7503/how-to-determine-if-a-bash-variable-is-empty require_env() { - local __env_var_name=$1 - local __env_var="$(eval echo \"\$$__env_var_name\")" - if [ -z "${__env_var+set}" ] ; then - report_error "requires environment variable $__env_var_name to work" - return 1 - fi + local __env_var_name=$1 + local __env_var="$(eval echo \"\$$__env_var_name\")" + if [ -z "${__env_var+set}" ]; then + report_error "requires environment variable $__env_var_name to work" + return 1 + fi } resolve_string() { - local __to_resolve=$1 - shift - local __flags=$@ + local __to_resolve=$1 + shift + local __flags=$@ - echo $("${SCRIPTDIR}/parse_if.py" $__flags <<< "${__to_resolve}") + echo $("${SCRIPTDIR}/parse_if.py" $__flags <<< "${__to_resolve}") } # check if a command is available check_command() { - local __command=$1 - if [ $# -eq 1 ] ; then - local __package=$1 - elif [ $# -gt 1 ] ; then - local __package=$2 - fi - if $(command -v $__command >&- 2>&-) ; then - echo "path to $__command is " $(command -v $__command) - else - report_error "cannot find $__command, please check if $__package is installed or in system search path" - return 1 - fi + local __command=$1 + if [ $# -eq 1 ]; then + local __package=$1 + elif [ $# -gt 1 ]; then + local __package=$2 + fi + if $(command -v $__command >&- 2>&-); then + echo "path to $__command is " $(command -v $__command) + else + report_error "cannot find $__command, please check if $__package is installed or in system search path" + return 1 + fi } # check if directory exists check_dir() { - local __dir=$1 - if [ -d "$__dir" ] ; then - echo "Found directory $__dir" - else - report_error "Cannot find $__dir" - return 1 - fi + local __dir=$1 + if [ -d "$__dir" ]; then + echo "Found directory $__dir" + else + report_error "Cannot find $__dir" + return 1 + fi } # check if a library can be found by ld, library names should in the # format -lname, which would then referred to libname.a or libname.so # by ld check_lib() { - local __libname="${1#-l}" - if [ $# -eq 1 ] ; then - local __package=lib"$__libname" - elif [ $# -gt 1 ] ; then - local __package=$2 - fi - # Note that LD_LIBRARY_PATH is NOT used by ld during linking - # stage, and is only used for searching to the shared libraries - # required by the executable AFTER it has already been compiled, to - # override its internal search paths built into the binary when it - # was compiled. Here, we explicitly include the commonly defined - # library search paths---including LD_LIBRARY_PATH---in the -L - # search paths of ld. This is the only way ld can include - # non-standard directories in its search path. If we use gcc - # instead of ld for linker then we can use LIBRARY_PATH, which IS - # used during link stage. However, I think using ld is more - # general, as in most systems LIBRARY_PATH is rarely defined, and - # we would have to reply on gcc. - local __search_engine="ld -o /dev/null" - local __search_paths="$LIB_PATHS" - # convert a list of paths to -L list used by ld - __search_engine="$__search_engine $(paths_to_ld $__search_paths)" - # needed the eval to interpret the quoted directories correctly (somehow) - if (eval $__search_engine -l$__libname 2>&1 | grep -q -s "\-l$__libname") ; then - # if library not found, ld will return error message - # containing the library name - report_error \ - "ld cannot find -l$__libname, please check if $__package is installed or in system search path" - return 1 - else - # if library is found, then ld will return error message about - # not able to find _start or _main symbol - echo "lib$__libname is found in ld search path" - fi + local __libname="${1#-l}" + if [ $# -eq 1 ]; then + local __package=lib"$__libname" + elif [ $# -gt 1 ]; then + local __package=$2 + fi + # Note that LD_LIBRARY_PATH is NOT used by ld during linking + # stage, and is only used for searching to the shared libraries + # required by the executable AFTER it has already been compiled, to + # override its internal search paths built into the binary when it + # was compiled. Here, we explicitly include the commonly defined + # library search paths---including LD_LIBRARY_PATH---in the -L + # search paths of ld. This is the only way ld can include + # non-standard directories in its search path. If we use gcc + # instead of ld for linker then we can use LIBRARY_PATH, which IS + # used during link stage. However, I think using ld is more + # general, as in most systems LIBRARY_PATH is rarely defined, and + # we would have to reply on gcc. + local __search_engine="ld -o /dev/null" + local __search_paths="$LIB_PATHS" + # convert a list of paths to -L list used by ld + __search_engine="$__search_engine $(paths_to_ld $__search_paths)" + # needed the eval to interpret the quoted directories correctly (somehow) + if (eval $__search_engine -l$__libname 2>&1 | grep -q -s "\-l$__libname"); then + # if library not found, ld will return error message + # containing the library name + report_error \ + "ld cannot find -l$__libname, please check if $__package is installed or in system search path" + return 1 + else + # if library is found, then ld will return error message about + # not able to find _start or _main symbol + echo "lib$__libname is found in ld search path" + fi } # check if a module is available for the current version of gfortran, # returns 0 if available and 1 if not check_gfortran_module() { - local __module_name=$1 - local __FC=${FC:-gfortran} - cat < /dev/null 2>&1 + local __module_name=$1 + local __FC=${FC:-gfortran} + cat << EOF | $__FC -c -o /dev/null -xf95 -ffree-form - > /dev/null 2>&1 PROGRAM check_gfortran_module USE ${__module_name} IMPLICIT NONE @@ -400,11 +406,11 @@ EOF # check if a flag is allowed for the current version of # gfortran. returns 0 if allowed and 1 if not check_gfortran_flag() { - local __flag=$1 - local __FC=${FC:-gfortran} - # no need to do a full compilation, just -E -cpp would do for - # checking flags - cat < /dev/null 2>&1 + local __flag=$1 + local __FC=${FC:-gfortran} + # no need to do a full compilation, just -E -cpp would do for + # checking flags + cat << EOF | $__FC -E -cpp $__flag -xf95 -ffree-form - > /dev/null 2>&1 PROGRAM test_code IMPLICIT NONE PRINT *, "PASS" @@ -415,11 +421,11 @@ EOF # check if a flag is allowed for the current version of # gcc. returns 0 if allowed and 1 if not check_gcc_flag() { - local __flag=$1 - local __CC=${CC:-gcc} - # no need to do a full compilation, just -E -cpp would do for - # checking flags - cat < /dev/null 2>&1 + local __flag=$1 + local __CC=${CC:-gcc} + # no need to do a full compilation, just -E -cpp would do for + # checking flags + cat << EOF | $__CC -E -cpp $__flag -xc - > /dev/null 2>&1 #include int main() { printf("PASS\n"); @@ -430,11 +436,11 @@ EOF # check if a flag is allowed for the current version of # g++. returns 0 if allowed and 1 if not check_gxx_flag() { - local __flag=$1 - local __CXX=${CXX:-g++} - # no need to do a full compilation, just -E -cpp would do for - # checking flags - cat < /dev/null 2>&1 + local __flag=$1 + local __CXX=${CXX:-g++} + # no need to do a full compilation, just -E -cpp would do for + # checking flags + cat << EOF | $__CXX -E -cpp $__flag -xc - > /dev/null 2>&1 #include int main() { printf("PASS\n"); @@ -445,252 +451,252 @@ EOF # given a list of flags, only print out what is allowed by the current # version of gfortran allowed_gfortran_flags() { - local __flags=$@ - local __flag='' - local __result='' - for __flag in $__flags ; do - if (check_gfortran_flag $__flag) ; then - [ -z "$__result" ] && __result="$__flag" || __result="$__result $__flag" - fi - done - echo $__result + local __flags=$@ + local __flag='' + local __result='' + for __flag in $__flags; do + if (check_gfortran_flag $__flag); then + [ -z "$__result" ] && __result="$__flag" || __result="$__result $__flag" + fi + done + echo $__result } # given a list of flags, only print out what is allowed by the current # version of gcc allowed_gcc_flags() { - local __flags=$@ - local __flag='' - local __result='' - for __flag in $__flags ; do - if (check_gcc_flag $__flag) ; then - [ -z "$__result" ] && __result="$__flag" || __result="$__result $__flag" - fi - done - echo $__result + local __flags=$@ + local __flag='' + local __result='' + for __flag in $__flags; do + if (check_gcc_flag $__flag); then + [ -z "$__result" ] && __result="$__flag" || __result="$__result $__flag" + fi + done + echo $__result } # given a list of flags, only print out what is allowed by the current # version of g++ allowed_gxx_flags() { - local __flags=$@ - local __flag='' - local __result='' - for __flag in $__flags ; do - if (check_gxx_flag $__flag) ; then - [ -z "$__result" ] && __result="$__flag" || __result="$__result $__flag" - fi - done - echo $__result + local __flags=$@ + local __flag='' + local __result='' + for __flag in $__flags; do + if (check_gxx_flag $__flag); then + [ -z "$__result" ] && __result="$__flag" || __result="$__result $__flag" + fi + done + echo $__result } # remove a directory to a given path remove_path() { - local __path_name=$1 - local __directory=$2 - local __path="$(eval echo \$$__path_name)" - # must remove all the middle ones first before treating two ends, - # otherwise there can be cases where not all __directory are - # removed. - __path=${__path//:$__directory:/:} - __path=${__path#$__directory:} - __path=${__path%:$__directory} - __path=$(echo "$__path" | sed "s:^$__directory\$::g") - eval $__path_name=\"$__path\" - export $__path_name + local __path_name=$1 + local __directory=$2 + local __path="$(eval echo \$$__path_name)" + # must remove all the middle ones first before treating two ends, + # otherwise there can be cases where not all __directory are + # removed. + __path=${__path//:$__directory:/:} + __path=${__path#$__directory:} + __path=${__path%:$__directory} + __path=$(echo "$__path" | sed "s:^$__directory\$::g") + eval $__path_name=\"$__path\" + export $__path_name } # prepend a directory to a given path prepend_path() { - # prepend directory to $path_name and then export path_name. If - # the directory already exists in path, bring the directory to the - # front of the list. - # $1 is path name - # $2 is directory - remove_path "$1" "$2" - eval $1=\"$2\${$1:+\":\$$1\"}\" - eval export $1 + # prepend directory to $path_name and then export path_name. If + # the directory already exists in path, bring the directory to the + # front of the list. + # $1 is path name + # $2 is directory + remove_path "$1" "$2" + eval $1=\"$2\${$1:+\":\$$1\"}\" + eval export $1 } # append a directory to a given path append_path() { - # append directory to $path_name and then export path_name. If - # the directory already exists in path, bring the directory to the - # back of the list. - # $1 is path name - # $2 is directory - remove_path "$1" "$2" - eval $1=\"\${$1:+\"\$$1:\"}$2\" - eval export $1 + # append directory to $path_name and then export path_name. If + # the directory already exists in path, bring the directory to the + # back of the list. + # $1 is path name + # $2 is directory + remove_path "$1" "$2" + eval $1=\"\${$1:+\"\$$1:\"}$2\" + eval export $1 } # helper routine for reading --enable=* input options read_enable() { - local __input_var="${1#*=}" - case $__input_var in - $1) - # if there is no "=" then treat as "yes" - echo "__TRUE__" - ;; - yes) - echo "__TRUE__" - ;; - no) - echo "__FALSE__" - ;; - *) - echo "__INVALID__" - ;; - esac + local __input_var="${1#*=}" + case $__input_var in + $1) + # if there is no "=" then treat as "yes" + echo "__TRUE__" + ;; + yes) + echo "__TRUE__" + ;; + no) + echo "__FALSE__" + ;; + *) + echo "__INVALID__" + ;; + esac } # helper routine for reading --with=* input options read_with() { - local __input_var="${1#--with*=}" - case $__input_var in - $1) - # if there is no "=" then treat as "install" - echo '__INSTALL__' - ;; - install) - echo '__INSTALL__' - ;; - system) - echo '__SYSTEM__' - ;; - no) - echo '__DONTUSE__' - ;; - *) - echo "${__input_var//\~/$HOME}" - ;; - esac + local __input_var="${1#--with*=}" + case $__input_var in + $1) + # if there is no "=" then treat as "install" + echo '__INSTALL__' + ;; + install) + echo '__INSTALL__' + ;; + system) + echo '__SYSTEM__' + ;; + no) + echo '__DONTUSE__' + ;; + *) + echo "${__input_var//\~/$HOME}" + ;; + esac } # helper routine to check integrity of downloaded files checksum() { - local __filename=$1 - local __sha256=$2 - local __shasum_command='sha256sum' - # check if we have sha256sum command, Mac OS X does not have - # sha256sum, but has an equivalent with shasum -a 256 - command -v "$__shasum_command" >&- 2>&- || \ - __shasum_command="shasum -a 256" - if echo "$__sha256 $__filename" | ${__shasum_command} --check ; then - echo "Checksum of $__filename Ok" - else - rm -v ${__filename} - report_error "Checksum of $__filename could not be verified, abort." - return 1 - fi + local __filename=$1 + local __sha256=$2 + local __shasum_command='sha256sum' + # check if we have sha256sum command, Mac OS X does not have + # sha256sum, but has an equivalent with shasum -a 256 + command -v "$__shasum_command" >&- 2>&- || + __shasum_command="shasum -a 256" + if echo "$__sha256 $__filename" | ${__shasum_command} --check; then + echo "Checksum of $__filename Ok" + else + rm -v ${__filename} + report_error "Checksum of $__filename could not be verified, abort." + return 1 + fi } # downloader for the package tars, excludes checksum download_pkg_no_checksum() { - # usage: download_pkg_no_checksum [-n] [-o output_filename] url - local __wget_flags='--quiet' - local __url='' - while [ $# -ge 1 ] ; do - case "$1" in - -n) - local __wget_flags="$__wget_flags --no-check-certificate" - ;; - -o) - shift - __wget_flags="$__wget_flags -O $1" - ;; - *) - __url="$1" - ;; - esac + # usage: download_pkg_no_checksum [-n] [-o output_filename] url + local __wget_flags='--quiet' + local __url='' + while [ $# -ge 1 ]; do + case "$1" in + -n) + local __wget_flags="$__wget_flags --no-check-certificate" + ;; + -o) shift - done - # download - if ! wget $__wget_flags $__url ; then - report_error "failed to download $__url" - return 1 - fi + __wget_flags="$__wget_flags -O $1" + ;; + *) + __url="$1" + ;; + esac + shift + done + # download + if ! wget $__wget_flags $__url; then + report_error "failed to download $__url" + return 1 + fi } # downloader for the package tars, includes checksum download_pkg() { - # usage: download_pkg [-n] [-o output_filename] sha256 url - local __wget_flags='--quiet' - local __filename='' - local __url='' - while [ $# -ge 2 ] ; do - case "$1" in - -n) - __wget_flags="$__wget_flags --no-check-certificate" - ;; - -o) - shift - __wget_flags="$__wget_flags -O $1" - __filename="$1" - ;; - *) - __sha256="$1" - __url="$2" - shift - ;; - esac + # usage: download_pkg [-n] [-o output_filename] sha256 url + local __wget_flags='--quiet' + local __filename='' + local __url='' + while [ $# -ge 2 ]; do + case "$1" in + -n) + __wget_flags="$__wget_flags --no-check-certificate" + ;; + -o) shift - done - if [ "$__filename" = "" ] ; then - __filename="$(basename $__url)" - fi - # download - if ! wget $__wget_flags $__url ; then - report_error "failed to download $__url" - return 1 - fi - # checksum - checksum "$__filename" "$__sha256" + __wget_flags="$__wget_flags -O $1" + __filename="$1" + ;; + *) + __sha256="$1" + __url="$2" + shift + ;; + esac + shift + done + if [ "$__filename" = "" ]; then + __filename="$(basename $__url)" + fi + # download + if ! wget $__wget_flags $__url; then + report_error "failed to download $__url" + return 1 + fi + # checksum + checksum "$__filename" "$__sha256" } # verify the checksums inside the given checksum file verify_checksums() { - local __checksum_file=$1 - local __shasum_command='sha256sum' + local __checksum_file=$1 + local __shasum_command='sha256sum' - # check if we have sha256sum command, Mac OS X does not have - # sha256sum, but has an equivalent with shasum -a 256 - command -v "$__shasum_command" >&- 2>&- || \ - __shasum_command="shasum -a 256" + # check if we have sha256sum command, Mac OS X does not have + # sha256sum, but has an equivalent with shasum -a 256 + command -v "$__shasum_command" >&- 2>&- || + __shasum_command="shasum -a 256" - ${__shasum_command} --check "${__checksum_file}" >/dev/null 2>&1 + ${__shasum_command} --check "${__checksum_file}" > /dev/null 2>&1 } # write a checksum file $1 containing checksums for each given file $2, $3, ... (plus the $VERSION_FILE) write_checksums() { - local __checksum_file=$1 - shift # remove output file from arguments to be able to pass them along properly quoted - local __shasum_command='sha256sum' + local __checksum_file=$1 + shift # remove output file from arguments to be able to pass them along properly quoted + local __shasum_command='sha256sum' - # check if we have sha256sum command, Mac OS X does not have - # sha256sum, but has an equivalent with shasum -a 256 - command -v "$__shasum_command" >&- 2>&- || \ - __shasum_command="shasum -a 256" + # check if we have sha256sum command, Mac OS X does not have + # sha256sum, but has an equivalent with shasum -a 256 + command -v "$__shasum_command" >&- 2>&- || + __shasum_command="shasum -a 256" - ${__shasum_command} "${VERSION_FILE}" "$@" >"${__checksum_file}" + ${__shasum_command} "${VERSION_FILE}" "$@" > "${__checksum_file}" } # generate a filtered toolchain.env write_toolchain_env() { - local __installdir=$1 + local __installdir=$1 - # we do not need to achieve complete filtering, it is sufficient to - # remove problematic variables (TERM/TERMCAP/COLORTERM) which may trigger - # 'too many arguments' (since the environment vars are stored in the same memory block as command line arguments) - # or which may not be valid anymore the next time the user runs the toolchain scripts, - # like the proxy vars which may affect fetching tarballs - export -p | sed \ - -e '/^\(declare -[rx]\+ \)\?\(COLORTERM\|DISPLAY\|EDITOR\|LESS\|LESSOPEN\|LOGNAME\|LS_COLORS\|PAGER\)=/d' \ - -e '/^\(declare -[rx]\+ \)\?\(TERM\|TERMCAP\|USER\)=/d' \ - -e '/^\(declare -[rx]\+ \)\?\(ftp\|http\|no\)_proxy=/d' \ - -e '/^\(declare -[rx]\+ \)\?\(GPG_AGENT_INFO\|SSH_AGENT_PID\|SSH_AUTH_SOCK\)=/d' \ - -e '/^\(declare -[rx]\+ \)\?LS_\(COLORS\|OPTIONS\)=/d' \ - -e '/^\(declare -[rx]\+ \)\?\(STY\|WINDOW\|XAUTHORITY\)=/d' \ - -e '/^\(declare -[rx]\+ \)\?XDG_/d' \ - > "${__installdir}/toolchain.env" + # we do not need to achieve complete filtering, it is sufficient to + # remove problematic variables (TERM/TERMCAP/COLORTERM) which may trigger + # 'too many arguments' (since the environment vars are stored in the same memory block as command line arguments) + # or which may not be valid anymore the next time the user runs the toolchain scripts, + # like the proxy vars which may affect fetching tarballs + export -p | sed \ + -e '/^\(declare -[rx]\+ \)\?\(COLORTERM\|DISPLAY\|EDITOR\|LESS\|LESSOPEN\|LOGNAME\|LS_COLORS\|PAGER\)=/d' \ + -e '/^\(declare -[rx]\+ \)\?\(TERM\|TERMCAP\|USER\)=/d' \ + -e '/^\(declare -[rx]\+ \)\?\(ftp\|http\|no\)_proxy=/d' \ + -e '/^\(declare -[rx]\+ \)\?\(GPG_AGENT_INFO\|SSH_AGENT_PID\|SSH_AUTH_SOCK\)=/d' \ + -e '/^\(declare -[rx]\+ \)\?LS_\(COLORS\|OPTIONS\)=/d' \ + -e '/^\(declare -[rx]\+ \)\?\(STY\|WINDOW\|XAUTHORITY\)=/d' \ + -e '/^\(declare -[rx]\+ \)\?XDG_/d' \ + > "${__installdir}/toolchain.env" }