howto:compile
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
howto:compile [2014/02/09 22:53] – Updated how to compile ltong | howto:compile [2021/01/12 15:02] – oschuett | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | <note warning>This text is probably out of date and needs to be revised.</ | + | This page has been moved to [[https://github.com/cp2k/cp2k/blob/master/INSTALL.md|GitHub]]. |
- | + | ||
- | ====== How to Compile CP2K ====== | + | |
- | + | ||
- | ===== Prerequisites ===== | + | |
- | + | ||
- | You need the following before you can compile CP2K | + | |
- | + | ||
- | * [[compile# | + | |
- | * [[compile# | + | |
- | * [[compile# | + | |
- | * [[compile# | + | |
- | * [[compile# | + | |
- | * [[compile# | + | |
- | * [[compile# | + | |
- | * [[compile# | + | |
- | * [[compile# | + | |
- | * [[compile# | + | |
- | * [[compile# | + | |
- | * [[compile# | + | |
- | * [[compile# | + | |
- | * [[compile# | + | |
- | + | ||
- | ==== Obtaining a copy of CP2K source ==== | + | |
- | + | ||
- | To obtain a copy of CP2K source, please follow the instructions given [[: | + | |
- | + | ||
- | ==== GNU make ==== | + | |
- | + | ||
- | GNU make should be on your system (gmake or make on Linux) and it is used for the build. If you do not have it, go to | + | |
- | + | ||
- | http:// | + | |
- | + | ||
- | and download from | + | |
- | + | ||
- | http:// | + | |
- | + | ||
- | ==== Fortran 95 Compiler ==== | + | |
- | + | ||
- | A Fortran 95 compiler should be installed on your system. We have good experience with gfortran 4.4.X and above. | + | |
- | + | ||
- | //Please report bugs to compiler vendors; they (and we) have an interest in fixing them.// | + | |
- | + | ||
- | ==== yacc ==== | + | |
- | + | ||
- | '' | + | |
- | + | ||
- | http:// | + | |
- | + | ||
- | ==== BLAS and LAPACK ==== | + | |
- | + | ||
- | BLAS and LAPACK linear algebra libraries should be installed. Using vendor-provided libraries can make a very significant difference (up to 100%, e.g., ACML, MKL, ESSL). | + | |
- | + | ||
- | //Note that the BLAS/LAPACK libraries must match the Fortran compiler used//. | + | |
- | + | ||
- | Use the latest versions available and download all patches! The canonical BLAS and LAPACK can be obtained from the Netetlib repository. | + | |
- | + | ||
- | * http:// | + | |
- | * http:// | + | |
- | * http:// | + | |
- | + | ||
- | A faster alternative is to use the ATLAS project. It provides BLAS and enough of LAPACK to run CP2K, both optimized for the local machine upon installation: | + | |
- | + | ||
- | GotoBLAS is yet a faster BLAS alternative: | + | |
- | + | ||
- | If compiling with OpenMP support then it is recommended to use a // | + | |
- | + | ||
- | ==== MPI and SCALAPACK ==== | + | |
- | + | ||
- | MPI (version 2) and ScaLAPACK are needed for parallel code ('' | + | |
- | + | ||
- | If your computing platform does not provide MPI, there are several freely available alternatives: | + | |
- | + | ||
- | * MPICH2 MPI: http:// | + | |
- | * OpenMPI MPI: http:// | + | |
- | + | ||
- | ScaLAPACK can be part of ACML or cluster MKL. These libraries are recommended if available. | + | |
- | + | ||
- | Canonical ScaLAPACK can be obtained from | + | |
- | + | ||
- | http:// | + | |
- | + | ||
- | and see also http:// | + | |
- | + | ||
- | Recently a ScaLAPACK installer | + | |
- | + | ||
- | ==== Exchange-Correlation Functionals Library ==== | + | |
- | + | ||
- | The version 2.0.1 (**ONLY this one**) of libxc needs to be downloaded from | + | |
- | + | ||
- | http:// | + | |
- | + | ||
- | and installed (to '' | + | |
- | + | ||
- | During the installation, | + | |
- | + | ||
- | | %%-D__LIBXC2%% | | + | |
- | + | ||
- | to '' | + | |
- | + | ||
- | | %%-L$(LIBXC_DIR)/ | + | |
- | + | ||
- | to '' | + | |
- | + | ||
- | ==== Fast Fourier Transform Library ==== | + | |
- | + | ||
- | FFTW can be used to improve FFT speed on a wide range of architectures. | + | |
- | + | ||
- | It is strongly recommended to install and use FFTW3. | + | |
- | + | ||
- | http://www.fftw.org/ | + | |
- | + | ||
- | Note that FFTW must know the Fortran compiler you will use in order to install properly (e.g., '' | + | |
- | + | ||
- | Compilers/ | + | |
- | + | ||
- | | %%-D__FFTW3_UNALIGNED%% | | + | |
- | + | ||
- | to '' | + | |
- | + | ||
- | When building an OpenMP parallel version of CP2K ('' | + | |
- | + | ||
- | When using FFTW3 library, add | + | |
- | + | ||
- | | %%-D__FFTW3%% | | + | |
- | + | ||
- | to '' | + | |
- | + | ||
- | ==== Hartree-Fock Exchange ==== | + | |
- | + | ||
- | Hartree-Fock exchange (optional) requires the libint package to be installed. | + | |
- | + | ||
- | It is easiest to install with a Fortran compiler that supports ISO_C_BINDING and Fortran procedure pointers (recent gfortran, xlf90, ifort). | + | |
- | + | ||
- | Additional information can be found in | + | |
- | < | + | |
- | cp2k/tools/ | + | |
- | </ | + | |
- | Tested against libinit-1.1.4 and currently hardcoded to the default angular momentum | + | |
- | < | + | |
- | LIBINT_MAX_AM 5 | + | |
- | </ | + | |
- | (check your '' | + | |
- | + | ||
- | http:// | + | |
- | + | ||
- | //Note, do **NOT** use libinit-1.1.3.// | + | |
- | + | ||
- | When using libint library, add | + | |
- | + | ||
- | | %%-D__LININT%% | | + | |
- | + | ||
- | to '' | + | |
- | + | ||
- | ==== Small Matrix Multiplication Library ==== | + | |
- | + | ||
- | A library for small matrix multiplies can be built from the included source: | + | |
- | < | + | |
- | cp2k/tools/build_libsmm | + | |
- | </code> | + | |
- | See the README file inside the '' | + | |
- | + | ||
- | Usually only the double precision real and perhaps complex is needed. Add the following to '' | + | |
- | + | ||
- | | %%-D__HAS_smm_dnn%% | to make the code use the double precision real library | | + | |
- | | %%-D__HAS_smm_snn%% | to make the code use the single precision real library | | + | |
- | | %%-D__HAS_smm_znn%% | to make the code use the double precision complex library | | + | |
- | | %%-D__HAS_smm_cnn%% | to make the code use the single precision complex library | | + | |
- | | %%-D__HAS_smm_vec%% | to enable the new vectorized interface of '' | + | |
- | + | ||
- | ==== Library ELPA ==== | + | |
- | + | ||
- | This is an alternative library to ScaLAPACK for the solution of eigenvalue problems. A version of ELPA can be downloaded from | + | |
- | + | ||
- | http:// | + | |
- | + | ||
- | ELPA replaces the ScaLAPACK '' | + | |
- | + | ||
- | During the installation, | + | |
- | + | ||
- | To use ELPA | + | |
- | + | ||
- | | %%-D__ELPA%% | | + | |
- | + | ||
- | to '' | + | |
- | + | ||
- | | %%-L$(ELPA_DIR)/ | + | |
- | + | ||
- | to '' | + | |
- | + | ||
- | ==== CUDA Support ==== | + | |
- | + | ||
- | **This is still experimental.** | + | |
- | + | ||
- | Add | + | |
- | + | ||
- | | %%-D__DBCSR_CUDA%% | | + | |
- | + | ||
- | to '' | + | |
- | + | ||
- | | %%-lcudart -lrt%% | | + | |
- | + | ||
- | to '' | + | |
- | + | ||
- | Use | + | |
- | + | ||
- | | %%-D__PW_CUDA%% | | + | |
- | + | ||
- | in '' | + | |
- | + | ||
- | USE | + | |
- | + | ||
- | | %%-D__CUDA_PROFILING%% | | + | |
- | + | ||
- | in '' | + | |
- | + | ||
- | Consult '' | + | |
- | + | ||
- | ==== Machine Architecture Abstraction Support ==== | + | |
- | + | ||
- | **Still under development** | + | |
- | + | ||
- | Add | + | |
- | + | ||
- | | %%-D__HWLOC%% | | + | |
- | + | ||
- | or | + | |
- | + | ||
- | | %%-D__LIBNUMA%% | | + | |
- | + | ||
- | to '' | + | |
- | + | ||
- | | %%-lhwloc%% | | + | |
- | + | ||
- | or | + | |
- | + | ||
- | | %%-lnuma%% | | + | |
- | + | ||
- | The compiler must support ISO_C_BINDING. | + | |
- | + | ||
- | Machine architecture visualization is supported only with '' | + | |
- | + | ||
- | Note that it is not possible to use at same time '' | + | |
- | + | ||
- | Consult '' | + | |
- | + | ||
- | ==== Process Mapping Support ==== | + | |
- | + | ||
- | **Still under development** | + | |
- | + | ||
- | Use the target machine to compile with topology support. | + | |
- | + | ||
- | You can also define the strategy to be used using a command line, with | + | |
- | < | + | |
- | -mpi-mapping [1, | + | |
- | </ | + | |
- | + | ||
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | + | ||
- | The compiler must support ISO_C_BINDING | + | |
- | + | ||
- | Consult '' | + | |
- | + | ||
- | ===== Compiling the Code ===== | + | |
- | + | ||
- | ==== I am Feeling Lucky ==== | + | |
- | + | ||
- | The " | + | |
- | < | + | |
- | make sopt | + | |
- | </ | + | |
- | in '' | + | |
- | < | + | |
- | export FORT_C_NAME=gfortran | + | |
- | </ | + | |
- | + | ||
- | If you are not feeling lucky... Or you want to know exactly what you are doing when compiling CP2K, and what options are available, please read on. | + | |
- | + | ||
- | ==== The arch File ==== | + | |
- | + | ||
- | The locations of the compilers and libraries needs to be specified, together with compilation options, in an " | + | |
- | + | ||
- | Conventionally, | + | |
- | + | ||
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | + | ||
- | You will need to modify one of these files to match your system' | + | |
- | + | ||
- | ==== Compilation Commands ==== | + | |
- | + | ||
- | After you have finished creating or editing your own arch file in '' | + | |
- | < | + | |
- | make -j N ARCH=architecture VERSION=version | + | |
- | </ | + | |
- | where '' | + | |
- | + | ||
- | For example, if you have created '' | + | |
- | < | + | |
- | make -j 4 ARCH=foo VERSION=sopt | + | |
- | </ | + | |
- | to compile (with 4 processes in parallel) the serial version of CP2K, with compilers, libraries and options specified in the file '' | + | |
- | + | ||
- | As a short-cut, you can build several version of the code at onece: | + | |
- | < | + | |
- | make -j N ARCH=architecture sopt popt ssmp psmp | + | |
- | </ | + | |
- | provided you have the corresponding arch files already in place. | + | |
- | + | ||
- | After a successful compilation, | + | |
- | + | ||
- | All compiled files, libraries, executables, | + | |
- | < | + | |
- | make distclean | + | |
- | </ | + | |
- | in '' | + | |
- | + | ||
- | To remove only objects and mod files (i.e. keep exe) for a given ARCH/ | + | |
- | < | + | |
- | make ARCH=architecture VERSION=version clean | + | |
- | </ | + | |
- | + | ||
- | To remove everything for a given ARCH/ | + | |
- | < | + | |
- | make ARCH=architecture VERSION=version realclean | + | |
- | </ | + | |
- | + | ||
- | ==== DFLAGS Options ==== | + | |
- | + | ||
- | The following flags should be present (or not) in the arch file: | + | |
- | + | ||
- | === For parallel versions === | + | |
- | + | ||
- | | %%-D__parallel%% | + | |
- | | %%-D__BLACS%% | + | |
- | | %%-D__SCALAPACK%% | | + | |
- | + | ||
- | === If using libint (needed for HF exchange) === | + | |
- | + | ||
- | | %%-D__LIBINT%% | | + | |
- | + | ||
- | === For libxc (needed by QUICKSTEP DFT calculations) === | + | |
- | + | ||
- | | %%-D__LIBXC%% | | + | |
- | + | ||
- | === If using ELPA in space of '' | + | |
- | + | ||
- | | %%-D__ELPA%% | | + | |
- | + | ||
- | === Various FFTs === | + | |
- | + | ||
- | | %%-D__FFTSG%% | + | |
- | | %%-D__FFTW3%% | + | |
- | | %%-D__PW_CUDA%% | CUDA FFT and associated gather/ | + | |
- | + | ||
- | === Various compilers/ | + | |
- | + | ||
- | | %%-D__NAG%% | if using NAG F95 compiler | | + | |
- | | %%-D__AIX%% | if using AIX compiler | | + | |
- | | %%-D__ABSOFT%% | if using ABSoft compiler | | + | |
- | | %%-D__PGI%% | if using PGI compiler | | + | |
- | | %%-D__INTEL%% | if using Intel compiler | | + | |
- | | %%-D__GFORTRAN%% | if using GNU '' | + | |
- | | %%-D__G95%% | if using '' | + | |
- | | %%-D__SX%% | | | + | |
- | | %%-D__DEC%% | | | + | |
- | | %%-D__XT3%% | if compiling on a XT3 machine | | + | |
- | | %%-D__XT5%% | if compiling on a XT5 machine | | + | |
- | + | ||
- | === Various network interconnections === | + | |
- | + | ||
- | | %%-D__GEMINI%% | if Gemini interconnect is used in the cluster | | + | |
- | | %%-D__SEASTAR%% | if SeaStar interconnect is used in the cluster | | + | |
- | | %%-D__BLUEGENE%% | if BlueGene interconnect is used in the cluster | | + | |
- | | %%-D__NET%% | | | + | |
- | + | ||
- | Specific optimized core routines can be selected with | + | |
- | + | ||
- | | %%-D__GRID_CORE=X%% | | + | |
- | + | ||
- | with '' | + | |
- | + | ||
- | Tuned versions of integrate and collocate routines can be generated using | + | |
- | + | ||
- | | %%-D__HAS_LIBGRID%% | | + | |
- | + | ||
- | and '' | + | |
- | + | ||
- | | %%-D__PILAENV_BLOCKSIZE=1024%% | | + | |
- | + | ||
- | or similar is a hack to overwrite (if the linker allows this) the '' | + | |
- | + | ||
- | === Options controlling MPI behavior and capabilities === | + | |
- | + | ||
- | | %%-D__NO_MPI_THREAD_SUPPORT_CHECK%% | Workaround for MPI libraries that do not declare they are thread safe but you want to use them with OpenMP anyways. | | + | |
- | | %%-D__NO_MPI_MEMORY%% | Do not use MPI memory allocation/ | + | |
- | + | ||
- | === Options on language features === | + | |
- | + | ||
- | CP2K currently assumes full Fortran 95 compliance and expects the ISO_C_BINDING module of Fortran 2003 to be present, which commonly is available even in current compilers. For OpenMP, version 3.0 is assumed. | + | |
- | + | ||
- | If you get compilation errors about unsupported language features, then some flags may be used to reduce the language features required. | + | |
- | + | ||
- | In addition, some flags are used to declare compiler support for additional language features. | + | |
- | + | ||
- | == Subparts of Fortran 2003 or later that help various aspects of the code: == | + | |
- | + | ||
- | | %%-D__PTR_RANK_REMAP%% | compiler supports pointer rank remapping | | + | |
- | | %%-D__HAS_NO_ISO_C_BINDING%% | compiler does not support all needed ISO_C_BINDING features. (At least g95 0.91 silently fails with segfaults since it does not support C_F_POINTER.) | | + | |
- | + | ||
- | == Other language capabilities and support: == | + | |
- | + | ||
- | | %%-D__HAS_NO_OMP_3%% | CP2K assumes that compilers support OpenMP version 3. If this is not the case, specify this flag to compile. Runtime performance will be poorer on low number of processors. | | + | |
- | | %%-D__CRAY_POINTERS%% | Compiler supports CRAY pointers | | + | |
- | | %%-D__HAS_NO_CUDA_STREAM_PRIORITIES%% | Needed for CUDA sdk version < 5.5 | | + | |
- | + | ||
- | === Additional esoteric, development and debugging options === | + | |
- | + | ||
- | This section can be safely skipped over. Listed here just for completeness besides the flags described in this document. | + | |
- | + | ||
- | | %%-D__NO_STATH_ACCESS%% | Do not try to read from ''/ | + | |
- | | %%-D__mp_timeset__%% | Timing of MPI routines. | | + | |
- | | %%-D__USE_LEGACY_WEIGHTS%% | Use legacy atomic weights | | + | |
- | | %%-D__NO_ASSUMED_SIZE_NOCOPY_ASSUMPTION%% | Do not assume that assumed-size dummy arguments will always be passed in by reference. Unless the ISO_C_BINDINGS is present, CP2K will //not// compile with this option. | | + | |
- | | %%-D__cray_pointers%% | CRAY pointers will be used in preference to the ISO_C_BINDINGS call to MPI_ALLOC_MEM | | + | |
- | | %%-D__PLASMA%% | PLASMA support for DBCSR (neglected, may not work) | | + | |
- | | %%-D__USE_PAT%% | Use with CRAY-PAT profiling | | + | |
- | | %%-D__HMD%% | | | + | |
- | | %%-D__HPM%% | | | + | |
- | | %%-D_USE_GA%% | Use Global Arrays Toolkit | | + | |
- | + | ||
- | ===== Compiling Together With PLUMED v1.3 ===== | + | |
- | + | ||
- | - Get version 1.3 of '' | + | |
- | - Unpack the '' | + | |
- | - Set the environment variable '' | + | |
- | - Symbolic link the '' | + | |
- | - run the '' | + | |
- | - compile cp2k and plumed together with (it is safer to run a distclean before compiling): '' | + | |
- | + | ||
- | ===== Tests ===== | + | |
- | + | ||
- | If CP2K compiled okay, you can run one of the test cases to try out the executable (most inputs in any of the '' | + | |
- | + | ||
- | < | + | |
- | cd / | + | |
- | / | + | |
- | </ | + | |
- | + | ||
- | systematic testing can be done following the description on [[dev: | + | |
- | + | ||
- | + | ||
- | ===== Troubleshooting ===== | + | |
- | + | ||
- | * If things fail, take a break... have a look at section [[compile# | + | |
- | * If your compiler/ | + |
howto/compile.txt · Last modified: 2023/11/13 13:04 by oschuett