1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-06-13 16:55:35 +02:00

Merge branch 'master' into trexio

This commit is contained in:
Anthony Scemama 2021-10-14 10:52:35 +02:00
commit c4467abb28
15 changed files with 891 additions and 725 deletions

View File

@ -14,20 +14,33 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: install dependencies
run: sudo apt-get install emacs autoconf
- name: Run test
- name: Install dependencies
run: sudo apt-get install emacs autoconf libhdf5-dev
- name: Install trexio
run: |
wget https://github.com/TREX-CoE/trexio/releases/download/v1.0/trexio-1.0.0.tar.gz
tar -zxf trexio-1.0.0.tar.gz
cd trexio-1.0.0
./configure --prefix=/usr
make -j 8
sudo make install
- name: Build
run: |
./autogen.sh
QMCKL_DEVEL=1 ./configure --enable-silent-rules --enable-maintainer-mode --enable-debug
make -j 8
- name: Run test
run: |
make -j check
make distcheck
ldd tests/test_qmckl_ao
- name: Archive test log file
uses: actions/upload-artifact@v2
with:
name: test-suite.log
name: test-report
path: test-suite.log
- name: Dist test
run: |
make distcheck
# x86_macos:
#
@ -41,6 +54,14 @@ jobs:
# brew install gfortran-10
# brew install emacs
# brew install autoconf automake libtool
# - name: install trexio
# run: |
# wget https://github.com/TREX-CoE/trexio/releases/download/v1.0/trexio-1.0.0.tar.gz
# tar -zxf trexio-1.0.0.tar.gz
# cd trexio-1.0.0
# ./configure
# make -j 8
# sudo make install
# - name: Run test
# run: |
# ./autogen.sh

51
.github/workflows/vfc_test_workflow.yml vendored Normal file
View File

@ -0,0 +1,51 @@
# This workflow will be executed when master is updated:
# it will run the configured tests and upload the results on vfc_ci_master.
name: "Verificarlo CI (master)"
on:
# Triggers the workflow when master is updated
push:
branches: [ master ]
workflow_dispatch:
jobs:
run_verificarlo_tests:
runs-on: ubuntu-latest
container: verificarlo/verificarlo
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install dependencies
run: |
ln -s /usr/bin/python3 /usr/bin/python
apt update
apt -y install emacs pkg-config
- name: Run tests
run: vfc_ci test -g -r
- name: Commit test results
run: |
git_hash=$(git rev-parse --short "$GITHUB_SHA")
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git checkout vfc_ci_master
mkdir -p vfcruns
mv *.vfcrun.h5 vfcruns
git add vfcruns/*
git commit -m "[auto] New test results for commit ${git_hash}"
git push
- name: Upload raw results as artifacts
uses: actions/upload-artifact@v2
with:
name: ${{github.sha}}.vfcraw
path: ./*.vfcraw.h5

3
.gitignore vendored
View File

@ -13,6 +13,8 @@ config.status
config.sub
configure
generated.mk
.vfcwrapper.o
libtool
m4/libtool.m4
m4/ltoptions.m4
m4/ltsugar.m4
@ -20,6 +22,7 @@ m4/ltversion.m4
m4/lt~obsolete.m4
qmckl-*.tar.gz
qmckl.mod
qmckl_probes_f.mod
qmckl.pc
stamp-h1
tools/compile

View File

@ -30,6 +30,9 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
if VFC_CI
AM_LDFLAGS=-lvfc_probes -lvfc_probes_f
endif
ACLOCAL_AMFLAGS = -I m4
@ -38,7 +41,7 @@ VERSION_MINOR = @VERSION_MINOR@
VERSION_PATCH = @VERSION_PATCH@
SUBDIRS =
CLEANFILES = qmckl.mod
CLEANFILES = qmckl.mod qmckl_probes_f.mod
EXTRA_DIST =
pkgconfigdir = $(libdir)/pkgconfig
@ -53,6 +56,8 @@ test_qmckl_fo = tests/qmckl_f.o
src_qmckl_f = src/qmckl_f.f90
src_qmckl_fo = src/qmckl_f.o
header_tests = tests/chbrclf.h tests/n2.h
qmckl_probes_src = src/qmckl_probes.h src/qmckl_probes.c src/qmckl_probes_f.f90
fortrandir = $(datadir)/qmckl/fortran/
@ -63,11 +68,11 @@ AM_CPPFLAGS += -DQMCKL_TEST_DIR="\"$(abs_srcdir)/share/qmckl/test_data/\""
lib_LTLIBRARIES = src/libqmckl.la
src_libqmckl_la_SOURCES = $(qmckl_h) $(src_qmckl_f) $(C_FILES) $(F_FILES) $(H_PRIVATE_FUNC_FILES) $(H_PRIVATE_TYPE_FILES) $(header_tests)
src_libqmckl_la_SOURCES = $(qmckl_h) $(src_qmckl_f) $(C_FILES) $(F_FILES) $(H_PRIVATE_FUNC_FILES) $(H_PRIVATE_TYPE_FILES) $(header_tests) $(qmckl_probes_src)
export qmckl_f qmckl_h srcdir
CLEANFILES+=$(test_qmckl_f) $(src_qmckl_f) $(test_qmckl_o) $(src_qmckl_o)
CLEANFILES+=$(test_qmckl_f) $(src_qmckl_f) $(test_qmckl_o) $(src_qmckl_o)
htmlize_el=$(srcdir)/share/doc/qmckl/html/htmlize.el
@ -94,6 +99,15 @@ $(src_qmckl_fo): $(src_qmckl_f)
$(src_qmckl_f): $(srcdir)/$(qmckl_f)
cp $(srcdir)/$(qmckl_f) $(src_qmckl_f)
src/qmckl_probes.c:
cp $(srcdir)/tools/qmckl_probes.c $(srcdir)/src/qmckl_probes.c
src/qmckl_probes.h:
cp $(srcdir)/tools/qmckl_probes.h $(srcdir)/src/qmckl_probes.h
src/qmckl_probes_f.f90:
cp $(srcdir)/tools/qmckl_probes_f.f90 $(srcdir)/src/qmckl_probes_f.f90
share/doc/qmckl/html/index.html: share/doc/qmckl/html/README.html
$(ln_s_verbose)cd share/doc/qmckl/html/ && \
rm -rf index.html && \
@ -112,7 +126,7 @@ dist_src_DATA = $(ORG_FILES) $(TANGLED_FILES) $(EXPORTED_FILES)
BUILT_SOURCES = $(C_FILES) $(F_FILES) $(FH_FUNC_FILES) $(FH_TYPE_FILES) $(H_FUNC_FILES) $(H_TYPE_FILES) $(H_PRIVATE_FUNC_FILES) $(H_PRIVATE_TYPE_FILES) $(qmckl_f) $(qmckl_h) $(header_tests)
CLEANFILES += $(BUILT_SOURCES) $(C_TEST_FILES) $(F_TEST_FILES) $(TANGLED_FILES) $(C_TEST_FILES) $(F_TEST_FILES) $(qmckl_f) $(qmckl_h) $(HTML_FILES) $(TEXT_FILES) share/doc/qmckl/html/index.html $(EXPORTED_FILES) $(header_tests)
CLEANFILES += $(BUILT_SOURCES) $(C_TEST_FILES) $(F_TEST_FILES) $(TANGLED_FILES) $(C_TEST_FILES) $(F_TEST_FILES) $(qmckl_f) $(qmckl_h) $(HTML_FILES) $(TEXT_FILES) share/doc/qmckl/html/index.html $(EXPORTED_FILES) $(header_tests)
EXTRA_DIST += \
$(srcdir)/tools/build_doc.sh \
@ -159,14 +173,14 @@ $(htmlize_el):
$(srcdir)/tools/install_htmlize.sh $(htmlize_el)
tests/chbrclf.h: $(qmckl_h)
tests/n2.h: $(qmckl_h)
generated.mk: $(ORG_FILES)
$(PYTHON) $(srcdir)/tools/build_makefile.py
cppcheck: cppcheck.out
cppcheck.out: $(qmckl_h)
cd src/ && \
cppcheck --addon=cert -q --error-exitcode=0 \

View File

@ -1,3 +1,5 @@
#+STARTUP: showeverything
* Set up CI on Travis
* Write tests
@ -19,3 +21,28 @@ context.
* Put pictures
* Make the Makefile part of the documented code ?
* Put the data-flow graph in the code.
* Verificarlo TODO
These are installation instructions for
verificarlo which needs to be moved to
an appropriate place at some point.
** Compilation and Testing
The following steps were required to get
the verificarlo version up and running on
an Ubuntu 20.04 laptop.
1. Compilers
a. clang - For e.g. clang-7
b. flang - For e.g. flang-7 : Care needs to be taken
that the flang version
is compatible with the
clang version used.
There are known issues
with using oneAPI due
to flang being incompatible
with oneAPI supplied clang.
c. gcc - For e.g. gcc-7
2. Environment varibales
a. VFC_BACKENDS - For e.g. `VFC_BACKENDS="libinterflop_ieee.so"`

18
ci_install.sh Executable file
View File

@ -0,0 +1,18 @@
#!/bin/bash
# This scripts is meant to be used by Verificarlo CI to automatically install
# the library dependencies and build it with Verificarlo with vfc_probes support
# enabled.
./autogen.sh
QMCKL_DEVEL=1 ./configure --prefix=$PWD/_install \
--enable-silent-rules --enable-maintainer-mode --enable-vfc_ci --host=x86_64 \
CC="verificarlo-f" FC="verificarlo-f"
make all
# Here we build the test suite, but expect it to fail because it is run without
# specifying VFC_BACKENDS. However, the generated executables will be reused
# individually by the CI.
make check
exit 0

View File

@ -185,7 +185,7 @@ AC_TYPE_UINT64_T
# Checks for library functions.
## qmckl
AC_FUNC_MALLOC
# AC_FUNC_MALLOC
AC_CHECK_FUNCS([memset strerror])
# Development mode
@ -214,6 +214,29 @@ if test "x${QMCKL_DEVEL}" != "x"; then
fi
# Enable Verificarlo tests
AC_ARG_ENABLE([vfc_ci],
[ --enable-vfc_ci Build the library with vfc_ci support],
[case "${enableval}" in
yes) vfc_ci=true && FCFLAGS="-D VFC_CI $FCFLAGS" && CFLAGS="-D VFC_CI $CFLAGS";;
no) vfc_ci=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable_vfc_ci]) ;;
esac],[vfc_ci=false])
AM_CONDITIONAL([VFC_CI], [test x$vfc_ci = xtrue])
# Enable Fortran preprocessor
if test "$FC" = "gfortran"; then
AC_MSG_NOTICE(gfortran detected)
# Arguments order is important here
FCFLAGS="-cpp $FCFLAGS"
fi
if test "$FC" = "verificarlo-f"; then
AC_MSG_NOTICE(verificarlo-f detected)
# Arguments order is important here
FCFLAGS="-Mpreprocess $FCFLAGS"
fi
#PKG-CONFIG
#mkl-dynamic-lp64-seq
@ -256,4 +279,3 @@ where the optional <target> is:
check - run tests
install - install ${PACKAGE_NAME}
--------------------------------------------------"

View File

@ -256,6 +256,53 @@ cppcheck --addon=cert --enable=all *.c &> cppcheck.out
functions will use the precision specified in the =context=
variable.
In order to automatize numerical accuracy tests, QMCkl uses
[[https://github.com/verificarlo/verificarlo][Verificarlo]] and
its CI functionality. You can read Verificarlo CI's documentation
at the [[https://github.com/verificarlo/verificarlo/blob/master/doc/06-Postprocessing.md#verificarlo-ci][following link]].
Reading it is advised to understand the remainder of this section.
To enable support for Verificarlo CI tests when building the
library, use the following configure command :
#+begin_src bash
QMCKL_DEVEL=1 ./configure --prefix=$PWD/_install --enable-silent-rules --enable-maintainer-mode CC=verificarlo-f FC=verificarlo-f --host=x86_64 --enable-vfc_ci
#+end_src
Note that this does require an install of Verificarlo *with
Fortran support*. Enabling the support for CI will define the
~VFC_CI~ preprocessor variable which use will be explained now.
As explained in the documentation, Verificarlo CI uses a probes
system to export variables from test programs to the tools itself.
To make tests easier to use, QMCkl has its own interface to the
probes system. To make the system very easy to use, these functions
are always defined, but will behave differently depending on the
~VFC_CI~ preprocessor variable. There are 3 functions at your
disposal. When the CI is enabled, they will place a ~vfc_ci~ probe
as if calling ~vfc_probes~ directly. Otherwise, they will either do
nothing or perform a check on the tested value and return its result
as a boolean that you are free to use or ignore.
Here are these 3 functions :
- ~qmckl_probe~ : place a normal probe witout any check. Won't do anything when ~vfc_ci~ is disabled (false is returned).
- ~qmckl_probe_check~ : place a probe with an absolute check. If ~vfc_ci~ is disabled, this will return the result of an absolute check (|val - ref| < accuracy target ?). If the check fails, true is returned (false otherwise).
- ~qmckl_probe_check_relative~ : place a probe with a relative check. If ~vfc_ci~ is disabled, this will return the result of a relative check (|val - ref| / ref < accuracy target?). If the check fails, true is returned (false otherwise).
If you need more details on these functions or their Fortran
interfaces, have a look at the ~tools/qmckl_probes~ files.
Finally, if you need to add a QMCkl kernel to the CI tests
or modify an existing one, you should pay attention to the
following points :
- you should add the new kernel to the ~vfc_tests_config.json~ file, which controls the backends and repetitions for each executable. More details can be found in the ~vfc_ci~ documentation.
- in order to call the ~qmckl_probes~ functions from Fortran, import the ~qmckl_probes_f~ module.
- if your tests include some asserts that rely on accurate FP values, you should probably wrap them inside a ~#ifndef VFC_CI~ statement, as the asserts would otherwise risk to fail when executed with the different Verificarlo backends.
** Algorithms
Reducing the scaling of an algorithm usually implies also reducing
@ -264,4 +311,3 @@ cppcheck --addon=cert --enable=all *.c &> cppcheck.out
algorithms are better adapted than linear scaling algorithms. As
QMCkl is a general purpose library, multiple algorithms should be
implemented adapted to different problem sizes.

File diff suppressed because it is too large Load Diff

View File

@ -12,6 +12,7 @@ Functions for the computation of distances between particles.
#+begin_src c :comments link :tangle (eval c_test) :noweb yes
#include "qmckl.h"
#include "assert.h"
#include <stdio.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@ -19,6 +20,7 @@ int main() {
qmckl_context context;
context = qmckl_context_create();
#+end_src
* Squared distance
@ -282,10 +284,17 @@ end function qmckl_distance_sq_f
*** Test :noexport:
#+begin_src f90 :tangle (eval f_test)
integer(qmckl_exit_code) function test_qmckl_distance_sq(context) bind(C)
use qmckl
use qmckl_probes_f
use iso_c_binding
implicit none
integer(qmckl_context), intent(in), value :: context
logical(C_BOOL) :: vfc_err
double precision, allocatable :: A(:,:), B(:,:), C(:,:)
integer*8 :: m, n, LDA, LDB, LDC
@ -299,7 +308,6 @@ integer(qmckl_exit_code) function test_qmckl_distance_sq(context) bind(C)
LDC = 5
allocate( A(LDA,m), B(LDB,n), C(LDC,n) )
do j=1,m
do i=1,m
A(i,j) = -10.d0 + dble(i+j)
@ -314,17 +322,26 @@ integer(qmckl_exit_code) function test_qmckl_distance_sq(context) bind(C)
test_qmckl_distance_sq = &
qmckl_distance_sq(context, 'X', 't', m, n, A, LDA, B, LDB, C, LDC)
vfc_err = qmckl_probe("distance"//C_NULL_CHAR, "distance_sq_Xt_2_2"//C_NULL_CHAR, DBLE(C(2,2)))
if (test_qmckl_distance_sq == 0) return
test_qmckl_distance_sq = &
qmckl_distance_sq(context, 't', 'X', m, n, A, LDA, B, LDB, C, LDC)
vfc_err = qmckl_probe("distance"//C_NULL_CHAR, "distance_sq_tX_2_2"//C_NULL_CHAR, DBLE(C(2,2)))
if (test_qmckl_distance_sq == 0) return
test_qmckl_distance_sq = &
qmckl_distance_sq(context, 'T', 't', m, n, A, LDA, B, LDB, C, LDC)
if (test_qmckl_distance_sq /= 0) return
vfc_err = qmckl_probe_check("distance"//C_NULL_CHAR, "distance_sq_Tt_2_2"//C_NULL_CHAR, DBLE(C(2,2)), DBLE(0), DBLE(1.d-14))
if (test_qmckl_distance_sq == 0) return
test_qmckl_distance_sq = QMCKL_FAILURE
@ -333,14 +350,17 @@ integer(qmckl_exit_code) function test_qmckl_distance_sq(context) bind(C)
x = (A(i,1)-B(j,1))**2 + &
(A(i,2)-B(j,2))**2 + &
(A(i,3)-B(j,3))**2
if ( dabs(1.d0 - C(i,j)/x) > 1.d-14 ) return
#ifndef VFC_CI
if ( dabs(1.d0 - C(i,j)/x) > 1.d-14) return
#endif
end do
end do
test_qmckl_distance_sq = &
qmckl_distance_sq(context, 'n', 'T', m, n, A, LDA, B, LDB, C, LDC)
if (test_qmckl_distance_sq /= 0) return
vfc_err = qmckl_probe_check("distance"//C_NULL_CHAR, "distance_sq_nT_2_2"//C_NULL_CHAR, DBLE(C(2,2)), DBLE(0), DBLE(1.d-14))
test_qmckl_distance_sq = QMCKL_FAILURE
@ -349,14 +369,18 @@ integer(qmckl_exit_code) function test_qmckl_distance_sq(context) bind(C)
x = (A(1,i)-B(j,1))**2 + &
(A(2,i)-B(j,2))**2 + &
(A(3,i)-B(j,3))**2
if ( dabs(1.d0 - C(i,j)/x) > 1.d-14 ) return
#ifndef VFC_CI
if ( dabs(1.d0 - C(i,j)/x) > 1.d-14) return
#endif
end do
end do
test_qmckl_distance_sq = &
qmckl_distance_sq(context, 'T', 'n', m, n, A, LDA, B, LDB, C, LDC)
if (test_qmckl_distance_sq /= 0) return
vfc_err = qmckl_probe_check("distance"//C_NULL_CHAR, "distance_sq_Tn_2_2"//C_NULL_CHAR, DBLE(C(2,2)), DBLE(0), DBLE(1.d-14))
if (test_qmckl_distance_sq == 0) return
test_qmckl_distance_sq = QMCKL_FAILURE
@ -365,14 +389,16 @@ integer(qmckl_exit_code) function test_qmckl_distance_sq(context) bind(C)
x = (A(i,1)-B(1,j))**2 + &
(A(i,2)-B(2,j))**2 + &
(A(i,3)-B(3,j))**2
if ( dabs(1.d0 - C(i,j)/x) > 1.d-14 ) return
#ifndef VFC_CI
if ( dabs(1.d0 - C(i,j)/x) > 1.d-14) return
#endif
end do
end do
test_qmckl_distance_sq = &
qmckl_distance_sq(context, 'n', 'N', m, n, A, LDA, B, LDB, C, LDC)
if (test_qmckl_distance_sq /= 0) return
vfc_err = qmckl_probe_check("distance"//C_NULL_CHAR, "distance_sq_nN_2_2"//C_NULL_CHAR, DBLE(C(2,2)), DBLE(0), DBLE(1.d-14))
test_qmckl_distance_sq = QMCKL_FAILURE
@ -392,8 +418,8 @@ end function test_qmckl_distance_sq
#+end_src
#+begin_src c :comments link :tangle (eval c_test)
qmckl_exit_code test_qmckl_distance_sq(qmckl_context context);
assert(test_qmckl_distance_sq(context) == QMCKL_SUCCESS);
qmckl_exit_code test_qmckl_distance_sq(qmckl_context context);
assert(test_qmckl_distance_sq(context) == QMCKL_SUCCESS);
#+end_src
* Distance
@ -690,10 +716,17 @@ end function qmckl_distance_f
*** Test :noexport:
#+begin_src f90 :tangle (eval f_test)
integer(qmckl_exit_code) function test_qmckl_dist(context) bind(C)
use qmckl
use qmckl_probes_f
use iso_c_binding
implicit none
integer(qmckl_context), intent(in), value :: context
logical(C_BOOL) :: vfc_err
double precision, allocatable :: A(:,:), B(:,:), C(:,:)
integer*8 :: m, n, LDA, LDB, LDC
@ -722,17 +755,24 @@ integer(qmckl_exit_code) function test_qmckl_dist(context) bind(C)
test_qmckl_dist = &
qmckl_distance(context, 'X', 't', m, n, A, LDA, B, LDB, C, LDC)
vfc_err = qmckl_probe("distance"//C_NULL_CHAR, "distance_Xt_2_2"//C_NULL_CHAR, DBLE(C(2,2)))
if (test_qmckl_dist == 0) return
test_qmckl_dist = &
qmckl_distance(context, 't', 'X', m, n, A, LDA, B, LDB, C, LDC)
vfc_err = qmckl_probe("distance"//C_NULL_CHAR, "distance_tX_2_2"//C_NULL_CHAR, DBLE(C(2,2)))
if (test_qmckl_dist == 0) return
test_qmckl_dist = &
qmckl_distance(context, 'T', 't', m, n, A, LDA, B, LDB, C, LDC)
if (test_qmckl_dist /= 0) return
vfc_err = qmckl_probe_check("distance"//C_NULL_CHAR, "distance_Tt_2_2"//C_NULL_CHAR, DBLE(C(2,2)), DBLE(0), DBLE(1.d-14))
if (test_qmckl_dist == 0) return
test_qmckl_dist = QMCKL_FAILURE
@ -741,14 +781,19 @@ integer(qmckl_exit_code) function test_qmckl_dist(context) bind(C)
x = dsqrt((A(i,1)-B(j,1))**2 + &
(A(i,2)-B(j,2))**2 + &
(A(i,3)-B(j,3))**2)
if ( dabs(1.d0 - C(i,j)/x) > 1.d-14 ) return
#ifndef VFC_CI
if ( dabs(1.d0 - C(i,j)/x) > 1.d-14) return
#endif
end do
end do
test_qmckl_dist = &
qmckl_distance(context, 'n', 'T', m, n, A, LDA, B, LDB, C, LDC)
if (test_qmckl_dist /= 0) return
vfc_err = qmckl_probe_check("distance"//C_NULL_CHAR, "distance_nT_2_2"//C_NULL_CHAR, DBLE(C(2,2)), DBLE(0), DBLE(1.d-14))
if (test_qmckl_dist == 0) return
test_qmckl_dist = QMCKL_FAILURE
@ -757,14 +802,19 @@ integer(qmckl_exit_code) function test_qmckl_dist(context) bind(C)
x = dsqrt((A(1,i)-B(j,1))**2 + &
(A(2,i)-B(j,2))**2 + &
(A(3,i)-B(j,3))**2)
if ( dabs(1.d0 - C(i,j)/x) > 1.d-14 ) return
#ifndef VFC_CI
if ( dabs(1.d0 - C(i,j)/x) > 1.d-14) return
#endif
end do
end do
test_qmckl_dist = &
qmckl_distance(context, 'T', 'n', m, n, A, LDA, B, LDB, C, LDC)
if (test_qmckl_dist /= 0) return
vfc_err = qmckl_probe_check("distance"//C_NULL_CHAR, "distance_Tn_2_2"//C_NULL_CHAR, DBLE(C(2,2)), DBLE(0), DBLE(1.d-14))
if (test_qmckl_dist == 0) return
test_qmckl_dist = QMCKL_FAILURE
@ -773,14 +823,19 @@ integer(qmckl_exit_code) function test_qmckl_dist(context) bind(C)
x = dsqrt((A(i,1)-B(1,j))**2 + &
(A(i,2)-B(2,j))**2 + &
(A(i,3)-B(3,j))**2)
if ( dabs(1.d0 - C(i,j)/x) > 1.d-14 ) return
#ifndef VFC_CI
if ( dabs(1.d0 - C(i,j)/x) > 1.d-14) return
#endif
end do
end do
test_qmckl_dist = &
qmckl_distance(context, 'n', 'N', m, n, A, LDA, B, LDB, C, LDC)
if (test_qmckl_dist /= 0) return
vfc_err = qmckl_probe_check("distance"//C_NULL_CHAR, "distance_nN_2_2"//C_NULL_CHAR, DBLE(C(2,2)), DBLE(0), DBLE(1.d-14))
if (test_qmckl_dist == 0) return
test_qmckl_dist = QMCKL_FAILURE
@ -789,7 +844,9 @@ integer(qmckl_exit_code) function test_qmckl_dist(context) bind(C)
x = dsqrt((A(1,i)-B(1,j))**2 + &
(A(2,i)-B(2,j))**2 + &
(A(3,i)-B(3,j))**2)
if ( dabs(1.d0 - C(i,j)/x) > 1.d-14 ) return
#ifndef VFC_CI
if ( dabs(1.d0 - C(i,j)/x) > 1.d-14) return
#endif
end do
end do
@ -800,8 +857,8 @@ end function test_qmckl_dist
#+end_src
#+begin_src c :comments link :tangle (eval c_test)
qmckl_exit_code test_qmckl_dist(qmckl_context context);
assert(test_qmckl_dist(context) == QMCKL_SUCCESS);
qmckl_exit_code test_qmckl_dist(qmckl_context context);
assert(test_qmckl_dist(context) == QMCKL_SUCCESS);
#+end_src
* Rescaled Distance
@ -1114,12 +1171,12 @@ end function qmckl_distance_rescaled_f
:FRetType: qmckl_exit_code
:END:
~qmckl_distance_rescaled_deriv_e~ computes the matrix of the gradient and laplacian of the
~qmckl_distance_rescaled_deriv_e~ computes the matrix of the gradient and laplacian of the
rescaled distance with respect to the electron coordinates. The derivative is a rank 3 tensor.
The first dimension has a dimension of 4 of which the first three coordinates
contains the gradient vector and the last index is the laplacian.
\[
C_{ij} = \left( 1 - \exp{-\kappa C_{ij}}\right)/\kappa
\]
@ -1130,12 +1187,12 @@ end function qmckl_distance_rescaled_f
\nabla (C_{ij}(\mathbf{r}_{ee})) = \left(\frac{\delta C_{ij}(\mathbf{r}_{ee})}{\delta x},\frac{\delta C_{ij}(\mathbf{r}_{ee})}{\delta y},\frac{\delta C_{ij}(\mathbf{r}_{ee})}{\delta z} \right)
\]
and the laplacian is defined as follows:
\[
\triangle (C_{ij}(r_{ee})) = \frac{\delta^2}{\delta x^2} + \frac{\delta^2}{\delta y^2} + \frac{\delta^2}{\delta z^2}
\]
Using the above three formulae, the expression for the gradient and laplacian is
Using the above three formulae, the expression for the gradient and laplacian is
as follows:
\[
@ -1462,7 +1519,9 @@ end function qmckl_distance_rescaled_deriv_e_f
* End of files :noexport:
#+begin_src c :comments link :tangle (eval c_test)
assert (qmckl_context_destroy(context) == QMCKL_SUCCESS);
return 0;
}

File diff suppressed because one or more lines are too long

141
tools/qmckl_probes.c Normal file
View File

@ -0,0 +1,141 @@
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#ifdef VFC_CI
#include <vfc_probes.h>
vfc_probes probes;
#endif
// QMCkl is a wrapper to Verificarlo's vfc_probes system. The goal of QMCkl
// probes isto simplify the use of vfc_probes, and to provide functions that
// can be called either wit or without vfc_ci support by using #ifndef
// statements :
//
// - when vfc_ci is disabled, qmckl_probes functions will either return false
// (no error) or perform a check based on a reference value
// - when vfc_ci is enabled, qmckl_probe functions will simply encapsulate
// calls to vfc_probe
//
// Moreover, one does not have to worry about the life cycle of the probes
// structure, as it is automatically created, dumped and freed by this wrapper.
//
// vfc_ci support can be enabled by using the following configure command :
// QMCKL_DEVEL=1 ./configure --prefix=$PWD/_install --enable-silent-rules
// --enable-maintainer-mode CC=verificarlo-f FC=verificarlo-f --host=x86_64
//
// Finally, this wrapper also comes with a Fortran interface (in its dedicated
// file).
//
// To learn more about Verificarlo CI :
// https://github.com/verificarlo/verificarlo/blob/master/doc/06-Postprocessing.md#verificarlo-ci
// Automatically initialize the vfc_probe object if VFC_CI is defined
#ifdef VFC_CI
void __attribute__((constructor)) qmckl_init_probes(){
probes = vfc_init_probes();
}
#endif
// Standard probe, without check
// - if VFC_CI is defined, place a standard probe
// - if VFC_CI is undefined, return false (no error)
bool qmckl_probe(
char * testName,
char * varName,
double value
) {
#ifdef VFC_CI
return vfc_probe(&probes, testName, varName, value);
#else
return false;
#endif
}
// Probe with absolute check
// - if VFC_CI is defined, place a probe with an absolute check
// - if VFC_CI is undefined, perform an absolute check based on target value
// and accuracy
bool qmckl_probe_check(
char * testName,
char * varName,
double value,
double expectedValue,
double accuracyTarget
) {
#ifdef VFC_CI
return vfc_probe_check(&probes, testName, varName, value, accuracyTarget);
#else
return !(abs(value - expectedValue) < accuracyTarget);
#endif
}
// Probe with relative check
// - if VFC_CI is defined, place a probe with a relative check
// - if VFC_CI is undefined, perform a relative check based on target value
// and accuracy
bool qmckl_probe_check_relative (
char * testName,
char * varName,
double value,
double expectedValue,
double accuracyTarget
) {
#ifdef VFC_CI
return vfc_probe_check_relative(&probes, testName, varName, value, accuracyTarget);
#else
return !(abs(value - expectedValue) / abs(expectedValue) < accuracyTarget);
#endif
}
// Automatically delete and dump the vfc_probe object if VFC_CI is defined
#ifdef VFC_CI
void __attribute__((destructor)) qmckl_dump_probes(){
vfc_dump_probes(&probes);
}
#endif
// Fortran wrappers
bool qmckl_probe_f(
char * testName,
char * varName,
double * value
) {
return qmckl_probe(testName, varName, *value);
}
bool qmckl_probe_check_f(
char * testName,
char * varName,
double * value,
double * expectedValue,
double * accuracyTarget
) {
return qmckl_probe_check(
testName, varName,
*value, *expectedValue, *accuracyTarget
);
}
bool qmckl_probe_check_relative_f(
char * testName,
char * varName,
double * value,
double * expectedValue,
double * accuracyTarget
) {
return qmckl_probe_check_relative(
testName, varName,
*value, *expectedValue, *accuracyTarget
);
}

65
tools/qmckl_probes.h Normal file
View File

@ -0,0 +1,65 @@
#include <stdbool.h>
#ifdef VFC_CI
#include <vfc_probes.h>
extern vfc_probes * probes;
#endif
// Wrappers to Verificarlo functions
#ifdef VFC_CI
void qmckl_init_probes() __attribute__((constructor));
#endif
bool qmckl_probe(
char * testName,
char * varName,
double value
);
bool qmckl_probe_check(
char * testName,
char * varName,
double value,
double expectedValue,
double accuracyTarget
);
bool qmckl_probe_check_relative(
char * testName,
char * varName,
double value,
double expectedValue,
double accuracyTarget
);
#ifdef VFC_CI
void qmckl_dump_probes() __attribute__((destructor));
#endif
// Fortran wrappers
bool qmckl_probe_f(
char * testName,
char * varName,
double * value
);
bool qmckl_probe_check_f(
char * testName,
char * varName,
double * value,
double * expectedValue,
double * accuracyTarget
);
bool qmckl_probe_check_relative_f(
char * testName,
char * varName,
double * value,
double * expectedValue,
double * accuracyTarget
);

49
tools/qmckl_probes_f.f90 Normal file
View File

@ -0,0 +1,49 @@
module qmckl_probes_f
interface
logical(c_bool) function qmckl_probe &
(testName, varName, val) &
bind(C, name="qmckl_probe_f")
use, intrinsic :: iso_c_binding
import
implicit none
character(C_CHAR), dimension(*) :: testName
character(C_CHAR), dimension(*) :: varName
real(C_DOUBLE) :: val
end function qmckl_probe
logical(c_bool) function qmckl_probe_check &
(testName, varName, val, expectedValue, accuracyTarget) &
bind(C, name="qmckl_probe_check_f")
use, intrinsic :: iso_c_binding
import
implicit none
character(C_CHAR), dimension(*) :: testName
character(C_CHAR), dimension(*) :: varName
real(C_DOUBLE) :: val
real(C_DOUBLE) :: expectedValue
real(C_DOUBLE) :: accuracyTarget
end function qmckl_probe_check
logical(c_bool) function qmckl_probe_check_relative &
(testName, varName, val, expectedValue, accuracyTarget) &
bind(C, name="qmckl_probe_check_relative_f")
use, intrinsic :: iso_c_binding
import
implicit none
character(C_CHAR), dimension(*) :: testName
character(C_CHAR), dimension(*) :: varName
real(C_DOUBLE) :: val
real(C_DOUBLE) :: expectedValue
real(C_DOUBLE) :: accuracyTarget
end function qmckl_probe_check_relative
end interface
end module qmckl_probes_f

19
vfc_tests_config.json Normal file
View File

@ -0,0 +1,19 @@
{
"make_command": "./ci_install.sh",
"executables": [
{
"executable": "tests/test_qmckl_distance",
"vfc_backends": [{
"name": "libinterflop_mca.so",
"repetitions": 25
}]
},
{
"executable": "tests/test_qmckl_ao",
"vfc_backends": [{
"name": "libinterflop_mca.so",
"repetitions": 25
}]
}
]
}