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 06:45] krackhowto:compile_on_windows [2023/12/01 14:07] (current) krack
Line 1: Line 1:
 ====== How to Compile CP2K on Windows ====== ====== How to Compile CP2K on Windows ======
  
-This howto has been tested under Windows10 using the Windows Subsystem for Linux (WSL).+This howto has been tested under Windows10 (22H2) using the Windows Subsystem for Linux (WSL).
  
 ==== Install Linux base system ==== ==== Install Linux base system ====
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>
 +and the ''stacksize'' to 65 MB (check with ''ulimit -a'').
 </code> </code>
  
Line 85: Line 90:
 make -j ARCH=local VERSION=ssmp test make -j ARCH=local VERSION=ssmp test
 </code> </code>
-This will more than 4000 test cases. At the end of that test, a summary is printed which should indicate that there are no ''FAILED'' or ''WRONG'' tests.+This will more than 4000 test cases. At the end of that test, a summary is printed which should indicate that there are no ''FAILED'' or ''WRONG'' tests. Instead or running the all tests, you can also restrict the testing to certain test folders in ''~/github/cp2k/cp2k/tests'' by passing ''TESTOPTS'' with the ''make'' command like 
 +<code> 
 +make -j ARCH=local VERSION=ssmp TESTOPTS="--restrictdir QS/regtest-gpw-1" test 
 +</code> 
 +which will only run the test cases in the folder ''~/github/cp2k/cp2k/tests/QS/regtest-1''. You can list all available ''TESTOPTS'' with 
 +<code> 
 +~/github/cp2k/cp2k/tests/do_regtest.py -h 
 +</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 98: Line 123:
 sudo apt -y install mpich bzip2 unzip zlib1g-dev sudo apt -y install mpich bzip2 unzip zlib1g-dev
 </code> </code>
-and some system packages for data compression have to be installed.+and some system packages for data compression have to be installed as well.
 The CP2K toolchain for a ''cp2k.psmp'' binary can then be built with The CP2K toolchain for a ''cp2k.psmp'' binary can then be built with
 <code> <code>
Line 111: Line 136:
 </code> </code>
 and testing and testing
 +<code>
 +source ~/github/cp2k/cp2k/tools/toolchain/install/setup
 make -j ARCH=local VERSION=psmp test make -j ARCH=local VERSION=psmp test
 </code> </code>
Line 117: Line 144:
 ==== Last but not least ==== ==== Last but not least ====
  
-Before using CP2K, do not forget to ''source'' always the ''setup'' file with+After loading the WSL and before using CP2K, do not forget to ''source'' always the ''setup'' file with
 <code> <code>
 source ~/github/cp2k/cp2k/tools/toolchain/install/setup source ~/github/cp2k/cp2k/tools/toolchain/install/setup
Line 130: Line 157:
 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.1701413134.txt.gz · Last modified: 2023/12/01 06:45 by krack