Skip to content

Commit

Permalink
Implement tools/toolchain/scripts/install_intelmpi.sh
Browse files Browse the repository at this point in the history
Support `--mpi-mode=intelmpi` and `--with-intelmpi`
  • Loading branch information
e-kwsm authored and oschuett committed Apr 12, 2020
1 parent d3bb141 commit f721000
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 9 deletions.
2 changes: 2 additions & 0 deletions tools/toolchain/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ RUN ./scripts/install_valgrind.sh && rm -rf ./build

COPY ./scripts/install_mpich.sh \
./scripts/install_openmpi.sh \
./scripts/install_intelmpi.sh \
./scripts/
RUN ./scripts/install_openmpi.sh && \
./scripts/install_mpich.sh && \
./scripts/install_intelmpi.sh && \
rm -rf ./build

COPY ./scripts/install_reflapack.sh \
Expand Down
49 changes: 40 additions & 9 deletions tools/toolchain/install_cp2k_toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ OPTIONS:
--with-PKG option placed AFTER this option on the
command line.
--mpi-mode Selects which MPI flavour to use. Available options
are: mpich, openmpi and no. By selecting no, you will
be disabling MPI support. By default the script
are: mpich, openmpi, intelmpi, and no. By selecting no,
you will be disabling MPI support. By default the script
will try to determine the flavour based on the MPI library
currently available in your system path. For CRAY (CLE)
systems, the default flavour is mpich. Note that explicitly
setting --with-mpich or --with-openmpi options to values
other than no will also switch --mpi-mode to the respective
mode.
setting --with-mpich, --with-openmpi or --with-intelmpi
options to values other than no will also switch --mpi-mode
to the respective mode.
--math-mode Selects which core math library to use. Available options
are: acml, cray, mkl, openblas and reflapack. cray
corresponds to cray libsci, and is the default for CRAY
Expand Down Expand Up @@ -153,7 +153,10 @@ The --with-PKG options follow the rules:
of CP2K.
Default = system
--with-mpich MPICH, MPI library like OpenMPI. one should
only use EITHER OpenMPI or MPICH and not both.
use only one of OpenMPI, MPICH or Intel MPI.
Default = system
--with-intelmpi Intel MPI, MPI library like OpenMPI. one should
use only one of OpenMPI, MPICH or Intel MPI.
Default = system
--with-libxc libxc, exchange-correlation library. Needed for
QuickStep DFT and hybrid calculations.
Expand Down Expand Up @@ -254,7 +257,7 @@ EOF
# is important, the first in the list gets installed first
# ------------------------------------------------------------------------
tool_list="gcc cmake valgrind"
mpi_list="mpich openmpi"
mpi_list="mpich openmpi intelmpi"
math_list="mkl acml openblas reflapack"
lib_list="fftw libint libxc libsmm libxsmm cosma scalapack elpa plumed \
spfft ptscotch superlu pexsi quip gsl spglib hdf5 libvdwxc sirius"
Expand Down Expand Up @@ -305,14 +308,19 @@ with_cosma=__INSTALL__
# for MPI, we try to detect system MPI variant
with_openmpi=__SYSTEM__
with_mpich=__SYSTEM__
with_intelmpi=__SYSTEM__
if (command -v mpirun >&- 2>&-) ; then
# check if we are dealing with openmpi or mpich
# 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
Expand Down Expand Up @@ -352,6 +360,7 @@ if [ "$CRAY_LD_LIBRARY_PATH" ] ; then
# 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__"
Expand Down Expand Up @@ -391,12 +400,15 @@ while [ $# -ge 1 ] ; do
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 and no as options"
"--mpi-mode currently only supports openmpi, mpich, intelmpi and no as options"
exit 1
;;
esac
Expand Down Expand Up @@ -522,6 +534,12 @@ while [ $# -ge 1 ] ; do
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)
;;
Expand Down Expand Up @@ -680,6 +698,7 @@ else
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

Expand Down Expand Up @@ -826,6 +845,17 @@ if [ "$ENABLE_CRAY" = "__TRUE__" ] ; then
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
Expand Down Expand Up @@ -899,6 +929,7 @@ else
./scripts/install_valgrind.sh
./scripts/install_mpich.sh
./scripts/install_openmpi.sh
./scripts/install_intelmpi.sh
./scripts/install_mathlibs.sh
./scripts/install_fftw.sh
./scripts/install_spfft.sh
Expand Down
83 changes: 83 additions & 0 deletions tools/toolchain/scripts/install_intelmpi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/bash -e
[ "${BASH_SOURCE[0]}" ] && SCRIPT_NAME="${BASH_SOURCE[0]}" || SCRIPT_NAME=$0
SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_NAME")" && pwd -P)"

source "${SCRIPT_DIR}"/common_vars.sh
source "${SCRIPT_DIR}"/tool_kit.sh
source "${SCRIPT_DIR}"/signal_trap.sh
source "${INSTALLDIR}"/toolchain.conf
source "${INSTALLDIR}"/toolchain.env

[ ${MPI_MODE} != "intelmpi" ] && exit 0
rm -f "${BUILDDIR}/setup_intelmpi"

INTELMPI_CFLAGS=''
INTELMPI_LDFLAGS=''
INTELMPI_LIBS=''
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'"
;;
esac
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 <<EOF >> "${BUILDDIR}/setup_intelmpi"
export MPI_MODE="${MPI_MODE}"
export INTELMPI_CFLAGS="${INTELMPI_CFLAGS}"
export INTELMPI_LDFLAGS="${INTELMPI_LDFLAGS}"
export INTELMPI_LIBS="${INTELMPI_LIBS}"
export MPI_CFLAGS="${INTELMPI_CFLAGS}"
export MPI_LDFLAGS="${INTELMPI_LDFLAGS}"
export MPI_LIBS="${INTELMPI_LIBS}"
export CP_DFLAGS="\${CP_DFLAGS} IF_MPI(-D__parallel ${mpi2_dflags}|)"
export CP_CFLAGS="\${CP_CFLAGS} IF_MPI(${INTELMPI_CFLAGS}|)"
export CP_LDFLAGS="\${CP_LDFLAGS} IF_MPI(${INTELMPI_LDFLAGS}|)"
export CP_LIBS="\${CP_LIBS} IF_MPI(${INTELMPI_LIBS}|)"
EOF
fi

# update toolchain environment
load "${BUILDDIR}/setup_intelmpi"
export -p > "${INSTALLDIR}/toolchain.env"

cd "${ROOTDIR}"
report_timing "intelmpi"

0 comments on commit f721000

Please sign in to comment.