User Tools

Site Tools


howto:compile

This is an old revision of the document!


How to compile the CP2K code

1. Acquire the code:

see http://www.cp2k.org/ The preferred method is to download it from the SVN

For the trunk (development) version:

svn checkout svn://svn.code.sf.net/p/cp2k/code/trunk cp2k

For released branch versions:

svn checkout svn://svn.code.sf.net/p/cp2k/code/branches/cp2k-2_5-branch cp2k

If SVN is not installed on your system get it at

http://subversion.apache.org/

2. Install Prerequisites

Sub-points here discuss prerequisites needed to build CP2K. Some of these can be conveniently installed by a script see: cp2k/tools/toolchain

2a. GNU make

GNU make should be on your system (gmake or make on linux) and used for the build, go to http://www.gnu.org/software/make/make.html download from http://ftp.gnu.org/pub/gnu/make/ also python (2.X) is required for building.

2b. Fortran and C Compiler

A Fortran 95 compiler and matching C compiler should be installed on your system. We have good experience with gcc/gfortran 4.6.X and above. Be aware that some compilers have bugs that might cause them to fail (internal compiler errors, segfaults) or, worse, yield a mis-compiled CP2K. Report bugs to compiler vendors; they (and we) have an interest in fixing them.

2c. BLAS and LAPACK

BLAS and LAPACK 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!

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 -D__MKL to ensure the code is thread-safe. MKL with multiple OpenMP threads in CP2K requires that CP2K was compiled with the Intel compiler (and -D__INTEL_COMPILER is defined if explicit pre-processing is performed using cpp instead of the compiler).

2d. MPI and SCALAPACK

MPI (version 2) and SCALAPACK are needed for parallel code. (Use the latest versions available and download all patches!) If your computing platform does not provide MPI, there are several freely available alternatives:

2e. FFTW

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 -D__FFTW3). http://www.fftw.org/

Note that FFTW must know the Fortran compiler you will use in order to install properly (e.g., export F77=gfortran before configure if you intend to use gfortran).

Note that on machines and compilers which support SSE you can configure FFTW3 with –enable-sse2. Compilers/systems that do not align memory (NAG f95, Intel IA32/gfortran) should either not use –enable-sse2 or otherwise set the define -D__FFTW3_UNALIGNED in the arch file. When building an OpenMP parallel version of CP2K (ssmp or psmp), the FFTW3 threading library libfftw3_threads (or libfftw3_omp) is required.

2f. LIBINT

Hartree-Fock exchange (optional, use -D__LIBINT) 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/hfx_tools/libint_tools/README_LIBINT Tested against libinit-1.1.4 and currently hardcoded to the default angular momentum LIBINT_MAX_AM 5 (check your include/libint/libint.h to see if it matches) http://www.chem.vt.edu/chem-dept/valeev/software/libint/libint.html

Note that you should NOT use libinit-1.1.3.

2g. libsmm (optional)

  • A library for small matrix multiplies can be built from the included source (see tools/build_libsmm/README). Usually only the double precision real and perhaps complex is needed. Link to the generated libraries.
  • Add -D__HAS_smm_dnn to the defines to make the code use the double precision real library. Similarly use -D__HAS_smm_snn for single precision real and -D__HAS_smm_znn / -D__HAS_smm_cnn for double / single precision complex.
  • Add -D__HAS_smm_vec to enable the new vectorized interfaces of libsmm.

2h. CUDA (optional)

  • (Experimental): Use the -D__DBCSR_ACC to compile with accelerator support support for matrix multiplication. For linking add -lcudart and -lrt to LIBS. The compiler must support ISO_C_BINDING.
  • Use -D__PW_CUDA for CUDA support for PW (gather/scatter/fft) calculations. The Fortran compiler must use an appended underscore for linking C subroutines.
  • USE -D__CUDA_PROFILING to turn on Nvidia Tools Extensions.

2i. Machine architecture abstraction (optional)

  • Use the -D__HWLOC or -D__LIBNUMA to compile with hwloc or libnuma support for machine architecture and process/threads/memory placement and visualization. It is necessary to link with -lhwloc or -lnuma. The compiler must support ISO_C_BINDING.
  • Machine architecture visualization is supported only with hwloc. Process/threads/memory placement and visualization is supported by both.
  • Note that it is not possible to use at same time hwloc and libnuma.
  • Consult cp2k/src/machine/README for more information.

2j. Process mapping (optional)

  • Use the target machine flag (see 3b) to compile with topology support.
  • The compiler must support ISO_C_BINDING.
  • Consult cp2k/src/machine/README for more information.
  • You can also define the strategy to be used using as a command line, with -mpi-mapping [1,2,3,4,5,6,7].
No. Strategy
1 SMP-style rank ordering
2 file based rank ordering
3 hilbert space-filling curve
4 peano space-fillinng curve
5 round-robin rank ordering
6 hilbert-peano
7 cannon pattern mapping

2k. libxc (optional)

  • The version 2.0.1 (or later) of libxc needs to be downloaded (http://www.tddft.org/programs/octopus/wiki/index.php/Libxc) and installed. During the installation, the directory $(LIBXC_DIR)/lib is created.
  • Add -D__LIBXC2 to DFLAGS and -L$(LIBXC_DIR)/lib -lxc to LIBS.
  • Add -D__LIBXC2 to DFLAGS and -L$(LIBXC_DIR)/lib -lxcf90 -lxc to LIBS for version 2.2.0.

2l. ELPA

Library ELPA for the solution of the eigenvalue problem

  • One version of ELPA need to be downloaded (http://elpa.rzg.mpg.de/software or directly http://elpa.rzg.mpg.de/elpa-tar-archive ) and installed. During the installation the libelpa.a (or libelpa_mt.a if omp active) is created. We tested the version of November 2013, with generic kernel and with/without omp
  • Add -D__ELPA to DFLAGS and -L$(ELPA_DIR) -lelpa to LIBS
  • ELPA replaces the ScaLapack SYEVD to improve the performance of the diagonalization
  • 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. Python

python 2.x is needed to run the dependency generator. On most system python is already installed. For more information visit: http://www.python.org/

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 cp2k/arch directories are tested on a daily basis).

>  cd ~/cp2k/tests/QS/
> ~/cp2k/exe/YOURMACHINE/cp2k.sopt C.inp

systematic regtesting is described here: http://cp2k.org/dev:regtesting

7. Talk to us

In any case please tell us your comments, praise, criticism, thanks, … you can send email to the people in the team: http://sourceforge.net/project/memberlist.php?group_id=614853

8. Manual

A reference manual of CP2K can be found on the web: http://manual.cp2k.org/ or can be generated using the cp2k executable, see http://manual.cp2k.org/trunk/generate_manual_howto.html

9. Happy computing!

The CP2K team.

howto/compile.1421618360.txt.gz · Last modified: 2020/08/21 10:15 (external edit)