diff --git a/CMakeLists.txt b/CMakeLists.txt index cfaf8c88..fcfb5d24 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 2.6) project (cint C) set(cint_VERSION_MAJOR "4") set(cint_VERSION_MINOR "0") -set(cint_VERSION_PATCH "3") +set(cint_VERSION_PATCH "4") set(cint_VERSION_TWEAK "0") set(cint_VERSION "${cint_VERSION_MAJOR}.${cint_VERSION_MINOR}.${cint_VERSION_PATCH}") set(cint_SOVERSION "${cint_VERSION_MAJOR}") diff --git a/ChangeLog b/ChangeLog index cca2540e..fe087dec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ +Version 4.0.4 (2020-10-29): + * Fix cache size bug in int3c1e Version 4.0.3 (2020-10-27): * Fix memory allocation in int3c1e * Improve macro MALLOC_INSTACK diff --git a/README b/README index d84d08ce..40602ab4 100644 --- a/README +++ b/README @@ -1,8 +1,8 @@ libcint ======= -version 4.0.3 -2020-10-27 +version 4.0.4 +2020-10-29 What is libcint diff --git a/src/cint3c1e.c b/src/cint3c1e.c index fd943a99..335753aa 100644 --- a/src/cint3c1e.c +++ b/src/cint3c1e.c @@ -377,6 +377,16 @@ FINT CINT3c1e_nuc_loop_nopt(double *gctr, CINTEnvVars *envs, return !*kempty; } +#define PAIRDATA_NON0IDX_SIZE(ps) \ + FINT *bas = envs->bas; \ + FINT *shls = envs->shls; \ + FINT i_prim = bas(NPRIM_OF, shls[0]); \ + FINT j_prim = bas(NPRIM_OF, shls[1]); \ + FINT k_prim = bas(NPRIM_OF, shls[2]); \ + FINT ps = (i_prim * x_ctr[0] \ + + j_prim * x_ctr[1] \ + + k_prim * x_ctr[2] \ + + envs->nf*3); FINT CINT3c1e_cart_drv(double *out, FINT *dims, CINTEnvVars *envs, CINTOpt *opt, double *cache, FINT int_type) @@ -385,16 +395,18 @@ FINT CINT3c1e_cart_drv(double *out, FINT *dims, CINTEnvVars *envs, CINTOpt *opt, FINT nc = envs->nf * x_ctr[0] * x_ctr[1] * x_ctr[2]; FINT n_comp = envs->ncomp_e1 * envs->ncomp_tensor; if (out == NULL) { + PAIRDATA_NON0IDX_SIZE(pdata_size); FINT leng = envs->g_size*3*((1<gbits)+1); FINT len0 = envs->nf*n_comp; - FINT cache_size = leng + len0 + nc*n_comp*4; + FINT cache_size = leng + len0 + nc*n_comp*4 + pdata_size; return cache_size; } double *stack = NULL; if (cache == NULL) { + PAIRDATA_NON0IDX_SIZE(pdata_size); FINT leng = envs->g_size*3*((1<gbits)+1); FINT len0 = envs->nf*n_comp; - FINT cache_size = leng + len0 + nc*n_comp*4; + FINT cache_size = leng + len0 + nc*n_comp*4 + pdata_size; stack = malloc(sizeof(double)*cache_size); cache = stack; } @@ -472,16 +484,20 @@ FINT CINT3c1e_spheric_drv(double *out, FINT *dims, CINTEnvVars *envs, CINTOpt *o FINT nc = envs->nf * x_ctr[0] * x_ctr[1] * x_ctr[2]; FINT n_comp = envs->ncomp_e1 * envs->ncomp_tensor; if (out == NULL) { + PAIRDATA_NON0IDX_SIZE(pdata_size); FINT leng = envs->g_size*3*((1<gbits)+1); FINT len0 = envs->nf*n_comp; - FINT cache_size = MAX(leng+len0+nc*n_comp*4, nc*n_comp+envs->nf*3); + FINT cache_size = MAX(leng+len0+nc*n_comp*4 + pdata_size, + nc*n_comp+envs->nf*3); return cache_size; } double *stack = NULL; if (cache == NULL) { + PAIRDATA_NON0IDX_SIZE(pdata_size); FINT leng = envs->g_size*3*((1<gbits)+1); FINT len0 = envs->nf*n_comp; - FINT cache_size = MAX(leng+len0+nc*n_comp*4, nc*n_comp+envs->nf*3); + FINT cache_size = MAX(leng+len0+nc*n_comp*4 + pdata_size, + nc*n_comp+envs->nf*3); stack = malloc(sizeof(double)*cache_size); cache = stack; } diff --git a/src/cint4c1e.c b/src/cint4c1e.c index b9a64c5b..9fad988f 100644 --- a/src/cint4c1e.c +++ b/src/cint4c1e.c @@ -252,12 +252,11 @@ k_contracted: ; FINT j_prim = bas(NPRIM_OF, shls[1]); \ FINT k_prim = bas(NPRIM_OF, shls[2]); \ FINT l_prim = bas(NPRIM_OF, shls[3]); \ - FINT ps = ((i_prim*j_prim + k_prim*l_prim) * 5 \ - + i_prim * x_ctr[0] \ + FINT ps = (i_prim * x_ctr[0] \ + j_prim * x_ctr[1] \ + k_prim * x_ctr[2] \ + l_prim * x_ctr[3] \ - +(i_prim+j_prim+k_prim+l_prim)*2 + envs->nf*3); + + envs->nf*3); FINT CINT4c1e_cart_drv(double *out, FINT *dims, CINTEnvVars *envs, CINTOpt *opt, double *cache)