mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2024-12-23 04:44:03 +01:00
Merge pull request #27 from PurplePachyderm/master
Integration of Verificarlo CI
This commit is contained in:
commit
8d190de55a
51
.github/workflows/vfc_test_workflow.yml
vendored
Normal file
51
.github/workflows/vfc_test_workflow.yml
vendored
Normal 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
3
.gitignore
vendored
@ -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
|
||||
|
18
Makefile.am
18
Makefile.am
@ -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)/$(PACKAGE_NAME)/fortran/
|
||||
dist_fortran_DATA = $(qmckl_f)
|
||||
@ -60,7 +65,7 @@ dist_fortran_DATA = $(qmckl_f)
|
||||
AM_CPPFLAGS = -I$(srcdir)/src -I$(srcdir)/include
|
||||
|
||||
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
|
||||
|
||||
@ -91,6 +96,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 && \
|
||||
|
27
TODO.org
27
TODO.org
@ -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
18
ci_install.sh
Executable 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
|
26
configure.ac
26
configure.ac
@ -167,7 +167,7 @@ AC_TYPE_UINT64_T
|
||||
# Checks for library functions.
|
||||
|
||||
## qmckl
|
||||
AC_FUNC_MALLOC
|
||||
# AC_FUNC_MALLOC
|
||||
AC_CHECK_FUNCS([memset strerror])
|
||||
|
||||
# Development mode
|
||||
@ -196,6 +196,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
|
||||
|
||||
@ -237,4 +260,3 @@ where the optional <target> is:
|
||||
check - run tests
|
||||
install - install ${PACKAGE_NAME}
|
||||
--------------------------------------------------"
|
||||
|
||||
|
@ -30,10 +30,6 @@
|
||||
/* Define to 1 if you have the `pthread' library (-lpthread). */
|
||||
#undef HAVE_LIBPTHREAD
|
||||
|
||||
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
|
||||
to 0 otherwise. */
|
||||
#undef HAVE_MALLOC
|
||||
|
||||
/* Define to 1 if you have the <malloc.h> header file. */
|
||||
#undef HAVE_MALLOC_H
|
||||
|
||||
@ -145,9 +141,6 @@
|
||||
such a type exists and the standard includes do not define it. */
|
||||
#undef int64_t
|
||||
|
||||
/* Define to rpl_malloc if the replacement function should be used. */
|
||||
#undef malloc
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
#undef size_t
|
||||
|
||||
|
@ -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.
|
||||
|
||||
|
@ -1745,9 +1745,12 @@ end function qmckl_ao_gaussian_vgl
|
||||
#+begin_src f90 :tangle (eval f_test)
|
||||
integer(c_int32_t) function test_qmckl_ao_gaussian_vgl(context) bind(C)
|
||||
use qmckl
|
||||
use qmckl_probes_f
|
||||
|
||||
implicit none
|
||||
|
||||
integer(c_int64_t), intent(in), value :: context
|
||||
logical(C_BOOL) :: vfc_err
|
||||
|
||||
integer*8 :: n, ldv, j, i
|
||||
double precision :: X(3), R(3), Y(3), r2
|
||||
@ -1756,6 +1759,13 @@ integer(c_int32_t) function test_qmckl_ao_gaussian_vgl(context) bind(C)
|
||||
|
||||
epsilon = qmckl_get_numprec_epsilon(context)
|
||||
|
||||
#ifdef VFC_CI
|
||||
! Multplying epsilon by 16 = 2^4 is equivalent to asking 4 significant digits
|
||||
! less. This makes sense because we are adding noise with MCA so we can't be
|
||||
! as strict on the accuracy target.
|
||||
epsilon = epsilon * 16
|
||||
#endif
|
||||
|
||||
X = (/ 1.1 , 2.2 , 3.3 /)
|
||||
R = (/ 0.1 , 1.2 , -2.3 /)
|
||||
Y(:) = X(:) - R(:)
|
||||
@ -1772,10 +1782,29 @@ integer(c_int32_t) function test_qmckl_ao_gaussian_vgl(context) bind(C)
|
||||
|
||||
test_qmckl_ao_gaussian_vgl = &
|
||||
qmckl_ao_gaussian_vgl(context, X, R, n, A, VGL, ldv)
|
||||
|
||||
vfc_err = qmckl_probe_check("ao"//C_NULL_CHAR, "gaussian_vgl_2_1"//C_NULL_CHAR, &
|
||||
DBLE(VGL(2,1)), DBLE(0), DBLE(epsilon))
|
||||
|
||||
vfc_err = qmckl_probe_check("ao"//C_NULL_CHAR, "gaussian_vgl_2_2"//C_NULL_CHAR, &
|
||||
DBLE(VGL(2,2)), DBLE(0), DBLE(epsilon))
|
||||
|
||||
vfc_err = qmckl_probe_check("ao"//C_NULL_CHAR, "gaussian_vgl_2_3"//C_NULL_CHAR, &
|
||||
DBLE(VGL(2,3)), DBLE(0), DBLE(epsilon))
|
||||
|
||||
vfc_err = qmckl_probe_check("ao"//C_NULL_CHAR, "gaussian_vgl_2_4"//C_NULL_CHAR, &
|
||||
DBLE(VGL(2,4)), DBLE(0), DBLE(epsilon))
|
||||
|
||||
vfc_err = qmckl_probe_check("ao"//C_NULL_CHAR, "gaussian_vgl_2_5"//C_NULL_CHAR, &
|
||||
DBLE(VGL(2,5)), DBLE(0), DBLE(epsilon))
|
||||
|
||||
#ifndef VFC_CI
|
||||
if (test_qmckl_ao_gaussian_vgl /= 0) return
|
||||
#endif
|
||||
|
||||
test_qmckl_ao_gaussian_vgl = -1
|
||||
|
||||
#ifndef VFC_CI
|
||||
do i=1,n
|
||||
test_qmckl_ao_gaussian_vgl = -11
|
||||
if (dabs(1.d0 - VGL(i,1) / (&
|
||||
@ -1802,6 +1831,7 @@ integer(c_int32_t) function test_qmckl_ao_gaussian_vgl(context) bind(C)
|
||||
A(i) * (4.d0*r2*A(i) - 6.d0) * dexp(-A(i) * r2) &
|
||||
)) > epsilon ) return
|
||||
end do
|
||||
#endif
|
||||
|
||||
test_qmckl_ao_gaussian_vgl = 0
|
||||
|
||||
@ -2744,8 +2774,12 @@ end function qmckl_ao_power_f
|
||||
#+begin_src f90 :tangle (eval f_test)
|
||||
integer(c_int32_t) function test_qmckl_ao_power(context) bind(C)
|
||||
use qmckl
|
||||
use qmckl_probes_f
|
||||
|
||||
implicit none
|
||||
|
||||
logical(C_BOOL) :: vfc_err
|
||||
|
||||
integer(qmckl_context), intent(in), value :: context
|
||||
|
||||
integer*8 :: n, LDP
|
||||
@ -2756,6 +2790,13 @@ integer(c_int32_t) function test_qmckl_ao_power(context) bind(C)
|
||||
|
||||
epsilon = qmckl_get_numprec_epsilon(context)
|
||||
|
||||
#ifdef VFC_CI
|
||||
! Multplying epsilon by 16 = 2^4 is equivalent to asking 4 significant digits
|
||||
! less. This makes sense because we are adding noise with MCA so we can't be
|
||||
! as strict on the accuracy target.
|
||||
epsilon = epsilon * 16
|
||||
#endif
|
||||
|
||||
n = 100;
|
||||
LDP = 10;
|
||||
|
||||
@ -2767,10 +2808,15 @@ integer(c_int32_t) function test_qmckl_ao_power(context) bind(C)
|
||||
end do
|
||||
|
||||
test_qmckl_ao_power = qmckl_ao_power(context, n, X, LMAX, P, LDP)
|
||||
|
||||
vfc_err = qmckl_probe_check("ao"//C_NULL_CHAR, "power_2_2"//C_NULL_CHAR, &
|
||||
DBLE(P(2,2)), DBLE(0), DBLE(epsilon))
|
||||
|
||||
if (test_qmckl_ao_power /= QMCKL_SUCCESS) return
|
||||
|
||||
test_qmckl_ao_power = QMCKL_FAILURE
|
||||
|
||||
#ifndef VFC_CI
|
||||
do j=1,n
|
||||
do i=1,LMAX(j)
|
||||
if ( X(j)**i == 0.d0 ) then
|
||||
@ -2780,6 +2826,7 @@ integer(c_int32_t) function test_qmckl_ao_power(context) bind(C)
|
||||
end if
|
||||
end do
|
||||
end do
|
||||
#endif
|
||||
|
||||
test_qmckl_ao_power = QMCKL_SUCCESS
|
||||
deallocate(X,P,LMAX)
|
||||
@ -3072,9 +3119,12 @@ end function qmckl_ao_polynomial_vgl_f
|
||||
#+begin_src f90 :tangle (eval f_test)
|
||||
integer(c_int32_t) function test_qmckl_ao_polynomial_vgl(context) bind(C)
|
||||
use qmckl
|
||||
use qmckl_probes_f
|
||||
|
||||
implicit none
|
||||
|
||||
integer(c_int64_t), intent(in), value :: context
|
||||
logical(C_BOOL) :: vfc_err
|
||||
|
||||
integer :: lmax, d, i
|
||||
integer, allocatable :: L(:,:)
|
||||
@ -3101,9 +3151,25 @@ integer(c_int32_t) function test_qmckl_ao_polynomial_vgl(context) bind(C)
|
||||
test_qmckl_ao_polynomial_vgl = &
|
||||
qmckl_ao_polynomial_vgl(context, X, R, lmax, n, L, ldl, VGL, ldv)
|
||||
|
||||
vfc_err = qmckl_probe_check("ao"//C_NULL_CHAR, "polynomial_vgl_1_2"//C_NULL_CHAR, &
|
||||
DBLE(VGL(1,2)), DBLE(0), DBLE(epsilon))
|
||||
|
||||
vfc_err = qmckl_probe_check("ao"//C_NULL_CHAR, "polynomial_vgl_2_2"//C_NULL_CHAR, &
|
||||
DBLE(VGL(2,2)), DBLE(0), DBLE(epsilon))
|
||||
|
||||
vfc_err = qmckl_probe_check("ao"//C_NULL_CHAR, "polynomial_vgl_3_2"//C_NULL_CHAR, &
|
||||
DBLE(VGL(3,2)), DBLE(0), DBLE(epsilon))
|
||||
|
||||
vfc_err = qmckl_probe_check("ao"//C_NULL_CHAR, "polynomial_vgl_4_2"//C_NULL_CHAR, &
|
||||
DBLE(VGL(4,2)), DBLE(0), DBLE(epsilon))
|
||||
|
||||
vfc_err = qmckl_probe_check("ao"//C_NULL_CHAR, "polynomial_vgl_5_2"//C_NULL_CHAR, &
|
||||
DBLE(VGL(5,2)), DBLE(0), DBLE(epsilon))
|
||||
|
||||
if (test_qmckl_ao_polynomial_vgl /= QMCKL_SUCCESS) return
|
||||
if (n /= d) return
|
||||
|
||||
#ifndef VFC_CI
|
||||
do j=1,n
|
||||
test_qmckl_ao_polynomial_vgl = QMCKL_FAILURE
|
||||
do i=1,3
|
||||
@ -3154,6 +3220,7 @@ integer(c_int32_t) function test_qmckl_ao_polynomial_vgl(context) bind(C)
|
||||
end if
|
||||
if (dabs(1.d0 - VGL(5,j) / w) > epsilon ) return
|
||||
end do
|
||||
#endif
|
||||
|
||||
test_qmckl_ao_polynomial_vgl = QMCKL_SUCCESS
|
||||
|
||||
@ -3705,5 +3772,3 @@ assert( fabs(ao_vgl[1][26][224] - (-3.843864637762753e-09)) < 1.e-14 );
|
||||
|
||||
# -*- mode: org -*-
|
||||
# vim: syntax=c
|
||||
|
||||
|
||||
|
@ -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
|
||||
#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
|
||||
#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
|
||||
#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
|
||||
|
||||
@ -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)
|
||||
#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)
|
||||
#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)
|
||||
#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)
|
||||
#ifndef VFC_CI
|
||||
if ( dabs(1.d0 - C(i,j)/x) > 1.d-14) return
|
||||
#endif
|
||||
end do
|
||||
end do
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
141
tools/qmckl_probes.c
Normal file
141
tools/qmckl_probes.c
Normal 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
65
tools/qmckl_probes.h
Normal 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
49
tools/qmckl_probes_f.f90
Normal 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
19
vfc_tests_config.json
Normal 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
|
||||
}]
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user