Skip to content

Commit

Permalink
Fix bug introduced by the optimization in 6678727
Browse files Browse the repository at this point in the history
  • Loading branch information
sunqm committed Jan 25, 2024
1 parent d853c6c commit 1c6489c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 24 deletions.
20 changes: 10 additions & 10 deletions src/cint2c2e.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) { \
Expand All @@ -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; \
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 7 additions & 3 deletions src/cint2e.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++; \
} \
Expand All @@ -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; \
Expand All @@ -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.; \
Expand Down Expand Up @@ -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++; \
Expand All @@ -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])(); \
Expand Down
22 changes: 11 additions & 11 deletions src/cint3c2e.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) { \
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 1c6489c

Please sign in to comment.