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

Before commencing the formal compilation process, you NEED to run the setvars.sh script located in the intel-oneapi directory to configure environmental support.

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.

OpenBLAS

OpenBLAS provides efficient matrix operations and vector processing capabilities, while also offering optimized implementations of functions defined in the BLAS and LAPACK interfaces. It can be obtained from https://github.com/OpenMathLib/OpenBLAS/releases/tag/v0.3.28. You can compile it using the following instructions:

$ tar -zxvf OpenBLAS-x.x.x.tar.gz
$ cd OpenBLAS-x.x.x
$ make
$ cp lib* /home/zhang/libs/OpenBLAS

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

xtb

xtb is primarily used in the field of computational chemistry, offering efficient methods for the calculation of molecules and materials, and supporting a variety of computational models. It can be obtained from https://github.com/grimme-lab/xtb/releases. You can compile it using the following instructions:

$ tar -xvf xtb-x.x.x.tar
$ cd xtb-x.x.x
$ cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=/home/zhang/libs/xtb
$ make install -C build -j

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

DL-FIND

DL-FIND is an open-source geometry optimization library designed for atomic simulation codes. It provides various optimization methods, including local minimization, transition state search, reaction path optimization, conical intersection optimization, and population-based global optimization. DL-FIND official website: https://chemshell.org/dl-find/.

$ tar -xvf dl-find-src.tar
$ cd dl-find-src
$ make -f Makefile.qbics

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 HEAD`\"" \
-DCodeFlag="\"beta testing\"" \
-DCodeMajorVer=0 \
-DCodeMinorVer=4 \
-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
-DEIGEN_USE_MKL_ALL

VERSION = linux-cpu

CXX     = g++
CXXFLAG = -O2 --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

# Third-party library
LIBGNU    = -lgfortran -lquadmath
LIBXC     = ../third-party/libxc-6.2.2/lib/libxc.a
LIBDFTD   = ../third-party/dftd3-0.9/libdftd3.a
LIBPLUMED   = ../third-party/plumed-2.9.2/lib/libplumed.a -lz -ldl
LIBFFTW3  = ../third-party/fftw-3.3.10/lib/libfftw3.a ../third-party/fftw-3.3.10/lib/libfftw3_omp.a
LIBXTB    = ../third-party/xtb-6.5.0/lib/libxtb.a ../third-party/xtb-6.5.0/lib/libmctc-lib.a 
LIBDLFIND    = ../third-party/dl-find/libdlf.a
LIBBLAS   = -L/opt/intel/oneapi/mkl/2021.4.0/lib/intel64 -Wl,--no-as-needed -lmkl_intel_lp64 -lmkl_gnu_thread
LIBCUDA   =
LIBSPONGE = 
LIBS      = $(LIBXC) $(LIBDFTD) $(LIBPLUMED) $(LIBFFTW3) $(LIBXTB) $(LIBDLFIND) $(LIBBLAS) $(LIBGNU)

# Third-party include
INCBOOST  = -I../third-party/boost_1_78_0
INCEIGEN  = -I../third-party/eigen-3.4.0
INCLIBXC  = -I../third-party/libxc-6.2.2/include
INCDFTD   = -I../third-party/dftd3-0.9
INCPLUMED   = -I../third-party/plumed-2.9.2/include
INCFFTW3  = -I../third-party/fftw-3.3.10/include
INCXTB    = -I../third-party/xtb-6.5.0/include
INCDLFIND    = -I../third-party/dl-find
INCBLAS   = -I/opt/intel/oneapi/mkl/2021.4.0/include
INCCUDA   = 
INCS      = $(INCLIBXC) $(INCDFTD) $(INCPLUMED) $(INCFFTW3) $(INCXTB) $(INCBLAS) $(INCBOOST) $(INCEIGEN)$(INCDLFIND)
  • 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.