Compiling Qbics

Compiling Qbics

To compile Qbics, please follow the instructions step-by-step.

Fundamental Components

The following fundamental components are needed:

  • gcc, version > 9.3;
  • make, version > 3.8;
  • OpenMPI, version > 3.0, if OpenMPI is enabled;
  • nvcc, version > 11.0, if CUDA is enabled;

Third-party Libraries

Boost and Eigen

Boost and Eigen are two header-only libraries that do not need compilation. They can be obtained from:

After downloading the source files,use the following code to extract the boost and eigen library directory.

$ tar -xf boost_x_x_x.tar.gz
$ tar -xf eigen-x.x.x.tar.gz

After you decompress them, you will find directories named boost_x_x_x and eigen-x.x.x, respectively. Copy boost_x_x_x and eigen-x.x.x to a suitable path, say /home/zhang/libs. This will be value for $INCBOOST and $INCEIGEN in the corresponding Makefile.

Of course, if your system has already installed Boost and Eigen somewhere, just use those then.

libxc

libxc is a density functional library. It can be obtained from https://libxc.gitlab.io/download/. You can compile it using the following instructions:

$ tar -xzf libxc-x.x.x.tar.gz
$ cd libxc-x.x.x
$ mkdir bin
$ autoreconf -i            # Use "autoreconf -i" to generate the configure file.
$ ./configure --prefix=/home/zhang/libs/libxc
$ make
$ make install

Now, all libxc files are available in /home/zhang/libs/libxc.

Of course, if your system has already installed libxc somewhere, just use it then.

libfftw3

libfftw3 is an efficient library for fast Fourier transformation. It can be obtained from https://www.fftw.org/download.html. You can compile it using the following instructions:

$ tar -xzf fftw-x.x.x.tar.gz
$ cd fftw-x.x.x
$ ./configure --prefix=/home/zhang/libs/fftw --enable-openmp
$ make
$ make install

Now, all libfftw3 files are available in /home/zhang/libs/fftw.

Of course, if your system has already installed libfftw3 somewhere, just use it then.

dftd3-lib

dftd3-lib is a library for carrying out DFT-D3 calculations. It can be obtained from https://github.com/dftbplus/dftd3-lib. You can compile it using the following instructions:

$ unzip dftd3-lib-master.zip
$ cd dftd3-lib-master
$ make lib
$ cp lib /home/zhang/libs/dftd3-lib -r

Of course, if your system has already installed dftd3-lib somewhere, just use it then.

plumed

plumed is a library for enhanced sampling algorithms. It can be obtained from https://github.com/plumed/plumed2/releases/. You can compile it using the following instructions:

$ unzip plumed2-x.x.x.zip
$ cd plumed2-x.x.x
$ ./configure --prefix=/home/zhang/libs/plumed2 --disable-mpi --disable-external-lapack --disable-external-blas
$ make
$ make install

Of course, if your system has already installed plumed somewhere, just use it then.

Edit Makefile

After decompressing the source file archive, you can find several Makefiles:

Makefile-win-cpu Native Windows version, OpenMP parallelized.
Makefile-linux-cpu Linux version, OpenMP parallelized.
Makefile-linux-gpu Linux version, OpenMP parallelized, GPU enabled.

Open the suitable one, say Makefile-linux-cpu, you can find the following:

CODEINFO = -DCodeCommit="\"`git rev-parse D`\"" \
-DCodeFlag="\"official version\"" \
-DCodeMajorVer=0 \
-DCodeMinorVer=1 \
-DCodeUser="\"`whoami | sed 's/\\\\/\\\\\\\\/g'`\"" \
-DCodeMachine="\"`hostname`\"" \
-DCodeCompiler="\"`$(CXX) --version | head -n 1`"\" \
-DCodeCompFlags="\"$(CXXFLAG)"\" \
-DCodeLibs="\"$(LIBS)"\" \
-DOSLinux \
-DUseMPI \      #  If you want to enable parallelization with MPI in Qbics, add this parameter during compilation.
-DUseCUDA \      #  If you want to enable CUDA support in Qbics, add this parameter during compilation. 
-DNDEBUG

CXX     = g++
CXXFLAG = -O2 -fno-exceptions --std=c++17 -fopenmp -ffast-math -fno-finite-math-only -fexpensive-optimizations -Wall -mavx2 -mfma
CC      = gcc
CCFLAG  = -O2 -fopenmp -Wall
FC      = gfortran
FCFLAG  = -O2 -fopenmp -Wall
NCC     = nvcc
NCCFLAG = -O2 -use_fast_math -arch=compute_75 -code=sm_75

# Third-party library
LIBGNU    = -lgfortran -lquadmath -static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive
LIBXC     = /opt/libxc-5.2.3/lib/libxc.a
LIBFFTW3  = /opt/fftw-3.3.10/lib/libfftw3.a /opt/fftw-3.3.10/lib/libfftw3_omp.a
LIBDFTD   = /opt/dftd3-3.2/dftd3-lib-0.9/lib/libdftd3.a
LIBPLUMED   = /opt/plumed-2.9.1/lib/libplumed.a -lz -ldl
LIBCUDA   =
LIBSPONGE = 
LIBS      = $(LIBXC) $(LIBFFTW3) $(LIBDFTD) $(LIBPLUMED) $(LIBGNU)

# Third-party include
INCBOOST  = -I/opt/include/boost_1_78_0
INCEIGEN  = -I/opt/include/eigen-3.4.0
INCLIBXC  = -I/opt/libxc-5.2.3/include
INCFFTW3  = -I/opt/fftw-3.3.10/include
INCDFTD   = -I/opt/dftd3-3.2/dftd3-lib-0.9/lib
INCPLUMED   = -I/opt/plumed-2.9.1/include
INCCUDA   = -I/usr/local/cuda-11.4/targets/x86_64-linux/include
INCS      = $(INCBOOST) $(INCEIGEN) $(INCLIBXC) $(INCFFTW3) $(INCDFTD) $(INCPLUMED)
  • You can modify the macro CodeFlag to give the code a unique identifier.
  • You can change CXXFLAG, FCFLAG or NCCFLAG to add suitable optimization options according to your systems.
  • You should change LIBXC, INCBOOST, etc. to provide the correct paths of libraries and header files.

Compile

After editing your Makefile, say Makefile-linux-cpu, just run the following command:

$ make -f Makefile-linux-cpu -j

After a long time, everything is ready in bin. You can copy bin to anywhere you like.