現在地

CP2K 7.1.0 (gnu)

ウェブページ

https://www.cp2k.org/

バージョン

7.1.0

ビルド環境

  • OpenMPI 4.0.2 (GCC 7.3 version)
  • GCC 7.3.1 (devtoolset-7)
  • cmake 3.16.3

ビルドに必要なファイル

  • cp2k-7.1.0.tar.gz
  • dbcsr-2.0.1.tar.gz
  • tc_install_cp2k_toolchain.sh.diff

--- install_cp2k_toolchain.sh.org       2020-01-31 17:07:19.000000000 +0900
+++ install_cp2k_toolchain.sh   2020-01-31 17:07:30.000000000 +0900
@@ -942,8 +942,8 @@
     ./scripts/install_superlu.sh
     ./scripts/install_pexsi.sh
     ./scripts/install_quip.sh
-    ./scripts/install_plumed.sh
     ./scripts/install_gsl.sh
+    ./scripts/install_plumed.sh
     ./scripts/install_spglib.sh
     ./scripts/install_hdf5.sh
     ./scripts/install_libvdwxc.sh

  • tc_install_sirius.sh.diff

--- install_sirius.sh.org       2020-02-25 14:50:50.000000000 +0900
+++ install_sirius.sh   2020-02-25 14:48:01.000000000 +0900
@@ -131,8 +131,8 @@
                    -DSpFFT_DIR="${SPFFT_ROOT}/lib/cmake/SpFFT" \
                    -DCMAKE_CXXFLAGS_RELEASE="${SIRIUS_OPT}" \
                    -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="${SIRIUS_DBG}" \
-                   -DCMAKE_CXX_COMPILER=mpic++ \
-                   -DCMAKE_C_COMPILER=mpicc \
+                   -DCMAKE_CXX_COMPILER=${MPICXX} \
+                   -DCMAKE_C_COMPILER=${MPICC} \
                   ${COMPILATION_OPTIONS} .. > compile.log 2>&1
              make -j $NPROCS -C src >> compile.log 2>&1
 
@@ -155,8 +155,8 @@
                       -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="${SIRIUS_DBG}" \
                       -DUSE_CUDA=ON \
                       -DGPU_MODEL=P100 \
-                      -DCMAKE_CXX_COMPILER=mpic++ \
-                      -DCMAKE_C_COMPILER=mpicc ${COMPILATION_OPTIONS} .. >> compile.log 2>&1
+                      -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

  • tc_install_plumed_noext.sh.diff

--- install_plumed.sh.org       2020-02-19 13:43:07.000000000 +0900
+++ install_plumed.sh   2020-02-19 13:42:49.000000000 +0900
@@ -40,7 +40,7 @@
 
             echo "Installing from scratch into ${pkg_install_dir}"
             cd plumed-${plumed_ver}
-            ./configure CXX="${MPICXX}" --prefix=${pkg_install_dir} --libdir="${pkg_install_dir}/lib" > configure.log 2>&1
+            ./configure CXX="${MPICXX}" --prefix=${pkg_install_dir} --libdir="${pkg_install_dir}/lib" CXXFLAGS="-I${GSLROOT}/include" LIBS="-L${GSLROOT}/lib" --enable-external-lapack=no --enable-external-blas=no > configure.log 2>&1
             make -j $NPROCS > make.log 2>&1
             make install > install.log 2>&1
             write_checksums "${install_lock_file}" "${SCRIPT_DIR}/$(basename ${SCRIPT_NAME})"
@@ -63,7 +63,7 @@
 esac
 
 if [ "$with_plumed" != "__DONTUSE__" ] ; then
-    PLUMED_LIBS='-lplumed -ldl -lstdc++ -lz -ldl'
+    PLUMED_LIBS='-lplumedKernel -lplumed -ldl -lstdc++ -lz -ldl'
     if [ "$with_plumed" != "__SYSTEM__" ] ; then
         cat <<EOF > "${BUILDDIR}/setup_plumed"
 prepend_path LD_LIBRARY_PATH "$pkg_install_dir/lib"

ビルド手順

#!/bin/sh

INSTDIR=/local/apl/lx/cp2k710-gnu

VERSION=7.1.0
DBCSR_VERSION=2.0.1

SOURCE_ROOT=/home/users/${USER}/Software/CP2K/${VERSION}

TARBALL=${SOURCE_ROOT}/cp2k-${VERSION}.tar.gz
TARBALL_DBCSR=${SOURCE_ROOT}/dbcsr-${DBCSR_VERSION}.tar.gz

TC_PATCH0=${SOURCE_ROOT}/tc_install_cp2k_toolchain.sh.diff
TC_PATCH5=${SOURCE_ROOT}/tc_install_sirius.sh.diff
TC_PATCH9=${SOURCE_ROOT}/tc_install_plumed_noext.sh.diff

PARALLEL=12

#---------------------------------------------------------------------------
umask 0022
export LANG=C
export LC_ALL=C

module purge
module load scl/devtoolset-7
module load mpi/openmpi/4.0.2/gnu7.3
module load cmake/3.16.3

cd $INSTDIR
if [ -d cp2k-${VERSION} ]; then
  mv cp2k-${VERSION} cp2k-erase
  rm -rf cp2k-erase &
fi
tar zxf ${TARBALL}
sleep 5
mv cp2k-${VERSION}/* .
sleep 5
rm -f cp2k-${VERSION}/.dockerignore
rmdir cp2k-${VERSION}

cd ${INSTDIR}/tools/toolchain
patch < ${TC_PATCH0}

cd scripts
patch < ${TC_PATCH5}
patch < ${TC_PATCH9}
cd ../

export MPICC=mpicc
export MPICXX=mpicxx
export MPIFC=mpif90

./install_cp2k_toolchain.sh --math-mode=openblas \
                            --mpi-mode=openmpi \
                            --with-cmake=system \
                            --with-mpich=no \
                            --with-libxc=install \
                            --with-libint=install \
                            --with-fftw=install \
                            --with-openblas=install \
                            --with-scalapack=install \
                            --with-reflapack=no \
                            --with-mkl=no \
                            --with-libxsmm=install \
                            --with-elpa=install \
                            --with-ptscotch=install \
                            --with-pexsi=install \
                            --with-parmetis=install \
                            --with-superlu=install \
                            --with-quip=install \
                            --with-plumed=install \
                            --with-gsl=install \
                            --with-libvdwxc=install \
                            --with-spglib=install \
                            --with-hdf5=install \
                            --with-spfft=install \
                            -j ${PARALLEL}

cp install/arch/local.psmp ../../arch/rccs.psmp

cd ${INSTDIR}/exts
rmdir dbcsr
tar zxf ${TARBALL_DBCSR}
mv dbcsr-${DBCSR_VERSION} dbcsr
cd ../
make -j ${PARALLEL} ARCH=rccs VERSION=psmp

テスト

以下のスクリプトを ccfep 上で実行しています。

#!/bin/sh

export LC_ALL=C
export LANG=""

# gcc8
module purge
module load scl/devtoolset-7
module load mpi/openmpi/4.0.2/gnu7.3
module load cmake/3.16.3
#CP2K=/home/users/qf7/Software/CP2K/7.1.0/cp2k-7.1.0-gcc7-openmpi4-openblas
CP2K=/local/apl/lx/cp2k710-gnu

CP2K_ARCH=rccs
CP2K_VER=psmp
TIMEOUT=120
PARALLEL=16

ulimit -s unlimited
cd ${CP2K}/regtesting/${CP2K_ARCH}/${CP2K_VER}
rm -rf LAST-${CP2K_ARCH}-${CP2K_VER}

# serial test
../../../tools/regtesting/do_regtest \
        -nobuild \
        -nosvn \
        -arch ${CP2K_ARCH} \
        -version ${CP2K_VER} \
        -mpiranks 1 \
        -ompthreads 1 \
        -jobmaxtime ${TIMEOUT} \
        -cp2kdir ../../../ \
        -maxtasks ${PARALLEL} >& regtest_mpi1_omp1.log
rm -rf LAST-${CP2K_ARCH}-${CP2K_VER}

# omp test
../../../tools/regtesting/do_regtest \
        -nobuild \
        -nosvn \
        -arch ${CP2K_ARCH} \
        -version ${CP2K_VER} \
        -mpiranks 1 \
        -ompthreads 2 \
        -jobmaxtime ${TIMEOUT} \
        -cp2kdir ../../../ \
        -maxtasks ${PARALLEL} >& regtest_mpi1_omp2.log
rm -rf LAST-${CP2K_ARCH}-${CP2K_VER}

# mpi test
../../../tools/regtesting/do_regtest \
        -nobuild \
        -nosvn \
        -arch ${CP2K_ARCH} \
        -version ${CP2K_VER} \
        -mpiranks 2 \
        -ompthreads 1 \
        -jobmaxtime ${TIMEOUT} \
        -cp2kdir ../../../ \
        -maxtasks ${PARALLEL} >& regtest_mpi2_omp1.log
rm -rf LAST-${CP2K_ARCH}-${CP2K_VER}

# mpi/openmp test
../../../tools/regtesting/do_regtest \
        -nobuild \
        -nosvn \
        -arch ${CP2K_ARCH} \
        -version ${CP2K_VER} \
        -mpiranks 2 \
        -ompthreads 2 \
        -jobmaxtime ${TIMEOUT} \
        -cp2kdir ../../../ \
        -maxtasks ${PARALLEL} >& regtest_mpi2_omp2.log
rm -rf LAST-${CP2K_ARCH}-${CP2K_VER}

# yet another mpi test
../../../tools/regtesting/do_regtest \
        -nobuild \
        -nosvn \
        -arch ${CP2K_ARCH} \
        -version ${CP2K_VER} \
        -mpiranks 8 \
        -ompthreads 1 \
        -jobmaxtime ${TIMEOUT} \
        -cp2kdir ../../../ \
        -maxtasks ${PARALLEL} >& regtest_mpi8_omp1.log
rm -rf LAST-${CP2K_ARCH}-${CP2K_VER}

# yet another mpi/openmp test
../../../tools/regtesting/do_regtest \
        -nobuild \
        -nosvn \
        -arch ${CP2K_ARCH} \
        -version ${CP2K_VER} \
        -mpiranks 8 \
        -ompthreads 2 \
        -jobmaxtime ${TIMEOUT} \
        -cp2kdir ../../../ \
        -maxtasks ${PARALLEL} >& regtest_mpi8_omp2.log
rm -rf LAST-${CP2K_ARCH}-${CP2K_VER}

テスト結果: MPI1 - OMP1

--------------------------------- Summary --------------------------------
Number of FAILED  tests 1
Number of WRONG   tests 0
Number of CORRECT tests 3217
Number of NEW     tests 3
Total number of   tests 3221

  • QS/regtest-almo-2/ion-pair.inp: RUNTIME FAIL

テスト結果: MPI1 - OMP2

--------------------------------- Summary --------------------------------
Number of FAILED  tests 1
Number of WRONG   tests 1
Number of CORRECT tests 3216
Number of NEW     tests 3
Total number of   tests 3221

  • QS/regtest-almo-2/ion-pair.inp: RUNTIME FAIL
  • SE/regtest/h2o_gks_e.inp: WRONG

テスト結果: MPI2 - OMP1

--------------------------------- Summary --------------------------------
Number of FAILED  tests 0
Number of WRONG   tests 0
Number of CORRECT tests 3278
Number of NEW     tests 8
Total number of   tests 3286

テスト結果: MPI2 - OMP2

--------------------------------- Summary --------------------------------
Number of FAILED  tests 0
Number of WRONG   tests 0
Number of CORRECT tests 3278
Number of NEW     tests 8
Total number of   tests 3286

テスト結果: MPI8 - OMP1

--------------------------------- Summary --------------------------------
Number of FAILED  tests 0
Number of WRONG   tests 9
Number of CORRECT tests 3228
Number of NEW     tests 6
Total number of   tests 3243

  • QS/regtest-mp2-lr/H2O-mp2-gpw-lr.inp: WRONG
  • xTB/regtest-2/HF-field-gopt.inp: WRONG
  • QS/regtest-mp2-grad/H2O_grad_mme.inp: WRONG
  • QS/regtest-gpw-4/H2O-debug-5.inp: WRONG
  • QS/regtest-gpw-4/H2O-debug-6.inp: WRONG
  • QS/regtest-mp2-4/H2O_NO_HFX.inp: WRONG
  • QS/regtest-rma-3D/H2O-32-dftb-ls-2_mult.inp: WRONG
  • QS/regtest-rma-3D/H2O-32-dftb-ls-2.inp: WRONG
  • QS/regtest-mp2-2/H2O-02.inp: WRONG

テスト結果: MPI8 - OMP2

--------------------------------- Summary --------------------------------
Number of FAILED  tests 0
Number of WRONG   tests 9
Number of CORRECT tests 3228
Number of NEW     tests 6
Total number of   tests 3243

  • QS/regtest-mp2-lr/H2O-mp2-gpw-lr.inp: WRONG
  • xTB/regtest-2/HF-field-gopt.inp: WRONG
  • QS/regtest-mp2-grad/H2O_grad_mme.inp: WRONG
  • QS/regtest-gpw-4/H2O-debug-5.inp: WRONG
  • QS/regtest-gpw-4/H2O-debug-6.inp: WRONG
  • QS/regtest-mp2-4/H2O_NO_HFX.inp: WRONG
  • QS/regtest-rma-3D/H2O-32-dftb-ls-2_mult.inp: WRONG
  • QS/regtest-rma-3D/H2O-32-dftb-ls-2.inp: WRONG
  • QS/regtest-mp2-2/H2O-02.inp: WRONG

ベンチマーク

6.1.0 と同じように H2O-64.inp を利用。(時間は grep "CP2K  " *.log で表示される値から)
21 回実行し、最初の 1 回を除いた平均値。(初回は速度が安定しないため)

jobtype 総コア数
(ノード数)
MPI OMP GPU elapse(sec)
core 18 (1) 18 1 - 72.685
small 40 (1) 40 1 - 51.424
small 80 (2) 80 1 - 36.697
small 160 (4) 32 5 - 27.455

雑多な情報

  • GPU 版はあまり意味が無いようなので今回ははじめから除外。
    • SIRIUS の GPU 版については MAGMA 等まで対応させれば速度が出るのかもしれませんが、今回は回避しています。
  • libgrid を使うとむしろ遅くなったため、使用せず。
    • pyratemp 0.3.2 で試行。そのままビルドすると xyz_to_vab 内の *.template ファイルを正しく処理できておらず、失敗する。
    • sed -i -e "s/\\$/\!/g" -e "s/\@</\@\!/g" -e "s/>\@/\!\@/g" であらかじめ *.template ファイルを処理することで一応動作は確認。速度面ではメリット無し。
      • (スクリプト中で実行する場合は sed -i -e "s/\\\$/\!/g" -e "s/\@</\@\!/g" -e "s/>\@/\!\@/g" )
  • libsmm については今回も未検証
  • dbcsr を指示通りに git で持ってくると master ブランチのものを使うことになる。タイミングによってはダメなことが起こるので、リリース版を使っている。
  • MKL を使うとはっきりと遅くなるため、OpenBlas を利用。
  • GCC + Intel MPI の組み合わせでは cp2k 本体のビルド時にモジュール関連のエラーで失敗する。原因が判然とせず。include パスの問題なのだろうか?
  • OpenMPI 3.1.0 でビルドした場合、MPI 時に正常に動作しない。どうやら既知のバグらしい。
  • OpenMPI 4.x を使う場合にはレガシーな MPI1 のサポートを入れておく必要がある。(scalapack (含 mkl) の要求)
  • gcc8 ではエラーが少し増えてしまうため、回避。速度的なメリットも無さそう。