howto:compile
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
howto:compile [2021/01/10 17:02] – external edit 127.0.0.1 | howto:compile [2023/11/13 13:03] – oschuett | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ~~NOCACHE~~ | + | This page has been moved to: https:// |
- | + | ||
- | ====== How to compile the CP2K code ====== | + | |
- | + | ||
- | ===== 1. Acquire the code ===== | + | |
- | + | ||
- | For users, the preferred method is to [[https:// | + | |
- | + | ||
- | For more details on downloading CP2K, see https:// | + | |
- | + | ||
- | ===== 2. Install prerequisites ===== | + | |
- | + | ||
- | The most convenient way to install pre-requisites is by using the [[https:// | + | |
- | + | ||
- | For a complete introduction to the toolchain script, see the [[https:// | + | |
- | + | ||
- | The basic steps are: | + | |
- | + | ||
- | * Read toolchain installation options: | + | |
- | + | ||
- | < | + | |
- | cd tools/ | + | |
- | ./ | + | |
- | </ | + | |
- | * Launch toolchain script (example option choice) | + | |
- | + | ||
- | < | + | |
- | ./ | + | |
- | | + | |
- | </ | + | |
- | * Once the script has completed successfully, | + | |
- | + | ||
- | Sub-points here discuss prerequisites needed to build CP2K. Copies of the recommended versions of 3rd party software can be downloaded from https:// | + | |
- | + | ||
- | ==== 2a. GNU make (required, build system) ==== | + | |
- | + | ||
- | GNU make should be on your system (gmake or make on linux) and used for the build, go to https:// | + | |
- | + | ||
- | ==== 2b. Python (required, build system) ==== | + | |
- | + | ||
- | Python 3.5+ is needed to run the dependency generator. On most system Python is already installed. For more information visit: https:// | + | |
- | + | ||
- | ==== 2c. Fortran and C Compiler (required, build system) ==== | + | |
- | + | ||
- | A Fortran 2008 compiler and matching C99 compiler should be installed on your system. We have good experience with gcc/ | + | |
- | + | ||
- | ==== 2d. BLAS and LAPACK (required, base functionality) ==== | + | |
- | + | ||
- | BLAS and LAPACK should be installed. Using vendor-provided libraries can make a very significant difference (up to 100%, e.g., ACML, MKL, ESSL), not all optimized libraries are bug free. Use the latest versions available, use the interfaces matching your compiler, and download all patches! | + | |
- | + | ||
- | * The canonical BLAS and LAPACK can be obtained from the Netlib repository: | + | |
- | * http:// | + | |
- | * http:// | + | |
- | * http:// | + | |
- | * Open fast alternatives, | + | |
- | * http:// | + | |
- | * http:// | + | |
- | * https:// | + | |
- | + | ||
- | If compiling with OpenMP support then it is recommended to use a non-threaded version of BLAS. In particular if compiling with MKL and using OpenMP you must define '' | + | |
- | + | ||
- | On the Mac, BLAS and LAPACK may be provided by Apple' | + | |
- | + | ||
- | When building on/for Windows using the Minimalist GNU for Windows (MinGW) environment, | + | |
- | + | ||
- | ==== 2e. MPI and SCALAPACK (optional, required for MPI parallel builds) ==== | + | |
- | + | ||
- | MPI (version 2) and SCALAPACK are needed for parallel code. (Use the latest versions available and download all patches!). | + | |
- | + | ||
- | + | ||
- | <note important> | + | |
- | Note that your MPI installation must match the used Fortran compiler. If your computing platform does not provide MPI, there are several freely available alternatives: | + | |
- | </ | + | |
- | + | ||
- | * MPICH2 MPI: http:// | + | |
- | * OpenMPI MPI: http:// | + | |
- | * ScaLAPACK: | + | |
- | * http:// | + | |
- | * http:// | + | |
- | * ScaLAPACK can be part of ACML or cluster MKL. These libraries are recommended if available. | + | |
- | * Recently a [[http:// | + | |
- | + | ||
- | CP2K assumes that the MPI library implements MPI version 3. If you have an older version of MPI (e.g. MPI 2.0) available you must define '' | + | |
- | + | ||
- | ==== 2f. FFTW (optional, improved performance of FFTs) ==== | + | |
- | + | ||
- | FFTW can be used to improve FFT speed on a wide range of architectures. It is strongly recommended to install and use FFTW3. The current version of CP2K works with FFTW 3.X (use '' | + | |
- | + | ||
- | + | ||
- | <note important> | + | |
- | Note that FFTW must know the Fortran compiler you will use in order to install properly (e.g., '' | + | |
- | </ | + | |
- | + | ||
- | + | ||
- | <note important> | + | |
- | Note that on machines and compilers which support SSE you can configure FFTW3 with '' | + | |
- | </ | + | |
- | + | ||
- | ==== 2g. LIBINT (optional, enables methods including HF exchange) ==== | + | |
- | + | ||
- | * Hartree-Fock exchange (optional, use '' | + | |
- | * Recommended way to build libint: Download a CP2K-configured libint library from [[https:// | + | |
- | * CP2K is not hardwired to these provided libraries and any other libint library (version >= 2.5.0) should be compatible as long as it was compiled with '' | + | |
- | * Avoid debugging information ('' | + | |
- | * In the arch file of CP2K: add '' | + | |
- | * Libint 1 is no longer supported and the previously needed flags '' | + | |
- | * '' | + | |
- | + | ||
- | ==== 2h. libsmm (optional, improved performance for matrix multiplication) ==== | + | |
- | + | ||
- | * A library for small matrix multiplies can be built from the included source (see exts/dbcsr/ | + | |
- | * Add '' | + | |
- | * Add '' | + | |
- | + | ||
- | ==== 2i. libxsmm (optional, improved performance for matrix multiplication) ==== | + | |
- | + | ||
- | * A library for matrix operations and deep learning primitives: https:// | + | |
- | * Add '' | + | |
- | + | ||
- | ==== 2j. CUDA (optional, improved performance on GPU systems) ==== | + | |
- | + | ||
- | * Specify NVCC (e.g. '' | + | |
- | * '' | + | |
- | * Use the '' | + | |
- | * Add '' | + | |
- | * Specify the GPU type (e.g. '' | + | |
- | * Specify the C++ compiler (e.g. '' | + | |
- | * Use '' | + | |
- | * CUFFT 7.0 has a known bug and is therefore disabled by default. NVIDIA' | + | |
- | * Use '' | + | |
- | * Link to a blas/ | + | |
- | * Use the '' | + | |
- | + | ||
- | ==== 2k. libxc (optional, wider choice of xc functionals) ==== | + | |
- | + | ||
- | * The version 4.0.3 (or later) of libxc can be downloaded from http:// | + | |
- | * During the installation, | + | |
- | * Add '' | + | |
- | * | + | |
- | <note important> | + | |
- | Note that the deprecated flags '' | + | |
- | </ | + | |
- | + | ||
- | ==== 2l. ELPA (optional, improved performance for diagonalization) ==== | + | |
- | + | ||
- | Library ELPA for the solution of the eigenvalue problem | + | |
- | + | ||
- | * ELPA replaces the ScaLapack '' | + | |
- | * A version of ELPA can to be downloaded from http:// | + | |
- | * During the installation the '' | + | |
- | * Minimal supported version of ELPA is 2018.05.001. | + | |
- | * Add '' | + | |
- | * Add '' | + | |
- | * Add '' | + | |
- | * Add '' | + | |
- | * Add '' | + | |
- | * For specific architectures it can be better to install specifically optimized kernels (see BG) and/or employ a higher optimization level to compile it. | + | |
- | + | ||
- | ==== 2m. PEXSI (optional, low scaling SCF method) ==== | + | |
- | + | ||
- | The Pole EXpansion and Selected Inversion (PEXSI) method requires the PEXSI library and two dependencies (ParMETIS or PT-Scotch and SuperLU_DIST). | + | |
- | + | ||
- | * Download PEXSI (www.pexsi.org) and install it and its dependencies by following its README.md. | + | |
- | * PEXSI versions 0.10.x have been tested with CP2K. Older versions are not supported. | + | |
- | * PEXSI needs to be built with '' | + | |
- | + | ||
- | In the arch file of CP2K: | + | |
- | + | ||
- | * Add '' | + | |
- | * It is important that a copy of LAPACK and BLAS is placed before and after these libraries (replace '' | + | |
- | * In order to link in PT-Scotch instead of ParMETIS replace '' | + | |
- | * Add '' | + | |
- | * Add '' | + | |
- | + | ||
- | Below are some additional hints that may help in the compilation process: | + | |
- | + | ||
- | * For building PT-Scotch, the flag '' | + | |
- | * For building SuperLU_DIST with PT-Scotch, you must set the following in '' | + | |
- | + | ||
- | < | + | |
- | METISLIB = -lscotchmetis -lscotch -lscotcherr | + | |
- | PARMETISLIB = -lptscotchparmetis -lptscotch -lptscotcherr | + | |
- | </ | + | |
- | ==== 2n. QUIP (optional, wider range of interaction potentials) ==== | + | |
- | + | ||
- | QUIP - QUantum mechanics and Interatomic Potentials Support for QUIP can be enabled via the flag '' | + | |
- | + | ||
- | For more information see http:// | + | |
- | + | ||
- | ==== 2o. PLUMED (optional, enables various enhanced sampling methods) ==== | + | |
- | + | ||
- | CP2K can be compiled with PLUMED 2.x ('' | + | |
- | + | ||
- | See https:// | + | |
- | + | ||
- | ==== 2p. spglib (optional, crystal symmetries tools) ==== | + | |
- | + | ||
- | A library for finding and handling crystal symmetries | + | |
- | + | ||
- | * The spglib can be downloaded from https:// | + | |
- | * For building CP2K with the spglib add '' | + | |
- | + | ||
- | ==== 2q. SIRIUS (optional, plane wave calculations) ==== | + | |
- | + | ||
- | SIRIUS is a domain specific library for electronic structure calculations. | + | |
- | + | ||
- | * The code is available at https:// | + | |
- | * For building CP2K with SIRIUS add '' | + | |
- | * See https:// | + | |
- | + | ||
- | ==== 2r. FPGA (optional, plane wave FFT calculations) ==== | + | |
- | + | ||
- | * Use '' | + | |
- | * Supports single precision and double precision fft calculations with the use of dedicated APIs. | + | |
- | * Double precision is the default API chosen when set using the '' | + | |
- | * Single precision can be set using an additional '' | + | |
- | * Kernel code has to be synthesized separately and copied to a specific location. | + | |
- | * See https:// | + | |
- | * Read '' | + | |
- | * Currently supported FFT3d sizes - 16^3, 32^3, 64^3. | + | |
- | * Include aocl compile flags and '' | + | |
- | * CUDA and FPGA are mutually exclusive. Building with both '' | + | |
- | + | ||
- | ==== 2s. COSMA (Distributed Communication-Optimal Matrix-Matrix Multiplication Algorithm) ==== | + | |
- | + | ||
- | * COSMA is a replacement of the pdgemm routine included in scalapack. The library supports both CPU and GPUs. No specific flag during compilation is needed to use the library in cp2k, excepted during linking time where the library should be placed in front of the scalapack library. | + | |
- | * see https:// | + | |
- | + | ||
- | ==== 2t. LibVori (Voronoi Integration for Electrostatic Properties from Electron Density) ==== | + | |
- | + | ||
- | * LibVori is a library which enables to compute electrostatic properties (charge, dipole vector, quadrupole tensor, ...) via integration of the total electron density in the Voronoi cell of each atom. | + | |
- | * Add '' | + | |
- | * see https:// | + | |
- | * LibVori also enables support for the BQB file format for compressed trajectories, | + | |
- | + | ||
- | ==== 2u. LibMaxwell (External Maxwell Solver) ==== | + | |
- | + | ||
- | * LibMaxwell is a library to solve the time-dependent Maxwell equations and use the resulting electric field in MD runs or real-time propagation. | + | |
- | * Add '' | + | |
- | * see https:// | + | |
- | + | ||
- | ===== 3. Compile ===== | + | |
- | + | ||
- | ==== 3a. ARCH files ==== | + | |
- | + | ||
- | The location of compiler and libraries needs to be specified. Examples for a number of common architectures examples can be found in [[https:// | + | |
- | + | ||
- | * With -DNDEBUG assertions may be stripped (" | + | |
- | * NDEBUG is the ANSI-conforming symbol name (not %%__%%NDEBUG). | + | |
- | * Regular release builds may carry assertions for safety. | + | |
- | + | ||
- | Conventionally, | + | |
- | + | ||
- | ^Acronym^Meaning | + | |
- | |sdbg | + | |
- | |popt | + | |
- | |ssmp | + | |
- | |pdbg |MPI + OpenMP + debug settings | + | |
- | |popt |MPI + OpenMP + OMP_NUM_THREADS=1| | + | |
- | |psmp |MPI + OpenMP | + | |
- | + | ||
- | You'll need to modify one of these files to match your system' | + | |
- | + | ||
- | You can now build CP2K using these settings (where -j N allows for a parallel build using N processes): | + | |
- | + | ||
- | < | + | |
- | make -j N ARCH=architecture VERSION=version | + | |
- | </ | + | |
- | e.g. | + | |
- | + | ||
- | < | + | |
- | make -j N ARCH=Linux-x86-64-gfortran VERSION=sopt | + | |
- | </ | + | |
- | as a short-cut, you can build several version of the code at once | + | |
- | + | ||
- | < | + | |
- | make -j N ARCH=Linux-x86-64-gfortran VERSION=" | + | |
- | </ | + | |
- | An executable should appear in the '' | + | |
- | + | ||
- | All compiled files, libraries, executables, | + | |
- | + | ||
- | < | + | |
- | make distclean | + | |
- | </ | + | |
- | To remove only objects and mod files (i.e., keep exe) for a given ARCH/ | + | |
- | + | ||
- | < | + | |
- | make ARCH=Linux-x86-64-gfortran VERSION=sopt clean | + | |
- | </ | + | |
- | to remove everything for a given ARCH/ | + | |
- | + | ||
- | < | + | |
- | make ARCH=Linux-x86-64-gfortran VERSION=sopt realclean | + | |
- | </ | + | |
- | ==== 3b. Compilation Flags ==== | + | |
- | + | ||
- | The following flags should be present (or not) in the arch file, partially depending on installed libraries (see 2.) | + | |
- | + | ||
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | + | ||
- | Features useful to deal with legacy systems | + | |
- | + | ||
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * The Makefile automatically compiles in the path to the data directory via the flag '' | + | |
- | * '' | + | |
- | * '' | + | |
- | + | ||
- | ==== 3c. Building CP2K as a library ==== | + | |
- | + | ||
- | You can build CP2K for use as a library by adding '' | + | |
- | + | ||
- | < | + | |
- | make -j N ARCH=Linux-x86-64-gfortran VERSION=sopt libcp2k | + | |
- | </ | + | |
- | This will create '' | + | |
- | + | ||
- | In order to use the functions in the library you will also require the '' | + | |
- | + | ||
- | For Fortran users, you will require the module interface file ('' | + | |
- | + | ||
- | < | + | |
- | ./ | + | |
- | </ | + | |
- | In order for your compiler to find these, you will need to indicate their location to the compiler as is done for header files (typically via the '' | + | |
- | + | ||
- | ===== 4. If it doesn' | + | |
- | + | ||
- | If things fail, take a break... go back to 2a (or skip to step 6). | + | |
- | + | ||
- | ===== 5. Regtesting ===== | + | |
- | + | ||
- | If compilation works fine, it is recommended to test the generated binary, to exclude errors in libraries, or miscompilations, | + | |
- | + | ||
- | < | + | |
- | make -j ARCH=... VERSION=... test | + | |
- | </ | + | |
- | 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:// | + | |
- | + | ||
- | ===== 6. Talk to us ===== | + | |
- | + | ||
- | In any case please tell us your comments, praise, criticism, thanks,... see https:// | + | |
- | + | ||
- | ===== 7. Manual ===== | + | |
- | + | ||
- | A reference manual of CP2K can be found on the web: https:// | + | |
- | + | ||
- | ===== 8. Happy computing ===== | + | |
- | + | ||
- | The CP2K team. | + | |
- | + |
howto/compile.txt · Last modified: 2023/11/13 13:04 by oschuett