From d9cfebba5070cc37a609033389a6231b51a6af0f Mon Sep 17 00:00:00 2001 From: v1j4y Date: Mon, 6 Dec 2021 15:32:24 +0100 Subject: [PATCH 1/6] Added chameleon support. --- configure.ac | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/configure.ac b/configure.ac index fa3277d..8d432c7 100644 --- a/configure.ac +++ b/configure.ac @@ -105,6 +105,52 @@ AC_CHECK_LIB([pthread], [pthread_create]) # CFLAGS="${CFLAGS} ${OPENMP_CFLAGS}" #fi +# CHAMELEON +AC_ARG_WITH(chameleon, + AS_HELP_STRING([--without-chameleon], + [Do not use Chameleon. Default: auto-detect]), [ +case "$with_chameleon" in + no) + : ;; + yes) + PKG_CHECK_MODULES([LIBCHAMELEON],[chameleon >= 1.0.0], + [PKG_CFLAGS="$PKG_CFLAGS $LIBCHAMELEON_CFLAGS" + PKG_LIBS="$PKG_LIBS $LIBCHAMELEON_LIBS"] + ,[ + + ## something went wrong. + ## try to find the package without pkg-config + + ## check that the library is actually new enough. + ## by testing for a 1.0.0+ function which we use + AC_CHECK_LIB(chameleon,CHAMELEON_finalize,[LIBCHAMELEON_LIBS="-lchameleon"]) + ]) + AH_TEMPLATE(HAVE_CHAMELEON,[Chameleon support is available]) + ;; + *) + if test ! -d "$withval" ; then + AC_MSG_ERROR([--with-chameleon path does not point to a directory]) + fi + LIBCHAMELEON_LIBS="-L$with_chameleon/lib -lchameleon -lchameleon_starpu -lhqr -lcoreblas" + LIBCHAMELEON_CFLAGS="-I$with_chameleon/include $CFLAGS" + LIBCHAMELEON_CPPFLAGS="-I$with_chameleon/include $CPPFLAGS" + esac +]) + +if test "x$LIBCHAMELEON_LIBS" != "x" ; then + LIBS="$LIBS $LIBCHAMELEON_LIBS" + CFLAGS="$CFLAGS $LIBCHAMELEON_CFLAGS" + CPPFLAGS="$CPPFLAGS $LIBCHAMELEON_CPPFLAGS" + AC_CHECK_HEADERS([chameleon.h], [], [AC_MSG_ERROR("chamelon.h not found")]) + AC_DEFINE_UNQUOTED([HAVE_CHAMELEON],1,[CHAMELEON support is available]) +fi + +#AS_IF([test "x$with_chameleon" != "xno"], [ +#]) + +AC_MSG_NOTICE([CHAMELEON library support: ${with_CHAMELEON:=auto} ${LIBCHAMELEON_PATH} ${LIBCHAMELEON_LIBS}]) + + # TREXIO AC_ARG_WITH(trexio, [AS_HELP_STRING([--without-trexio],[disable support for TREXIO])], @@ -280,6 +326,7 @@ FC..............: ${FC} FCLAGS..........: ${FCFLAGS} LDFLAGS:........: ${LDFLAGS} LIBS............: ${LIBS} +USE CHAMELEON...: ${with_chameleon} Package features: ${ARGS} From e8a7b1a3f6dc6bcc68315043506b4c027cb390c9 Mon Sep 17 00:00:00 2001 From: v1j4y Date: Thu, 27 Jan 2022 16:35:39 +0100 Subject: [PATCH 2/6] compute_asymp_jasb started. --- org/qmckl_jastrow.org | 44 ++++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index ad6826f..17fa2b8 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -13,7 +13,6 @@ these factors along with their derivatives. (org-babel-lob-ingest "../tools/lib.org") #+end_src - #+begin_src c :tangle (eval h_private_func) #ifndef QMCKL_JASTROW_HPF #define QMCKL_JASTROW_HPF @@ -1328,48 +1327,37 @@ integer function qmckl_compute_asymp_jasb_f(context, bord_num, bord_vector, resc x = x * kappa_inv asymp_jasb(i) = asymp_jasb(i) + bord_vector(p + 1) * x end do - end do + end function qmckl_compute_asymp_jasb_f #+end_src +#+begin_src c :tangle (eval c) +qmckl_exit_code qmckl_compute_asymp_jasb ( + const qmckl_context context, + const int64_t bord_num, + const double* bord_vector, + const double rescale_factor_kappa_ee, + double* const asymp_jasb ) { + // Put some code here + + return QMCKL_SUCCESS; +} // end function qmckl_exit_code +#+end_src + #+CALL: generate_c_header(table=qmckl_asymp_jasb_args,rettyp=get_value("CRetType"),fname=get_value("Name")) #+RESULTS: - #+BEGIN_src c :tangle (eval h_func) :comments org + #+begin_src c :tangle (eval h_func) :comments org qmckl_exit_code qmckl_compute_asymp_jasb ( const qmckl_context context, const int64_t bord_num, const double* bord_vector, const double rescale_factor_kappa_ee, double* const asymp_jasb ); - #+END_src + #+end_src - #+CALL: generate_c_interface(table=qmckl_asymp_jasb_args,rettyp=get_value("CRetType"),fname=get_value("Name")) - - #+RESULTS: - #+BEGIN_src f90 :tangle (eval f) :comments org :exports none - integer(c_int32_t) function qmckl_compute_asymp_jasb & - (context, bord_num, bord_vector, rescale_factor_kappa_ee, asymp_jasb) & - bind(C) result(info) - - use, intrinsic :: iso_c_binding - implicit none - - integer (c_int64_t) , intent(in) , value :: context - integer (c_int64_t) , intent(in) , value :: bord_num - real (c_double ) , intent(in) :: bord_vector(bord_num + 1) - real (c_double ) , intent(in) , value :: rescale_factor_kappa_ee - real (c_double ) , intent(out) :: asymp_jasb(2) - - integer(c_int32_t), external :: qmckl_compute_asymp_jasb_f - info = qmckl_compute_asymp_jasb_f & - (context, bord_num, bord_vector, rescale_factor_kappa_ee, asymp_jasb) - - end function qmckl_compute_asymp_jasb - #+END_src - *** Test #+name: asymp_jasb #+begin_src python :results output :exports none :noweb yes From 158c2afb411646699ce27309a1c862f32afa5703 Mon Sep 17 00:00:00 2001 From: v1j4y Date: Thu, 27 Jan 2022 16:38:28 +0100 Subject: [PATCH 3/6] Fixed edits. --- org/qmckl_jastrow.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 17fa2b8..0beaaa1 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1327,7 +1327,7 @@ integer function qmckl_compute_asymp_jasb_f(context, bord_num, bord_vector, resc x = x * kappa_inv asymp_jasb(i) = asymp_jasb(i) + bord_vector(p + 1) * x end do - + end do end function qmckl_compute_asymp_jasb_f #+end_src From f6f346d5117b040647e95cba8284a2f3fc1fcd6c Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Wed, 2 Feb 2022 16:37:26 +0100 Subject: [PATCH 4/6] seg fault at qmckl_compute_asymp_jasb --- org/qmckl_jastrow.org | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 0beaaa1..15223ea 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1340,8 +1340,36 @@ qmckl_exit_code qmckl_compute_asymp_jasb ( const double rescale_factor_kappa_ee, double* const asymp_jasb ) { // Put some code here + int64_t i, p, info; + double kappa_inv, x, asym_one; - return QMCKL_SUCCESS; + kappa_inv = 1.0/ rescale_factor_kappa_ee; + + info = QMCKL_SUCCESS; + + if (context == QMCKL_NULL_CONTEXT){ + info = QMCKL_INVALID_CONTEXT; + return info; + } + + if (bord_num <= 0) { + info = QMCKL_INVALID_ARG_2; + return info; + } + asym_one = bord_vector[0] * kappa_inv / (1.0 + bord_vector[1] * kappa_inv); + asymp_jasb[0] = asym_one; + asymp_jasb[1] = 0.5 * asym_one; + + for (int i=0; i<=1; ++i) { + x = kappa_inv; + + for (int p = 1; p < bord_num-1; ++i){ + x = x * kappa_inv; + asymp_jasb[i] = asymp_jasb[i] + bord_vector[p + 1] * x; + } + } + + return info; } // end function qmckl_exit_code #+end_src From 67f80532f99f371967c8934d98fee2f3df676ea6 Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Wed, 2 Feb 2022 18:21:40 +0100 Subject: [PATCH 5/6] still failing --- org/qmckl_jastrow.org | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 15223ea..7c37818 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1340,7 +1340,7 @@ qmckl_exit_code qmckl_compute_asymp_jasb ( const double rescale_factor_kappa_ee, double* const asymp_jasb ) { // Put some code here - int64_t i, p, info; + int64_t info; double kappa_inv, x, asym_one; kappa_inv = 1.0/ rescale_factor_kappa_ee; @@ -1363,7 +1363,7 @@ qmckl_exit_code qmckl_compute_asymp_jasb ( for (int i=0; i<=1; ++i) { x = kappa_inv; - for (int p = 1; p < bord_num-1; ++i){ + for (int p = 1; p < bord_num; ++i){ x = x * kappa_inv; asymp_jasb[i] = asymp_jasb[i] + bord_vector[p + 1] * x; } From 6a0c54f48c4df59ec8481a6239c027a0f6b64e7c Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Thu, 3 Feb 2022 11:40:54 +0100 Subject: [PATCH 6/6] fixed seg fault: incremented wrong counter --- org/qmckl_jastrow.org | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 7c37818..c70ef9f 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1332,45 +1332,40 @@ integer function qmckl_compute_asymp_jasb_f(context, bord_num, bord_vector, resc end function qmckl_compute_asymp_jasb_f #+end_src -#+begin_src c :tangle (eval c) +#+begin_src c :comments org :tangle (eval c) :noweb yes qmckl_exit_code qmckl_compute_asymp_jasb ( const qmckl_context context, const int64_t bord_num, const double* bord_vector, const double rescale_factor_kappa_ee, double* const asymp_jasb ) { - // Put some code here - int64_t info; + // What is wrong here? double kappa_inv, x, asym_one; - kappa_inv = 1.0/ rescale_factor_kappa_ee; - - info = QMCKL_SUCCESS; + kappa_inv = 1.0 / rescale_factor_kappa_ee; if (context == QMCKL_NULL_CONTEXT){ - info = QMCKL_INVALID_CONTEXT; - return info; + return QMCKL_INVALID_CONTEXT; } if (bord_num <= 0) { - info = QMCKL_INVALID_ARG_2; - return info; + return QMCKL_INVALID_ARG_2; } + asym_one = bord_vector[0] * kappa_inv / (1.0 + bord_vector[1] * kappa_inv); asymp_jasb[0] = asym_one; asymp_jasb[1] = 0.5 * asym_one; - for (int i=0; i<=1; ++i) { + for (int i = 0 ; i <= 1; ++i) { x = kappa_inv; - - for (int p = 1; p < bord_num; ++i){ + for (int p = 1; p < bord_num; ++p){ x = x * kappa_inv; asymp_jasb[i] = asymp_jasb[i] + bord_vector[p + 1] * x; } } - return info; -} // end function qmckl_exit_code + return QMCKL_SUCCESS; +} #+end_src #+CALL: generate_c_header(table=qmckl_asymp_jasb_args,rettyp=get_value("CRetType"),fname=get_value("Name"))