3.2 KiB
How to compile the CP2K code
1. Acquire the code
For users, the preferred method is to download a release
(use the versioned tarballs, cp2k-X.Y.tar.bz2). For developers, the preferred method is to
download from Git.
For more details on downloading CP2K, see https://www.cp2k.org/download.
2. Install prerequisites
Method 1: make_cp2k.sh
The easiest way to build CP2K with its dependencies is via the make_cp2k.sh script, which builds
CP2K using Spack and CMake locally within the CP2K_ROOT folder.
The script can either be sourced with:
source ./make_cp2k.sh
or run in a subshell with:
./make_cp2k.sh
You can run the following command to get information about how to use this script:
./make_cp2k.sh --help
Note: it is recommended to install podman to take advantage of a spack cache. This will accelerate the build of the CP2K dependencies with Spack significantly.
Method 2: Toolchain
Alternatively, the toolchain script can also be run directly.
For a complete introduction to the toolchain script, see the README.
The basic steps are:
- Read toolchain installation options:
cd tools/toolchain/
./install_cp2k_toolchain.sh --help
CP2K supports GPU acceleration via CUDA (for NVIDIA GPUs), HIP/ROCm (for AMD GPUs), and OpenCL (for a range of devices). If you wish to build with GPU support, please see the manual.
- Launch toolchain script (example option choice for NVIDIA/CUDA):
./install_cp2k_toolchain.sh --with-libxsmm=install --with-openblas=system \
--with-fftw=system --enable-cuda
- For AMD/ROCm/HIP support, use:
./install_cp2k_toolchain.sh --with-libxsmm=install --with-openblas=system \
--with-fftw=system --enable-hip
- Build and install CP2K with prepared toolchain environment:
./build_cp2k.sh
It is also available to make installed program and dependencies outside the source tree:
./install_cp2k_toolchain.sh --install-dir=/opt/cp2k/toolchain
./build_cp2k.sh --prefix /opt/cp2k
3. Compile
This section has been moved to the manual.
4. If it doesn't work
If things fail, take a break... go back to step 2.
5. Regtesting
If compilation works fine, it is recommended to test the generated binary, to exclude errors in libraries, or miscompilations, etc.
./tests/do_regtest.py ./build/bin/ ${VERSION}
should work if you can locally execute CP2K without the need for, e.g., batch submission.
In the other case, you might need to configure the underlying testing script as described more systematically at https://www.cp2k.org/dev:regtesting
6. Talk to us
In any case please tell us your comments, praise, criticism, thanks, etc. see https://www.cp2k.org.
7. Manual
A reference manual of CP2K can be found on the web: https://manual.cp2k.org or can be generated using the cp2k binary, see https://manual.cp2k.org/trunk/generate_manual_howto.html
8. Happy computing
The CP2K team.