From 1c6489c6ee43d46dd64e6595b1fecb8155a65b3f Mon Sep 17 00:00:00 2001 From: Qiming Sun Date: Wed, 24 Jan 2024 15:03:23 -0800 Subject: [PATCH] Fix bug introduced by the optimization in 6678727e --- src/cint2c2e.c | 20 ++++++++++---------- src/cint2e.c | 10 +++++++--- src/cint3c2e.c | 22 +++++++++++----------- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/src/cint2c2e.c b/src/cint2c2e.c index e1602a0..12915c3 100644 --- a/src/cint2c2e.c +++ b/src/cint2c2e.c @@ -44,19 +44,19 @@ g1 += len##x; \ } -#define PRIM2CTR(ctrsymb, gp) \ - if (ctrsymb##_ctr > 1) {\ - if (*ctrsymb##empty) { \ +#define PRIM2CTR(psymb, csymb) \ + if (csymb##_ctr > 1) {\ + if (*csymb##empty) { \ fp2c[np2c] = CINTprim_to_ctr_0; \ } else { \ fp2c[np2c] = CINTprim_to_ctr_1; \ } \ - shltyp[np2c] = SHLTYP##ctrsymb; \ - gprim[np2c] = gp; \ - iprim[np2c] = ctrsymb##p; \ + shltyp[np2c] = SHLTYP##csymb; \ + gprim[np2c] = gctr[SHLTYP##psymb]; \ + iprim[np2c] = csymb##p; \ np2c++; \ } \ - *ctrsymb##empty = 0; \ + *csymb##empty = 0; \ #define POP_PRIM2CTR \ for (i = 0; i < np2c; i++) { \ @@ -75,7 +75,7 @@ it = shltyp[i]; \ if (it != SHLTYPi) { \ im = iprim[i]; \ - (*(fp2c[i]))(gctr[i], gprim[i], coeff[it]+im, \ + (*(fp2c[i]))(gctr[it], gprim[i], coeff[it]+im, \ ngp[it], x_prim[it], x_ctr[it], \ non0ctr[it][im], non0idx[it]+im*x_ctr[it]); \ empty_overall = 0; \ @@ -238,7 +238,7 @@ int CINT2c2e_loop_nopt(double *out, CINTEnvVars *envs, double *cache, int *empty PUSH; } // end loop i_prim if (!*iempty) { - PRIM2CTR(k, gctr[SHLTYPi]); + PRIM2CTR(i, k); } } // end loop k_prim RUN_REST; @@ -323,7 +323,7 @@ int CINT2c2e_loop(double *out, CINTEnvVars *envs, double *cache, int *empty) PUSH; } // end loop i_prim if (!*iempty) { - PRIM2CTR(k, gctr[SHLTYPi]); + PRIM2CTR(i, k); } } // end loop k_prim RUN_REST; diff --git a/src/cint2e.c b/src/cint2e.c index 4c6e11b..337277d 100644 --- a/src/cint2e.c +++ b/src/cint2e.c @@ -65,12 +65,14 @@ fp2c[np2c] = CINTprim_to_ctr_0; \ shltyp[np2c] = SHLTYP##csymb; \ gprim[np2c] = gctr[SHLTYP##psymb]; \ + gp2c [np2c] = gctr[SHLTYP##csymb]; \ iprim[np2c] = csymb##p; \ np2c++; \ } else if (non0ctr##csymb[csymb##p] > 1) { \ fp2c[np2c] = CINTprim_to_ctr_1; \ shltyp[np2c] = SHLTYP##csymb; \ gprim[np2c] = gctr[SHLTYP##psymb]; \ + gp2c [np2c] = gctr[SHLTYP##csymb]; \ iprim[np2c] = csymb##p; \ np2c++; \ } \ @@ -81,7 +83,7 @@ for (i = 0; i < np2c; i++) { \ it = shltyp[i]; \ im = iprim[i]; \ - (*(fp2c[i]))(gctr[it], gprim[i], coeff[it]+im, \ + (*(fp2c[i]))(gp2c[i], gprim[i], coeff[it]+im, \ ngp[it], x_prim[it], x_ctr[it], \ non0ctr[it][im], non0idx[it]+im*x_ctr[it]); \ empty_overall = 0; \ @@ -94,12 +96,12 @@ it = shltyp[i]; \ if (it != SHLTYPi) { \ im = iprim[i]; \ - (*(fp2c[i]))(gctr[it], gprim[i], coeff[it]+im, \ + (*(fp2c[i]))(gp2c[i], gprim[i], coeff[it]+im, \ ngp[it], x_prim[it], x_ctr[it], \ non0ctr[it][im], non0idx[it]+im*x_ctr[it]); \ empty_overall = 0; \ } else if (fp2c[i] == CINTiprim_to_ctr_0) { \ - double *pout = gctr[it]; \ + double *pout = gp2c[i]; \ int k; \ for (k = 0; k < ngp[1]; k++) { \ pout[k] = 0.; \ @@ -146,6 +148,7 @@ fp2c[np2c] = CINTiprim_to_ctr_1; \ } \ gprim[np2c] = gout + cum * ngp[0]; \ + gp2c [np2c] = gctr[SHLTYPi]; \ iprim[np2c] = ip; \ shltyp[np2c] = SHLTYPi; \ cum++; \ @@ -162,6 +165,7 @@ int cum = 0; \ int np2c = 0; \ double *gprim[SIMDD*4]; \ + double *gp2c [SIMDD*4]; \ int shltyp[SIMDD*4]; \ int iprim[SIMDD*4]; \ void (*fp2c[SIMDD*4])(); \ diff --git a/src/cint3c2e.c b/src/cint3c2e.c index 70decbc..0d41ad9 100644 --- a/src/cint3c2e.c +++ b/src/cint3c2e.c @@ -43,19 +43,19 @@ g1 += len##x; \ } -#define PRIM2CTR(ctrsymb, gp) \ - if (ctrsymb##_ctr > 1) {\ - if (*ctrsymb##empty) { \ +#define PRIM2CTR(psymb, csymb) \ + if (csymb##_ctr > 1) {\ + if (*csymb##empty) { \ fp2c[np2c] = CINTprim_to_ctr_0; \ } else { \ fp2c[np2c] = CINTprim_to_ctr_1; \ } \ - shltyp[np2c] = SHLTYP##ctrsymb; \ - gprim[np2c] = gp; \ - iprim[np2c] = ctrsymb##p; \ + shltyp[np2c] = SHLTYP##csymb; \ + gprim[np2c] = gctr[SHLTYP##psymb]; \ + iprim[np2c] = csymb##p; \ np2c++; \ } \ - *ctrsymb##empty = 0; \ + *csymb##empty = 0; \ #define POP_PRIM2CTR \ for (i = 0; i < np2c; i++) { \ @@ -307,11 +307,11 @@ int CINT3c2e_loop_nopt(double *out, CINTEnvVars *envs, double *cache, int *empty } } // end loop i_prim if (!*iempty) { - PRIM2CTR(j, gctr[SHLTYPi]); + PRIM2CTR(i, j); } } // end loop j_prim if (!*jempty) { - PRIM2CTR(k, gctr[SHLTYPj]); + PRIM2CTR(j, k); } } // end loop k_prim RUN_REST; @@ -469,11 +469,11 @@ int CINT3c2e_loop(double *out, CINTEnvVars *envs, double *cache, int *empty) } } // end loop i_prim if (!*iempty) { - PRIM2CTR(j, gctr[SHLTYPi]); + PRIM2CTR(i, j); } } // end loop j_prim if (!*jempty) { - PRIM2CTR(k, gctr[SHLTYPj]); + PRIM2CTR(j, k); } } // end loop k_prim RUN_REST;