User Tools

Site Tools


howto:compile_on_windows

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
howto:compile_on_windows [2023/12/01 08:57] krackhowto:compile_on_windows [2025/08/21 14:08] (current) – Revert last change and force full cleaning krack
Line 5: Line 5:
 ==== Install Linux base system ==== ==== Install Linux base system ====
  
-Search in the [[https://apps.microsoft.com/|Microsoft App Store]] for [[https://apps.microsoft.com/search?query=ubuntu+22.04|Ubuntu 22.04]] and download that app. Follow the installation instructions from Windows, define a Linux username and password. Your user will have administrator (root) rights via ''sudo'' command. These rights are required for the installation of system packages but not for the CP2K installation further down. +Search in the [[https://apps.microsoft.com/|Microsoft App Store]] for [[https://apps.microsoft.com/search?query=ubuntu+24.04|Ubuntu 24.04]] and download that app. Follow the installation instructions from Windows, define a Linux username and password. Your user will have administrator (root) rights via ''sudo'' command. These rights are required for the installation of system packages but not for the CP2K installation further down. 
  
 ==== Install required packages ==== ==== Install required packages ====
Line 17: Line 17:
 Install additional software packages required to build CP2K which are not included in the base system like ''make'' and the GNU compiler Install additional software packages required to build CP2K which are not included in the base system like ''make'' and the GNU compiler
 <code> <code>
-sudo apt -y install make+sudo apt -y install bzip2 make unzip
 sudo apt -y install gcc g++ gfortran sudo apt -y install gcc g++ gfortran
 </code> </code>
Line 34: Line 34:
 git clone --recursive https://github.com/cp2k/cp2k.git cp2k git clone --recursive https://github.com/cp2k/cp2k.git cp2k
 </code> </code>
-or download a CP2K release version like 2023.2+or download a CP2K release version like 2025.2
 <code> <code>
-git clone --recursive -b support/v2023.2 https://github.com/cp2k/cp2k.git cp2k+git clone --recursive -b support/v2025.2 https://github.com/cp2k/cp2k.git cp2k
 </code> </code>
  
Line 74: Line 74:
 export OMP_NUM_THREADS=2 export OMP_NUM_THREADS=2
 </code> </code>
-The binaries with the file extension ''sopt'' are automatically run with only one OpenMP thread. It is also suggest to use an increased ''OMP_STACKSIZE'' of at least 16 MB+The binaries with the file extension ''sopt'' are automatically run with only one OpenMP thread. 
 + 
 +It is also suggested to increase the ''OMP_STACKSIZE'' to at least 16 MB
 <code> <code>
 export OMP_STACKSIZE=16M export OMP_STACKSIZE=16M
 +ulimit -s 65000
 </code> </code>
 +and the ''stacksize'' to 65 MB (check with ''ulimit -a'').
  
 ==== Test the serial CP2K binary ==== ==== Test the serial CP2K binary ====
Line 93: Line 97:
 ~/github/cp2k/cp2k/tests/do_regtest.py -h ~/github/cp2k/cp2k/tests/do_regtest.py -h
 </code> </code>
 +All data generated by ''test'' can be removed with
 +<code>
 +make ARCH=local VERSION=ssmp testclean
 +</code>
 +whereas
 +<code>
 +make ARCH=local VERSION=ssmp realclean
 +</code>
 +and
 +<code>
 +make distclean
 +</code>
 +will remove all data from ''make ARCH=local VERSION=ssmp'' and from any ''make'', respectively.
  
 ==== Build and test a parallel CP2K binary ==== ==== Build and test a parallel CP2K binary ====
Line 99: Line 116:
 First reset the CP2K repository to the state of a fresh ''git clone'' if needed with First reset the CP2K repository to the state of a fresh ''git clone'' if needed with
 <code> <code>
-git clean -fdx+git clean -ffdx
 </code> </code>
 Install additional packages needed for an MPI/OpenMP parallel CP2K binary. Here we use the MPI implementation ''MPICH'' Install additional packages needed for an MPI/OpenMP parallel CP2K binary. Here we use the MPI implementation ''MPICH''
 <code> <code>
-sudo apt -y install mpich bzip2 unzip zlib1g-dev+sudo apt -y install automake mpich libmpich-dev pkg-config zlib1g-dev
 </code> </code>
 and some system packages for data compression have to be installed as well. and some system packages for data compression have to be installed as well.
Line 109: Line 126:
 <code> <code>
 cd tools/toolchain cd tools/toolchain
-./install_cp2k_toolchain.sh --install-all --with-gcc=system --with-mpich=system --with-sirius=no+./install_cp2k_toolchain.sh --install-all --with-gcc=system --with-mpich=system --with-dftd4=no
 </code> </code>
 The commands for compiling The commands for compiling
Line 139: Line 156:
 cp2k.ssmp cp2k.ssmp
 </code> </code>
-and likewise with ''cp2k.sopt'' or ''cp2k.psmp''.+and likewise with ''cp2k.sopt''
 + 
 +CP2K MPI/OpenMP parallel runs are launched with ''mpirun'' or ''mpiexec'', e.g. 
 +<code> 
 +mpiexec -n 4 -genv OMP_NUM_THREADS=2 cp2k.psmp H2O-32.inp 
 +</code> 
 +will use 4 MPI ranks with 2 OpenMP threads each (i.e. it will consume 8 CPU cores) to run the input file ''H2O-32.inp'' which can be found in  the cp2k folder ''benchmarks/QS''
 + 
 +The ''cp2k.popt'' binary is only MPI parallel and will run just one thread per MPI rank automatically (like ''cp2k.sopt'') which is usually the most efficient usage of CP2K performance-wise if no memory limitation per MPI rank come into play. Therefore, the following commands 
 +<code> 
 +mpiexec -n 4 -genv OMP_NUM_THREADS=1 cp2k.psmp H2O-32.inp 
 +mpiexec -n 4                         cp2k.popt H2O-32.inp 
 +</code> 
 +are basically equivalent.
  
-**Enjoy CP2K !**+**Enjoy CP2K under Windows!**
howto/compile_on_windows.1701421059.txt.gz · Last modified: by krack