diff --git a/org/qmckl_jastrow_champ.org b/org/qmckl_jastrow_champ.org index c22bb58..e4b1a51 100644 --- a/org/qmckl_jastrow_champ.org +++ b/org/qmckl_jastrow_champ.org @@ -166,11 +166,11 @@ int main() { | ~dtmp_c~ | ~double[walk_num][elec_num][4][nucl_num][cord_num+1][cord_num]~ | vector of non-zero coefficients | | ~ee_distance_rescaled~ | ~double[walk_num][num][num]~ | Electron-electron rescaled distances | | ~ee_distance_rescaled_date~ | ~uint64_t~ | Last modification date of the electron-electron distances | - | ~ee_distance_rescaled_gl~ | ~double[walk_num][4][num][num]~ | Electron-electron rescaled distances derivatives | + | ~ee_distance_rescaled_gl~ | ~double[walk_num][num][num][4]~ | Electron-electron rescaled distances derivatives | | ~ee_distance_rescaled_gl_date~ | ~uint64_t~ | Last modification date of the electron-electron distance derivatives | | ~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_gl~ | ~double[walk_num][4][nucl_num][num]~ | Electron-electron rescaled distances derivatives | + | ~en_distance_rescaled_gl~ | ~double[walk_num][nucl_num][num][4]~ | Electron-electron rescaled distances derivatives | | ~en_distance_rescaled_gl_date~ | ~uint64_t~ | Last modification date of the electron-electron distance derivatives | | ~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 | @@ -1927,12 +1927,11 @@ qmckl_exit_code qmckl_compute_jastrow_champ_asymp_jasb ( double* const asymp_jasb ) { #ifdef HAVE_HPC - return qmckl_compute_jastrow_champ_asymp_jasb_hpc (context, - bord_num, b_vector, rescale_factor_ee, asymp_jasb); + return qmckl_compute_jastrow_champ_asymp_jasb_hpc #else - return qmckl_compute_jastrow_champ_asymp_jasb_doc (context, - bord_num, b_vector, rescale_factor_ee, asymp_jasb); + return qmckl_compute_jastrow_champ_asymp_jasb_doc #endif + (context, bord_num, b_vector, rescale_factor_ee, asymp_jasb); } #+end_src **** Test @@ -2455,14 +2454,12 @@ qmckl_compute_jastrow_champ_factor_ee (const qmckl_context context, { #ifdef HAVE_HPC - return qmckl_compute_jastrow_champ_factor_ee_hpc(context, walk_num, elec_num, - up_num, bord_num, b_vector, ee_distance_rescaled, asymp_jasb, - factor_ee); + return qmckl_compute_jastrow_champ_factor_ee_hpc #else - return qmckl_compute_jastrow_champ_factor_ee_doc(context, walk_num, elec_num, - up_num, bord_num, b_vector, ee_distance_rescaled, asymp_jasb, - factor_ee); + return qmckl_compute_jastrow_champ_factor_ee_doc #endif + (context, walk_num, elec_num, up_num, bord_num, b_vector, + ee_distance_rescaled, asymp_jasb, factor_ee); } #+end_src **** Test @@ -2811,31 +2808,25 @@ qmckl_exit_code qmckl_compute_jastrow_champ_factor_ee_gl_hpc( const double* ee_distance_rescaled_gl, double* const factor_ee_gl ) { - 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; - } - - - memset(factor_ee_gl, 0, elec_num*4*walk_num*sizeof(double)); + 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 (up_num <= 0) return QMCKL_INVALID_ARG_4; + if (bord_num < 0) return QMCKL_INVALID_ARG_5; + if (b_vector == NULL) return QMCKL_INVALID_ARG_6; + if (ee_distance_rescaled == NULL) return QMCKL_INVALID_ARG_7; + if (ee_distance_rescaled_gl == NULL) return QMCKL_INVALID_ARG_8; + if (factor_ee_gl == NULL) return QMCKL_INVALID_ARG_9; double kf[bord_num+1]; for (int k=0 ; k<=bord_num ; ++k) { kf[k] = (double) k; } + #pragma omp parallel for for (int nw = 0; nw < walk_num; ++nw) { + memset(&(factor_ee_gl[nw*4*elec_num]), 0, elec_num*4*sizeof(double)); + for (int j = 0; j < elec_num; ++j) { const double* dxj = &ee_distance_rescaled_gl[4*elec_num*(j+nw*elec_num)]; const double* xj = &ee_distance_rescaled [ elec_num*(j+nw*elec_num)]; @@ -2982,7 +2973,7 @@ integer(c_int32_t) function qmckl_compute_jastrow_champ_factor_ee_gl_doc & #+begin_src c :comments org :tangle (eval c) :noweb yes - qmckl_exit_code qmckl_compute_jastrow_champ_factor_ee_gl ( +qmckl_exit_code qmckl_compute_jastrow_champ_factor_ee_gl ( const qmckl_context context, const int64_t walk_num, const int64_t elec_num, @@ -2993,11 +2984,13 @@ integer(c_int32_t) function qmckl_compute_jastrow_champ_factor_ee_gl_doc & const double* ee_distance_rescaled_gl, double* const factor_ee_gl ) { - #ifdef HAVE_HPC - return qmckl_compute_jastrow_champ_factor_ee_gl_hpc(context, walk_num, elec_num, up_num, bord_num, b_vector, ee_distance_rescaled, ee_distance_rescaled_gl, factor_ee_gl ); - #else - return qmckl_compute_jastrow_champ_factor_ee_gl_doc(context, walk_num, elec_num, up_num, bord_num, b_vector, ee_distance_rescaled, ee_distance_rescaled_gl, factor_ee_gl ); - #endif +#ifdef HAVE_HPC + return qmckl_compute_jastrow_champ_factor_ee_gl_hpc +#else + return qmckl_compute_jastrow_champ_factor_ee_gl_doc +#endif + (context, walk_num, elec_num, up_num, bord_num, b_vector, + ee_distance_rescaled, ee_distance_rescaled_gl, factor_ee_gl ); } #+end_src @@ -3024,7 +3017,6 @@ def make_dist(elec_coord): - def make_dist_deriv(elec_coord): elec_dist_d = np.zeros(shape=(4, elec_num, elec_num),dtype=float) @@ -3272,7 +3264,7 @@ qmckl_exit_code qmckl_provide_ee_distance_rescaled(qmckl_context context) | ~ee_distance~ | ~double[walk_num][elec_num][elec_num]~ | out | Electron-electron rescaled distances | #+begin_src f90 :comments org :tangle (eval f) :noweb yes -integer function qmckl_compute_ee_distance_rescaled_f(context, elec_num, rescale_factor_ee, walk_num, & +integer function qmckl_compute_ee_distance_rescaled_doc_f(context, elec_num, rescale_factor_ee, walk_num, & coord, ee_distance_rescaled) & result(info) use qmckl @@ -3313,10 +3305,26 @@ integer function qmckl_compute_ee_distance_rescaled_f(context, elec_num, rescale endif end do -end function qmckl_compute_ee_distance_rescaled_f +end function qmckl_compute_ee_distance_rescaled_doc_f #+end_src #+begin_src c :tangle (eval h_private_func) :comments org :exports none +qmckl_exit_code qmckl_compute_ee_distance_rescaled_doc ( + const qmckl_context context, + const int64_t elec_num, + const double rescale_factor_ee, + const int64_t walk_num, + const double* coord, + double* const ee_distance_rescaled ); + +qmckl_exit_code qmckl_compute_ee_distance_rescaled_hpc ( + const qmckl_context context, + const int64_t elec_num, + const double rescale_factor_ee, + const int64_t walk_num, + const double* coord, + double* const ee_distance_rescaled ); + qmckl_exit_code qmckl_compute_ee_distance_rescaled ( const qmckl_context context, const int64_t elec_num, @@ -3326,29 +3334,98 @@ qmckl_exit_code qmckl_compute_ee_distance_rescaled ( double* const ee_distance_rescaled ); #+end_src - #+CALL: generate_c_interface(table=qmckl_ee_distance_rescaled_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + #+begin_src c :tangle (eval c) :comments org :exports none +qmckl_exit_code qmckl_compute_ee_distance_rescaled_hpc ( + const qmckl_context context, + const int64_t elec_num, + const double rescale_factor_ee, + const int64_t walk_num, + const double* coord, + double* const ee_distance_rescaled ) +{ + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return QMCKL_INVALID_CONTEXT; + } + + if (elec_num <= 0) { + return QMCKL_INVALID_ARG_2; + } + + if (walk_num <= 0) { + return QMCKL_INVALID_ARG_4; + } + + if (coord == NULL) { + return QMCKL_INVALID_ARG_5; + } + + if (ee_distance_rescaled == NULL) { + return QMCKL_INVALID_ARG_6; + } + + + int64_t sze = elec_num*walk_num; + int64_t elec_num2= elec_num*elec_num; + + + qmckl_exit_code result = QMCKL_SUCCESS; + #pragma omp parallel + { + qmckl_exit_code rc = QMCKL_SUCCESS; + #pragma omp for + for (int64_t k=0 ; k