Skip to content

Commit

Permalink
Toolchain: Make OpenMP mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
oschuett committed Jun 11, 2020
1 parent 31333cd commit 1e4446c
Show file tree
Hide file tree
Showing 16 changed files with 116 additions and 232 deletions.
4 changes: 2 additions & 2 deletions tools/toolchain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ This provides more flexibility.
## The IF_XYZ constructs

Due to the fact that `install_cp2k_toolchain.sh` needs to produce
several different versions of the arch files: `popt`, `psmp`, `pdbg`,
`sopt`, `ssmp` etc, it will have to resolve different flags for
several different versions of the arch files: `psmp`, `pdbg`,
`ssmp`, `sdbg`, etc, it will have to resolve different flags for
different arch file versions.

The solution used by this script is to use a syntax construct:
Expand Down
13 changes: 1 addition & 12 deletions tools/toolchain/install_cp2k_toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ The --enable-FEATURE options follow the rules:
this option forces the master development version
to be installed.
Default = no
--enable-omp Turn on OpenMP (threading) support.
Default = yes
--enable-cuda Turn on GPU (CUDA) support.
Default = no
--enable-cray Turn on or off support for CRAY Linux Environment
Expand Down Expand Up @@ -338,7 +336,6 @@ dry_run=__FALSE__
enable_tsan=__FALSE__
enable_gcc_master=__FALSE__
enable_libxsmm_master=__FALSE__
enable_omp=__TRUE__
if (command -v nvcc >&- 2>&-) ; then
echo "nvcc found, enabling CUDA by default"
enable_cuda=__TRUE__
Expand Down Expand Up @@ -492,13 +489,6 @@ while [ $# -ge 1 ] ; do
exit 1
fi
;;
--enable-omp*)
enable_omp=$(read_enable $1)
if [ $enable_omp = "__INVALID__" ] ; then
report_error "invalid value for --enable-omp, please use yes or no"
exit 1
fi
;;
--enable-cuda*)
enable_cuda=$(read_enable $1)
if [ $enable_cuda = "__INVALID__" ] ; then
Expand Down Expand Up @@ -636,7 +626,6 @@ done

# consolidate settings after user input
export ENABLE_TSAN=$enable_tsan
export ENABLE_OMP=$enable_omp
export ENABLE_CUDA=$enable_cuda
export ENABLE_CRAY=$enable_cray
[ "$enable_gcc_master" = "__TRUE__" ] && export gcc_ver=master
Expand Down Expand Up @@ -776,7 +765,7 @@ mkdir -p "$INSTALLDIR"
# variables used for generating cp2k ARCH file
export CP_DFLAGS=''
export CP_LIBS=''
export CP_CFLAGS='IF_OMP(-fopenmp|)'
export CP_CFLAGS='-fopenmp'
export CP_LDFLAGS="-Wl,--enable-new-dtags"

# ------------------------------------------------------------------------
Expand Down
65 changes: 27 additions & 38 deletions tools/toolchain/scripts/generate_arch_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ gen_arch_file() {
local __filename=$1
shift
local __flags=$@
local __full_flag_list="MPI OMP DEBUG CUDA WARNALL VALGRIND COVERAGE"
local __full_flag_list="MPI DEBUG CUDA WARNALL VALGRIND COVERAGE"
local __flag=''
for __flag in $__full_flag_list ; do
eval "local __${__flag}=off"
Expand All @@ -158,7 +158,7 @@ gen_arch_file() {
cat <<EOF >> $__filename
#
CXX = \${CC}
CXXFLAGS = \${CXXFLAGS} -I\\\${CUDA_PATH}/include -std=c++11 IF_OMP(-fopenmp|)
CXXFLAGS = \${CXXFLAGS} -I\\\${CUDA_PATH}/include -std=c++11 -fopenmp
GPUVER = \${GPUVER}
NVCC = \${NVCC}
NVFLAGS = \${NVFLAGS}
Expand Down Expand Up @@ -187,48 +187,37 @@ EOF

rm -f ${INSTALLDIR}/arch/local*
# normal production arch files
{ gen_arch_file "local.sopt" ; arch_vers="sopt"; }
{ gen_arch_file "local.sdbg" OMP DEBUG; arch_vers="${arch_vers} sdbg"; }
[ "$ENABLE_OMP" = __TRUE__ ] && \
{ gen_arch_file "local.ssmp" OMP; arch_vers="${arch_vers} ssmp"; }
[ "$MPI_MODE" != no ] && \
{ gen_arch_file "local.popt" MPI; arch_vers="${arch_vers} popt"; }
[ "$MPI_MODE" != no ] && \
{ gen_arch_file "local.pdbg" MPI OMP DEBUG; arch_vers="${arch_vers} pdbg"; }
[ "$MPI_MODE" != no ] && \
[ "$ENABLE_OMP" = __TRUE__ ] && \
{ gen_arch_file "local.psmp" MPI OMP; arch_vers="${arch_vers} psmp"; }
[ "$MPI_MODE" != no ] && \
[ "$ENABLE_OMP" = __TRUE__ ] && \
gen_arch_file "local_warn.psmp" MPI OMP WARNALL
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"
fi

# cuda enabled arch files
if [ "$ENABLE_CUDA" = __TRUE__ ] ; then
[ "$ENABLE_OMP" = __TRUE__ ] && \
gen_arch_file "local_cuda.ssmp" CUDA OMP
[ "$MPI_MODE" != no ] && \
[ "$ENABLE_OMP" = __TRUE__ ] && \
gen_arch_file "local_cuda.psmp" CUDA OMP MPI
[ "$ENABLE_OMP" = __TRUE__ ] && \
gen_arch_file "local_cuda.sdbg" CUDA DEBUG OMP
[ "$MPI_MODE" != no ] && \
[ "$ENABLE_OMP" = __TRUE__ ] && \
gen_arch_file "local_cuda.pdbg" CUDA DEBUG OMP MPI
[ "$MPI_MODE" != no ] && \
[ "$ENABLE_OMP" = __TRUE__ ] && \
gen_arch_file "local_cuda_warn.psmp" CUDA MPI OMP WARNALL
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.sopt" VALGRIND OMP
[ "$MPI_MODE" != no ] && \
gen_arch_file "local_valgrind.popt" VALGRIND OMP MPI
gen_arch_file "local_valgrind.ssmp" VALGRIND
if [ "$MPI_MODE" != no ] ; then
gen_arch_file "local_valgrind.psmp" VALGRIND MPI
fi
fi
# coverage enabled arch files
gen_arch_file "local_coverage.sdbg" COVERAGE OMP
[ "$MPI_MODE" != no ] && \
gen_arch_file "local_coverage.pdbg" COVERAGE OMP MPI
[ "$ENABLE_CUDA" = __TRUE__ ] && \
gen_arch_file "local_coverage_cuda.pdbg" COVERAGE OMP MPI CUDA

cd "${ROOTDIR}"

Expand Down
4 changes: 2 additions & 2 deletions tools/toolchain/scripts/install_cosma.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,15 @@ EOF
export COSMA_CFLAGS="${COSMA_CFLAGS}"
export COSMA_LDFLAGS="${COSMA_LDFLAGS}"
export COSMA_CUDA_LDFLAGS="${COSMA_CUDA_LDFLAGS}"
export CP_DFLAGS="\${CP_DFLAGS} IF_MPI(IF_OMP(-D__COSMA|)|)"
export CP_DFLAGS="\${CP_DFLAGS} IF_MPI(-D__COSMA|)"
export CP_CFLAGS="\${CP_CFLAGS} ${COSMA_CFLAGS}"
export CP_LDFLAGS="\${CP_LDFLAGS} IF_CUDA(${COSMA_CUDA_LDFLAGS}|${COSMA_LDFLAGS})"
export COSMA_LIBS="${COSMA_LIBS}"
export COSMA_ROOT="$pkg_install_dir"
export COSMA_INCLUDE_DIR="$pkg_install_dir/include"
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:${COSMA_LIBDIR}/pkgconfig"
export COSMA_VERSION=${cosma_ver}
export CP_LIBS="IF_MPI(IF_OMP(${COSMA_LIBS}|)|) \${CP_LIBS}"
export CP_LIBS="IF_MPI(${COSMA_LIBS}|) \${CP_LIBS}"
EOF
cat "${BUILDDIR}/setup_cosma" >> $SETUPFILE
fi
Expand Down
88 changes: 16 additions & 72 deletions tools/toolchain/scripts/install_elpa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ source "${INSTALLDIR}"/toolchain.env
ELPA_CFLAGS=''
ELPA_LDFLAGS=''
ELPA_LIBS=''
ELPA_CFLAGS_OMP=''
ELPA_LIBS_OMP=''
# ELPA 2019.05.001 has a parallel build issue, restricting to -j1
ELPA_MAKEOPTS='-j1'

Expand Down Expand Up @@ -88,11 +86,10 @@ case "$with_elpa" in
SSE4_flag=""
config_flags="--disable-avx --disable-avx2 --disable-sse --disable-sse-assembly"
fi
# non-threaded version
mkdir -p obj_no_thread; cd obj_no_thread
mkdir -p build; cd build
../configure --prefix="${pkg_install_dir}" \
--libdir="${pkg_install_dir}/lib" \
--enable-openmp=no \
--enable-openmp=yes \
--enable-shared=no \
--enable-static=yes \
${config_flags} \
Expand All @@ -105,65 +102,28 @@ case "$with_elpa" in
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} $(resolve_string "${MATH_LIBS}")" \
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 ..
# threaded version
if [ "$ENABLE_OMP" = "__TRUE__" ] ; then
mkdir -p obj_thread; cd obj_thread
../configure --prefix="${pkg_install_dir}" \
--libdir="${pkg_install_dir}/lib" \
--enable-openmp=yes \
--enable-shared=no \
--enable-static=yes \
${config_flags} \
--enable-gpu=${has_GPU} \
--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} $(resolve_string "${MATH_LIBS}" OMP)" \
>configure.log 2>&1
make -j $NPROCS ${ELPA_MAKEOPTS} >make.log 2>&1
make install >install.log 2>&1
cd ..
fi
cd ..
make install >install.log 2>&1
cd ../../
write_checksums "${install_lock_file}" "${SCRIPT_DIR}/$(basename ${SCRIPT_NAME})"
fi
ELPA_CFLAGS="-I'${pkg_install_dir}/include/elpa-${elpa_ver}/modules' -I'${pkg_install_dir}/include/elpa-${elpa_ver}/elpa'"
ELPA_CFLAGS_OMP="-I'${pkg_install_dir}/include/elpa_openmp-${elpa_ver}/modules' -I'${pkg_install_dir}/include/elpa_openmp-${elpa_ver}/elpa'"
ELPA_CFLAGS="-I'${pkg_install_dir}/include/elpa_openmp-${elpa_ver}/modules' -I'${pkg_install_dir}/include/elpa_openmp-${elpa_ver}/elpa'"
ELPA_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'"
;;
__SYSTEM__)
echo "==================== Finding ELPA from system paths ===================="
check_lib -lelpa "ELPA"
[ "$ENABLE_OMP" = "__TRUE__" ] && check_lib -lelpa_openmp "ELPA threaded version"
check_lib -lelpa_openmp "ELPA"
# get the include paths
elpa_include="$(find_in_paths "elpa-*" $INCLUDE_PATHS)"
elpa_include="$(find_in_paths "elpa_openmp-*" $INCLUDE_PATHS)"
if [ "$elpa_include" != "__FALSE__" ] ; then
echo "ELPA include directory is found to be $elpa_include"
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-* from paths $INCLUDE_PATHS"
echo "Cannot find elpa_openmp-${elpa_ver} from paths $INCLUDE_PATHS"
exit 1
fi
if [ "$ENABLE_OMP" = "__TRUE__" ] ; then
elpa_include_omp="$(find_in_paths "elpa_openmp-*" $INCLUDE_PATHS)"
if [ "$elpa_include_omp" != "__FALSE__" ] ; then
echo "ELPA include directory threaded version is found to be $elpa_include_omp"
ELPA_CFLAGS_OMP="-I'$elpa_include_omp/modules' -I'$elpa_include_omp/elpa'"
else
echo "Cannot find elpa_openmp-${elpa_ver} from paths $INCLUDE_PATHS"
exit 1
fi
fi
# get the lib paths
add_lib_from_paths ELPA_LDFLAGS "libelpa.*" $LIB_PATHS
;;
Expand All @@ -175,35 +135,22 @@ case "$with_elpa" in
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-*" user_include_path)"
elpa_include="$(find_in_paths "elpa_openmp-*" user_include_path)"
if [ "$elpa_include" != "__FALSE__" ] ; then
echo "ELPA include directory is found to be $elpa_include/modules"
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-* from path $user_include_path"
echo "Cannot find elpa_openmp-* from path $user_include_path"
exit 1
fi
if [ "$ENABLE_OMP" = "__TRUE__" ] ; then
elpa_include_omp="$(find_in_paths "elpa_openmp-*" user_include_path)"
if [ "$elpa_include_omp" != "__FALSE__" ] ; then
echo "ELPA include directory threaded version is found to be $elpa_include_omp/modules"
check_dir "$elpa_include_omp/modules"
ELPA_CFLAGS_OMP="-I'$elpa_include_omp/modules' -I'$elpa_include_omp/elpa'"
else
echo "Cannot find elpa_openmp-* from path $user_include_path"
exit 1
fi
fi
ELPA_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'"
;;
esac
if [ "$with_elpa" != "__DONTUSE__" ] ; then
ELPA_LIBS="-lelpa"
ELPA_LIBS_OMP="-lelpa_openmp"
ELPA_LIBS="-lelpa_openmp"
cat <<EOF > "${BUILDDIR}/setup_elpa"
prepend_path CPATH "$elpa_include"
prepend_path CPATH "$elpa_include_omp"
EOF
if [ "$with_elpa" != "__SYSTEM__" ] ; then
cat <<EOF >> "${BUILDDIR}/setup_elpa"
Expand All @@ -219,13 +166,10 @@ EOF
export ELPA_CFLAGS="${ELPA_CFLAGS}"
export ELPA_LDFLAGS="${ELPA_LDFLAGS}"
export ELPA_LIBS="${ELPA_LIBS}"
export ELPA_CFLAGS_OMP="${ELPA_CFLAGS_OMP}"
export ELPA_LDFLAGS_OMP="${ELPA_LDFLAGS_OMP}"
export ELPA_LIBS_OMP="${ELPA_LIBS_OMP}"
export CP_DFLAGS="\${CP_DFLAGS} IF_MPI(-D__ELPA|)"
export CP_CFLAGS="\${CP_CFLAGS} IF_MPI(IF_OMP(${ELPA_CFLAGS_OMP}|${ELPA_CFLAGS})|)"
export CP_CFLAGS="\${CP_CFLAGS} IF_MPI(${ELPA_CFLAGS}|)"
export CP_LDFLAGS="\${CP_LDFLAGS} IF_MPI(${ELPA_LDFLAGS}|)"
export CP_LIBS="IF_MPI(IF_OMP(${ELPA_LIBS_OMP}|${ELPA_LIBS})|) \${CP_LIBS}"
export CP_LIBS="IF_MPI(${ELPA_LIBS}|) \${CP_LIBS}"
prepend_path PKG_CONFIG_PATH "$pkg_install_dir/lib/pkgconfig"
export ELPAROOT="$pkg_install_dir"
export ELPAVERSION="${elpa_ver}"
Expand Down
9 changes: 3 additions & 6 deletions tools/toolchain/scripts/install_fftw.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ source "${INSTALLDIR}"/toolchain.env
FFTW_CFLAGS=''
FFTW_LDFLAGS=''
FFTW_LIBS=''
FFTW_LIBS_OMP=''
! [ -d "${BUILDDIR}" ] && mkdir -p "${BUILDDIR}"
cd "${BUILDDIR}"

Expand Down Expand Up @@ -60,7 +59,7 @@ case "$with_fftw" in
__SYSTEM__)
echo "==================== Finding FFTW from system paths ===================="
check_lib -lfftw3 "FFTW"
[ $ENABLE_OMP = "__TRUE__" ] && check_lib -lfftw3_omp "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
Expand All @@ -77,8 +76,7 @@ case "$with_fftw" in
;;
esac
if [ "$with_fftw" != "__DONTUSE__" ] ; then
FFTW_LIBS="-lfftw3"
FFTW_LIBS_OMP="-lfftw3_omp"
FFTW_LIBS="-lfftw3 -lfftw3_omp"
if [ "$with_fftw" != "__SYSTEM__" ] ; then
cat <<EOF > "${BUILDDIR}/setup_fftw"
prepend_path LD_LIBRARY_PATH "$pkg_install_dir/lib"
Expand All @@ -92,11 +90,10 @@ EOF
export FFTW_CFLAGS="${FFTW_CFLAGS}"
export FFTW_LDFLAGS="${FFTW_LDFLAGS}"
export FFTW_LIBS="${FFTW_LIBS}"
export FFTW_LIBS_OMP="${FFTW_LIBS_OMP}"
export CP_DFLAGS="\${CP_DFLAGS} -D__FFTW3 IF_COVERAGE(IF_MPI(|-U__FFTW3)|)"
export CP_CFLAGS="\${CP_CFLAGS} ${FFTW_CFLAGS}"
export CP_LDFLAGS="\${CP_LDFLAGS} ${FFTW_LDFLAGS}"
export CP_LIBS="IF_MPI(-lfftw3_mpi|) ${FFTW_LIBS} IF_OMP(${FFTW_LIBS_OMP}|) \${CP_LIBS}"
export CP_LIBS="IF_MPI(-lfftw3_mpi|) ${FFTW_LIBS} \${CP_LIBS}"
prepend_path PKG_CONFIG_PATH "$pkg_install_dir/lib/pkgconfig"
export FFTW_ROOT="$pkg_install_dir"
EOF
Expand Down
6 changes: 3 additions & 3 deletions tools/toolchain/scripts/install_gsl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ EOF
cat << EOF >> "${BUILDDIR}/setup_gsl"
export GSL_CFLAGS="${GSL_CFLAGS}"
export GSL_LDFLAGS="${GSL_LDFLAGS}"
export CP_DFLAGS="\${CP_DFLAGS} IF_MPI(IF_OMP(-D__GSL|)|)"
export CP_DFLAGS="\${CP_DFLAGS} IF_MPI(-D__GSL|)"
export CP_CFLAGS="\${CP_CFLAGS} ${GSL_CFLAGS}"
export CP_LDFLAGS="\${CP_LDFLAGS} ${GSL_LDFLAGS}"
export GSL_LIBRARY="-lgsl"
Expand All @@ -93,12 +93,12 @@ export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$pkg_install_dir/lib64/pkgconfig:$pkg_i
##########################################################
#
# I only include the library when SIRIUS is activated
# which depends explicitly on MPI and OMP
# which depends explicitly on MPI
#
##########################################################
export CP_LIBS="IF_MPI(IF_OMP(${GSL_LIBS}|)|) \${CP_LIBS}"
export CP_LIBS="IF_MPI(${GSL_LIBS}|) \${CP_LIBS}"
EOF
cat "${BUILDDIR}/setup_gsl" >> $SETUPFILE
fi
Expand Down

0 comments on commit 1e4446c

Please sign in to comment.