Giter Club home page Giter Club logo

qmckl's Introduction

QMCkl: Quantum Monte Carlo Kernel Library

Build Status The domain of quantum chemistry needs a library in which the main kernels of Quantum Monte Carlo (QMC) methods are implemented. In the library proposed in this project, we expose the main algorithms in a simple language and provide a standard API and tests to enable the development of high-performance QMCkl implementations taking advantage of modern hardware.

See the source code to read the documentation.

To clone the repository, use:

git clone https://github.com/TREX-CoE/qmckl.git

Installation

The simplest way to obtain the source files of QMCkl is to download a source distribution. This particular repository is for maintainers, who write the kernels in org-mode files and produce the source code and the documentation from these files.

For maintainers

./autogen.sh
./configure --prefix=$PWD/_install

make
make check

A good practice is to make out-of-source builds, because you can easily find out what files have been produced by the build system, and you can also work with differently configured versions of the library at the same time.

For example, you can create a debug build compiled with gcc, and a fast build compiled with Intel compilers:

./autogen.sh

mkdir -p _build_gcc_debug/_install
cd _build_gcc_debug
../configure --enable-debug --prefix=$PWD/_install
make -j
make -j check

cd ..

mkdir -p _build_intel_fast/_install
cd _build_intel_fast
../configure --prefix=$PWD/_install --enable-hpc --with-icc --with-ifort 
make -j
make -j check

For users

Obtain a source distribution.

To build the documentation version:

./configure

To build an optimized version with Intel compilers:

./configure \
   --with-icc \
   --with-ifort \
   --enable-hpc 

To build an optimized version with GCC:

./configure \
  CC=gcc \
  CFLAGS="-g -O2 -march=native  -flto -fno-trapping-math -fno-math-errno -ftree-vectorize" \
  FC=gfortran \
  FCFLAGS="-g -O2 -march=native  -flto -ftree-vectorize" \
  --enable-hpc 

Then, compile with:

make -j
make -j check
sudo make install
sudo make installcheck

Python API

  • SWIG (>= 4.0) is required to build the Python API for maintainers

In order to install the qmckl Python package, first install the shared C library libqmckl following the installation guide above and then run the following command:

make python-install

To test the installation, run

make python-test

Minimal example demonstrating the use of the qmckl Python API can be found in the test_api.py file.

We highly recommend to use virtual environments to avoid compatibility issues and to improve reproducibility.

Installation procedure for Guix users

QMCkl can be installed with the GNU Guix functional package manager. The qmckl.scm Schema file contains the manifest specification for the qmckl installations. It can be installed within the selected $GUIX_PROFILE as follows:

guix package \
	--profile=$GUIX_PROFILE 		\
	--load-path=<path_to_trexio_scm> 	\
	--cores=<n_cores>			\
	--install-from-file=qmckl.scm

where <path_to_trexio_scm> should point to a folder, which contains the TREXIO manifest file trexio.scm (e.g. ~/trexio/tools/ if TREXIO repository was cloned under $HOME).

Installation procedures for both development version (qmckl-dev) and stable releases (qmckl-hpc) are provided. One can switch between them using the return value (last line) in the qmckl.scm file.

Linking to your program

The make install command takes care of installing the QMCkl shared library on the user machine. Once installed, add -lqmckl to the list of compiler options.

In some cases (e.g. when using custom prefix during configuration), the QMCkl library might end up installed in a directory, which is absent in the default $LIBRARY_PATH. In order to link the program against QMCkl, the search paths can be modified as follows:

export LIBRARY_PATH=$LIBRARY_PATH:<path_to_qmckl>/lib

(same holds for $LD_LIBRARY_PATH). The <path_to_qmckl> has to be replaced with the prefix used during the installation.

If your project relies on the CMake build system, feel free to use the FindQMCKL.cmake module to find and link the QMCkl library automatically.

Verificarlo CI

Since Verificarlo should not be a dependency of QMCkl, all Verificarlo functions are called only when the support is explicitely enabled (and ignored by the preprocessor otherwise). To enable vfc_ci support, the library should be configured with the following command :

./configure \
  CC="verificarlo-f" \
  FC="verificarlo-f" \
  --prefix=$PWD/_install \
  --enable-vfc_ci \
  --host=x86_64 \

where CC and FC are set to verificarlo-f, and support is explicitely enabled with the --enable-vfc_ci flag. Configuring the library with the "standard" command will cause all calls to Verificarlo related functions to be ignored, and the library will be built as usual.


European flag TREX: Targeting Real Chemical Accuracy at the Exascale project has received funding from the European Union’s Horizon 2020 - Research and Innovation program - under grant agreement no. 952165. The content of this document does not represent the opinion of the European Union, and the European Union is not responsible for any use that might be made of such content.

qmckl's People

Contributors

addman2 avatar gianfree avatar haampie avatar justemax avatar pablooliveira avatar purplepachyderm avatar q-posev avatar scemama avatar tgorni avatar v1j4y avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

qmckl's Issues

Jastrow Factor

Calculate the Jastrow factor and derivatives using a simple DGEMM formulation.

  • Build factor_ee
  • Build factor_en
  • Build factor_een
  • Build factor_ee_deriv_e
  • Build factor_en_deriv_e
  • Build factor_een_deriv_e

Mixed language compilation with `ifort` and `gcc`

While compiling fortran files with ifort the following FLAGS are needed:

FCFLAGS='-nofor-main -assume nounderscore'

The call to configure including the above options for developers would look like:

QMCKL_DEVEL=1 ./configure --enable-silent-rules --enable-maintainer-mode FC='ifort' FCFLAGS='-nofor-main -assume nounderscore'

Too big stack arrays in qmckl_compute_een_rescaled_e

Some compilers/systems are limiting stack size (beyond "ulimit -s").
About Intel compilers, limitation is 4 MB. That can be changed via the KMP_STACKSIZE env. variable, for instance using "10m" value for a 10 Megabytes limit.

source: https://community.intel.com/t5/Intel-Fortran-Compiler/Segmentation-fault-when-using-large-array-with-OpenMP/m-p/758829

bench_jastrow is segfaulting on the Alz_large dataset, more precisely on the een_rescaled_e_ij local stack array defined in the parallel region of the qmckl_compute_een_rescaled_e_hpc function.

A naive workaround consist in dynamically (heap) allocating that array (and then freeing it at the end of the scope). Maybe you could find a smarter fix...

Instead of
double een_rescaled_e_ij[len_een_ij];
I have succesfuly tested
double *een_rescaled_e_ij = malloc (len_een_ij * sizeof (een_rescaled_e_ij[0]));
...
free (een_rescaled_e_ij);

Probably better to use qmckl_malloc/free, if applicable.

Autogenerate c and fortran interface

The c and fortran inteface of qmckl can be set up to be autogenerated from the documentation of the functions.

There are multiple advantages of this strategy which are as follows:

  • Consistent interface generation
  • Consistent conventions of function names
  • Consistent conventions for arguments
  • Documentation is by construction up to date with the code
  • Users and developers are not required to write the interface thus reducing hand written lines of code

Some important points that need to be stressed while adopting this strategy are as follows:

  • New users and developers need to be introduced to the documentation procedure
  • A standard has to be clearly documented and defined

[WIP] electron nuclear distances

Write en-distances based on ee-distances already started.

  • Make sure build is working
  • Make sure testing is working
  • en distance implementation
  • Write tests

[WIP] Slater Determinant and Local Energy

TODO for calculating Kinetic Energy:

  • Implement determinant, adjoint, and inverse of the matrix
  • VGL of Determinant
  • Adjoint matrix
  • Inverse of Determinant
  • Kinetic energy
  • Potential energy
  • Local energy
  • Drift vector
  • Move
  • Acceptance probability

GPU library

TODO: Create a new repo containing all GPU functions. This will allow to configure and compile teh GPU functions with the best GPU compiler and keep the best CPU compiler for CPU functions.

munit alias

The following define statement can be added before including munit.h
#define MUNIT_ENABLE_ASSERT_ALIASES
in order to get rid of the munit_ prefix in munit_assert calls, e.g. assert_int instead of munit_assert_int

Non-uniform lists of arguments in the header file

In the generated qmckl.h header file the lists of arguments follow 3 different patterns (see below). It adds additional complexity to processing the header file by external tools (e.g. SWIG which parses the header file looking for certain patterns in the arguments lists).

Having arguments in one line is also good for grep-ing but might decrease the readability of the header file.

<func_name> (<type1>* <arg1>, ...)

<func_name> (<type1> * <arg1>, ...) (space between pointer and type declaration)

<func_name> (<type1> <arg1>,
             <type2> <arg2>,
                       ...
                      )

Sherman-Morrison-Woodbury

Integrate Sherman-Morrison-Woodbury into QMCkl

  • Basic integration of kernels (QMCkl compiles and kernels are callable from outside)
  • Complete basic requirements documentation
  • Add real tests
  • Add and complete documentation
  • Take care of compiler warnings

Ignore failures on docs generation

We should not require the make all to depend on building the html documentation files using htmlize.el. The reason is that it happens every now and then that the htmlize.el is not present and so each make attempt will try to download it (e.g. after make maintainer-clean). Several issues that I observed:

  1. No internet connection at build time: this is quite common (maybe remove htmlize.el from the files to be cleaned?)
  2. No access to git: in principal, it would be nice to decouple the build process from the git commands, see one of my last commits #85a0d485575e55b0a04a192331f37538e0ab5900 . For example. building Guix package from the GitHub repo fails exactly because of that (internal issue to clone the git submodule).

Compilation : User side improvement

Same issue as the one reported for TREXIO: TREX-CoE/trexio#62


  • Issue: Compilation fails with the following message

make[2]: *** No rule to make target 'share/qmckl/fortran/qmckl_f.f90', needed by 'src/qmckl_f.f90'. Stop.

  • Steps to reproduce

Clone the repository
git clone https://github.com/TREX-CoE/qmckl
configure
./autogen
./configure --without-trexio
Issue make command
make


Bug in `qmckl_get_ao_basis_nucleus_index` function

The function was not updated after transition to the new TREXIO basis set format and so it currently returns nucleus_index array of size nucleus_num instead of ao_basis_shell_num.

I can fix that one but now the tests have to be updated too.

MOs

TODO list for MOs

  • Implement native qmckl_dgemm
  • Implement MOs
  • Add tests

Fail: local_energy and det tests with `icc` and `ifort`

TLDR: Local energy and Determinant tests failing with icc and ifort

Configure command used:

./configure --prefix=$CONDA_PREFIX FC=ifort FCFLAGS='-g -xCORE-AVX2 -O3 ' CC='icc' CFLAGS='-g -xCORE-AVX2 -O3 -fno-omit-frame-pointer'

Summary of configuration:

CC..............: icc
CPPFLAGS........: 
CFLAGS..........: -g -xCORE-AVX2 -O3 -fno-omit-frame-pointer  
FC..............: ifort
FCLAGS..........: -g -xCORE-AVX2 -O3  -nofor-main
LDFLAGS:........: 
LIBS............: -lopenblas    -ltrexio -lpthread -lm 
USE CHAMELEON...: 
HPC version.....: no

Package features:
   trexio

Output running make check:

============================================================================
Testsuite summary for qmckl 0.1.1
============================================================================
# TOTAL: 16
# PASS:  14
# SKIP:  0
# XFAIL: 0
# FAIL:  2
# XPASS: 0
# ERROR: 0

Failing tests:

./tools/test-driver: line 107: 226043 Segmentation fault      (core dumped) "$@" > $log_file 2>&1
FAIL: tests/test_qmckl_determinant
...
./tools/test-driver: line 107: 226277 Segmentation fault      (core dumped) "$@" > $log_file 2>&1
FAIL: tests/test_qmckl_local_energy

Chameleon build options

Begin the Chameleon build of QMCkl. This implies extensive work to make it easy for the user to install QMCkl with Chameleon support.

  • Build with chameleon
  • Use chameleon via define flags
  • Example version of dgemm with chameleon

Improvements

  • README: out of source build
  • configure without swig

Confusion between main and master branches

Currently there are two principal branches: main and master.
It's not clear which one is the authoritative one. I suggest we pick one and stick with it.

The main branch seems to lag behind but some of the links still point to it. For example, the README.md in master branch documentation has links that point to the main branch instead.

What do you think @scemama ?

Thanks !

Verificarlo-CI -> org

Files in tools` directory should be put in org-mode files with documentation around.

FAIL : test_qmckl_local_energy

On latest master commit while using icc/ifort 2021.3 + -xCORE-AVX2 + fno-omit-frame-pointer
I tried to run test-driver directly but didn't manage to have it to work (was always missing one argument apparently ...).

Configure command used :
./configure --prefix=$PWD/_install CC=icc FC=ifort CFLAGS="-g -O2 -xCORE-AVX2 -fno-omit-frame-pointer" FCFLAGS="-cpp -g -O2 -xCORE-AVX2 -fno-omit-frame-pointer"

Resume :

qmckl Version 0.1.1  -- Developer mode

Prefix: '/home/kcamus/Trex/qmckl/qmckl/_install'.

CC..............: icc
CPPFLAGS........: 
CFLAGS..........: -g -O2 -xCORE-AVX2 -fno-omit-frame-pointer  
FC..............: ifort
FCLAGS..........: -cpp -g -O2 -xCORE-AVX2 -fno-omit-frame-pointer -nofor-main
LDFLAGS:........: 
LIBS............: -lopenblas -llapack -lopenblas   -ltrexio -lpthread -lm 
USE CHAMELEON...: 

Package features:
   trexio

Output extract when running make check (all others tests pass):

PASS: tests/test_qmckl_jastrow
./tools/test-driver: line 109: 541134 Segmentation fault      (core dumped) "$@" > $log_file 2>&1
FAIL: tests/test_qmckl_local_energy

Let me know if you need anything specific or if I need to try something.

Parallel make

With Nvidia compilers, fortran generates an internal compiler error. Dependencies in configure need to be checked.

Add argument to qmkl_malloc

An extra pointer argument to an abstract struct is needed to enable the possibility to pass infos to allocate memory on CPU or GPU, alignment, etc...

Build install issue

Try to fix build install fails in 4a63473

  • First make sure make install works
  • Make sure the make dist check works

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.