From 1f31183be48fe86d3dbb3015f20d5418903ff759 Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Thu, 3 Feb 2022 12:11:33 +0100 Subject: [PATCH 01/29] init compute_factor_ee --- org/qmckl_jastrow.org | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index c70ef9f..a713a5e 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1642,6 +1642,22 @@ integer function qmckl_compute_factor_ee_f(context, walk_num, elec_num, up_num, end function qmckl_compute_factor_ee_f #+end_src +#+begin_src c :tangle (eval h_func) :comments org + qmckl_exit_code qmckl_compute_factor_ee ( + const qmckl_context context, + const int64_t walk_num, + const int64_t elec_num, + const int64_t up_num, + const int64_t bord_num, + const double* bord_vector, + const double* ee_distance_rescaled, + const double* asymp_jasb, + double* const factor_ee ) { + + + } +#+end_src + #+CALL: generate_c_header(table=qmckl_factor_ee_args,rettyp=get_value("CRetType"),fname=get_value("Name")) #+RESULTS: From b0bfb3157c7ae9a34943fd9a8ce8b0d302c3a426 Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Thu, 3 Feb 2022 17:10:31 +0100 Subject: [PATCH 02/29] translation completed; error at accessing ee_distance_rescaled --- org/qmckl_jastrow.org | 91 +++++++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 42 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index a713a5e..0f63118 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1642,7 +1642,7 @@ integer function qmckl_compute_factor_ee_f(context, walk_num, elec_num, up_num, end function qmckl_compute_factor_ee_f #+end_src -#+begin_src c :tangle (eval h_func) :comments org +#+begin_src c :comments org :tangle (eval c) :noweb yes qmckl_exit_code qmckl_compute_factor_ee ( const qmckl_context context, const int64_t walk_num, @@ -1654,8 +1654,56 @@ end function qmckl_compute_factor_ee_f const double* asymp_jasb, double* const factor_ee ) { + int64_t ipar; // can we use a smaller integer? + double pow_ser, x, spin_fact, power_ser; + if (context == QMCKL_NULL_CONTEXT) { + return QMCKL_INVALID_CONTEXT; + } + + if (walk_num <= 0) { + return QMCKL_INVALID_ARG_2; + } + + if (elec_num <= 0) { + return QMCKL_INVALID_ARG_3; + } + + if (bord_num <= 0) { + return QMCKL_INVALID_ARG_4; + } + + for (int nw = 0; nw < walk_num; ++nw) { + factor_ee[nw] = 0.0; // put init array here. + for (int j = 0; j < elec_num; ++j ) { + for (int i = 0; i < j; ++i) { + x = ee_distance_rescaled[nw][i][j]; + power_ser = 0.0; + spin_fact = 1.0; + ipar = 0; // index of asymp_jasb + + for (int p = 1; p < bord_num; ++p) { + x = x * ee_distance_rescaled[nw][i][j]; + power_ser = power_ser + bord_vector[p + 1] * x; + } + + if(j <= up_num || i > up_num) { + spin_fact = 0.5; + ipar = 1; + } + + factor_ee[nw] = factor_ee[nw] + spin_fact * bord_vector[0] * \ + ee_distance_rescaled[nw][i][j] / \ + (1.0 + bord_vector[1] * \ + ee_distance_rescaled[nw][i][j]) \ + -asymp_jasb[ipar] + power_ser; + + } } + } + + return QMCKL_SUCCESS; +} #+end_src #+CALL: generate_c_header(table=qmckl_factor_ee_args,rettyp=get_value("CRetType"),fname=get_value("Name")) @@ -1677,47 +1725,6 @@ end function qmckl_compute_factor_ee_f #+CALL: generate_c_interface(table=qmckl_factor_ee_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_factor_ee & - (context, & - walk_num, & - elec_num, & - up_num, & - bord_num, & - bord_vector, & - ee_distance_rescaled, & - asymp_jasb, & - factor_ee) & - 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 :: walk_num - integer (c_int64_t) , intent(in) , value :: elec_num - integer (c_int64_t) , intent(in) , value :: up_num - integer (c_int64_t) , intent(in) , value :: bord_num - real (c_double ) , intent(in) :: bord_vector(bord_num + 1) - real (c_double ) , intent(in) :: ee_distance_rescaled(elec_num,elec_num,walk_num) - real (c_double ) , intent(in) :: asymp_jasb(2) - real (c_double ) , intent(out) :: factor_ee(walk_num) - - integer(c_int32_t), external :: qmckl_compute_factor_ee_f - info = qmckl_compute_factor_ee_f & - (context, & - walk_num, & - elec_num, & - up_num, & - bord_num, & - bord_vector, & - ee_distance_rescaled, & - asymp_jasb, & - factor_ee) - - end function qmckl_compute_factor_ee - #+end_src *** Test #+begin_src python :results output :exports none :noweb yes From 81d55b4189daf7b5ca22444eb03b598e13cece14 Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Thu, 3 Feb 2022 18:27:33 +0100 Subject: [PATCH 03/29] ee_distance_rescaled fixed;assert fails due to number mismatch --- org/qmckl_jastrow.org | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 0f63118..f47139f 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1654,7 +1654,7 @@ end function qmckl_compute_factor_ee_f const double* asymp_jasb, double* const factor_ee ) { - int64_t ipar; // can we use a smaller integer? + int ipar; // can we use a smaller integer? double pow_ser, x, spin_fact, power_ser; if (context == QMCKL_NULL_CONTEXT) { @@ -1677,13 +1677,13 @@ end function qmckl_compute_factor_ee_f factor_ee[nw] = 0.0; // put init array here. for (int j = 0; j < elec_num; ++j ) { for (int i = 0; i < j; ++i) { - x = ee_distance_rescaled[nw][i][j]; + x = ee_distance_rescaled[j + elec_num*(i + elec_num*nw)]; power_ser = 0.0; spin_fact = 1.0; ipar = 0; // index of asymp_jasb for (int p = 1; p < bord_num; ++p) { - x = x * ee_distance_rescaled[nw][i][j]; + x = x * ee_distance_rescaled[j + elec_num*(i + elec_num*nw)]; power_ser = power_ser + bord_vector[p + 1] * x; } @@ -1693,9 +1693,9 @@ end function qmckl_compute_factor_ee_f } factor_ee[nw] = factor_ee[nw] + spin_fact * bord_vector[0] * \ - ee_distance_rescaled[nw][i][j] / \ + ee_distance_rescaled[j + elec_num*(i + elec_num*nw)] / \ (1.0 + bord_vector[1] * \ - ee_distance_rescaled[nw][i][j]) \ + ee_distance_rescaled[j + elec_num*(i + elec_num*nw)]) \ -asymp_jasb[ipar] + power_ser; } From b8b2997382dd883aa80d330e6a2aefa2d5c323a1 Mon Sep 17 00:00:00 2001 From: v1j4y Date: Fri, 4 Feb 2022 17:13:15 +0100 Subject: [PATCH 04/29] Fixed indexing of ee_distance_rescaled. --- org/qmckl_jastrow.org | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index fd2c8a5..57628bf 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1624,7 +1624,7 @@ end function qmckl_compute_factor_ee_f double* const factor_ee ) { int ipar; // can we use a smaller integer? - double pow_ser, x, spin_fact, power_ser; + double pow_ser, x, x1, spin_fact, power_ser; if (context == QMCKL_NULL_CONTEXT) { return QMCKL_INVALID_CONTEXT; @@ -1646,13 +1646,14 @@ end function qmckl_compute_factor_ee_f factor_ee[nw] = 0.0; // put init array here. for (int j = 0; j < elec_num; ++j ) { for (int i = 0; i < j; ++i) { - x = ee_distance_rescaled[j + elec_num*(i + elec_num*nw)]; + x = ee_distance_rescaled[j * (walk_num * elec_num) + i * (walk_num) + nw]; + x1 = x; power_ser = 0.0; spin_fact = 1.0; ipar = 0; // index of asymp_jasb for (int p = 1; p < bord_num; ++p) { - x = x * ee_distance_rescaled[j + elec_num*(i + elec_num*nw)]; + x = x * x1; power_ser = power_ser + bord_vector[p + 1] * x; } @@ -1662,9 +1663,9 @@ end function qmckl_compute_factor_ee_f } factor_ee[nw] = factor_ee[nw] + spin_fact * bord_vector[0] * \ - ee_distance_rescaled[j + elec_num*(i + elec_num*nw)] / \ + x1 / \ (1.0 + bord_vector[1] * \ - ee_distance_rescaled[j + elec_num*(i + elec_num*nw)]) \ + x1) \ -asymp_jasb[ipar] + power_ser; } From 794ee5fe8c7a55c1c888c54c6f4df6f23a01cd7f Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Mon, 7 Feb 2022 12:17:44 +0100 Subject: [PATCH 05/29] remove generate interface --- org/qmckl_jastrow.org | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 57628bf..32e2fb4 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1652,7 +1652,7 @@ end function qmckl_compute_factor_ee_f spin_fact = 1.0; ipar = 0; // index of asymp_jasb - for (int p = 1; p < bord_num; ++p) { + for (int p = 1; p <= bord_num; ++p) { x = x * x1; power_ser = power_ser + bord_vector[p + 1] * x; } @@ -1693,7 +1693,6 @@ end function qmckl_compute_factor_ee_f #+end_src - #+CALL: generate_c_interface(table=qmckl_factor_ee_args,rettyp=get_value("CRetType"),fname=get_value("Name")) *** Test From 2332007a7ce21a5ab7c978e0363a10dceb60e96e Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Mon, 7 Feb 2022 13:53:50 +0100 Subject: [PATCH 06/29] fixed qmckl_compute_factor_ee --- org/qmckl_jastrow.org | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 32e2fb4..a55d85a 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1644,20 +1644,20 @@ end function qmckl_compute_factor_ee_f for (int nw = 0; nw < walk_num; ++nw) { factor_ee[nw] = 0.0; // put init array here. - for (int j = 0; j < elec_num; ++j ) { - for (int i = 0; i < j; ++i) { + for (int i = 0; i < elec_num; ++i ) { + for (int j = 0; j < i; ++j) { x = ee_distance_rescaled[j * (walk_num * elec_num) + i * (walk_num) + nw]; x1 = x; power_ser = 0.0; spin_fact = 1.0; ipar = 0; // index of asymp_jasb - for (int p = 1; p <= bord_num; ++p) { + for (int p = 1; p < bord_num; ++p) { x = x * x1; power_ser = power_ser + bord_vector[p + 1] * x; } - if(j <= up_num || i > up_num) { + if(i < up_num || j >= up_num) { spin_fact = 0.5; ipar = 1; } From 05cfd10cc48fe728905de11127bce640ccdfe7de Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Wed, 16 Feb 2022 14:14:05 +0100 Subject: [PATCH 07/29] completed qmckl_compute_factor_en --- org/qmckl_jastrow.org | 115 +++++++++++++++++++++++++----------------- 1 file changed, 68 insertions(+), 47 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index c46fe63..a177d91 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -2442,6 +2442,74 @@ integer function qmckl_compute_factor_en_f(context, walk_num, elec_num, nucl_num end function qmckl_compute_factor_en_f #+end_src + + + #+begin_src c :comments org :tangle (eval c) :noweb yes +qmckl_exit_code qmckl_compute_factor_en ( + const qmckl_context context, + const int64_t walk_num, + const int64_t elec_num, + const int64_t nucl_num, + const int64_t type_nucl_num, + const int64_t* type_nucl_vector, + const int64_t aord_num, + const double* aord_vector, + const double* en_distance_rescaled, + double* const factor_en ) { + + + int ipar; + double x, x1, spin_fact, power_ser; + + + if (context == QMCKL_NULL_CONTEXT) { + return QMCKL_INVALID_CONTEXT; + } + + if (walk_num <= 0) { + return QMCKL_INVALID_ARG_2; + } + + if (elec_num <= 0) { + return QMCKL_INVALID_ARG_3; + } + + if (nucl_num <= 0) { + return QMCKL_INVALID_ARG_4; + } + + if (aord_num <= 0) { + return QMCKL_INVALID_ARG_7; + } + + + for (int nw = 0; nw < walk_num; ++nw ) { + // init array + factor_en[nw] = 0.0; + for (int a = 0; a < nucl_num; ++a ) { + for (int i = 0; i < elec_num; ++i ) { + // x = ee_distance_rescaled[j * (walk_num * elec_num) + i * (walk_num) + nw]; + x = en_distance_rescaled[i * (walk_num * nucl_num) + a * (walk_num) + nw]; + x1 = x; + power_ser = 0.0; + + for (int p = 2; p < aord_num+1; ++p) { + x = x * x1; + power_ser = power_ser + aord_vector[(p+1)-1 + (type_nucl_vector[a]-1) * aord_num] * x; + } + + factor_en[nw] = factor_en[nw] + aord_vector[0 + (type_nucl_vector[a]-1)*aord_num] * x1 / \ + (1.0 + aord_vector[1 + (type_nucl_vector[a]-1) * aord_num] * x1) + \ + power_ser; + + } + } + } + + return QMCKL_SUCCESS; +} + #+end_src + #+CALL: generate_c_header(table=qmckl_factor_en_args,rettyp=get_value("CRetType"),fname=get_value("Name")) @@ -2461,53 +2529,6 @@ end function qmckl_compute_factor_en_f #+end_src - #+CALL: generate_c_interface(table=qmckl_factor_en_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_factor_en & - (context, & - walk_num, & - elec_num, & - nucl_num, & - type_nucl_num, & - type_nucl_vector, & - aord_num, & - aord_vector, & - en_distance_rescaled, & - factor_en) & - 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 :: walk_num - integer (c_int64_t) , intent(in) , value :: elec_num - integer (c_int64_t) , intent(in) , value :: nucl_num - integer (c_int64_t) , intent(in) , value :: type_nucl_num - integer (c_int64_t) , intent(in) :: type_nucl_vector(nucl_num) - integer (c_int64_t) , intent(in) , value :: aord_num - real (c_double ) , intent(in) :: aord_vector(aord_num + 1, type_nucl_num) - real (c_double ) , intent(in) :: en_distance_rescaled(elec_num, nucl_num, walk_num) - real (c_double ) , intent(out) :: factor_en(walk_num) - - integer(c_int32_t), external :: qmckl_compute_factor_en_f - info = qmckl_compute_factor_en_f & - (context, & - walk_num, & - elec_num, & - nucl_num, & - type_nucl_num, & - type_nucl_vector, & - aord_num, & - aord_vector, & - en_distance_rescaled, & - factor_en) - - end function qmckl_compute_factor_en - #+end_src - *** Test #+begin_src python :results output :exports none :noweb yes import numpy as np From bf8cec7f3cf39c3bb8b100675401304b60da4d8b Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Wed, 16 Feb 2022 18:09:02 +0100 Subject: [PATCH 08/29] reordered index in ee_distance_rescaled that makes sense --- org/qmckl_jastrow.org | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index a177d91..eabde1e 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1735,7 +1735,8 @@ end function qmckl_compute_factor_ee_f factor_ee[nw] = 0.0; // put init array here. for (int i = 0; i < elec_num; ++i ) { for (int j = 0; j < i; ++j) { - x = ee_distance_rescaled[j * (walk_num * elec_num) + i * (walk_num) + nw]; + //x = ee_distance_rescaled[j * (walk_num * elec_num) + i * (walk_num) + nw]; + x = ee_distance_rescaled[j + i * elec_num + nw*(elec_num * elec_num)]; x1 = x; power_ser = 0.0; spin_fact = 1.0; From bb2e8384e8b8cde1bab3edef6bbc44c8949b0ba2 Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Wed, 16 Feb 2022 18:13:57 +0100 Subject: [PATCH 09/29] fix reorder of nex function --- 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 eabde1e..7b1f0b8 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -2490,7 +2490,7 @@ qmckl_exit_code qmckl_compute_factor_en ( for (int a = 0; a < nucl_num; ++a ) { for (int i = 0; i < elec_num; ++i ) { // x = ee_distance_rescaled[j * (walk_num * elec_num) + i * (walk_num) + nw]; - x = en_distance_rescaled[i * (walk_num * nucl_num) + a * (walk_num) + nw]; + x = en_distance_rescaled[i + a * elec_num + nw * (elec_num * nucl_num)]; x1 = x; power_ser = 0.0; From 2427d1b56ebc836c603a8466ac6098fd2d8820f9 Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Tue, 22 Feb 2022 14:52:21 +0100 Subject: [PATCH 10/29] working qmckl_compute_een_rescaled_n --- org/qmckl_jastrow.org | 106 +++++++++++++++++++++++++----------------- 1 file changed, 64 insertions(+), 42 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 7b1f0b8..9867010 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -3855,6 +3855,70 @@ integer function qmckl_compute_een_rescaled_n_f(context, walk_num, elec_num, nuc end function qmckl_compute_een_rescaled_n_f #+end_src + #+begin_src c :comments org :tangle (eval c) :noweb yes +qmckl_exit_code qmckl_compute_een_rescaled_n ( + const qmckl_context context, + const int64_t walk_num, + const int64_t elec_num, + const int64_t nucl_num, + const int64_t cord_num, + const double rescale_factor_kappa_en, + const double* en_distance, + double* const een_rescaled_n ) { + + + if (context == QMCKL_NULL_CONTEXT) { + return QMCKL_INVALID_CONTEXT; + } + + if (walk_num <= 0) { + return QMCKL_INVALID_ARG_2; + } + + if (elec_num <= 0) { + return QMCKL_INVALID_ARG_3; + } + + if (nucl_num <= 0) { + return QMCKL_INVALID_ARG_4; + } + + if (cord_num <= 0) { + return QMCKL_INVALID_ARG_5; + } + + // Prepare table of exponentiated distances raised to appropriate power + for (int i = 0; i < (walk_num*(cord_num+1)*nucl_num*elec_num); ++i) { + een_rescaled_n[i] = 17.0; + } + + for (int nw = 0; nw < walk_num; ++nw) { + for (int a = 0; a < nucl_num; ++a) { + for (int i = 0; i < elec_num; ++i) { + // prepare the actual een table + //een_rescaled_n(:, :, 0, nw) = 1.0d0 + een_rescaled_n[i + a * elec_num + 0 + nw * elec_num*nucl_num*(cord_num+1)] = 1.0; + //een_rescaled_n(i, a, 1, nw) = dexp(-rescale_factor_kappa_en * en_distance(i, a, nw)) + een_rescaled_n[i + a*elec_num + elec_num*nucl_num + nw*elec_num*nucl_num*(cord_num+1)] = exp(-rescale_factor_kappa_en * \ + en_distance[i + a*elec_num + nw*elec_num*nucl_num]); + } + } + + for (int l = 2; l < (cord_num+1); ++l){ + for (int a = 0; a < nucl_num; ++a) { + for (int i = 0; i < elec_num; ++i) { + een_rescaled_n[i + a*elec_num + l*elec_num*nucl_num + nw*elec_num*nucl_num*(cord_num+1)] = een_rescaled_n[i + a*elec_num + (l-1)*elec_num*nucl_num + nw*elec_num*nucl_num*(cord_num+1)] *\ + een_rescaled_n[i + a*elec_num + elec_num*nucl_num + nw*elec_num*nucl_num*(cord_num+1)]; + } + } + } + + } + + return QMCKL_SUCCESS; +} + #+end_src + #+CALL: generate_c_header(table=qmckl_factor_een_rescaled_n_args,rettyp=get_value("CRetType"),fname=get_value("Name")) #+RESULTS: @@ -3870,47 +3934,6 @@ end function qmckl_compute_een_rescaled_n_f double* const een_rescaled_n ); #+end_src - #+CALL: generate_c_interface(table=qmckl_factor_een_rescaled_n_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_een_rescaled_n & - (context, & - walk_num, & - elec_num, & - nucl_num, & - cord_num, & - rescale_factor_kappa_en, & - en_distance, & - een_rescaled_n) & - 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 :: walk_num - integer (c_int64_t) , intent(in) , value :: elec_num - integer (c_int64_t) , intent(in) , value :: nucl_num - integer (c_int64_t) , intent(in) , value :: cord_num - real (c_double ) , intent(in) , value :: rescale_factor_kappa_en - real (c_double ) , intent(in) :: en_distance(nucl_num,elec_num,walk_num) - real (c_double ) , intent(out) :: een_rescaled_n(nucl_num,elec_num,0:cord_num,walk_num) - - integer(c_int32_t), external :: qmckl_compute_een_rescaled_n_f - info = qmckl_compute_een_rescaled_n_f & - (context, & - walk_num, & - elec_num, & - nucl_num, & - cord_num, & - rescale_factor_kappa_en, & - en_distance, & - een_rescaled_n) - - end function qmckl_compute_een_rescaled_n - #+end_src - *** Test #+begin_src python :results output :exports none :noweb yes @@ -3969,7 +3992,6 @@ assert(fabs(een_rescaled_n[0][1][0][4]-0.023391817607642338) < 1.e-12); assert(fabs(een_rescaled_n[0][2][1][3]-0.880957224822116) < 1.e-12); assert(fabs(een_rescaled_n[0][2][1][4]-0.027185942659395074) < 1.e-12); assert(fabs(een_rescaled_n[0][2][1][5]-0.01343938025140174) < 1.e-12); - #+end_src ** Electron-nucleus rescaled distances for each order and derivatives From 4fac9f06c9f86e6072fac909c1132f403f6f6267 Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Mon, 28 Feb 2022 17:47:24 +0100 Subject: [PATCH 11/29] to be checked --- org/qmckl_jastrow.org | 61 +++++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index aac48b8..9674f47 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -4962,6 +4962,45 @@ integer function qmckl_compute_dim_cord_vect_f(context, cord_num, dim_cord_vect) end function qmckl_compute_dim_cord_vect_f #+end_src + #+begin_src c :comments org :tangle (eval c) :noweb yes +qmckl_exit_code qmckl_compute_dim_cord_vect ( + const qmckl_context context, + const int64_t cord_num, + int64_t* const dim_cord_vect){ + + int lmax; + + + if (context == QMCKL_NULL_CONTEXT) { + return QMCKL_INVALID_CONTEXT; + } + + if (cord_num <= 0) { + return QMCKL_INVALID_ARG_2; + } + + dim_cord_vect = 0; + + for (int p=2; p < cord_num; ++p){ + for (int k=p-1; k <= 0; --k) { + if (k != 0) { + lmax = p - k; + } else { + lmax = p - k - 2; + } + for (l = lmax; l <= 0; --l) { +// if ( iand(p - k - l, 1_8) == 1) continue; +// Does it make sense? it should + if ( ((p - k - l) & 1)==1) continue; + dim_cord_vect = dim_cord_vect + 1; + } + } + } + + return QMCKL_SUCCESS; +} + #+end_src + #+CALL: generate_c_header(table=qmckl_factor_dim_cord_vect_args,rettyp=get_value("CRetType"),fname=get_value("Name")) #+RESULTS: @@ -4973,28 +5012,6 @@ end function qmckl_compute_dim_cord_vect_f #+end_src - #+CALL: generate_c_interface(table=qmckl_factor_dim_cord_vect_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_dim_cord_vect & - (context, cord_num, dim_cord_vect) & - 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 :: cord_num - integer (c_int64_t) , intent(out) :: dim_cord_vect - - integer(c_int32_t), external :: qmckl_compute_dim_cord_vect_f - info = qmckl_compute_dim_cord_vect_f & - (context, cord_num, dim_cord_vect) - - end function qmckl_compute_dim_cord_vect - #+end_src - *** Compute cord_vect_full :PROPERTIES: :Name: qmckl_compute_cord_vect_full From d13693a822c22acff50d9b7b640fc94d4a71751c Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Wed, 2 Mar 2022 10:18:45 +0100 Subject: [PATCH 12/29] to be cleaned from print --- org/qmckl_jastrow.org | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 9674f47..518ddfb 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -4979,23 +4979,28 @@ qmckl_exit_code qmckl_compute_dim_cord_vect ( return QMCKL_INVALID_ARG_2; } - dim_cord_vect = 0; + printf("hello %d\n", *dim_cord_vect); + *dim_cord_vect = 0; for (int p=2; p < cord_num; ++p){ + printf("in da loop\n"); for (int k=p-1; k <= 0; --k) { if (k != 0) { lmax = p - k; } else { lmax = p - k - 2; } - for (l = lmax; l <= 0; --l) { + printf("lmax %d\n", lmax); + for (int l = lmax; l <= 0; --l) { // if ( iand(p - k - l, 1_8) == 1) continue; // Does it make sense? it should if ( ((p - k - l) & 1)==1) continue; - dim_cord_vect = dim_cord_vect + 1; + printf("in da loop\n"); + *dim_cord_vect = *dim_cord_vect + 1; } } } + printf("hello 2 %d\n", *dim_cord_vect); return QMCKL_SUCCESS; } From a4ba5deac4a74fe48c8d928408d8d611f285826b Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Wed, 9 Mar 2022 11:15:15 +0100 Subject: [PATCH 13/29] compute_dim_cord_vect done --- org/qmckl_jastrow.org | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 518ddfb..74fe58e 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -4979,29 +4979,22 @@ qmckl_exit_code qmckl_compute_dim_cord_vect ( return QMCKL_INVALID_ARG_2; } - printf("hello %d\n", *dim_cord_vect); *dim_cord_vect = 0; - - for (int p=2; p < cord_num; ++p){ - printf("in da loop\n"); - for (int k=p-1; k <= 0; --k) { + + for (int p=2; p <= cord_num; ++p){ + for (int k=p-1; k >= 0; --k) { if (k != 0) { lmax = p - k; } else { lmax = p - k - 2; } - printf("lmax %d\n", lmax); - for (int l = lmax; l <= 0; --l) { -// if ( iand(p - k - l, 1_8) == 1) continue; -// Does it make sense? it should + for (int l = lmax; l >= 0; --l) { if ( ((p - k - l) & 1)==1) continue; - printf("in da loop\n"); - *dim_cord_vect = *dim_cord_vect + 1; + *dim_cord_vect=*dim_cord_vect+1; } } } - printf("hello 2 %d\n", *dim_cord_vect); - + return QMCKL_SUCCESS; } #+end_src From b222ee3156a273a8580964c1de03096bd3b1b5fc Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Mon, 14 Mar 2022 11:21:31 +0100 Subject: [PATCH 14/29] lkpm works --- org/qmckl_jastrow.org | 73 +++++++++++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 24 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 74fe58e..423f152 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -5128,7 +5128,7 @@ end function qmckl_compute_cord_vect_full_f | ~context~ | ~qmckl_context~ | in | Global state | | ~cord_num~ | ~int64_t~ | in | Order of polynomials | | ~dim_cord_vect~ | ~int64_t~ | in | dimension of cord full table | - | ~lpkm_combined_index~ | ~int64_t[4][dim_cord_vect]~ | out | Full list of combined indices | + | ~lkpm_combined_index~ | ~int64_t[4][dim_cord_vect]~ | out | Full list of combined indices | #+begin_src f90 :comments org :tangle (eval f) :noweb yes integer function qmckl_compute_lkpm_combined_index_f(context, cord_num, dim_cord_vect, & @@ -5184,6 +5184,53 @@ integer function qmckl_compute_lkpm_combined_index_f(context, cord_num, dim_cord end function qmckl_compute_lkpm_combined_index_f #+end_src + #+begin_src c :comments org :tangle (eval c) :noweb yes +qmckl_exit_code qmckl_compute_lkpm_combined_index ( + const qmckl_context context, + const int64_t cord_num, + const int64_t dim_cord_vect, + int64_t* const lkpm_combined_index ) { + + int kk, lmax, m; + + if (context == QMCKL_NULL_CONTEXT) { + return QMCKL_INVALID_CONTEXT; + } + + if (cord_num <= 0) { + return QMCKL_INVALID_ARG_2; + } + + if (dim_cord_vect <= 0) { + return QMCKL_INVALID_ARG_3; + } + +/* +*/ + kk = 0; + for (int p = 2; p <= cord_num; ++p) { + for (int k=(p-1); k >= 0; --k) { + if (k != 0) { + lmax = p - k; + } else { + lmax = p - k - 2; + } + for (int l=lmax; l >= 0; --l) { + if (((p - k - l) & 1) == 1) continue; + m = (p - k - l)/2; + lkpm_combined_index[kk ] = l; + lkpm_combined_index[kk + dim_cord_vect] = k; + lkpm_combined_index[kk + 2*dim_cord_vect] = p; + lkpm_combined_index[kk + 3*dim_cord_vect] = m; + kk = kk + 1; + } + } + } + + return QMCKL_SUCCESS; +} + #+end_src + #+CALL: generate_c_header(table=qmckl_factor_lkpm_combined_index_args,rettyp=get_value("CRetType"),fname=get_value("Name")) #+RESULTS: @@ -5192,32 +5239,10 @@ end function qmckl_compute_lkpm_combined_index_f const qmckl_context context, const int64_t cord_num, const int64_t dim_cord_vect, - int64_t* const lpkm_combined_index ); + int64_t* const lkpm_combined_index ); #+end_src - #+CALL: generate_c_interface(table=qmckl_factor_lkpm_combined_index_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_lkpm_combined_index & - (context, cord_num, dim_cord_vect, lpkm_combined_index) & - 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 :: cord_num - integer (c_int64_t) , intent(in) , value :: dim_cord_vect - integer (c_int64_t) , intent(out) :: lpkm_combined_index(dim_cord_vect,4) - - integer(c_int32_t), external :: qmckl_compute_lkpm_combined_index_f - info = qmckl_compute_lkpm_combined_index_f & - (context, cord_num, dim_cord_vect, lpkm_combined_index) - - end function qmckl_compute_lkpm_combined_index - #+end_src *** Compute tmp_c :PROPERTIES: From 6b45157212c211f398dca3c2c99eeef859852029 Mon Sep 17 00:00:00 2001 From: Gianfranco Abrusci Date: Thu, 17 Mar 2022 17:46:21 +0100 Subject: [PATCH 15/29] tmp_c done --- org/qmckl_jastrow.org | 94 ++++++++++++++++++++++++++++++------------- 1 file changed, 67 insertions(+), 27 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 423f152..4f777da 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -5330,6 +5330,73 @@ integer function qmckl_compute_tmp_c_f(context, cord_num, elec_num, nucl_num, & end function qmckl_compute_tmp_c_f #+end_src + #+begin_src c :comments org :tangle (eval c) :noweb yes +qmckl_exit_code qmckl_compute_tmp_c ( + const qmckl_context context, + const int64_t cord_num, + const int64_t elec_num, + const int64_t nucl_num, + const int64_t walk_num, + const double* een_rescaled_e, + const double* een_rescaled_n, + double* const tmp_c ) { + + qmckl_exit_code info; + int i, j, a, l, kk, p, lmax, nw; + char TransA, TransB; + double alpha, beta; + int M, N, K, LDA, LDB, LDC; + + TransA = 'N'; + TransB = 'N'; + alpha = 1.0; + beta = 0.0; + + if (context == QMCKL_NULL_CONTEXT) { + return QMCKL_INVALID_CONTEXT; + } + + if (cord_num <= 0) { + return QMCKL_INVALID_ARG_2; + } + + if (elec_num <= 0) { + return QMCKL_INVALID_ARG_3; + } + + if (nucl_num <= 0) { + return QMCKL_INVALID_ARG_4; + } + + M = elec_num; + N = nucl_num*(cord_num + 1); + K = elec_num; + + LDA = sizeof(een_rescaled_e)/sizeof(double); + LDB = sizeof(een_rescaled_n)/sizeof(double); + LDC = sizeof(tmp_c)/sizeof(double); + +// DOING + for (int nw=0; nw < walk_num; ++nw) { + for (int i=0; i Date: Thu, 17 Mar 2022 22:27:10 +0100 Subject: [PATCH 16/29] dtmp_c done --- org/qmckl_jastrow.org | 95 ++++++++++++++++++++++++++++++------------- 1 file changed, 66 insertions(+), 29 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 4f777da..9b0370c 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -5376,7 +5376,6 @@ qmckl_exit_code qmckl_compute_tmp_c ( LDB = sizeof(een_rescaled_n)/sizeof(double); LDC = sizeof(tmp_c)/sizeof(double); -// DOING for (int nw=0; nw < walk_num; ++nw) { for (int i=0; i Date: Mon, 28 Mar 2022 16:53:36 +0200 Subject: [PATCH 17/29] Accelerated AO->MO transformation --- org/qmckl_ao.org | 2 + org/qmckl_determinant.org | 8 +- org/qmckl_local_energy.org | 8 +- org/qmckl_mo.org | 344 ++++++++++++++++++++++++++++--------- 4 files changed, 274 insertions(+), 88 deletions(-) diff --git a/org/qmckl_ao.org b/org/qmckl_ao.org index 5bc9235..54c5319 100644 --- a/org/qmckl_ao.org +++ b/org/qmckl_ao.org @@ -139,6 +139,7 @@ int main() { | ~ao_num~ | ~int64_t~ | Number of AOs | | ~ao_cartesian~ | ~bool~ | If true, use polynomials. Otherwise, use spherical harmonics | | ~ao_factor~ | ~double[ao_num]~ | Normalization factor of the AO | + |---------------------+----------------------+----------------------------------------------------------------------| For H_2 with the following basis set, @@ -2491,6 +2492,7 @@ free(ao_factor_test); | ~shell_vgl_date~ | ~uint64_t~ | Last modification date of Value, gradients, Laplacian of the AOs at current positions | | ~ao_vgl~ | ~double[point_num][5][ao_num]~ | Value, gradients, Laplacian of the primitives at current positions | | ~ao_vgl_date~ | ~uint64_t~ | Last modification date of Value, gradients, Laplacian of the AOs at current positions | + |----------------------+-----------------------------------+----------------------------------------------------------------------------------------------| *** After initialization diff --git a/org/qmckl_determinant.org b/org/qmckl_determinant.org index a28f49c..0412db6 100644 --- a/org/qmckl_determinant.org +++ b/org/qmckl_determinant.org @@ -1239,9 +1239,9 @@ assert(rc == QMCKL_SUCCESS); assert(qmckl_ao_basis_provided(context)); -double ao_vgl[5][walk_num][elec_num][chbrclf_ao_num]; +double ao_vgl[walk_num*elec_num][5][chbrclf_ao_num]; -rc = qmckl_get_ao_basis_ao_vgl(context, &(ao_vgl[0][0][0][0]), (int64_t) 5*walk_num*elec_num*chbrclf_ao_num); +rc = qmckl_get_ao_basis_ao_vgl(context, &(ao_vgl[0][0][0]), (int64_t) 5*walk_num*elec_num*chbrclf_ao_num); assert (rc == QMCKL_SUCCESS); /* Set up MO data */ @@ -1256,8 +1256,8 @@ assert (rc == QMCKL_SUCCESS); assert(qmckl_mo_basis_provided(context)); -double mo_vgl[5][elec_num][chbrclf_mo_num]; -rc = qmckl_get_mo_basis_vgl(context, &(mo_vgl[0][0][0])); +double mo_vgl[walk_num*elec_num][5][chbrclf_mo_num]; +rc = qmckl_get_mo_basis_mo_vgl(context, &(mo_vgl[0][0][0]), 5*walk_num*elec_num*chbrclf_mo_num); assert (rc == QMCKL_SUCCESS); /* Set up determinant data */ diff --git a/org/qmckl_local_energy.org b/org/qmckl_local_energy.org index ccd933d..c5018c0 100644 --- a/org/qmckl_local_energy.org +++ b/org/qmckl_local_energy.org @@ -655,9 +655,9 @@ assert(rc == QMCKL_SUCCESS); assert(qmckl_ao_basis_provided(context)); -double ao_vgl[5][walk_num][elec_num][chbrclf_ao_num]; +double ao_vgl[walk_num*elec_num][5][chbrclf_ao_num]; -rc = qmckl_get_ao_basis_ao_vgl(context, &(ao_vgl[0][0][0][0]), +rc = qmckl_get_ao_basis_ao_vgl(context, &(ao_vgl[0][0][0]), (int64_t) 5*walk_num*elec_num*chbrclf_ao_num); assert (rc == QMCKL_SUCCESS); @@ -673,8 +673,8 @@ assert (rc == QMCKL_SUCCESS); assert(qmckl_mo_basis_provided(context)); -double mo_vgl[5][elec_num][chbrclf_mo_num]; -rc = qmckl_get_mo_basis_vgl(context, &(mo_vgl[0][0][0])); +double mo_vgl[walk_num*elec_num][5][chbrclf_mo_num]; +rc = qmckl_get_mo_basis_mo_vgl(context, &(mo_vgl[0][0][0]), 5*walk_num*elec_num*chbrclf_mo_num); assert (rc == QMCKL_SUCCESS); /* Set up determinant data */ diff --git a/org/qmckl_mo.org b/org/qmckl_mo.org index d4efb41..f374e57 100644 --- a/org/qmckl_mo.org +++ b/org/qmckl_mo.org @@ -84,13 +84,14 @@ int main() { The following arrays are stored in the context: - |---------------+--------------------+----------------------| - | ~mo_num~ | | Number of MOs | - | ~coefficient~ | ~[mo_num][ao_num]~ | Orbital coefficients | + |-----------------+--------------------+----------------------------------------| + | ~mo_num~ | | Number of MOs | + | ~coefficient~ | ~[mo_num][ao_num]~ | Orbital coefficients | + | ~coefficient_t~ | ~[ao_num][mo_num]~ | Transposed of the Orbital coefficients | + |-----------------+--------------------+----------------------------------------| Computed data: - |---------------+--------------------------+-------------------------------------------------------------------------------------| |---------------+--------------------------+-------------------------------------------------------------------------------------| | ~mo_vgl~ | ~[point_num][5][mo_num]~ | Value, gradients, Laplacian of the MOs at point positions | | ~mo_vgl_date~ | ~uint64_t~ | Late modification date of Value, gradients, Laplacian of the MOs at point positions | @@ -101,9 +102,10 @@ int main() { #+begin_src c :comments org :tangle (eval h_private_type) typedef struct qmckl_mo_basis_struct { int64_t mo_num; - double * coefficient; + double * restrict coefficient; + double * restrict coefficient_t; - double * mo_vgl; + double * restrict mo_vgl; uint64_t mo_vgl_date; int32_t uninitialized; @@ -355,6 +357,34 @@ qmckl_exit_code qmckl_finalize_mo_basis(qmckl_context context) { qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); + qmckl_memory_info_struct mem_info = qmckl_memory_info_struct_zero; + mem_info.size = ctx->ao_basis.ao_num * ctx->mo_basis.mo_num * sizeof(double); + double* new_array = (double*) qmckl_malloc(context, mem_info); + if (new_array == NULL) { + return qmckl_failwith( context, + QMCKL_ALLOCATION_FAILED, + "qmckl_finalize_mo_basis", + NULL); + } + + assert (ctx->mo_basis.coefficient != NULL); + + if (ctx->mo_basis.coefficient_t != NULL) { + qmckl_exit_code rc = qmckl_free(context, ctx->mo_basis.coefficient); + if (rc != QMCKL_SUCCESS) { + return qmckl_failwith( context, rc, + "qmckl_finalize_mo_basis", + NULL); + } + } + + for (int64_t i=0 ; iao_basis.ao_num ; ++i) { + for (int64_t j=0 ; jmo_basis.mo_num ; ++j) { + new_array[i*ctx->mo_basis.mo_num + j] = ctx->mo_basis.coefficient[j*ctx->ao_basis.ao_num + i]; + } + } + + ctx->mo_basis.coefficient_t = new_array; qmckl_exit_code rc = QMCKL_SUCCESS; return rc; } @@ -367,11 +397,18 @@ qmckl_exit_code qmckl_finalize_mo_basis(qmckl_context context) { *** Get #+begin_src c :comments org :tangle (eval h_func) :noweb yes -qmckl_exit_code qmckl_get_mo_basis_vgl(qmckl_context context, double* const mo_vgl); +qmckl_exit_code +qmckl_get_mo_basis_mo_vgl(qmckl_context context, + double* const mo_vgl, + const int64_t size_max); #+end_src #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none -qmckl_exit_code qmckl_get_mo_basis_vgl(qmckl_context context, double* const mo_vgl) { +qmckl_exit_code +qmckl_get_mo_basis_mo_vgl(qmckl_context context, + double* const mo_vgl, + const int64_t size_max) +{ if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { return QMCKL_NULL_CONTEXT; @@ -388,7 +425,13 @@ qmckl_exit_code qmckl_get_mo_basis_vgl(qmckl_context context, double* const mo_v qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); - size_t sze = 5 * ctx->point.num * ctx->mo_basis.mo_num; + size_t sze = ctx->point.num * 5 * ctx->mo_basis.mo_num; + if (size_max < sze) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_3, + "qmckl_get_mo_basis_mo_vgl", + "input array too small"); + } memcpy(mo_vgl, ctx->mo_basis.mo_vgl, sze * sizeof(double)); return QMCKL_SUCCESS; @@ -396,17 +439,84 @@ qmckl_exit_code qmckl_get_mo_basis_vgl(qmckl_context context, double* const mo_v #+end_src #+begin_src f90 :tangle (eval fh_func) :comments org :exports none - interface - integer(c_int32_t) function qmckl_get_mo_basis_vgl (context, mo_vgl) & - bind(C) - use, intrinsic :: iso_c_binding - import - implicit none + interface + integer(c_int32_t) function qmckl_get_mo_basis_mo_vgl (context, & + mo_vgl, size_max) bind(C) + use, intrinsic :: iso_c_binding + import + implicit none + + integer (c_int64_t) , intent(in) , value :: context + double precision, intent(out) :: mo_vgl(*) + integer (c_int64_t) , intent(in) , value :: size_max + end function qmckl_get_mo_basis_mo_vgl + end interface + #+end_src - integer (c_int64_t) , intent(in) , value :: context - double precision, intent(out) :: mo_vgl(*) - end function - end interface + Uses the given array to compute the VGL. + + #+begin_src c :comments org :tangle (eval h_func) :noweb yes +qmckl_exit_code +qmckl_get_mo_basis_mo_vgl_inplace (qmckl_context context, + double* const mo_vgl, + const int64_t size_max); + #+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes :exports none +qmckl_exit_code +qmckl_get_mo_basis_mo_vgl_inplace (qmckl_context context, + double* const mo_vgl, + const int64_t size_max) +{ + + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return qmckl_failwith( context, + QMCKL_INVALID_CONTEXT, + "qmckl_get_mo_basis_mo_vgl", + NULL); + } + + qmckl_exit_code rc; + + qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + assert (ctx != NULL); + + int64_t sze = ctx->mo_basis.mo_num * 5 * ctx->point.num; + if (size_max < sze) { + return qmckl_failwith( context, + QMCKL_INVALID_ARG_3, + "qmckl_get_mo_basis_mo_vgl", + "input array too small"); + } + + rc = qmckl_context_touch(context); + if (rc != QMCKL_SUCCESS) return rc; + + double* old_array = ctx->mo_basis.mo_vgl; + + ctx->mo_basis.mo_vgl = mo_vgl; + + rc = qmckl_provide_mo_vgl(context); + if (rc != QMCKL_SUCCESS) return rc; + + ctx->mo_basis.mo_vgl = old_array; + + return QMCKL_SUCCESS; +} + #+end_src + + #+begin_src f90 :tangle (eval fh_func) :comments org :exports none + interface + integer(c_int32_t) function qmckl_get_mo_basis_mo_vgl_inplace (context, & + mo_vgl, size_max) bind(C) + use, intrinsic :: iso_c_binding + import + implicit none + integer (c_int64_t) , intent(in) , value :: context + double precision, intent(out) :: mo_vgl(*) + integer (c_int64_t) , intent(in) , value :: size_max + end function qmckl_get_mo_basis_mo_vgl_inplace + end interface #+end_src *** Provide @@ -462,19 +572,19 @@ qmckl_exit_code qmckl_provide_mo_vgl(qmckl_context context) if (mo_vgl == NULL) { return qmckl_failwith( context, QMCKL_ALLOCATION_FAILED, - "qmckl_mo_basis_vgl", + "qmckl_mo_basis_mo_vgl", NULL); } ctx->mo_basis.mo_vgl = mo_vgl; } - rc = qmckl_compute_mo_basis_vgl(context, - ctx->ao_basis.ao_num, - ctx->mo_basis.mo_num, - ctx->point.num, - ctx->mo_basis.coefficient, - ctx->ao_basis.ao_vgl, - ctx->mo_basis.mo_vgl); + rc = qmckl_compute_mo_basis_mo_vgl(context, + ctx->ao_basis.ao_num, + ctx->mo_basis.mo_num, + ctx->point.num, + ctx->mo_basis.coefficient_t, + ctx->ao_basis.ao_vgl, + ctx->mo_basis.mo_vgl); if (rc != QMCKL_SUCCESS) { return rc; } @@ -488,25 +598,34 @@ qmckl_exit_code qmckl_provide_mo_vgl(qmckl_context context) *** Compute :PROPERTIES: - :Name: qmckl_compute_mo_basis_vgl + :Name: qmckl_compute_mo_basis_mo_vgl :CRetType: qmckl_exit_code :FRetType: qmckl_exit_code :END: - #+NAME: qmckl_mo_basis_vgl_args - | ~qmckl_context~ | ~context~ | in | Global state | - | ~int64_t~ | ~ao_num~ | in | Number of AOs | - | ~int64_t~ | ~mo_num~ | in | Number of MOs | - | ~int64_t~ | ~point_num~ | in | Number of points | - | ~double~ | ~coef_normalized[mo_num][ao_num]~ | in | AO to MO transformation matrix | - | ~double~ | ~ao_vgl[point_num][5][ao_num]~ | in | Value, gradients and Laplacian of the AOs | - | ~double~ | ~mo_vgl[point_num][5][mo_num]~ | out | Value, gradients and Laplacian of the MOs | + #+NAME: qmckl_mo_basis_mo_vgl_args + | Variable | Type | In/Out | Description | + |---------------------+--------------------------------+--------+-------------------------------------------------| + | ~context~ | ~qmckl_context~ | in | Global state | + | ~ao_num~ | ~int64_t~ | in | Number of AOs | + | ~mo_num~ | ~int64_t~ | in | Number of MOs | + | ~point_num~ | ~int64_t~ | in | Number of points | + | ~coef_normalized_t~ | ~double[mo_num][ao_num]~ | in | Transpose of the AO to MO transformation matrix | + | ~ao_vgl~ | ~double[point_num][5][ao_num]~ | in | Value, gradients and Laplacian of the AOs | + | ~mo_vgl~ | ~double[point_num][5][mo_num]~ | out | Value, gradients and Laplacian of the MOs | + The matrix of AO values is very sparse, so we use a sparse-dense + matrix multiplication instead of a dgemm, as exposed in + https://dx.doi.org/10.1007/978-3-642-38718-0_14. + + + + #+begin_src f90 :comments org :tangle (eval f) :noweb yes -integer function qmckl_compute_mo_basis_vgl_f(context, & +integer function qmckl_compute_mo_basis_mo_vgl_doc_f(context, & ao_num, mo_num, point_num, & - coef_normalized, ao_vgl, mo_vgl) & + coef_normalized_t, ao_vgl, mo_vgl) & result(info) use qmckl implicit none @@ -514,55 +633,69 @@ integer function qmckl_compute_mo_basis_vgl_f(context, & integer*8 , intent(in) :: ao_num, mo_num integer*8 , intent(in) :: point_num double precision , intent(in) :: ao_vgl(ao_num,5,point_num) - double precision , intent(in) :: coef_normalized(ao_num,mo_num) + double precision , intent(in) :: coef_normalized_t(ao_num,mo_num) double precision , intent(out) :: mo_vgl(mo_num,5,point_num) - character :: TransA, TransB - double precision :: alpha, beta - integer*8 :: M, N, K, LDA, LDB, LDC, i,j + integer :: i,j,k + double precision :: c1, c2, c3, c4, c5 - TransA = 'T' - TransB = 'N' - M = mo_num - N = point_num*5_8 - K = int(ao_num,8) - alpha = 1.d0 - beta = 0.d0 - LDA = size(coef_normalized,1) - LDB = size(ao_vgl,1) - LDC = size(mo_vgl,1) + do j=1,point_num + mo_vgl(:,:,j) = 0.d0 + do k=1,ao_num + if (ao_vgl(k,1,j) /= 0.d0) then + c1 = ao_vgl(k,1,j) + c2 = ao_vgl(k,2,j) + c3 = ao_vgl(k,3,j) + c4 = ao_vgl(k,4,j) + c5 = ao_vgl(k,5,j) + do i=1,mo_num + mo_vgl(i,1,j) = mo_vgl(i,1,j) + coef_normalized_t(i,k) * c1 + mo_vgl(i,2,j) = mo_vgl(i,2,j) + coef_normalized_t(i,k) * c2 + mo_vgl(i,3,j) = mo_vgl(i,3,j) + coef_normalized_t(i,k) * c3 + mo_vgl(i,4,j) = mo_vgl(i,4,j) + coef_normalized_t(i,k) * c4 + mo_vgl(i,5,j) = mo_vgl(i,5,j) + coef_normalized_t(i,k) * c5 + end do + end if + end do + end do - info = qmckl_dgemm(context,TransA, TransB, M, N, K, alpha, & - coef_normalized, int(size(coef_normalized,1),8), & - ao_vgl, int(size(ao_vgl,1),8), beta, & - mo_vgl,LDC) - - info = QMCKL_SUCCESS - -end function qmckl_compute_mo_basis_vgl_f +end function qmckl_compute_mo_basis_mo_vgl_doc_f #+end_src - #+CALL: generate_c_header(table=qmckl_mo_basis_vgl_args,rettyp=get_value("CRetType"),fname="qmckl_compute_mo_basis_vgl")) + #+CALL: generate_c_header(table=qmckl_mo_basis_mo_vgl_args,rettyp=get_value("CRetType"),fname="qmckl_compute_mo_basis_mo_vgl")) #+RESULTS: #+begin_src c :tangle (eval h_func) :comments org - qmckl_exit_code qmckl_compute_mo_basis_vgl ( - const qmckl_context context, - const int64_t ao_num, - const int64_t mo_num, - const int64_t point_num, - const double* coef_normalized, - const double* ao_vgl, - double* const mo_vgl ); + qmckl_exit_code qmckl_compute_mo_basis_mo_vgl ( + const qmckl_context context, + const int64_t ao_num, + const int64_t mo_num, + const int64_t point_num, + const double* coef_normalized_t, + const double* ao_vgl, + double* const mo_vgl ); #+end_src + #+CALL: generate_c_header(table=qmckl_mo_basis_mo_vgl_args,rettyp=get_value("CRetType"),fname="qmckl_compute_mo_basis_mo_vgl_doc")) - #+CALL: generate_c_interface(table=qmckl_mo_basis_vgl_args,rettyp=get_value("CRetType"),fname="qmckl_compute_mo_basis_vgl")) + #+RESULTS: + #+begin_src c :tangle (eval h_func) :comments org + qmckl_exit_code qmckl_compute_mo_basis_mo_vgl_doc ( + const qmckl_context context, + const int64_t ao_num, + const int64_t mo_num, + const int64_t point_num, + const double* coef_normalized_t, + const double* ao_vgl, + double* const mo_vgl ); + #+end_src + #+CALL: generate_c_interface(table=qmckl_mo_basis_mo_vgl_args,rettyp=get_value("CRetType"),fname="qmckl_compute_mo_basis_mo_vgl_doc")) + #+RESULTS: #+begin_src f90 :tangle (eval f) :comments org :exports none - integer(c_int32_t) function qmckl_compute_mo_basis_vgl & - (context, ao_num, mo_num, point_num, coef_normalized, ao_vgl, mo_vgl) & - bind(C) result(info) + integer(c_int32_t) function qmckl_compute_mo_basis_mo_vgl_doc & + (context, ao_num, mo_num, point_num, coef_normalized_t, ao_vgl, mo_vgl) & + bind(C) result(info) use, intrinsic :: iso_c_binding implicit none @@ -571,15 +704,66 @@ end function qmckl_compute_mo_basis_vgl_f integer (c_int64_t) , intent(in) , value :: ao_num integer (c_int64_t) , intent(in) , value :: mo_num integer (c_int64_t) , intent(in) , value :: point_num - real (c_double ) , intent(in) :: coef_normalized(ao_num,mo_num) + real (c_double ) , intent(in) :: coef_normalized_t(ao_num,mo_num) real (c_double ) , intent(in) :: ao_vgl(ao_num,5,point_num) real (c_double ) , intent(out) :: mo_vgl(mo_num,5,point_num) - integer(c_int32_t), external :: qmckl_compute_mo_basis_vgl_f - info = qmckl_compute_mo_basis_vgl_f & - (context, ao_num, mo_num, point_num, coef_normalized, ao_vgl, mo_vgl) + integer(c_int32_t), external :: qmckl_compute_mo_basis_mo_vgl_doc_f + info = qmckl_compute_mo_basis_mo_vgl_doc_f & + (context, ao_num, mo_num, point_num, coef_normalized_t, ao_vgl, mo_vgl) - end function qmckl_compute_mo_basis_vgl + end function qmckl_compute_mo_basis_mo_vgl_doc + #+end_src + + #+begin_src c :tangle (eval c) :comments org +qmckl_exit_code +qmckl_compute_mo_basis_mo_vgl (const qmckl_context context, + const int64_t ao_num, + const int64_t mo_num, + const int64_t point_num, + const double* coef_normalized_t, + const double* ao_vgl, + double* const mo_vgl ) +{ +#ifdef HAVE_HPC + return qmckl_compute_mo_basis_mo_vgl_hpc (context, ao_num, mo_num, point_num, coef_normalized_t, ao_vgl, mo_vgl); +#else + return qmckl_compute_mo_basis_mo_vgl_doc (context, ao_num, mo_num, point_num, coef_normalized_t, ao_vgl, mo_vgl); +#endif +} + #+end_src + + +*** HPC version + + + #+begin_src c :tangle (eval h_func) :comments org +#ifdef HAVE_HPC +qmckl_exit_code +qmckl_compute_mo_basis_mo_vgl_hpc (const qmckl_context context, + const int64_t ao_num, + const int64_t mo_num, + const int64_t point_num, + const double* coef_normalized_t, + const double* ao_vgl, + double* const mo_vgl ); +#endif + #+end_src + + #+begin_src c :tangle (eval c) :comments org +#ifdef HAVE_HPC +qmckl_exit_code +qmckl_compute_mo_basis_mo_vgl_hpc (const qmckl_context context, + const int64_t ao_num, + const int64_t mo_num, + const int64_t point_num, + const double* restrict coef_normalized_t, + const double* restrict ao_vgl, + double* restrict const mo_vgl ) +{ + return qmckl_compute_mo_basis_mo_vgl_doc (context, ao_num, mo_num, point_num, coef_normalized_t, ao_vgl, mo_vgl); +} +#endif #+end_src *** Test @@ -772,7 +956,7 @@ assert (rc == QMCKL_SUCCESS); assert(qmckl_mo_basis_provided(context)); double mo_vgl[walk_num*elec_num][5][chbrclf_mo_num]; -rc = qmckl_get_mo_basis_vgl(context, &(mo_vgl[0][0][0])); +rc = qmckl_get_mo_basis_mo_vgl(context, &(mo_vgl[0][0][0]), walk_num*elec_num*5*chbrclf_mo_num); assert (rc == QMCKL_SUCCESS); // Test overlap of MO @@ -807,7 +991,7 @@ assert (rc == QMCKL_SUCCESS); // // // Calculate value of MO (1st electron) // double mo_vgl[5][walk_num][elec_num][chbrclf_mo_num]; -// rc = qmckl_get_mo_basis_vgl(context, &(mo_vgl[0][0][0][0])); +// rc = qmckl_get_mo_basis_mo_vgl(context, &(mo_vgl[0][0][0][0])); // assert (rc == QMCKL_SUCCESS); // ovlmo1 += mo_vgl[0][0][0][0]*mo_vgl[0][0][0][0]*dr3; // } From 1b0bfd40be0972142b55eed705a35315fbc8d883 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 28 Mar 2022 17:37:50 +0200 Subject: [PATCH 18/29] HPC version of AO->MO transformation --- org/qmckl_mo.org | 68 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/org/qmckl_mo.org b/org/qmckl_mo.org index f374e57..baeaef3 100644 --- a/org/qmckl_mo.org +++ b/org/qmckl_mo.org @@ -621,7 +621,6 @@ qmckl_exit_code qmckl_provide_mo_vgl(qmckl_context context) - #+begin_src f90 :comments org :tangle (eval f) :noweb yes integer function qmckl_compute_mo_basis_mo_vgl_doc_f(context, & ao_num, mo_num, point_num, & @@ -761,7 +760,72 @@ qmckl_compute_mo_basis_mo_vgl_hpc (const qmckl_context context, const double* restrict ao_vgl, double* restrict const mo_vgl ) { - return qmckl_compute_mo_basis_mo_vgl_doc (context, ao_num, mo_num, point_num, coef_normalized_t, ao_vgl, mo_vgl); +#ifdef HAVE_OPENMP + #pragma omp parallel for +#endif + for (int64_t ipoint=0 ; ipoint < point_num ; ++ipoint) { + double* restrict const vgl1 = &(mo_vgl[ipoint*5*mo_num]); + const double* restrict avgl1 = &(ao_vgl[ipoint*5*ao_num]); + double* restrict const vgl2 = vgl1 + mo_num; + double* restrict const vgl3 = vgl1 + (mo_num << 1); + double* restrict const vgl4 = vgl1 + (mo_num << 1) + mo_num; + double* restrict const vgl5 = vgl1 + (mo_num << 2); + const double* restrict avgl2 = avgl1 + ao_num; + const double* restrict avgl3 = avgl1 + (ao_num << 1); + const double* restrict avgl4 = avgl1 + (ao_num << 1) + ao_num; + const double* restrict avgl5 = avgl1 + (ao_num << 2); + + for (int64_t i=0 ; i Date: Mon, 28 Mar 2022 17:58:03 +0200 Subject: [PATCH 19/29] Accelerated HPC AO->MO transformation --- org/qmckl_mo.org | 75 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 15 deletions(-) diff --git a/org/qmckl_mo.org b/org/qmckl_mo.org index baeaef3..a9a2047 100644 --- a/org/qmckl_mo.org +++ b/org/qmckl_mo.org @@ -803,25 +803,70 @@ qmckl_compute_mo_basis_mo_vgl_hpc (const qmckl_context context, } } - for (int64_t n=0 ; n < nidx ; ++n) { + int64_t n; + for (n=0 ; n < nidx-4 ; n+=4) { int64_t k = idx[n]; - const double* restrict ck1 = coef_normalized_t + k*mo_num; - if (avgl1[n] != 0.) { - const double a1 = av1[n]; - const double a2 = av2[n]; - const double a3 = av3[n]; - const double a4 = av4[n]; - const double a5 = av5[n]; + const double* restrict ck1 = coef_normalized_t + idx[n ]*mo_num; + const double* restrict ck2 = coef_normalized_t + idx[n+1]*mo_num; + const double* restrict ck3 = coef_normalized_t + idx[n+2]*mo_num; + const double* restrict ck4 = coef_normalized_t + idx[n+3]*mo_num; + + const double a11 = av1[n ]; + const double a21 = av1[n+1]; + const double a31 = av1[n+2]; + const double a41 = av1[n+3]; + + const double a12 = av2[n ]; + const double a22 = av2[n+1]; + const double a32 = av2[n+2]; + const double a42 = av2[n+3]; + + const double a13 = av3[n ]; + const double a23 = av3[n+1]; + const double a33 = av3[n+2]; + const double a43 = av3[n+3]; + + const double a14 = av4[n ]; + const double a24 = av4[n+1]; + const double a34 = av4[n+2]; + const double a44 = av4[n+3]; + + const double a15 = av5[n ]; + const double a25 = av5[n+1]; + const double a35 = av5[n+2]; + const double a45 = av5[n+3]; + +#ifdef HAVE_OPENMP +#pragma omp simd +#endif + for (int64_t i=0 ; i Date: Mon, 28 Mar 2022 18:26:20 +0200 Subject: [PATCH 20/29] Fix type error --- org/qmckl_mo.org | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org/qmckl_mo.org b/org/qmckl_mo.org index a9a2047..eb37368 100644 --- a/org/qmckl_mo.org +++ b/org/qmckl_mo.org @@ -425,7 +425,7 @@ qmckl_get_mo_basis_mo_vgl(qmckl_context context, qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); - size_t sze = ctx->point.num * 5 * ctx->mo_basis.mo_num; + const int64_t sze = ctx->point.num * 5 * ctx->mo_basis.mo_num; if (size_max < sze) { return qmckl_failwith( context, QMCKL_INVALID_ARG_3, @@ -481,7 +481,7 @@ qmckl_get_mo_basis_mo_vgl_inplace (qmckl_context context, qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; assert (ctx != NULL); - int64_t sze = ctx->mo_basis.mo_num * 5 * ctx->point.num; + const int64_t sze = ctx->mo_basis.mo_num * 5 * ctx->point.num; if (size_max < sze) { return qmckl_failwith( context, QMCKL_INVALID_ARG_3, From 91811079d30a7d9d2ab82ff8ad9879e4bdce1fdb Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 28 Mar 2022 18:29:29 +0200 Subject: [PATCH 21/29] Fixed bugs. Travis OK. --- org/qmckl_mo.org | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org/qmckl_mo.org b/org/qmckl_mo.org index eb37368..4f8bb57 100644 --- a/org/qmckl_mo.org +++ b/org/qmckl_mo.org @@ -632,9 +632,9 @@ integer function qmckl_compute_mo_basis_mo_vgl_doc_f(context, & integer*8 , intent(in) :: ao_num, mo_num integer*8 , intent(in) :: point_num double precision , intent(in) :: ao_vgl(ao_num,5,point_num) - double precision , intent(in) :: coef_normalized_t(ao_num,mo_num) + double precision , intent(in) :: coef_normalized_t(mo_num,ao_num) double precision , intent(out) :: mo_vgl(mo_num,5,point_num) - integer :: i,j,k + integer*8 :: i,j,k double precision :: c1, c2, c3, c4, c5 do j=1,point_num From bac1eb33f0fd836ac37d0598ed061967f8f3c498 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 4 Apr 2022 12:11:26 +0200 Subject: [PATCH 22/29] Fixed configure for Nvidian compilers --- configure.ac | 18 ++++++++++++------ org/qmckl_context.org | 16 ++++++++-------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/configure.ac b/configure.ac index 56f0ed1..fdae5dc 100644 --- a/configure.ac +++ b/configure.ac @@ -200,16 +200,22 @@ AS_IF([test "$BLAS_LIBS" == "$LAPACK_LIBS"], [BLAS_LIBS=""]) # Specific options required with some compilers case $FC in - ifort*) + *ifort*) FCFLAGS="$FCFLAGS -nofor-main" ;; -#gfortran*) -# # Order is important here -# FCFLAGS="-cpp $FCFLAGS" -# ;; + *nvfortran*) + FCFLAGS="$FCFLAGS -fPIC -Mnomain" + ;; + esac +case $CC in + + *nvc*) + CFLAGS="$CFLAGS -fPIC" + ;; +esac # Options. @@ -358,7 +364,7 @@ CC..............: ${CC} CPPFLAGS........: ${CPPFLAGS} CFLAGS..........: ${CFLAGS} FC..............: ${FC} -FCLAGS..........: ${FCFLAGS} +FCFLAGS.........: ${FCFLAGS} LDFLAGS:........: ${LDFLAGS} LIBS............: ${LIBS} USE CHAMELEON...: ${with_chameleon} diff --git a/org/qmckl_context.org b/org/qmckl_context.org index 6a35789..ac389f0 100644 --- a/org/qmckl_context.org +++ b/org/qmckl_context.org @@ -169,7 +169,7 @@ qmckl_context qmckl_context_check(const qmckl_context context) { if (context == QMCKL_NULL_CONTEXT) return QMCKL_NULL_CONTEXT; - const qmckl_context_struct* const ctx = (const qmckl_context_struct* const) context; + const qmckl_context_struct* const ctx = (const qmckl_context_struct*) context; /* Try to access memory */ if (ctx->tag != VALID_TAG) { @@ -209,7 +209,7 @@ qmckl_context_touch(const qmckl_context context) NULL); } - qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + qmckl_context_struct* const ctx = (qmckl_context_struct*) context; ctx->date += 1UL; ctx->point.date += 1UL; @@ -234,7 +234,7 @@ qmckl_context qmckl_context_create(); qmckl_context qmckl_context_create() { qmckl_context_struct* const ctx = - (qmckl_context_struct* const) malloc (sizeof(qmckl_context_struct)); + (qmckl_context_struct*) malloc (sizeof(qmckl_context_struct)); if (ctx == NULL) { return QMCKL_NULL_CONTEXT; @@ -350,7 +350,7 @@ void qmckl_unlock(qmckl_context context); void qmckl_lock(qmckl_context context) { if (context == QMCKL_NULL_CONTEXT) return ; - qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + qmckl_context_struct* const ctx = (qmckl_context_struct*) context; errno = 0; int rc = pthread_mutex_lock( &(ctx->mutex) ); if (rc != 0) { @@ -362,7 +362,7 @@ void qmckl_lock(qmckl_context context) { } void qmckl_unlock(const qmckl_context context) { - qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + qmckl_context_struct* const ctx = (qmckl_context_struct*) context; int rc = pthread_mutex_unlock( &(ctx->mutex) ); if (rc != 0) { fprintf(stderr, "DEBUG qmckl_unlock:%s\n", strerror(rc) ); @@ -401,10 +401,10 @@ qmckl_context qmckl_context_copy(const qmckl_context context) { { const qmckl_context_struct* const old_ctx = - (qmckl_context_struct* const) checked_context; + (qmckl_context_struct*) checked_context; qmckl_context_struct* const new_ctx = - (qmckl_context_struct* const) malloc (context, sizeof(qmckl_context_struct)); + (qmckl_context_struct*) malloc (context, sizeof(qmckl_context_struct)); if (new_ctx == NULL) { qmckl_unlock(context); @@ -467,7 +467,7 @@ qmckl_context_destroy (const qmckl_context context) const qmckl_context checked_context = qmckl_context_check(context); if (checked_context == QMCKL_NULL_CONTEXT) return QMCKL_INVALID_CONTEXT; - qmckl_context_struct* const ctx = (qmckl_context_struct* const) context; + qmckl_context_struct* const ctx = (qmckl_context_struct*) context; assert (ctx != NULL); /* Shouldn't be possible because the context is valid */ qmckl_lock(context); From 31a05c47e2de79162743a2feb4b04f0f3681d630 Mon Sep 17 00:00:00 2001 From: hoffer Date: Mon, 4 Apr 2022 12:41:00 +0200 Subject: [PATCH 23/29] Add flags for nvc and nvfortran to support offload --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index fdae5dc..c746a41 100644 --- a/configure.ac +++ b/configure.ac @@ -201,11 +201,11 @@ AS_IF([test "$BLAS_LIBS" == "$LAPACK_LIBS"], [BLAS_LIBS=""]) case $FC in *ifort*) - FCFLAGS="$FCFLAGS -nofor-main" + FCFLAGS="$FCFLAGS -nofor-main -mp -target=gpu" ;; *nvfortran*) - FCFLAGS="$FCFLAGS -fPIC -Mnomain" + FCFLAGS="$FCFLAGS -fPIC -Mnomain -mp -target=gpu" ;; esac From 1f9ea610d44265813dd89bd31fe2a35564da9d42 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 4 Apr 2022 16:56:33 +0200 Subject: [PATCH 24/29] Moved C version of Jastrow into HPC --- org/qmckl_jastrow.org | 349 +++++++++++++++++++++++++++++++----------- 1 file changed, 256 insertions(+), 93 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 9b0370c..d4eaaa8 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -1727,7 +1727,7 @@ integer function qmckl_compute_factor_ee_f(context, walk_num, elec_num, up_num, double precision , intent(out) :: factor_ee(walk_num) integer*8 :: i, j, p, ipar, nw - double precision :: pow_ser, x, spin_fact, power_ser + double precision :: x, power_ser, spin_fact info = QMCKL_SUCCESS @@ -1766,7 +1766,7 @@ integer function qmckl_compute_factor_ee_f(context, walk_num, elec_num, up_num, power_ser = power_ser + bord_vector(p + 1) * x end do - if(j .LE. up_num .OR. i .GT. up_num) then + if(j <= up_num .OR. i > up_num) then spin_fact = 0.5d0 ipar = 2 endif @@ -1785,7 +1785,7 @@ end function qmckl_compute_factor_ee_f #+end_src #+begin_src c :comments org :tangle (eval c) :noweb yes - qmckl_exit_code qmckl_compute_factor_ee ( +qmckl_exit_code qmckl_compute_factor_ee ( const qmckl_context context, const int64_t walk_num, const int64_t elec_num, @@ -1797,7 +1797,7 @@ end function qmckl_compute_factor_ee_f double* const factor_ee ) { int ipar; // can we use a smaller integer? - double pow_ser, x, x1, spin_fact, power_ser; + double x, x1, spin_fact, power_ser; if (context == QMCKL_NULL_CONTEXT) { return QMCKL_INVALID_CONTEXT; @@ -2493,8 +2493,8 @@ integer function qmckl_compute_factor_en_f(context, walk_num, elec_num, nucl_num double precision , intent(in) :: en_distance_rescaled(elec_num, nucl_num, walk_num) double precision , intent(out) :: factor_en(walk_num) - integer*8 :: i, a, p, ipar, nw - double precision :: x, spin_fact, power_ser + integer*8 :: i, a, p, nw + double precision :: x, power_ser info = QMCKL_SUCCESS @@ -2563,10 +2563,7 @@ qmckl_exit_code qmckl_compute_factor_en ( const double* en_distance_rescaled, double* const factor_en ) { - - int ipar; - double x, x1, spin_fact, power_ser; - + double x, x1, power_ser; if (context == QMCKL_NULL_CONTEXT) { return QMCKL_INVALID_CONTEXT; @@ -2584,10 +2581,30 @@ qmckl_exit_code qmckl_compute_factor_en ( return QMCKL_INVALID_ARG_4; } + if (type_nucl_num <= 0) { + return QMCKL_INVALID_ARG_5; + } + + if (type_nucl_vector == NULL) { + return QMCKL_INVALID_ARG_6; + } + if (aord_num <= 0) { return QMCKL_INVALID_ARG_7; } + if (aord_vector == NULL) { + return QMCKL_INVALID_ARG_8; + } + + if (en_distance_rescaled == NULL) { + return QMCKL_INVALID_ARG_9; + } + + if (factor_en == NULL) { + return QMCKL_INVALID_ARG_10; + } + for (int nw = 0; nw < walk_num; ++nw ) { // init array @@ -2826,7 +2843,7 @@ integer function qmckl_compute_factor_en_deriv_e_f(context, walk_num, elec_num, double precision , intent(out) :: factor_en_deriv_e(elec_num,4,walk_num) integer*8 :: i, a, p, ipar, nw, ii - double precision :: x, spin_fact, den, invden, invden2, invden3, xinv + double precision :: x, den, invden, invden2, invden3, xinv double precision :: y, lap1, lap2, lap3, third double precision, dimension(3) :: power_ser_g double precision, dimension(4) :: dx @@ -5264,7 +5281,7 @@ qmckl_exit_code qmckl_compute_lkpm_combined_index ( | ~tmp_c~ | ~double[walk_num][0:cord_num-1][0:cord_num][nucl_num][elec_num]~ | out | vector of non-zero coefficients | #+begin_src f90 :comments org :tangle (eval f) :noweb yes -integer function qmckl_compute_tmp_c_f(context, cord_num, elec_num, nucl_num, & +integer function qmckl_compute_tmp_c_doc_f(context, cord_num, elec_num, nucl_num, & walk_num, een_rescaled_e, een_rescaled_n, tmp_c) & result(info) use qmckl @@ -5319,7 +5336,7 @@ integer function qmckl_compute_tmp_c_f(context, cord_num, elec_num, nucl_num, & do nw=1, walk_num do i=0, cord_num-1 - info = qmckl_dgemm(context,TransA, TransB, M, N, K, alpha, & + info = qmckl_dgemm(context, TransA, TransB, M, N, K, alpha, & een_rescaled_e(1,1,i,nw),LDA*1_8, & een_rescaled_n(1,1,0,nw),LDB*1_8, & beta, & @@ -5327,11 +5344,39 @@ integer function qmckl_compute_tmp_c_f(context, cord_num, elec_num, nucl_num, & end do end do -end function qmckl_compute_tmp_c_f +end function qmckl_compute_tmp_c_doc_f #+end_src +#+CALL: generate_c_interface(table=qmckl_factor_tmp_c_args,rettyp=get_value("FRetType"),fname="qmckl_compute_tmp_c_doc") + +#+RESULTS: +#+begin_src f90 :tangle (eval f) :comments org :exports none +integer(c_int32_t) function qmckl_compute_tmp_c_doc & + (context, cord_num, elec_num, nucl_num, walk_num, een_rescaled_e, een_rescaled_n, tmp_c) & + 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 :: cord_num + integer (c_int64_t) , intent(in) , value :: elec_num + integer (c_int64_t) , intent(in) , value :: nucl_num + integer (c_int64_t) , intent(in) , value :: walk_num + real (c_double ) , intent(in) :: een_rescaled_e(elec_num,elec_num,0:cord_num,walk_num) + real (c_double ) , intent(in) :: een_rescaled_n(elec_num,nucl_num,0:cord_num,walk_num) + real (c_double ) , intent(out) :: tmp_c(elec_num,nucl_num,0:cord_num,0:cord_num-1,walk_num) + + integer(c_int32_t), external :: qmckl_compute_tmp_c_doc_f + info = qmckl_compute_tmp_c_doc_f & + (context, cord_num, elec_num, nucl_num, walk_num, een_rescaled_e, een_rescaled_n, tmp_c) + +end function qmckl_compute_tmp_c_doc +#+end_src + + #+begin_src c :comments org :tangle (eval c) :noweb yes -qmckl_exit_code qmckl_compute_tmp_c ( +qmckl_exit_code qmckl_compute_tmp_c_hpc ( const qmckl_context context, const int64_t cord_num, const int64_t elec_num, @@ -5341,17 +5386,6 @@ qmckl_exit_code qmckl_compute_tmp_c ( const double* een_rescaled_n, double* const tmp_c ) { - qmckl_exit_code info; - int i, j, a, l, kk, p, lmax, nw; - char TransA, TransB; - double alpha, beta; - int M, N, K, LDA, LDB, LDC; - - TransA = 'N'; - TransB = 'N'; - alpha = 1.0; - beta = 0.0; - if (context == QMCKL_NULL_CONTEXT) { return QMCKL_INVALID_CONTEXT; } @@ -5368,26 +5402,37 @@ qmckl_exit_code qmckl_compute_tmp_c ( return QMCKL_INVALID_ARG_4; } - M = elec_num; - N = nucl_num*(cord_num + 1); - K = elec_num; - - LDA = sizeof(een_rescaled_e)/sizeof(double); - LDB = sizeof(een_rescaled_n)/sizeof(double); - LDC = sizeof(tmp_c)/sizeof(double); + if (walk_num <= 0) { + return QMCKL_INVALID_ARG_5; + } - for (int nw=0; nw < walk_num; ++nw) { - for (int i=0; i Date: Mon, 4 Apr 2022 17:30:38 +0200 Subject: [PATCH 25/29] Fixed documentation --- org/qmckl_electron.org | 28 ++++++++++++++-------------- org/qmckl_jastrow.org | 38 +++++++++++++++++++------------------- org/qmckl_point.org | 2 +- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/org/qmckl_electron.org b/org/qmckl_electron.org index 33ac366..360d1bf 100644 --- a/org/qmckl_electron.org +++ b/org/qmckl_electron.org @@ -97,8 +97,8 @@ int main() { | ~ee_distance_rescaled_deriv_e_date~ | ~uint64_t~ | Last modification date of the electron-electron distance derivatives | | ~ee_pot~ | ~double[walk_num]~ | Electron-electron rescaled distances derivatives | | ~ee_pot_date~ | ~uint64_t~ | Last modification date of the electron-electron distance derivatives | - | ~en_pot~ | double[walk_num] | Electron-nucleus potential energy | - | ~en_pot_date~ | int64_t | Date when the electron-nucleus potential energy was computed | + | ~en_pot~ | ~double[walk_num]~ | Electron-nucleus potential energy | + | ~en_pot_date~ | ~int64_t~ | Date when the electron-nucleus potential energy was computed | | ~en_distance_rescaled~ | ~double[walk_num][nucl_num][num]~ | Electron-nucleus distances | | ~en_distance_rescaled_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | | ~en_distance_rescaled_deriv_e~ | ~double[walk_num][4][nucl_num][num]~ | Electron-electron rescaled distances derivatives | @@ -1218,7 +1218,7 @@ qmckl_exit_code qmckl_provide_ee_distance_rescaled(qmckl_context context) | ~elec_num~ | ~int64_t~ | in | Number of electrons | | ~rescale_factor_kappa_ee~ | ~double~ | in | Factor to rescale ee distances | | ~walk_num~ | ~int64_t~ | in | Number of walkers | - | ~coord~ | ~double[walk_num][3][elec_num]~ | in | Electron coordinates | + | ~coord~ | ~double[3][walk_num][elec_num]~ | in | Electron coordinates | | ~ee_distance~ | ~double[walk_num][elec_num][elec_num]~ | out | Electron-electron rescaled distances | #+begin_src f90 :comments org :tangle (eval f) :noweb yes @@ -1231,7 +1231,7 @@ integer function qmckl_compute_ee_distance_rescaled_f(context, elec_num, rescale integer*8 , intent(in) :: elec_num double precision , intent(in) :: rescale_factor_kappa_ee integer*8 , intent(in) :: walk_num - double precision , intent(in) :: coord(elec_num,3,walk_num) + double precision , intent(in) :: coord(elec_num,walk_num,3) double precision , intent(out) :: ee_distance_rescaled(elec_num,elec_num,walk_num) integer*8 :: k @@ -1357,7 +1357,7 @@ assert(fabs(ee_distance_rescaled[elec_num*elec_num+1]-0.9985724058042633) < 1.e- #+end_src -** Electron-electron rescaled distance gradients and laplacian with respect to electron coords +** Electron-electron rescaled distance gradients and Laplacian with respect to electron coords The rescaled distances which is given as $R = (1 - \exp{-\kappa r})/\kappa$ needs to be perturbed with respect to the electorn coordinates. @@ -1464,7 +1464,7 @@ qmckl_exit_code qmckl_provide_ee_distance_rescaled_deriv_e(qmckl_context context | ~elec_num~ | ~int64_t~ | in | Number of electrons | | ~rescale_factor_kappa_ee~ | ~double~ | in | Factor to rescale ee distances | | ~walk_num~ | ~int64_t~ | in | Number of walkers | - | ~coord~ | ~double[walk_num][3][elec_num]~ | in | Electron coordinates | + | ~coord~ | ~double[3][walk_num][elec_num]~ | in | Electron coordinates | | ~ee_distance_deriv_e~ | ~double[walk_num][4][elec_num][elec_num]~ | out | Electron-electron rescaled distance derivatives | #+begin_src f90 :comments org :tangle (eval f) :noweb yes @@ -1477,7 +1477,7 @@ integer function qmckl_compute_ee_distance_rescaled_deriv_e_f(context, elec_num, integer*8 , intent(in) :: elec_num double precision , intent(in) :: rescale_factor_kappa_ee integer*8 , intent(in) :: walk_num - double precision , intent(in) :: coord(elec_num,3,walk_num) + double precision , intent(in) :: coord(elec_num,walk_num,3) double precision , intent(out) :: ee_distance_rescaled_deriv_e(4,elec_num,elec_num,walk_num) integer*8 :: k @@ -1501,8 +1501,8 @@ integer function qmckl_compute_ee_distance_rescaled_deriv_e_f(context, elec_num, do k=1,walk_num info = qmckl_distance_rescaled_deriv_e(context, 'T', 'T', elec_num, elec_num, & - coord(1,1,k), elec_num, & - coord(1,1,k), elec_num, & + coord(1,k,1), elec_num*walk_num, & + coord(1,k,1), elec_num*walk_num, & ee_distance_rescaled_deriv_e(1,1,1,k), elec_num, rescale_factor_kappa_ee) if (info /= QMCKL_SUCCESS) then exit @@ -1905,7 +1905,7 @@ qmckl_exit_code qmckl_provide_en_distance(qmckl_context context) | ~elec_num~ | ~int64_t~ | in | Number of electrons | | ~nucl_num~ | ~int64_t~ | in | Number of nuclei | | ~walk_num~ | ~int64_t~ | in | Number of walkers | - | ~elec_coord~ | ~double[walk_num][3][elec_num]~ | in | Electron coordinates | + | ~elec_coord~ | ~double[3][walk_num][elec_num]~ | in | Electron coordinates | | ~nucl_coord~ | ~double[3][elec_num]~ | in | Nuclear coordinates | | ~en_distance~ | ~double[walk_num][nucl_num][elec_num]~ | out | Electron-nucleus distances | @@ -2183,7 +2183,7 @@ qmckl_exit_code qmckl_provide_en_distance_rescaled(qmckl_context context) | ~nucl_num~ | ~int64_t~ | in | Number of nuclei | | ~rescale_factor_kappa_en~ | ~double~ | in | The factor for rescaled distances | | ~walk_num~ | ~int64_t~ | in | Number of walkers | - | ~elec_coord~ | ~double[walk_num][3][elec_num]~ | in | Electron coordinates | + | ~elec_coord~ | ~double[3][walk_num][elec_num]~ | in | Electron coordinates | | ~nucl_coord~ | ~double[3][elec_num]~ | in | Nuclear coordinates | | ~en_distance_rescaled~ | ~double[walk_num][nucl_num][elec_num]~ | out | Electron-nucleus distances | @@ -2471,9 +2471,9 @@ qmckl_exit_code qmckl_provide_en_distance_rescaled_deriv_e(qmckl_context context | ~nucl_num~ | ~int64_t~ | in | Number of nuclei | | ~rescale_factor_kappa_en~ | ~double~ | in | The factor for rescaled distances | | ~walk_num~ | ~int64_t~ | in | Number of walkers | - | ~elec_coord~ | ~double[walk_num][3][elec_num]~ | in | Electron coordinates | + | ~elec_coord~ | ~double[3][walk_num][elec_num]~ | in | Electron coordinates | | ~nucl_coord~ | ~double[3][elec_num]~ | in | Nuclear coordinates | - | ~en_distance_rescaled_deriv_e~ | ~double[walk_num][4][nucl_num][elec_num]~ | out | Electron-nucleus distance derivatives | + | ~en_distance_rescaled_deriv_e~ | ~double[walk_num][nucl_num][elec_num][4]~ | out | Electron-nucleus distance derivatives | #+begin_src f90 :comments org :tangle (eval f) :noweb yes integer function qmckl_compute_en_distance_rescaled_deriv_e_f(context, elec_num, nucl_num, & @@ -2843,7 +2843,7 @@ assert (rc == QMCKL_SUCCESS); *** Compute :noexport: - # begin_src f90 :comments org :tangle (eval f) :noweb yes + # begin_src f90 :comments org :tangle (eval f) :noweb yes subroutine draw_init_points implicit none BEGIN_DOC diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index d4eaaa8..ff94f28 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -154,25 +154,25 @@ int main() { computed data: - | Variable | Type | In/Out | Description | - |----------------------------+---------------------------------------------------------------------+-------------------------------------------------+---------------------------------| - | ~dim_cord_vect~ | ~int64_t~ | Number of unique C coefficients | | - | ~dim_cord_vect_date~ | ~uint64_t~ | Number of unique C coefficients | | - | ~asymp_jasb~ | ~double[2]~ | Asymptotic component | | - | ~asymp_jasb_date~ | ~uint64_t~ | Asymptotic component | | - | ~cord_vect_full~ | ~double[dim_cord_vect][nucl_num]~ | vector of non-zero coefficients | | - | ~cord_vect_full_date~ | ~uint64_t~ | Keep track of changes here | | - | ~lkpm_combined_index~ | ~int64_t[4][dim_cord_vect]~ | Transform l,k,p, and m into consecutive indices | | - | ~lkpm_combined_index_date~ | ~uint64_t~ | Transform l,k,p, and m into consecutive indices | | - | ~tmp_c~ | ~double[walk_num][0:cord_num-1][0:cord_num][nucl_num][elec_num]~ | out | vector of non-zero coefficients | - | ~dtmp_c~ | ~double[walk_num][elec_num][4][nucl_num][0:cord_num][0:cord_num-1]~ | vector of non-zero coefficients | | + | Variable | Type | In/Out | + |----------------------------+-----------------------------------------------------------------+-------------------------------------------------| + | ~dim_cord_vect~ | ~int64_t~ | Number of unique C coefficients | + | ~dim_cord_vect_date~ | ~uint64_t~ | Number of unique C coefficients | + | ~asymp_jasb~ | ~double[2]~ | Asymptotic component | + | ~asymp_jasb_date~ | ~uint64_t~ | Asymptotic component | + | ~cord_vect_full~ | ~double[dim_cord_vect][nucl_num]~ | vector of non-zero coefficients | + | ~cord_vect_full_date~ | ~uint64_t~ | Keep track of changes here | + | ~lkpm_combined_index~ | ~int64_t[4][dim_cord_vect]~ | Transform l,k,p, and m into consecutive indices | + | ~lkpm_combined_index_date~ | ~uint64_t~ | Transform l,k,p, and m into consecutive indices | + | ~tmp_c~ | ~double[walk_num][cord_num][cord_num+1][nucl_num][elec_num]~ | vector of non-zero coefficients | + | ~dtmp_c~ | ~double[walk_num][elec_num][4][nucl_num][cord_num+1][cord_num]~ | vector of non-zero coefficients | - | ~een_rescaled_n~ | ~double[walk_num][elec_num][nucl_num][0:cord_num]~ | The electron-electron rescaled distances raised to the powers defined by cord | | - | ~een_rescaled_n_date~ | ~uint64_t~ | Keep track of the date of creation | | - | ~een_rescaled_e_deriv_e~ | ~double[walk_num][elec_num][4][elec_num][0:cord_num]~ | The electron-electron rescaled distances raised to the powers defined by cord derivatives wrt electrons | | - | ~een_rescaled_e_deriv_e_date~ | ~uint64_t~ | Keep track of the date of creation | | - | ~een_rescaled_n_deriv_e~ | ~double[walk_num][elec_num][4][nucl_num][0:cord_num]~ | The electron-electron rescaled distances raised to the powers defined by cord derivatives wrt electrons | | - | ~een_rescaled_n_deriv_e_date~ | ~uint64_t~ | Keep track of the date of creation | | + | ~een_rescaled_n~ | ~double[walk_num][cord_num+1][nucl_num][elec_num]~ | The electron-electron rescaled distances raised to the powers defined by cord | + | ~een_rescaled_n_date~ | ~uint64_t~ | Keep track of the date of creation | + | ~een_rescaled_e_deriv_e~ | ~double[walk_num][cord_num+1][elec_num][4][elec_num]~ | The electron-electron rescaled distances raised to the powers defined by cord derivatives wrt electrons | + | ~een_rescaled_e_deriv_e_date~ | ~uint64_t~ | Keep track of the date of creation | + | ~een_rescaled_n_deriv_e~ | ~double[walk_num][cord_num+1][nucl_num][4][elec_num]~ | The electron-electron rescaled distances raised to the powers defined by cord derivatives wrt electrons | + | ~een_rescaled_n_deriv_e_date~ | ~uint64_t~ | Keep track of the date of creation | #+NAME: jastrow_data #+BEGIN_SRC python :results none :exports none @@ -5731,7 +5731,7 @@ qmckl_exit_code qmckl_compute_dtmp_c (const qmckl_context context, #+end_src #+begin_src c :tangle (eval h_private_func) :comments org - qmckl_exit_code qmckl_compute_dtmp_c_hpc ( +qmckl_exit_code qmckl_compute_dtmp_c_hpc ( const qmckl_context context, const int64_t cord_num, const int64_t elec_num, diff --git a/org/qmckl_point.org b/org/qmckl_point.org index 07b0863..e9ce0b7 100644 --- a/org/qmckl_point.org +++ b/org/qmckl_point.org @@ -81,7 +81,7 @@ int main() { |----------+----------------+-------------------------------------------| | ~num~ | ~int64_t~ | Total number of points | | ~date~ | ~uint64_t~ | Last modification date of the coordinates | - | ~coord~ | ~qmckl_matrix~ | ~num~ \times 3 matrix3 | + | ~coord~ | ~qmckl_matrix~ | ~num~ \times 3 matrix | We consider that the matrix is stored 'transposed' and 'normal' corresponds to the 3 \times ~num~ matrix. From bcdbc49d5fdbabbb493a7cb140586e3a1372a07f Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 4 Apr 2022 23:53:58 +0200 Subject: [PATCH 26/29] Cleaning --- org/qmckl_jastrow.org | 91 +++++++++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 38 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index ff94f28..659f23a 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -2058,9 +2058,10 @@ qmckl_exit_code qmckl_provide_factor_ee_deriv_e(qmckl_context context) | ~factor_ee_deriv_e~ | ~double[walk_num][4][elec_num]~ | out | Electron-electron distances | #+begin_src f90 :comments org :tangle (eval f) :noweb yes -integer function qmckl_compute_factor_ee_deriv_e_f(context, walk_num, elec_num, up_num, bord_num, & - bord_vector, ee_distance_rescaled, ee_distance_rescaled_deriv_e, & - asymp_jasb, factor_ee_deriv_e) & +integer function qmckl_compute_factor_ee_deriv_e_f( & + context, walk_num, elec_num, up_num, bord_num, & + bord_vector, ee_distance_rescaled, ee_distance_rescaled_deriv_e, & + asymp_jasb, factor_ee_deriv_e) & result(info) use qmckl implicit none @@ -2068,7 +2069,7 @@ integer function qmckl_compute_factor_ee_deriv_e_f(context, walk_num, elec_num, integer*8 , intent(in) :: walk_num, elec_num, bord_num, up_num double precision , intent(in) :: bord_vector(bord_num + 1) double precision , intent(in) :: ee_distance_rescaled(elec_num, elec_num,walk_num) - double precision , intent(in) :: ee_distance_rescaled_deriv_e(4,elec_num, elec_num,walk_num) + double precision , intent(in) :: ee_distance_rescaled_deriv_e(4,elec_num, elec_num,walk_num) !TODO double precision , intent(in) :: asymp_jasb(2) double precision , intent(out) :: factor_ee_deriv_e(elec_num,4,walk_num) @@ -2183,7 +2184,7 @@ end function qmckl_compute_factor_ee_deriv_e_f #+RESULTS: #+begin_src f90 :tangle (eval f) :comments org :exports none - integer(c_int32_t) function qmckl_compute_factor_ee_deriv_e & +integer(c_int32_t) function qmckl_compute_factor_ee_deriv_e & (context, & walk_num, & elec_num, & @@ -2480,9 +2481,10 @@ qmckl_exit_code qmckl_provide_factor_en(qmckl_context context) | ~factor_en~ | ~double[walk_num]~ | out | Electron-nucleus jastrow | #+begin_src f90 :comments org :tangle (eval f) :noweb yes -integer function qmckl_compute_factor_en_f(context, walk_num, elec_num, nucl_num, type_nucl_num, & - type_nucl_vector, aord_num, aord_vector, & - en_distance_rescaled, factor_en) & +integer function qmckl_compute_factor_en_f( & + context, walk_num, elec_num, nucl_num, type_nucl_num, & + type_nucl_vector, aord_num, aord_vector, & + en_distance_rescaled, factor_en) & result(info) use qmckl implicit none @@ -2828,9 +2830,10 @@ qmckl_exit_code qmckl_provide_factor_en_deriv_e(qmckl_context context) | ~factor_en_deriv_e~ | ~double[walk_num][4][elec_num]~ | out | Electron-nucleus jastrow | #+begin_src f90 :comments org :tangle (eval f) :noweb yes -integer function qmckl_compute_factor_en_deriv_e_f(context, walk_num, elec_num, nucl_num, type_nucl_num, & - type_nucl_vector, aord_num, aord_vector, & - en_distance_rescaled, en_distance_rescaled_deriv_e, factor_en_deriv_e) & +integer function qmckl_compute_factor_en_deriv_e_f( & + context, walk_num, elec_num, nucl_num, type_nucl_num, & + type_nucl_vector, aord_num, aord_vector, & + en_distance_rescaled, en_distance_rescaled_deriv_e, factor_en_deriv_e) & result(info) use qmckl implicit none @@ -2910,7 +2913,7 @@ integer function qmckl_compute_factor_en_deriv_e_f(context, walk_num, elec_num, lap3 = lap3 - 2.0d0 * aord_vector(2, type_nucl_vector(a)) * dx(ii) * dx(ii) factor_en_deriv_e(i, ii, nw) = factor_en_deriv_e(i, ii, nw) + aord_vector(1, type_nucl_vector(a)) & - * dx(ii) * invden2 & + ,* dx(ii) * invden2 & + power_ser_g(ii) end do @@ -3238,7 +3241,8 @@ qmckl_exit_code qmckl_provide_een_rescaled_e(qmckl_context context) | ~een_rescaled_e~ | ~double[walk_num][0:cord_num][elec_num][elec_num]~ | out | Electron-electron rescaled distances | #+begin_src f90 :comments org :tangle (eval f) :noweb yes -integer function qmckl_compute_een_rescaled_e_f(context, walk_num, elec_num, cord_num, rescale_factor_kappa_ee, & +integer function qmckl_compute_een_rescaled_e_f( & + context, walk_num, elec_num, cord_num, rescale_factor_kappa_ee, & ee_distance, een_rescaled_e) & result(info) use qmckl @@ -3343,7 +3347,8 @@ end function qmckl_compute_een_rescaled_e_f #+RESULTS: #+begin_src f90 :tangle (eval f) :comments org :exports none integer(c_int32_t) function qmckl_compute_een_rescaled_e & - (context, walk_num, elec_num, cord_num, rescale_factor_kappa_ee, ee_distance, een_rescaled_e) & + (context, walk_num, elec_num, cord_num, rescale_factor_kappa_ee, & + ee_distance, een_rescaled_e) & bind(C) result(info) use, intrinsic :: iso_c_binding @@ -3574,7 +3579,8 @@ qmckl_exit_code qmckl_provide_een_rescaled_e_deriv_e(qmckl_context context) | ~een_rescaled_e_deriv_e~ | ~double[walk_num][0:cord_num][elec_num][4][elec_num]~ | out | Electron-electron rescaled distances | #+begin_src f90 :comments org :tangle (eval f) :noweb yes -integer function qmckl_compute_factor_een_rescaled_e_deriv_e_f(context, walk_num, elec_num, cord_num, rescale_factor_kappa_ee, & +integer function qmckl_compute_factor_een_rescaled_e_deriv_e_f( & + context, walk_num, elec_num, cord_num, rescale_factor_kappa_ee, & coord_new, ee_distance, een_rescaled_e, een_rescaled_e_deriv_e) & result(info) use qmckl @@ -3951,7 +3957,8 @@ qmckl_exit_code qmckl_provide_een_rescaled_n(qmckl_context context) | ~een_rescaled_n~ | ~double[walk_num][0:cord_num][nucl_num][elec_num]~ | out | Electron-nucleus rescaled distances | #+begin_src f90 :comments org :tangle (eval f) :noweb yes -integer function qmckl_compute_een_rescaled_n_f(context, walk_num, elec_num, nucl_num, cord_num, rescale_factor_kappa_en, & +integer function qmckl_compute_een_rescaled_n_f( & + context, walk_num, elec_num, nucl_num, cord_num, rescale_factor_kappa_en, & en_distance, een_rescaled_n) & result(info) use qmckl @@ -4295,9 +4302,10 @@ qmckl_exit_code qmckl_provide_een_rescaled_n_deriv_e(qmckl_context context) | ~een_rescaled_n_deriv_e~ | ~double[walk_num][0:cord_num][nucl_num][4][elec_num]~ | out | Electron-nucleus rescaled distances | #+begin_src f90 :comments org :tangle (eval f) :noweb yes -integer function qmckl_compute_factor_een_rescaled_n_deriv_e_f(context, walk_num, elec_num, nucl_num, & - cord_num, rescale_factor_kappa_en, & - coord_new, coord, en_distance, een_rescaled_n, een_rescaled_n_deriv_e) & +integer function qmckl_compute_factor_een_rescaled_n_deriv_e_f( & + context, walk_num, elec_num, nucl_num, & + cord_num, rescale_factor_kappa_en, & + coord_new, coord, en_distance, een_rescaled_n, een_rescaled_n_deriv_e) & result(info) use qmckl implicit none @@ -4938,7 +4946,8 @@ qmckl_exit_code qmckl_provide_dtmp_c(qmckl_context context) | ~dim_cord_vect~ | ~int64_t~ | out | dimension of cord_vect_full table | #+begin_src f90 :comments org :tangle (eval f) :noweb yes -integer function qmckl_compute_dim_cord_vect_f(context, cord_num, dim_cord_vect) & +integer function qmckl_compute_dim_cord_vect_f( & + context, cord_num, dim_cord_vect) & result(info) use qmckl implicit none @@ -5046,7 +5055,8 @@ qmckl_exit_code qmckl_compute_dim_cord_vect ( | ~cord_vect_full~ | ~double[dim_cord_vect][nucl_num]~ | out | Full list of coefficients | #+begin_src f90 :comments org :tangle (eval f) :noweb yes -integer function qmckl_compute_cord_vect_full_f(context, nucl_num, dim_cord_vect, type_nucl_num, & +integer function qmckl_compute_cord_vect_full_f( & + context, nucl_num, dim_cord_vect, type_nucl_num, & type_nucl_vector, cord_vector, cord_vect_full) & result(info) use qmckl @@ -5148,8 +5158,8 @@ end function qmckl_compute_cord_vect_full_f | ~lkpm_combined_index~ | ~int64_t[4][dim_cord_vect]~ | out | Full list of combined indices | #+begin_src f90 :comments org :tangle (eval f) :noweb yes -integer function qmckl_compute_lkpm_combined_index_f(context, cord_num, dim_cord_vect, & - lkpm_combined_index) & +integer function qmckl_compute_lkpm_combined_index_f( & + context, cord_num, dim_cord_vect, lkpm_combined_index) & result(info) use qmckl implicit none @@ -5281,7 +5291,8 @@ qmckl_exit_code qmckl_compute_lkpm_combined_index ( | ~tmp_c~ | ~double[walk_num][0:cord_num-1][0:cord_num][nucl_num][elec_num]~ | out | vector of non-zero coefficients | #+begin_src f90 :comments org :tangle (eval f) :noweb yes -integer function qmckl_compute_tmp_c_doc_f(context, cord_num, elec_num, nucl_num, & +integer function qmckl_compute_tmp_c_doc_f( & + context, cord_num, elec_num, nucl_num, & walk_num, een_rescaled_e, een_rescaled_n, tmp_c) & result(info) use qmckl @@ -5525,7 +5536,8 @@ qmckl_exit_code qmckl_compute_tmp_c (const qmckl_context context, | ~dtmp_c~ | ~double[walk_num][0:cord_num-1][0:cord_num][nucl_num][elec_num]~ | out | vector of non-zero coefficients | #+begin_src f90 :comments org :tangle (eval f) :noweb yes -integer function qmckl_compute_dtmp_c_doc_f(context, cord_num, elec_num, nucl_num, & +integer function qmckl_compute_dtmp_c_doc_f( & + context, cord_num, elec_num, nucl_num, & walk_num, een_rescaled_e_deriv_e, een_rescaled_n, dtmp_c) & result(info) use qmckl @@ -5975,9 +5987,10 @@ qmckl_exit_code qmckl_provide_factor_een(qmckl_context context) | ~factor_een~ | ~double[walk_num]~ | out | Electron-nucleus jastrow | #+begin_src f90 :comments org :tangle (eval f) :noweb yes -integer function qmckl_compute_factor_een_naive_f(context, walk_num, elec_num, nucl_num, cord_num,& - dim_cord_vect, cord_vect_full, lkpm_combined_index, & - een_rescaled_e, een_rescaled_n, factor_een) & +integer function qmckl_compute_factor_een_naive_f( & + context, walk_num, elec_num, nucl_num, cord_num,& + dim_cord_vect, cord_vect_full, lkpm_combined_index, & + een_rescaled_e, een_rescaled_n, factor_een) & result(info) use qmckl implicit none @@ -6142,9 +6155,10 @@ end function qmckl_compute_factor_een_naive_f | ~factor_een~ | ~double[walk_num]~ | out | Electron-nucleus jastrow | #+begin_src f90 :comments org :tangle (eval f) :noweb yes -integer function qmckl_compute_factor_een_f(context, walk_num, elec_num, nucl_num, cord_num, & - dim_cord_vect, cord_vect_full, lkpm_combined_index, & - tmp_c, een_rescaled_n, factor_een) & +integer function qmckl_compute_factor_een_f( & + context, walk_num, elec_num, nucl_num, cord_num, & + dim_cord_vect, cord_vect_full, lkpm_combined_index, & + tmp_c, een_rescaled_n, factor_een) & result(info) use qmckl implicit none @@ -6490,10 +6504,10 @@ qmckl_exit_code qmckl_provide_factor_een_deriv_e(qmckl_context context) | ~factor_een_deriv_e~ | ~double[walk_num][4][elec_num]~ | out | Electron-nucleus jastrow | #+begin_src f90 :comments org :tangle (eval f) :noweb yes -integer function qmckl_compute_factor_een_deriv_e_naive_f(context, walk_num, elec_num, nucl_num, cord_num, & - dim_cord_vect, cord_vect_full, lkpm_combined_index, & - een_rescaled_e, een_rescaled_n, & - een_rescaled_e_deriv_e, een_rescaled_n_deriv_e, factor_een_deriv_e)& +integer function qmckl_compute_factor_een_deriv_e_naive_f( & + context, walk_num, elec_num, nucl_num, cord_num, dim_cord_vect, & + cord_vect_full, lkpm_combined_index, een_rescaled_e, een_rescaled_n, & + een_rescaled_e_deriv_e, een_rescaled_n_deriv_e, factor_een_deriv_e)& result(info) use qmckl implicit none @@ -6689,9 +6703,10 @@ end function qmckl_compute_factor_een_deriv_e_naive_f #+begin_src f90 :comments org :tangle (eval f) :noweb yes -integer function qmckl_compute_factor_een_deriv_e_f(context, walk_num, elec_num, nucl_num, cord_num, dim_cord_vect, & - cord_vect_full, lkpm_combined_index, & - tmp_c, dtmp_c, een_rescaled_n, een_rescaled_n_deriv_e, factor_een_deriv_e) & +integer function qmckl_compute_factor_een_deriv_e_f( & + context, walk_num, elec_num, nucl_num, & + cord_num, dim_cord_vect, cord_vect_full, lkpm_combined_index, & + tmp_c, dtmp_c, een_rescaled_n, een_rescaled_n_deriv_e, factor_een_deriv_e)& result(info) use qmckl implicit none From 511eba58430cc1e448f64fc83ab63c15e6b1eb71 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 5 Apr 2022 09:56:13 +0200 Subject: [PATCH 27/29] Fixed dgemm bug --- org/qmckl_jastrow.org | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/org/qmckl_jastrow.org b/org/qmckl_jastrow.org index 659f23a..5d600f6 100644 --- a/org/qmckl_jastrow.org +++ b/org/qmckl_jastrow.org @@ -5432,18 +5432,19 @@ qmckl_exit_code qmckl_compute_tmp_c_hpc ( const int64_t LDB = elec_num; const int64_t LDC = elec_num; + const int64_t af = elec_num*elec_num; + const int64_t bf = elec_num*nucl_num*(cord_num+1); + const int64_t cf = bf; + for (int64_t nw=0; nw < walk_num; ++nw) { for (int64_t i=0; i Date: Tue, 5 Apr 2022 10:07:25 +0200 Subject: [PATCH 28/29] Fix flag for nvc and nvfortran --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index c746a41..fe54fc2 100644 --- a/configure.ac +++ b/configure.ac @@ -201,7 +201,7 @@ AS_IF([test "$BLAS_LIBS" == "$LAPACK_LIBS"], [BLAS_LIBS=""]) case $FC in *ifort*) - FCFLAGS="$FCFLAGS -nofor-main -mp -target=gpu" + FCFLAGS="$FCFLAGS -nofor-main" ;; *nvfortran*) @@ -213,7 +213,7 @@ esac case $CC in *nvc*) - CFLAGS="$CFLAGS -fPIC" + CFLAGS="$CFLAGS -fPIC -mp -target=gpu" ;; esac From 731fded4a80da4cf66380f6563da435c36a4b4c0 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 5 Apr 2022 10:50:51 +0200 Subject: [PATCH 29/29] warnings --- org/qmckl_determinant.org | 69 +++++++++++++++++---------------------- org/qmckl_nucleus.org | 37 ++++++++++----------- 2 files changed, 48 insertions(+), 58 deletions(-) diff --git a/org/qmckl_determinant.org b/org/qmckl_determinant.org index 0412db6..8c205fc 100644 --- a/org/qmckl_determinant.org +++ b/org/qmckl_determinant.org @@ -1134,36 +1134,28 @@ end function qmckl_compute_det_vgl_beta_f #+begin_src c :tangle (eval c_test) :exports none -#define walk_num chbrclf_walk_num -#define elec_num chbrclf_elec_num -#define shell_num chbrclf_shell_num -#define ao_num chbrclf_ao_num - -int64_t elec_up_num = chbrclf_elec_up_num; -int64_t elec_dn_num = chbrclf_elec_dn_num; double* elec_coord = &(chbrclf_elec_coord[0][0][0]); -const int64_t nucl_num = chbrclf_nucl_num; const double* nucl_charge = chbrclf_charge; const double* nucl_coord = &(chbrclf_nucl_coord[0][0]); -rc = qmckl_set_electron_num (context, elec_up_num, elec_dn_num); +rc = qmckl_set_electron_num (context, chbrclf_elec_up_num, chbrclf_elec_dn_num); assert (rc == QMCKL_SUCCESS); -rc = qmckl_set_electron_walk_num (context, walk_num); +rc = qmckl_set_electron_walk_num (context, chbrclf_walk_num); assert (rc == QMCKL_SUCCESS); assert(qmckl_electron_provided(context)); -rc = qmckl_set_electron_coord (context, 'N', elec_coord, walk_num*elec_num*3); +rc = qmckl_set_electron_coord (context, 'N', elec_coord, chbrclf_walk_num*chbrclf_elec_num*3); assert(rc == QMCKL_SUCCESS); -rc = qmckl_set_nucleus_num (context, nucl_num); +rc = qmckl_set_nucleus_num (context, chbrclf_nucl_num); assert(rc == QMCKL_SUCCESS); -rc = qmckl_set_nucleus_coord (context, 'T', &(nucl_coord[0]), nucl_num*3); +rc = qmckl_set_nucleus_coord (context, 'T', &(nucl_coord[0]), chbrclf_nucl_num*3); assert(rc == QMCKL_SUCCESS); -rc = qmckl_set_nucleus_charge(context, nucl_charge, nucl_num); +rc = qmckl_set_nucleus_charge(context, nucl_charge, chbrclf_nucl_num); assert(rc == QMCKL_SUCCESS); assert(qmckl_nucleus_provided(context)); @@ -1195,27 +1187,27 @@ rc = qmckl_set_ao_basis_prim_num (context, chbrclf_prim_num); assert(rc == QMCKL_SUCCESS); assert(!qmckl_ao_basis_provided(context)); -rc = qmckl_set_ao_basis_nucleus_index (context, nucleus_index, nucl_num); +rc = qmckl_set_ao_basis_nucleus_index (context, nucleus_index, chbrclf_nucl_num); assert(rc == QMCKL_SUCCESS); assert(!qmckl_ao_basis_provided(context)); -rc = qmckl_set_ao_basis_nucleus_shell_num (context, nucleus_shell_num, nucl_num); +rc = qmckl_set_ao_basis_nucleus_shell_num (context, nucleus_shell_num, chbrclf_nucl_num); assert(rc == QMCKL_SUCCESS); assert(!qmckl_ao_basis_provided(context)); -rc = qmckl_set_ao_basis_shell_ang_mom (context, shell_ang_mom, shell_num); +rc = qmckl_set_ao_basis_shell_ang_mom (context, shell_ang_mom, chbrclf_shell_num); assert(rc == QMCKL_SUCCESS); assert(!qmckl_ao_basis_provided(context)); -rc = qmckl_set_ao_basis_shell_factor (context, shell_factor, shell_num); +rc = qmckl_set_ao_basis_shell_factor (context, shell_factor, chbrclf_shell_num); assert(rc == QMCKL_SUCCESS); assert(!qmckl_ao_basis_provided(context)); -rc = qmckl_set_ao_basis_shell_prim_num (context, shell_prim_num, shell_num); +rc = qmckl_set_ao_basis_shell_prim_num (context, shell_prim_num, chbrclf_shell_num); assert(rc == QMCKL_SUCCESS); assert(!qmckl_ao_basis_provided(context)); -rc = qmckl_set_ao_basis_shell_prim_index (context, shell_prim_index, shell_num); +rc = qmckl_set_ao_basis_shell_prim_index (context, shell_prim_index, chbrclf_shell_num); assert(rc == QMCKL_SUCCESS); assert(!qmckl_ao_basis_provided(context)); @@ -1239,14 +1231,13 @@ assert(rc == QMCKL_SUCCESS); assert(qmckl_ao_basis_provided(context)); -double ao_vgl[walk_num*elec_num][5][chbrclf_ao_num]; +double ao_vgl[chbrclf_walk_num*chbrclf_elec_num][5][chbrclf_ao_num]; -rc = qmckl_get_ao_basis_ao_vgl(context, &(ao_vgl[0][0][0]), (int64_t) 5*walk_num*elec_num*chbrclf_ao_num); +rc = qmckl_get_ao_basis_ao_vgl(context, &(ao_vgl[0][0][0]), (int64_t) 5*chbrclf_walk_num*chbrclf_elec_num*chbrclf_ao_num); assert (rc == QMCKL_SUCCESS); /* Set up MO data */ -const int64_t mo_num = chbrclf_mo_num; -rc = qmckl_set_mo_basis_mo_num(context, mo_num); +rc = qmckl_set_mo_basis_mo_num(context, chbrclf_mo_num); assert (rc == QMCKL_SUCCESS); const double * mo_coefficient = &(chbrclf_mo_coef[0]); @@ -1256,31 +1247,31 @@ assert (rc == QMCKL_SUCCESS); assert(qmckl_mo_basis_provided(context)); -double mo_vgl[walk_num*elec_num][5][chbrclf_mo_num]; -rc = qmckl_get_mo_basis_mo_vgl(context, &(mo_vgl[0][0][0]), 5*walk_num*elec_num*chbrclf_mo_num); +double mo_vgl[chbrclf_walk_num*chbrclf_elec_num][5][chbrclf_mo_num]; +rc = qmckl_get_mo_basis_mo_vgl(context, &(mo_vgl[0][0][0]), 5*chbrclf_walk_num*chbrclf_elec_num*chbrclf_mo_num); assert (rc == QMCKL_SUCCESS); /* Set up determinant data */ -const int64_t det_num_alpha = 1; -const int64_t det_num_beta = 1; -int64_t mo_index_alpha[det_num_alpha][walk_num][elec_up_num]; -int64_t mo_index_beta[det_num_alpha][walk_num][elec_dn_num]; +#define det_num_alpha 1 +#define det_num_beta 1 +int64_t mo_index_alpha[det_num_alpha][chbrclf_walk_num][chbrclf_elec_up_num]; +int64_t mo_index_beta[det_num_alpha][chbrclf_walk_num][chbrclf_elec_dn_num]; int i, j, k; for(k = 0; k < det_num_alpha; ++k) - for(i = 0; i < walk_num; ++i) - for(j = 0; j < elec_up_num; ++j) + for(i = 0; i < chbrclf_walk_num; ++i) + for(j = 0; j < chbrclf_elec_up_num; ++j) mo_index_alpha[k][i][j] = j + 1; for(k = 0; k < det_num_beta; ++k) - for(i = 0; i < walk_num; ++i) - for(j = 0; j < elec_up_num; ++j) + for(i = 0; i < chbrclf_walk_num; ++i) + for(j = 0; j < chbrclf_elec_up_num; ++j) mo_index_beta[k][i][j] = j + 1; rc = qmckl_set_determinant_type (context, typ); assert(rc == QMCKL_SUCCESS); -rc = qmckl_set_determinant_walk_num (context, walk_num); +rc = qmckl_set_determinant_walk_num (context, chbrclf_walk_num); assert (rc == QMCKL_SUCCESS); rc = qmckl_set_determinant_det_num_alpha (context, det_num_alpha); @@ -1297,8 +1288,8 @@ assert (rc == QMCKL_SUCCESS); // Get slater-determinant -double det_vgl_alpha[det_num_alpha][walk_num][5][elec_up_num][elec_up_num]; -double det_vgl_beta[det_num_beta][walk_num][5][elec_dn_num][elec_dn_num]; +double det_vgl_alpha[det_num_alpha][chbrclf_walk_num][5][chbrclf_elec_up_num][chbrclf_elec_up_num]; +double det_vgl_beta[det_num_beta][chbrclf_walk_num][5][chbrclf_elec_dn_num][chbrclf_elec_dn_num]; rc = qmckl_get_det_vgl_alpha(context, &(det_vgl_alpha[0][0][0][0][0])); assert (rc == QMCKL_SUCCESS); @@ -2047,8 +2038,8 @@ end function qmckl_compute_det_inv_matrix_beta_f #+begin_src c :tangle (eval c_test) :exports none // Get adjoint of the slater-determinant -double det_inv_matrix_alpha[det_num_alpha][walk_num][elec_up_num][elec_up_num]; -double det_inv_matrix_beta[det_num_beta][walk_num][elec_dn_num][elec_dn_num]; +double det_inv_matrix_alpha[det_num_alpha][chbrclf_walk_num][chbrclf_elec_up_num][chbrclf_elec_up_num]; +double det_inv_matrix_beta[det_num_beta][chbrclf_walk_num][chbrclf_elec_dn_num][chbrclf_elec_dn_num]; rc = qmckl_get_det_inv_matrix_alpha(context, &(det_inv_matrix_alpha[0][0][0][0])); assert (rc == QMCKL_SUCCESS); diff --git a/org/qmckl_nucleus.org b/org/qmckl_nucleus.org index 319d5d1..e191d3e 100644 --- a/org/qmckl_nucleus.org +++ b/org/qmckl_nucleus.org @@ -672,7 +672,6 @@ end interface ** Test #+begin_src c :tangle (eval c_test) -const int64_t nucl_num = chbrclf_nucl_num; const double* nucl_charge = chbrclf_charge; const double* nucl_coord = &(chbrclf_nucl_coord[0][0]); const double nucl_rescale_factor_kappa = 2.0; @@ -688,13 +687,13 @@ rc = qmckl_get_nucleus_num (context, &n); assert(rc == QMCKL_NOT_PROVIDED); -rc = qmckl_set_nucleus_num (context, nucl_num); +rc = qmckl_set_nucleus_num (context, chbrclf_nucl_num); assert(rc == QMCKL_SUCCESS); assert(!qmckl_nucleus_provided(context)); rc = qmckl_get_nucleus_num (context, &n); assert(rc == QMCKL_SUCCESS); -assert(n == nucl_num); +assert(n == chbrclf_nucl_num); double k; rc = qmckl_get_nucleus_rescale_factor (context, &k); @@ -709,41 +708,41 @@ rc = qmckl_get_nucleus_rescale_factor (context, &k); assert(rc == QMCKL_SUCCESS); assert(k == nucl_rescale_factor_kappa); -double nucl_coord2[3*nucl_num]; +double nucl_coord2[3*chbrclf_nucl_num]; -rc = qmckl_get_nucleus_coord (context, 'T', nucl_coord2, 3*nucl_num); +rc = qmckl_get_nucleus_coord (context, 'T', nucl_coord2, 3*chbrclf_nucl_num); assert(rc == QMCKL_NOT_PROVIDED); -rc = qmckl_set_nucleus_coord (context, 'T', &(nucl_coord[0]), 3*nucl_num); +rc = qmckl_set_nucleus_coord (context, 'T', &(nucl_coord[0]), 3*chbrclf_nucl_num); assert(rc == QMCKL_SUCCESS); assert(!qmckl_nucleus_provided(context)); -rc = qmckl_get_nucleus_coord (context, 'N', nucl_coord2, 3*nucl_num); +rc = qmckl_get_nucleus_coord (context, 'N', nucl_coord2, 3*chbrclf_nucl_num); assert(rc == QMCKL_SUCCESS); for (size_t k=0 ; k<3 ; ++k) { - for (int64_t i=0 ; i