diff --git a/pylibxc/flags.py b/pylibxc/flags.py index 60a76675c..02c543934 100644 --- a/pylibxc/flags.py +++ b/pylibxc/flags.py @@ -40,9 +40,6 @@ XC_FLAGS_STABLE = (1 << 13) # 8192 XC_FLAGS_DEVELOPMENT = (1 << 14) # 16384 XC_FLAGS_NEEDS_LAPLACIAN = (1 << 15) # 32768 - -XC_TAU_EXPLICIT = 0 -XC_TAU_EXPANSION = 1 +XC_FLAGS_NEEDS_TAU = (1 << 16) # 65536 XC_MAX_REFERENCES = 5 - diff --git a/src/add_param_num.py b/src/add_param_num.py new file mode 100644 index 000000000..7caf10d68 --- /dev/null +++ b/src/add_param_num.py @@ -0,0 +1,32 @@ +import os +import re +import glob + +left = r'p->params = libxc_malloc(sizeof(' +right= r'));' + +new_left = r'p->params = malloc(sizeof(' +new_right= r'));' + +pattern = fr'{re.escape(left)}(.*?){re.escape(right)}' +count = 0 +for file_path in glob.iglob('*.c'): + if os.path.isfile(file_path): + with open(file_path, 'r', encoding='utf-8') as file: + file_content = file.read() + + match = re.search(pattern, file_content) + + if match: + count += 1 + struct_name = match.group(1) + new_line = f'{new_left}{struct_name}{new_right} \n p->params_size = sizeof({struct_name});' + print(f'in {file_path}, find {new_line}') + + file_content = re.sub(pattern, new_line, file_content) + print(file_content) + + with open(file_path, 'w', encoding='utf-8') as file: + file.write(file_content) + +print(f'{count} files are changed') diff --git a/src/deorbitalize_func.c b/src/deorbitalize_func.c index 0b0495568..a01f8b3c0 100644 --- a/src/deorbitalize_func.c +++ b/src/deorbitalize_func.c @@ -257,7 +257,7 @@ xc_mgga_evaluate_functional(const xc_func_type *func, size_t np, if(func->info->flags & XC_FLAGS_HAVE_EXC) mzk = zk; - + /* Evaluate the functional */ switch(func->info->family){ case XC_FAMILY_LDA: @@ -286,10 +286,10 @@ xc_deorbitalize_init(xc_func_type *p, int mgga_id, int ked_id) /* allocate structures needed for */ p->n_func_aux = 2; - p->func_aux = (xc_func_type **) libxc_malloc(2*sizeof(xc_func_type *)); + p->func_aux = (xc_func_type **) malloc(2*sizeof(xc_func_type *)); - p->func_aux[0] = (xc_func_type *) libxc_malloc(sizeof(xc_func_type)); - p->func_aux[1] = (xc_func_type *) libxc_malloc(sizeof(xc_func_type)); + p->func_aux[0] = (xc_func_type *) malloc(sizeof(xc_func_type)); + p->func_aux[1] = (xc_func_type *) malloc(sizeof(xc_func_type)); xc_func_init (p->func_aux[0], mgga_id, p->nspin); xc_func_init (p->func_aux[1], ked_id, p->nspin); @@ -470,4 +470,4 @@ xc_mgga_funcs_variants xc_deorbitalize_func = {deorb_new, deorb_new, deorb_new, deorb_new, deorb_new}, {deorb_new, deorb_new, deorb_new, deorb_new, deorb_new} }; - + diff --git a/src/expint_e1.c b/src/expint_e1.c index f676487d6..1c981e21a 100644 --- a/src/expint_e1.c +++ b/src/expint_e1.c @@ -133,4 +133,3 @@ GPU_FUNCTION double xc_expint_e1_impl(double x, const int scale){ return e1; } - diff --git a/src/functionals.c b/src/functionals.c index d58191dde..83609ecee 100644 --- a/src/functionals.c +++ b/src/functionals.c @@ -66,7 +66,7 @@ char *xc_functional_get_name(int number) if(xc_functional_keys[ii].number == number) { /* return duplicated: caller has the responsibility to dealloc string. Do this the old way since strdup and strndup aren't C standard. */ - p = (char *) libxc_malloc(strlen(xc_functional_keys[ii].name) + 1); + p = (char *) malloc(strlen(xc_functional_keys[ii].name) + 1); strcpy(p,xc_functional_keys[ii].name); return p; } @@ -229,7 +229,7 @@ void xc_available_functional_names(char **list) /* Arrange list of functional IDs by name */ N=xc_number_of_functionals(); - idlist=(int *) libxc_malloc(N*sizeof(int)); + idlist=(int *) malloc(N*sizeof(int)); for(ii=0;iiext_params = NULL; func->params = NULL; + func->params_size = 0; func->dens_threshold = 0.0; func->zeta_threshold = 0.0; @@ -293,13 +294,11 @@ int xc_func_init(xc_func_type *func, int functional, int nspin) /* initialize structure */ func->nspin = nspin; - // we have to make a copy because the *_known_funct arrays live in - // host memory (libxc_malloc instead returns memory than can be read - // from GPU and CPU). - xc_func_info_type * finfo = (xc_func_info_type *) libxc_malloc(sizeof(xc_func_info_type)); + // TODO: remove the copy + xc_func_info_type * finfo = (xc_func_info_type *) malloc(sizeof(xc_func_info_type)); // initialize the dimension structure - libxc_memset(&(func->dim), 0, sizeof(xc_dimensions)); + memset(&(func->dim), 0, sizeof(xc_dimensions)); switch(xc_family_from_id(functional, NULL, &number)){ case(XC_FAMILY_LDA): *finfo = *xc_lda_known_funct[number]; @@ -354,7 +353,7 @@ int xc_func_init(xc_func_type *func, int functional, int nspin) /* see if we need to initialize the external parameters */ if(func->info->ext_params.n > 0) { - func->ext_params = (double *) libxc_malloc(func->info->ext_params.n * sizeof(double)); + func->ext_params = (double *) malloc(func->info->ext_params.n * sizeof(double)); xc_func_set_ext_params(func, func->info->ext_params.values); /* sanity check external parameter names and descriptions */ @@ -395,22 +394,22 @@ void xc_func_end(xc_func_type *func) for(ii=0; iin_func_aux; ii++){ xc_func_end(func->func_aux[ii]); - libxc_free(func->func_aux[ii]); + free(func->func_aux[ii]); } - libxc_free(func->func_aux); + free(func->func_aux); } /* deallocate coefficients for mixed functionals */ if(func->mix_coef != NULL) - libxc_free(func->mix_coef); + free(func->mix_coef); /* deallocate any used parameter */ if(func->ext_params != NULL) - libxc_free(func->ext_params); + free(func->ext_params); if(func->params != NULL) - libxc_free(func->params); + free(func->params); - libxc_free((void *) func->info); + free((void *) func->info); xc_func_nullify(func); } @@ -418,7 +417,7 @@ void xc_func_end(xc_func_type *func) /*------------------------------------------------------*/ void xc_func_free(xc_func_type *p) { - libxc_free(p); + free(p); } /*------------------------------------------------------*/ diff --git a/src/genwiki.c b/src/genwiki.c index 58d09ed68..8b937f71f 100644 --- a/src/genwiki.c +++ b/src/genwiki.c @@ -141,7 +141,7 @@ char * sanitize_link(const char * doi) { buf[j++]='\0'; /* Allocate return array */ - r = (char *) libxc_malloc(strlen(buf) + 1); + r = (char *) malloc(strlen(buf) + 1); strcpy(r,buf); return r; diff --git a/src/gga.c b/src/gga.c index 2a695bde2..c30b0c783 100644 --- a/src/gga.c +++ b/src/gga.c @@ -23,7 +23,7 @@ xc_gga_sanity_check(const xc_func_info_type *info, int order, xc_gga_out_params order); exit(1); } - + /* sanity check */ if(out->zk != NULL && !(info->flags & XC_FLAGS_HAVE_EXC)){ fprintf(stderr, "Functional '%s' does not provide an implementation of Exc\n", @@ -46,7 +46,7 @@ xc_gga_sanity_check(const xc_func_info_type *info, int order, xc_gga_out_params info->name); exit(1); } - check_out_var(v2rhosigma); + check_out_var(v2rhosigma); check_out_var(v2sigma2); } @@ -153,7 +153,7 @@ void xc_gga_new(const xc_func_type *func, int order, size_t np, const double *rh xc_gga_sanity_check(func->info, order, out); xc_gga_initalize(func, np, out); - + /* call the GGA routines */ if(func->info->gga != NULL){ if(func->nspin == XC_UNPOLARIZED){ @@ -196,7 +196,7 @@ xc_gga(const xc_func_type *p, size_t np, const double *rho, const double *sigma, if(order < 0) return; xc_gga_out_params out; - libxc_memset(&out, 0, sizeof(xc_gga_out_params)); + memset(&out, 0, sizeof(xc_gga_out_params)); out.zk = zk; out.vrho = vrho; out.vsigma = vsigma; out.v2rho2 = v2rho2; out.v2rhosigma = v2rhosigma; out.v2sigma2 = v2sigma2; @@ -214,9 +214,9 @@ xc_gga_exc(const xc_func_type *p, size_t np, const double *rho, const double *si double *zk) { xc_gga_out_params out; - libxc_memset(&out, 0, sizeof(xc_gga_out_params)); + memset(&out, 0, sizeof(xc_gga_out_params)); out.zk = zk; - + xc_gga_new(p, 0, np, rho, sigma, &out); } @@ -225,10 +225,10 @@ xc_gga_exc_vxc(const xc_func_type *p, size_t np, const double *rho, const double double *zk, double *vrho, double *vsigma) { xc_gga_out_params out; - libxc_memset(&out, 0, sizeof(xc_gga_out_params)); + memset(&out, 0, sizeof(xc_gga_out_params)); out.zk = zk; out.vrho = vrho; out.vsigma = vsigma; - + xc_gga_new(p, 1, np, rho, sigma, &out); } @@ -238,11 +238,11 @@ xc_gga_exc_vxc_fxc (const xc_func_type *p, size_t np, const double *rho, const d double *v2rho2, double *v2rhosigma, double *v2sigma2) { xc_gga_out_params out; - libxc_memset(&out, 0, sizeof(xc_gga_out_params)); + memset(&out, 0, sizeof(xc_gga_out_params)); out.zk = zk; out.vrho = vrho; out.vsigma = vsigma; out.v2rho2 = v2rho2; out.v2rhosigma = v2rhosigma; out.v2sigma2 = v2sigma2; - + xc_gga_new(p, 2, np, rho, sigma, &out); } @@ -252,10 +252,10 @@ xc_gga_vxc_fxc (const xc_func_type *p, size_t np, const double *rho, const doubl double *v2rho2, double *v2rhosigma, double *v2sigma2) { xc_gga_out_params out; - libxc_memset(&out, 0, sizeof(xc_gga_out_params)); + memset(&out, 0, sizeof(xc_gga_out_params)); out.vrho = vrho; out.vsigma = vsigma; out.v2rho2 = v2rho2; out.v2rhosigma = v2rhosigma; out.v2sigma2 = v2sigma2; - + xc_gga_new(p, 2, np, rho, sigma, &out); } @@ -265,12 +265,12 @@ xc_gga_exc_vxc_fxc_kxc (const xc_func_type *p, size_t np, const double *rho, con double *v3rho3, double *v3rho2sigma, double *v3rhosigma2, double *v3sigma3) { xc_gga_out_params out; - libxc_memset(&out, 0, sizeof(xc_gga_out_params)); + memset(&out, 0, sizeof(xc_gga_out_params)); out.zk = zk; out.vrho = vrho; out.vsigma = vsigma; out.v2rho2 = v2rho2; out.v2rhosigma = v2rhosigma; out.v2sigma2 = v2sigma2; out.v3rho3 = v3rho3; out.v3rho2sigma = v3rho2sigma; out.v3rhosigma2 = v3rhosigma2; out.v3sigma3 = v3sigma3; - + xc_gga_new(p, 3, np, rho, sigma, &out); } @@ -280,7 +280,7 @@ xc_gga_vxc_fxc_kxc (const xc_func_type *p, size_t np, const double *rho, const d double *v3rho3, double *v3rho2sigma, double *v3rhosigma2, double *v3sigma3) { xc_gga_out_params out; - libxc_memset(&out, 0, sizeof(xc_gga_out_params)); + memset(&out, 0, sizeof(xc_gga_out_params)); out.vrho = vrho; out.vsigma = vsigma; out.v2rho2 = v2rho2; out.v2rhosigma = v2rhosigma; out.v2sigma2 = v2sigma2; out.v3rho3 = v3rho3; out.v3rho2sigma = v3rho2sigma; out.v3rhosigma2 = v3rhosigma2; out.v3sigma3 = v3sigma3; @@ -293,7 +293,7 @@ xc_gga_vxc(const xc_func_type *p, size_t np, const double *rho, const double *si double *vrho, double *vsigma) { xc_gga_out_params out; - libxc_memset(&out, 0, sizeof(xc_gga_out_params)); + memset(&out, 0, sizeof(xc_gga_out_params)); out.vrho = vrho; out.vsigma = vsigma; xc_gga_new(p, 1, np, rho, sigma, &out); @@ -304,7 +304,7 @@ xc_gga_fxc(const xc_func_type *p, size_t np, const double *rho, const double *si double *v2rho2, double *v2rhosigma, double *v2sigma2) { xc_gga_out_params out; - libxc_memset(&out, 0, sizeof(xc_gga_out_params)); + memset(&out, 0, sizeof(xc_gga_out_params)); out.v2rho2 = v2rho2; out.v2rhosigma = v2rhosigma; out.v2sigma2 = v2sigma2; xc_gga_new(p, 2, np, rho, sigma, &out); @@ -315,7 +315,7 @@ xc_gga_kxc(const xc_func_type *p, size_t np, const double *rho, const double *si double *v3rho3, double *v3rho2sigma, double *v3rhosigma2, double *v3sigma3) { xc_gga_out_params out; - libxc_memset(&out, 0, sizeof(xc_gga_out_params)); + memset(&out, 0, sizeof(xc_gga_out_params)); out.v3rho3 = v3rho3; out.v3rho2sigma = v3rho2sigma; out.v3rhosigma2 = v3rhosigma2; out.v3sigma3 = v3sigma3; xc_gga_new(p, 3, np, rho, sigma, &out); @@ -327,7 +327,7 @@ xc_gga_lxc(const xc_func_type *p, size_t np, const double *rho, const double *si double *v4rho4, double *v4rho3sigma, double *v4rho2sigma2, double *v4rhosigma3, double *v4sigma4) { xc_gga_out_params out; - libxc_memset(&out, 0, sizeof(xc_gga_out_params)); + memset(&out, 0, sizeof(xc_gga_out_params)); out.v4rho4 = v4rho4; out.v4rho3sigma = v4rho3sigma; out.v4rho2sigma2 = v4rho2sigma2; out.v4rhosigma3 = v4rhosigma3; out.v4sigma4 = v4sigma4; xc_gga_new(p, 4, np, rho, sigma, &out); diff --git a/src/gga_c_am05.c b/src/gga_c_am05.c index 2ef36d3dc..381fd3e90 100644 --- a/src/gga_c_am05.c +++ b/src/gga_c_am05.c @@ -20,7 +20,8 @@ static void gga_c_am05_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_c_am05_params)); + p->params = malloc(sizeof(gga_c_am05_params)); + p->params_size = sizeof(gga_c_am05_params); } #include "maple2c/gga_exc/gga_c_am05.c" diff --git a/src/gga_c_bmk.c b/src/gga_c_bmk.c index 6bdd32475..3439a10e1 100644 --- a/src/gga_c_bmk.c +++ b/src/gga_c_bmk.c @@ -64,7 +64,8 @@ static const double par_hyb_tau_hcth[BMK_N_PAR] = { static void gga_c_bmk_init(xc_func_type *p) { assert(p->params == NULL); - p->params = libxc_malloc(sizeof(gga_c_bmk_params)); + p->params = malloc(sizeof(gga_c_bmk_params)); + p->params_size = sizeof(gga_c_bmk_params); } #include "maple2c/gga_exc/gga_c_bmk.c" diff --git a/src/gga_c_ccdf.c b/src/gga_c_ccdf.c index be4821ae3..41ccd6f27 100644 --- a/src/gga_c_ccdf.c +++ b/src/gga_c_ccdf.c @@ -21,7 +21,8 @@ typedef struct{ static void gga_c_ccdf_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_c_ccdf_params)); + p->params = malloc(sizeof(gga_c_ccdf_params)); + p->params_size = sizeof(gga_c_ccdf_params); } #define N_PAR 5 diff --git a/src/gga_c_chachiyo.c b/src/gga_c_chachiyo.c index 201403db2..9c59cf6f0 100644 --- a/src/gga_c_chachiyo.c +++ b/src/gga_c_chachiyo.c @@ -24,7 +24,8 @@ static void gga_c_chachiyo_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_c_chachiyo_params)); + p->params = malloc(sizeof(gga_c_chachiyo_params)); + p->params_size = sizeof(gga_c_chachiyo_params); } #include "maple2c/gga_exc/gga_c_chachiyo.c" diff --git a/src/gga_c_lm.c b/src/gga_c_lm.c index f8c7653b2..478f10e0c 100644 --- a/src/gga_c_lm.c +++ b/src/gga_c_lm.c @@ -24,7 +24,8 @@ static void gga_c_lm_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_c_lm_params)); + p->params = malloc(sizeof(gga_c_lm_params)); + p->params_size = sizeof(gga_c_lm_params); } #define N_PAR 1 diff --git a/src/gga_c_lyp.c b/src/gga_c_lyp.c index db4926b35..d5677be20 100644 --- a/src/gga_c_lyp.c +++ b/src/gga_c_lyp.c @@ -20,7 +20,8 @@ typedef struct{ void xc_gga_c_lyp_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_c_lyp_params)); + p->params = malloc(sizeof(gga_c_lyp_params)); + p->params_size = sizeof(gga_c_lyp_params); } #define LYP_N_PAR 4 diff --git a/src/gga_c_lypr.c b/src/gga_c_lypr.c index d3280e032..fa73a0c24 100644 --- a/src/gga_c_lypr.c +++ b/src/gga_c_lypr.c @@ -41,7 +41,8 @@ static const double lypr_values[LYPR_N_PAR] = void xc_gga_c_lypr_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_c_lypr_params)); + p->params = malloc(sizeof(gga_c_lypr_params)); + p->params_size = sizeof(gga_c_lypr_params); } #include "maple2c/gga_exc/gga_c_lypr.c" diff --git a/src/gga_c_optc.c b/src/gga_c_optc.c index 0e59ce47a..1dedf1f0b 100644 --- a/src/gga_c_optc.c +++ b/src/gga_c_optc.c @@ -19,7 +19,8 @@ static void gga_c_optc_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_c_optc_params)); + p->params = malloc(sizeof(gga_c_optc_params)); + p->params_size = sizeof(gga_c_optc_params); } #include "maple2c/gga_exc/gga_c_optc.c" diff --git a/src/gga_c_p86.c b/src/gga_c_p86.c index 631d4d59d..a4194e66d 100644 --- a/src/gga_c_p86.c +++ b/src/gga_c_p86.c @@ -33,7 +33,8 @@ static const double p86ft_val[N_PAR] = {0.023266, 7.389e-6, 8.723, 0.472, 0.0016 static void gga_c_p86_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_c_p86_params)); + p->params = malloc(sizeof(gga_c_p86_params)); + p->params_size = sizeof(gga_c_p86_params); } #include "maple2c/gga_exc/gga_c_p86.c" diff --git a/src/gga_c_p86vwn.c b/src/gga_c_p86vwn.c index 97c798685..0b012961f 100644 --- a/src/gga_c_p86vwn.c +++ b/src/gga_c_p86vwn.c @@ -33,7 +33,8 @@ static const double p86vwnft_val[N_PAR] = {0.023266, 7.389e-6, 8.723, 0.472, 0.0 static void gga_c_p86vwn_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_c_p86vwn_params)); + p->params = malloc(sizeof(gga_c_p86vwn_params)); + p->params_size = sizeof(gga_c_p86vwn_params); } #include "maple2c/gga_exc/gga_c_p86vwn.c" diff --git a/src/gga_c_pbe.c b/src/gga_c_pbe.c index fba6e4fa4..b8cd04e93 100644 --- a/src/gga_c_pbe.c +++ b/src/gga_c_pbe.c @@ -36,7 +36,8 @@ typedef struct{ static void gga_c_pbe_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_c_pbe_params)); + p->params = malloc(sizeof(gga_c_pbe_params)); + p->params_size = sizeof(gga_c_pbe_params); } #define PBE_N_PAR 3 diff --git a/src/gga_c_pbe_erf_gws.c b/src/gga_c_pbe_erf_gws.c index e271d2ac9..7cd5c1d71 100644 --- a/src/gga_c_pbe_erf_gws.c +++ b/src/gga_c_pbe_erf_gws.c @@ -25,7 +25,8 @@ xc_gga_c_pbe_erf_gws_init(xc_func_type *p) { xc_hyb_init_hybrid(p, 0.0); assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_c_pbe_erf_gws_params)); + p->params = malloc(sizeof(gga_c_pbe_erf_gws_params)); + p->params_size = sizeof(gga_c_pbe_erf_gws_params); } static const char *param_names[N_PAR] = {"_beta", "_gamma", "_a_c","_omega"}; diff --git a/src/gga_c_pbe_vwn.c b/src/gga_c_pbe_vwn.c index 6da4cf958..259a0a442 100644 --- a/src/gga_c_pbe_vwn.c +++ b/src/gga_c_pbe_vwn.c @@ -17,7 +17,8 @@ typedef struct{ static void gga_c_pbe_vwn_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_c_pbe_vwn_params)); + p->params = malloc(sizeof(gga_c_pbe_vwn_params)); + p->params_size = sizeof(gga_c_pbe_vwn_params); } #define PBEVWN_N_PAR 3 diff --git a/src/gga_c_sogga11.c b/src/gga_c_sogga11.c index 72a7ae712..6c758eb90 100644 --- a/src/gga_c_sogga11.c +++ b/src/gga_c_sogga11.c @@ -31,7 +31,8 @@ static const double par_sogga11_x[N_PAR] = { static void gga_c_sogga11_init(xc_func_type *p) { assert(p != NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_c_sogga11_params)); + p->params = malloc(sizeof(gga_c_sogga11_params)); + p->params_size = sizeof(gga_c_sogga11_params); } #include "maple2c/gga_exc/gga_c_sogga11.c" diff --git a/src/gga_c_wi.c b/src/gga_c_wi.c index 49bd2bd80..e4f787e5c 100644 --- a/src/gga_c_wi.c +++ b/src/gga_c_wi.c @@ -26,7 +26,8 @@ static const double wi_par[N_PAR] = {-0.00652, 0.0007, 0.21, 0.002, 0.001}; static void gga_c_wi_init(xc_func_type *p) { assert(p != NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_c_wi_params)); + p->params = malloc(sizeof(gga_c_wi_params)); + p->params_size = sizeof(gga_c_wi_params); } #include "maple2c/gga_exc/gga_c_wi.c" diff --git a/src/gga_c_zpbeint.c b/src/gga_c_zpbeint.c index 6c5a5f375..d0561a75f 100644 --- a/src/gga_c_zpbeint.c +++ b/src/gga_c_zpbeint.c @@ -21,7 +21,8 @@ gga_c_zpbeint_init(xc_func_type *p) gga_c_zpbeint_params *params; assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_c_zpbeint_params)); + p->params = malloc(sizeof(gga_c_zpbeint_params)); + p->params_size = sizeof(gga_c_zpbeint_params); params = (gga_c_zpbeint_params *) (p->params); switch(p->info->number){ diff --git a/src/gga_c_zvpbeint.c b/src/gga_c_zvpbeint.c index c7f7f3c2e..185d9d4cb 100644 --- a/src/gga_c_zvpbeint.c +++ b/src/gga_c_zvpbeint.c @@ -21,7 +21,8 @@ gga_c_zvpbeint_init(xc_func_type *p) gga_c_zvpbeint_params *params; assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_c_zvpbeint_params)); + p->params = malloc(sizeof(gga_c_zvpbeint_params)); + p->params_size = sizeof(gga_c_zvpbeint_params); params = (gga_c_zvpbeint_params *) (p->params); switch(p->info->number){ diff --git a/src/gga_k_apbe.c b/src/gga_k_apbe.c index 2092fddef..12d8c75ce 100644 --- a/src/gga_k_apbe.c +++ b/src/gga_k_apbe.c @@ -28,7 +28,8 @@ gga_k_apbe_init(xc_func_type *p) gga_k_apbe_params *params; assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_k_apbe_params)); + p->params = malloc(sizeof(gga_k_apbe_params)); + p->params_size = sizeof(gga_k_apbe_params); params = (gga_k_apbe_params *) (p->params); params->lambda = 0.0; diff --git a/src/gga_k_apbeint.c b/src/gga_k_apbeint.c index 91e817412..a17c410e7 100644 --- a/src/gga_k_apbeint.c +++ b/src/gga_k_apbeint.c @@ -23,7 +23,8 @@ gga_k_apbe_init(xc_func_type *p) gga_k_apbeint_params *params; assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_k_apbeint_params)); + p->params = malloc(sizeof(gga_k_apbeint_params)); + p->params_size = sizeof(gga_k_apbeint_params); params = (gga_k_apbeint_params *) (p->params); switch(p->info->number){ diff --git a/src/gga_k_dk.c b/src/gga_k_dk.c index 0142cae98..08a199a61 100644 --- a/src/gga_k_dk.c +++ b/src/gga_k_dk.c @@ -39,7 +39,8 @@ static void gga_k_dk_init(xc_func_type *p) { assert(p != NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_k_dk_params)); + p->params = malloc(sizeof(gga_k_dk_params)); + p->params_size = sizeof(gga_k_dk_params); } #define KINS (X2S*X2S) /* conversion to s^2 */ diff --git a/src/gga_k_lc94.c b/src/gga_k_lc94.c index 09d1dfaae..89f71655d 100644 --- a/src/gga_k_lc94.c +++ b/src/gga_k_lc94.c @@ -25,7 +25,8 @@ static void gga_k_lc94_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_k_lc94_params)); + p->params = malloc(sizeof(gga_k_lc94_params)); + p->params_size = sizeof(gga_k_lc94_params); } #include "maple2c/gga_exc/gga_k_lc94.c" diff --git a/src/gga_k_lgap.c b/src/gga_k_lgap.c index 94bdf71fb..a3c7a1354 100644 --- a/src/gga_k_lgap.c +++ b/src/gga_k_lgap.c @@ -20,7 +20,8 @@ static void gga_k_lgap_init(xc_func_type *p) { assert(p->params == NULL); - p->params = libxc_malloc(sizeof(gga_k_lgap_params)); + p->params = malloc(sizeof(gga_k_lgap_params)); + p->params_size = sizeof(gga_k_lgap_params); } #include "maple2c/gga_exc/gga_k_lgap.c" diff --git a/src/gga_k_lgap_ge.c b/src/gga_k_lgap_ge.c index 7aaa4829d..a99996e10 100644 --- a/src/gga_k_lgap_ge.c +++ b/src/gga_k_lgap_ge.c @@ -18,7 +18,8 @@ static void gga_k_lgap_ge_init(xc_func_type *p) { assert(p->params == NULL); - p->params = libxc_malloc(sizeof(gga_k_lgap_ge_params)); + p->params = malloc(sizeof(gga_k_lgap_ge_params)); + p->params_size = sizeof(gga_k_lgap_ge_params); } #include "maple2c/gga_exc/gga_k_lgap_ge.c" diff --git a/src/gga_k_lkt.c b/src/gga_k_lkt.c index e2c266bcf..03a1efd31 100644 --- a/src/gga_k_lkt.c +++ b/src/gga_k_lkt.c @@ -23,7 +23,8 @@ static void gga_k_lkt_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_k_lkt_params)); + p->params = malloc(sizeof(gga_k_lkt_params)); + p->params_size = sizeof(gga_k_lkt_params); } #include "maple2c/gga_exc/gga_k_lkt.c" diff --git a/src/gga_k_llp.c b/src/gga_k_llp.c index 13081f319..989d4d3b9 100644 --- a/src/gga_k_llp.c +++ b/src/gga_k_llp.c @@ -22,7 +22,8 @@ gga_k_llp_init(xc_func_type *p) gga_k_llp_params *params; assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_k_llp_params)); + p->params = malloc(sizeof(gga_k_llp_params)); + p->params_size = sizeof(gga_k_llp_params); params = (gga_k_llp_params *) (p->params); /* value of beta in standard Becke 88 functional */ diff --git a/src/gga_k_mpbe.c b/src/gga_k_mpbe.c index 68ea12f75..92b921583 100644 --- a/src/gga_k_mpbe.c +++ b/src/gga_k_mpbe.c @@ -28,7 +28,8 @@ static void gga_k_mpbe_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_k_mpbe_params)); + p->params = malloc(sizeof(gga_k_mpbe_params)); + p->params_size = sizeof(gga_k_mpbe_params); } #include "maple2c/gga_exc/gga_k_mpbe.c" diff --git a/src/gga_k_ol2.c b/src/gga_k_ol2.c index 5859777de..03b8b20aa 100644 --- a/src/gga_k_ol2.c +++ b/src/gga_k_ol2.c @@ -20,7 +20,8 @@ gga_k_ol2_init(xc_func_type *p) gga_k_ol2_params *params; assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_k_ol2_params)); + p->params = malloc(sizeof(gga_k_ol2_params)); + p->params_size = sizeof(gga_k_ol2_params); params = (gga_k_ol2_params *) (p->params); switch(p->info->number){ diff --git a/src/gga_k_pg.c b/src/gga_k_pg.c index e81440770..016035dcf 100644 --- a/src/gga_k_pg.c +++ b/src/gga_k_pg.c @@ -18,7 +18,8 @@ static void gga_k_pg_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_k_pg_params)); + p->params = malloc(sizeof(gga_k_pg_params)); + p->params_size = sizeof(gga_k_pg_params); } #define N_PAR 1 diff --git a/src/gga_k_rational_p.c b/src/gga_k_rational_p.c index 40d2e2711..7699525d6 100644 --- a/src/gga_k_rational_p.c +++ b/src/gga_k_rational_p.c @@ -19,7 +19,8 @@ static void gga_k_rational_p_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_k_rational_p_params)); + p->params = malloc(sizeof(gga_k_rational_p_params)); + p->params_size = sizeof(gga_k_rational_p_params); } #define N_PAR 2 diff --git a/src/gga_k_tflw.c b/src/gga_k_tflw.c index 43ff9efc6..9b625ad06 100644 --- a/src/gga_k_tflw.c +++ b/src/gga_k_tflw.c @@ -39,7 +39,8 @@ static void gga_k_tflw_init(xc_func_type *p) { assert(p->params == NULL); - p->params = libxc_malloc(sizeof(gga_k_tflw_params)); + p->params = malloc(sizeof(gga_k_tflw_params)); + p->params_size = sizeof(gga_k_tflw_params); } #include "maple2c/gga_exc/gga_k_tflw.c" diff --git a/src/gga_k_vt84f.c b/src/gga_k_vt84f.c index 7cbd9142e..1c9553bea 100644 --- a/src/gga_k_vt84f.c +++ b/src/gga_k_vt84f.c @@ -19,7 +19,8 @@ static void gga_k_vt84f_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_k_vt84f_params)); + p->params = malloc(sizeof(gga_k_vt84f_params)); + p->params_size = sizeof(gga_k_vt84f_params); } #define N_PAR 2 diff --git a/src/gga_x_ak13.c b/src/gga_x_ak13.c index 3af31c3d4..15a4384b9 100644 --- a/src/gga_x_ak13.c +++ b/src/gga_x_ak13.c @@ -19,7 +19,8 @@ static void gga_x_ak13_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_ak13_params)); + p->params = malloc(sizeof(gga_x_ak13_params)); + p->params_size = sizeof(gga_x_ak13_params); } #include "maple2c/gga_exc/gga_x_ak13.c" diff --git a/src/gga_x_am05.c b/src/gga_x_am05.c index 3d805b300..69c0f0414 100644 --- a/src/gga_x_am05.c +++ b/src/gga_x_am05.c @@ -19,7 +19,8 @@ static void gga_x_am05_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_am05_params)); + p->params = malloc(sizeof(gga_x_am05_params)); + p->params_size = sizeof(gga_x_am05_params); } #include "maple2c/gga_exc/gga_x_am05.c" diff --git a/src/gga_x_b86.c b/src/gga_x_b86.c index 75dd2d1d1..c905b025a 100644 --- a/src/gga_x_b86.c +++ b/src/gga_x_b86.c @@ -23,7 +23,8 @@ static void gga_x_b86_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_b86_params)); + p->params = malloc(sizeof(gga_x_b86_params)); + p->params_size = sizeof(gga_x_b86_params); } #define B86_N_PAR 3 diff --git a/src/gga_x_b88.c b/src/gga_x_b88.c index 1a235ed1d..5d2192001 100644 --- a/src/gga_x_b88.c +++ b/src/gga_x_b88.c @@ -24,7 +24,8 @@ static void gga_x_b88_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_b88_params)); + p->params = malloc(sizeof(gga_x_b88_params)); + p->params_size = sizeof(gga_x_b88_params); } #define B88_N_PAR 2 diff --git a/src/gga_x_bkl.c b/src/gga_x_bkl.c index 1e39c19d8..bf89aa638 100644 --- a/src/gga_x_bkl.c +++ b/src/gga_x_bkl.c @@ -25,7 +25,8 @@ gga_x_bkl_init(xc_func_type *p) gga_x_bkl_params *params; assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_bkl_params)); + p->params = malloc(sizeof(gga_x_bkl_params)); + p->params_size = sizeof(gga_x_bkl_params); params = (gga_x_bkl_params *) (p->params); } diff --git a/src/gga_x_cap.c b/src/gga_x_cap.c index b2f0320e7..ec3ebbb2f 100644 --- a/src/gga_x_cap.c +++ b/src/gga_x_cap.c @@ -20,7 +20,8 @@ static void gga_x_cap_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_cap_params)); + p->params = malloc(sizeof(gga_x_cap_params)); + p->params_size = sizeof(gga_x_cap_params); } #include "maple2c/gga_exc/gga_x_cap.c" diff --git a/src/gga_x_dk87.c b/src/gga_x_dk87.c index cf2d8a0b4..0256e023f 100644 --- a/src/gga_x_dk87.c +++ b/src/gga_x_dk87.c @@ -26,7 +26,8 @@ static const double par_dk87_r2[N_PAR] = {0.861213, 0.042076, 0.98}; static void gga_x_dk87_init(xc_func_type *p) { assert(p != NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_dk87_params)); + p->params = malloc(sizeof(gga_x_dk87_params)); + p->params_size = sizeof(gga_x_dk87_params); } #include "maple2c/gga_exc/gga_x_dk87.c" diff --git a/src/gga_x_ev93.c b/src/gga_x_ev93.c index 7286c0ac7..b0a008417 100644 --- a/src/gga_x_ev93.c +++ b/src/gga_x_ev93.c @@ -24,7 +24,8 @@ static void gga_x_ev93_init(xc_func_type *p) { assert(p != NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_ev93_params)); + p->params = malloc(sizeof(gga_x_ev93_params)); + p->params_size = sizeof(gga_x_ev93_params); } #define EV93_N_PAR 6 diff --git a/src/gga_x_fd_lb94.c b/src/gga_x_fd_lb94.c index 418d22cbf..c7923ea98 100644 --- a/src/gga_x_fd_lb94.c +++ b/src/gga_x_fd_lb94.c @@ -27,7 +27,8 @@ static void gga_x_fd_lb94_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_fd_lb94_params)); + p->params = malloc(sizeof(gga_x_fd_lb94_params)); + p->params_size = sizeof(gga_x_fd_lb94_params); } GPU_FUNCTION diff --git a/src/gga_x_ft97.c b/src/gga_x_ft97.c index 2a63b61f2..79d1e4e0e 100644 --- a/src/gga_x_ft97.c +++ b/src/gga_x_ft97.c @@ -20,7 +20,8 @@ static void gga_x_ft97_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_ft97_params)); + p->params = malloc(sizeof(gga_x_ft97_params)); + p->params_size = sizeof(gga_x_ft97_params); } #define FT97_N_PAR 3 diff --git a/src/gga_x_hjs.c b/src/gga_x_hjs.c index 991234baa..743735c82 100644 --- a/src/gga_x_hjs.c +++ b/src/gga_x_hjs.c @@ -41,7 +41,8 @@ static void gga_x_hjs_init(xc_func_type *p) { assert(p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_hjs_params)); + p->params = malloc(sizeof(gga_x_hjs_params)); + p->params_size = sizeof(gga_x_hjs_params); xc_hyb_init_hybrid(p, 0.0); } diff --git a/src/gga_x_hjs_b88_v2.c b/src/gga_x_hjs_b88_v2.c index f8c5fe01e..8a941af9f 100644 --- a/src/gga_x_hjs_b88_v2.c +++ b/src/gga_x_hjs_b88_v2.c @@ -26,7 +26,8 @@ static void gga_x_hjs_init(xc_func_type *p) { assert(p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_hjs_params)); + p->params = malloc(sizeof(gga_x_hjs_params)); + p->params_size = sizeof(gga_x_hjs_params); xc_hyb_init_hybrid(p, 0.0); } diff --git a/src/gga_x_ityh_optx.c b/src/gga_x_ityh_optx.c index 709fa6d40..0f1bcd395 100644 --- a/src/gga_x_ityh_optx.c +++ b/src/gga_x_ityh_optx.c @@ -22,7 +22,8 @@ static void xc_gga_x_ityh_optx_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_ityh_optx_params)); + p->params = malloc(sizeof(gga_x_ityh_optx_params)); + p->params_size = sizeof(gga_x_ityh_optx_params); xc_hyb_init_hybrid(p, 0.0); } diff --git a/src/gga_x_ityh_pbe.c b/src/gga_x_ityh_pbe.c index 6b607f0e7..9241761fd 100644 --- a/src/gga_x_ityh_pbe.c +++ b/src/gga_x_ityh_pbe.c @@ -34,7 +34,8 @@ gga_x_ityh_pbe_init(xc_func_type *p) gga_x_ityh_pbe_params *params; assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_ityh_pbe_params)); + p->params = malloc(sizeof(gga_x_ityh_pbe_params)); + p->params_size = sizeof(gga_x_ityh_pbe_params); params = (gga_x_ityh_pbe_params *) (p->params); /* This has to be explicitly initialized here */ diff --git a/src/gga_x_kt.c b/src/gga_x_kt.c index 4690d17aa..8545550a1 100644 --- a/src/gga_x_kt.c +++ b/src/gga_x_kt.c @@ -22,7 +22,8 @@ static void gga_x_kt_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_kt_params)); + p->params = malloc(sizeof(gga_x_kt_params)); + p->params_size = sizeof(gga_x_kt_params); } #include "maple2c/gga_exc/gga_x_kt.c" diff --git a/src/gga_x_lb.c b/src/gga_x_lb.c index fb529576a..74fb8f273 100644 --- a/src/gga_x_lb.c +++ b/src/gga_x_lb.c @@ -35,7 +35,8 @@ gga_lb_init(xc_func_type *p) gga_x_lb_params *params; assert(p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_lb_params)); + p->params = malloc(sizeof(gga_x_lb_params)); + p->params_size = sizeof(gga_x_lb_params); params = (gga_x_lb_params *) (p->params); switch(p->info->number){ diff --git a/src/gga_x_lspbe.c b/src/gga_x_lspbe.c index 4e574a1fc..6e61a409c 100644 --- a/src/gga_x_lspbe.c +++ b/src/gga_x_lspbe.c @@ -21,7 +21,8 @@ static void gga_x_lspbe_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_lspbe_params)); + p->params = malloc(sizeof(gga_x_lspbe_params)); + p->params_size = sizeof(gga_x_lspbe_params); } #define LSPBE_N_PAR 3 diff --git a/src/gga_x_lsrpbe.c b/src/gga_x_lsrpbe.c index b309b308e..64f9af7d6 100644 --- a/src/gga_x_lsrpbe.c +++ b/src/gga_x_lsrpbe.c @@ -21,7 +21,8 @@ static void gga_x_lsrpbe_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_lsrpbe_params)); + p->params = malloc(sizeof(gga_x_lsrpbe_params)); + p->params_size = sizeof(gga_x_lsrpbe_params); } #define LSRPBE_N_PAR 3 diff --git a/src/gga_x_mpbe.c b/src/gga_x_mpbe.c index 561f6f193..5309b52a3 100644 --- a/src/gga_x_mpbe.c +++ b/src/gga_x_mpbe.c @@ -22,7 +22,8 @@ gga_x_mpbe_init(xc_func_type *p) gga_x_mpbe_params *params; assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_mpbe_params)); + p->params = malloc(sizeof(gga_x_mpbe_params)); + p->params_size = sizeof(gga_x_mpbe_params); params = (gga_x_mpbe_params *) (p->params); switch(p->info->number){ diff --git a/src/gga_x_n12.c b/src/gga_x_n12.c index ee83f3c9c..3187bd1ed 100644 --- a/src/gga_x_n12.c +++ b/src/gga_x_n12.c @@ -64,7 +64,8 @@ gga_x_n12_init(xc_func_type *p) { assert(p != NULL); assert(p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_n12_params)); + p->params = malloc(sizeof(gga_x_n12_params)); + p->params_size = sizeof(gga_x_n12_params); if(p->info->number == XC_HYB_GGA_X_N12_SX) xc_hyb_init_sr(p, 0.0, 0.0); diff --git a/src/gga_x_ncap.c b/src/gga_x_ncap.c index 7fc048607..23c1819dc 100644 --- a/src/gga_x_ncap.c +++ b/src/gga_x_ncap.c @@ -21,7 +21,8 @@ static void gga_x_ncap_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_ncap_params)); + p->params = malloc(sizeof(gga_x_ncap_params)); + p->params_size = sizeof(gga_x_ncap_params); } #include "maple2c/gga_exc/gga_x_ncap.c" diff --git a/src/gga_x_ol2.c b/src/gga_x_ol2.c index 5eb21e83f..68f937ad1 100644 --- a/src/gga_x_ol2.c +++ b/src/gga_x_ol2.c @@ -18,7 +18,8 @@ static void gga_x_ol2_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_ol2_params)); + p->params = malloc(sizeof(gga_x_ol2_params)); + p->params_size = sizeof(gga_x_ol2_params); } #include "maple2c/gga_exc/gga_x_ol2.c" diff --git a/src/gga_x_optx.c b/src/gga_x_optx.c index 6ceb80642..b4c5e20f6 100644 --- a/src/gga_x_optx.c +++ b/src/gga_x_optx.c @@ -19,7 +19,8 @@ static void gga_x_optx_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_optx_params)); + p->params = malloc(sizeof(gga_x_optx_params)); + p->params_size = sizeof(gga_x_optx_params); } #define OPTX_N_PAR 3 diff --git a/src/gga_x_pbe.c b/src/gga_x_pbe.c index c099f4b28..5ee23b25d 100644 --- a/src/gga_x_pbe.c +++ b/src/gga_x_pbe.c @@ -37,7 +37,8 @@ gga_x_pbe_init(xc_func_type *p) gga_x_pbe_params *params; assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_pbe_params)); + p->params = malloc(sizeof(gga_x_pbe_params)); + p->params_size = sizeof(gga_x_pbe_params); params = (gga_x_pbe_params *) (p->params); /* This has to be explicitly initialized here */ diff --git a/src/gga_x_pbe_erf_gws.c b/src/gga_x_pbe_erf_gws.c index dae87f4de..c5d228340 100644 --- a/src/gga_x_pbe_erf_gws.c +++ b/src/gga_x_pbe_erf_gws.c @@ -36,7 +36,8 @@ static const double param_values[N_PAR] = {0.8040, 0.2195149727645171, 19.0, 0.5 static void xc_gga_x_pbe_erf_gws_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_pbe_erf_gws_params)); + p->params = malloc(sizeof(gga_x_pbe_erf_gws_params)); + p->params_size = sizeof(gga_x_pbe_erf_gws_params); xc_hyb_init_hybrid(p, 0.0); } @@ -63,7 +64,8 @@ const xc_func_info_type xc_func_info_gga_x_pbe_erf_gws = { static void xc_hyb_gga_x_pbe_erf_gws_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_pbe_erf_gws_params)); + p->params = malloc(sizeof(gga_x_pbe_erf_gws_params)); + p->params_size = sizeof(gga_x_pbe_erf_gws_params); xc_hyb_init_cam(p, 0.0, 0.0, 0.0); } diff --git a/src/gga_x_pbeint.c b/src/gga_x_pbeint.c index 5a7756633..7ce97a724 100644 --- a/src/gga_x_pbeint.c +++ b/src/gga_x_pbeint.c @@ -19,7 +19,8 @@ static void gga_x_pbe_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_pbeint_params)); + p->params = malloc(sizeof(gga_x_pbeint_params)); + p->params_size = sizeof(gga_x_pbeint_params); } #define PBEINT_N_PAR 4 diff --git a/src/gga_x_pw86.c b/src/gga_x_pw86.c index f2ac65b19..b2f9db66f 100644 --- a/src/gga_x_pw86.c +++ b/src/gga_x_pw86.c @@ -27,7 +27,8 @@ static const double par_rpw86[3] = {15.0 * 0.1234, 17.33, 0.163}; static void gga_x_pw86_init(xc_func_type *p) { assert(p != NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_pw86_params)); + p->params = malloc(sizeof(gga_x_pw86_params)); + p->params_size = sizeof(gga_x_pw86_params); } #include "maple2c/gga_exc/gga_x_pw86.c" diff --git a/src/gga_x_pw91.c b/src/gga_x_pw91.c index 76490eee9..0138ffa73 100644 --- a/src/gga_x_pw91.c +++ b/src/gga_x_pw91.c @@ -29,7 +29,8 @@ static void gga_x_pw91_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_pw91_params)); + p->params = malloc(sizeof(gga_x_pw91_params)); + p->params_size = sizeof(gga_x_pw91_params); } /* diff --git a/src/gga_x_rpbe.c b/src/gga_x_rpbe.c index 391b96d74..910e9a5eb 100644 --- a/src/gga_x_rpbe.c +++ b/src/gga_x_rpbe.c @@ -20,7 +20,8 @@ static void gga_x_rpbe_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_rpbe_params)); + p->params = malloc(sizeof(gga_x_rpbe_params)); + p->params_size = sizeof(gga_x_rpbe_params); } #define RPBE_N_PAR 2 diff --git a/src/gga_x_s12.c b/src/gga_x_s12.c index 2c1e57661..cf0abd9ef 100644 --- a/src/gga_x_s12.c +++ b/src/gga_x_s12.c @@ -22,7 +22,8 @@ gga_x_s12_init(xc_func_type *p) gga_x_s12_params *params; assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_s12_params)); + p->params = malloc(sizeof(gga_x_s12_params)); + p->params_size = sizeof(gga_x_s12_params); params = (gga_x_s12_params *) (p->params); params->bx = 1.0; /* we initialize it here */ diff --git a/src/gga_x_sogga11.c b/src/gga_x_sogga11.c index ed58cc9a6..4131eee06 100644 --- a/src/gga_x_sogga11.c +++ b/src/gga_x_sogga11.c @@ -54,7 +54,8 @@ static void gga_x_sogga11_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_sogga11_params)); + p->params = malloc(sizeof(gga_x_sogga11_params)); + p->params_size = sizeof(gga_x_sogga11_params); if(p->info->number == XC_HYB_GGA_X_SOGGA11_X) xc_hyb_init_hybrid(p, 0.0); diff --git a/src/gga_x_ssb_sw.c b/src/gga_x_ssb_sw.c index 26c7ee6f5..b16d5c5c1 100644 --- a/src/gga_x_ssb_sw.c +++ b/src/gga_x_ssb_sw.c @@ -23,7 +23,8 @@ static void gga_x_ssb_sw_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_ssb_sw_params)); + p->params = malloc(sizeof(gga_x_ssb_sw_params)); + p->params_size = sizeof(gga_x_ssb_sw_params); } #define N_PAR 5 diff --git a/src/gga_x_vmt.c b/src/gga_x_vmt.c index c91492287..b75d4d423 100644 --- a/src/gga_x_vmt.c +++ b/src/gga_x_vmt.c @@ -23,7 +23,8 @@ gga_x_vmt_init(xc_func_type *p) gga_x_vmt_params *params; assert(p != NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_vmt_params)); + p->params = malloc(sizeof(gga_x_vmt_params)); + p->params_size = sizeof(gga_x_vmt_params); params = (gga_x_vmt_params *) (p->params); switch(p->info->number){ diff --git a/src/gga_x_vmt84.c b/src/gga_x_vmt84.c index afe94952b..ef9fb6af3 100644 --- a/src/gga_x_vmt84.c +++ b/src/gga_x_vmt84.c @@ -22,7 +22,8 @@ gga_x_vmt84_init(xc_func_type *p) gga_x_vmt84_params *params; assert(p != NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(gga_x_vmt84_params)); + p->params = malloc(sizeof(gga_x_vmt84_params)); + p->params_size = sizeof(gga_x_vmt84_params); params = (gga_x_vmt84_params *) (p->params); switch(p->info->number){ diff --git a/src/gga_xc_b97.c b/src/gga_xc_b97.c index 6fea7560b..03dce9da9 100644 --- a/src/gga_xc_b97.c +++ b/src/gga_xc_b97.c @@ -194,7 +194,8 @@ static void gga_xc_b97_init(xc_func_type *p) { assert(p->params == NULL); - p->params = libxc_malloc(sizeof(gga_xc_b97_params)); + p->params = malloc(sizeof(gga_xc_b97_params)); + p->params_size = sizeof(gga_xc_b97_params); if(p->info->number == XC_HYB_GGA_XC_B97 || p->info->number == XC_HYB_GGA_XC_B97_1 || diff --git a/src/gga_xc_th1.c b/src/gga_xc_th1.c index 8e29eec9e..d1b7ad4d5 100644 --- a/src/gga_xc_th1.c +++ b/src/gga_xc_th1.c @@ -66,7 +66,8 @@ static void gga_xc_th1_init(xc_func_type *p) { assert(p->params == NULL); - p->params = libxc_malloc(sizeof(gga_xc_th1_params)); + p->params = malloc(sizeof(gga_xc_th1_params)); + p->params_size = sizeof(gga_xc_th1_params); } #include "maple2c/gga_exc/gga_xc_th1.c" diff --git a/src/gga_xc_th3.c b/src/gga_xc_th3.c index bd832bf2a..567f3d9c1 100644 --- a/src/gga_xc_th3.c +++ b/src/gga_xc_th3.c @@ -39,7 +39,8 @@ gga_xc_th3_init(xc_func_type *p) int ii; assert(p->params == NULL); - p->params = libxc_malloc(sizeof(gga_xc_th3_params)); + p->params = malloc(sizeof(gga_xc_th3_params)); + p->params_size = sizeof(gga_xc_th3_params); params = (gga_xc_th3_params *)p->params; for(ii = 0; ii < 19; ii++){ diff --git a/src/hyb_gga_x_cam_s12.c b/src/hyb_gga_x_cam_s12.c index a7374022f..e8485d5be 100644 --- a/src/hyb_gga_x_cam_s12.c +++ b/src/hyb_gga_x_cam_s12.c @@ -19,7 +19,8 @@ static void hyb_gga_x_cam_s12_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(hyb_gga_x_cam_s12_params)); + p->params = malloc(sizeof(hyb_gga_x_cam_s12_params)); + p->params_size = sizeof(hyb_gga_x_cam_s12_params); xc_hyb_init_cam(p, 0.0, 0.0, 0.0); } diff --git a/src/hyb_gga_xc_case21.c b/src/hyb_gga_xc_case21.c index f1910551e..96210e2b9 100644 --- a/src/hyb_gga_xc_case21.c +++ b/src/hyb_gga_xc_case21.c @@ -104,7 +104,8 @@ static void hyb_gga_xc_case21_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(hyb_gga_xc_case21_params)); + p->params = malloc(sizeof(hyb_gga_xc_case21_params)); + p->params_size = sizeof(hyb_gga_xc_case21_params); xc_hyb_init_hybrid(p, 0.0); } diff --git a/src/hyb_gga_xc_wb97.c b/src/hyb_gga_xc_wb97.c index cfe63a8af..17f9b46ae 100644 --- a/src/hyb_gga_xc_wb97.c +++ b/src/hyb_gga_xc_wb97.c @@ -84,7 +84,8 @@ static void gga_xc_wb97_init(xc_func_type *p) { assert(p->params == NULL); - p->params = libxc_malloc(sizeof(gga_xc_wb97_params)); + p->params = malloc(sizeof(gga_xc_wb97_params)); + p->params_size = sizeof(gga_xc_wb97_params); xc_hyb_init_cam(p, 0.0, 0.0, 0.0); switch(p->info->number){ diff --git a/src/hyb_mgga_x_m05.c b/src/hyb_mgga_x_m05.c index cfaea5b24..0ae1135e3 100644 --- a/src/hyb_mgga_x_m05.c +++ b/src/hyb_mgga_x_m05.c @@ -78,7 +78,8 @@ static void mgga_x_m05_init(xc_func_type *p) { assert(p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_m05_params)); + p->params = malloc(sizeof(mgga_x_m05_params)); + p->params_size = sizeof(mgga_x_m05_params); xc_hyb_init_hybrid(p, 0.0); } diff --git a/src/hyb_mgga_xc_gas22.c b/src/hyb_mgga_xc_gas22.c index fc4ba4647..16e52f805 100644 --- a/src/hyb_mgga_xc_gas22.c +++ b/src/hyb_mgga_xc_gas22.c @@ -51,7 +51,8 @@ static void hyb_mgga_xc_gas22_init(xc_func_type *p) { assert(p->params == NULL); - p->params = libxc_malloc(sizeof(hyb_mgga_xc_gas22_params)); + p->params = malloc(sizeof(hyb_mgga_xc_gas22_params)); + p->params_size = sizeof(hyb_mgga_xc_gas22_params); xc_hyb_init_cam(p, 0.0, 0.0, 0.0); p->nlc_b = 6.0; diff --git a/src/hyb_mgga_xc_wb97mv.c b/src/hyb_mgga_xc_wb97mv.c index fcb0e78e9..93af894dc 100644 --- a/src/hyb_mgga_xc_wb97mv.c +++ b/src/hyb_mgga_xc_wb97mv.c @@ -52,7 +52,8 @@ static void hyb_mgga_xc_wb97mv_init(xc_func_type *p) { assert(p->params == NULL); - p->params = libxc_malloc(sizeof(hyb_mgga_xc_wb97_mv_params)); + p->params = malloc(sizeof(hyb_mgga_xc_wb97_mv_params)); + p->params_size = sizeof(hyb_mgga_xc_wb97_mv_params); xc_hyb_init_cam(p, 0.0, 0.0, 0.0); p->nlc_b = 6.0; diff --git a/src/lda.c b/src/lda.c index e7b88ef87..4bcdbd39e 100644 --- a/src/lda.c +++ b/src/lda.c @@ -115,7 +115,7 @@ xc_lda(const xc_func_type *p, size_t np, const double *rho, double *zk, double * if(order < 0) return; xc_lda_out_params out; - libxc_memset(&out, 0, sizeof(xc_lda_out_params)); + memset(&out, 0, sizeof(xc_lda_out_params)); out.zk = zk; out.vrho = vrho; out.v2rho2 = v2rho2; @@ -131,7 +131,7 @@ void xc_lda_exc(const xc_func_type *p, size_t np, const double *rho, double *zk) { xc_lda_out_params out; - libxc_memset(&out, 0, sizeof(xc_lda_out_params)); + memset(&out, 0, sizeof(xc_lda_out_params)); out.zk = zk; xc_lda_new(p, 0, np, rho, &out); @@ -141,7 +141,7 @@ void xc_lda_exc_vxc(const xc_func_type *p, size_t np, const double *rho, double *zk, double *vrho) { xc_lda_out_params out; - libxc_memset(&out, 0, sizeof(xc_lda_out_params)); + memset(&out, 0, sizeof(xc_lda_out_params)); out.zk = zk; out.vrho = vrho; @@ -152,7 +152,7 @@ void xc_lda_exc_vxc_fxc(const xc_func_type *p, size_t np, const double *rho, double *zk, double *vrho, double *v2rho2) { xc_lda_out_params out; - libxc_memset(&out, 0, sizeof(xc_lda_out_params)); + memset(&out, 0, sizeof(xc_lda_out_params)); out.zk = zk; out.vrho = vrho; out.v2rho2 = v2rho2; @@ -164,7 +164,7 @@ void xc_lda_vxc_fxc(const xc_func_type *p, size_t np, const double *rho, double *vrho, double *v2rho2) { xc_lda_out_params out; - libxc_memset(&out, 0, sizeof(xc_lda_out_params)); + memset(&out, 0, sizeof(xc_lda_out_params)); out.vrho = vrho; out.v2rho2 = v2rho2; @@ -175,7 +175,7 @@ void xc_lda_exc_vxc_fxc_kxc(const xc_func_type *p, size_t np, const double *rho, double *zk, double *vrho, double *v2rho2, double *v3rho3) { xc_lda_out_params out; - libxc_memset(&out, 0, sizeof(xc_lda_out_params)); + memset(&out, 0, sizeof(xc_lda_out_params)); out.zk = zk; out.vrho = vrho; out.v2rho2 = v2rho2; @@ -188,7 +188,7 @@ void xc_lda_vxc_fxc_kxc(const xc_func_type *p, size_t np, const double *rho, double *vrho, double *v2rho2, double *v3rho3) { xc_lda_out_params out; - libxc_memset(&out, 0, sizeof(xc_lda_out_params)); + memset(&out, 0, sizeof(xc_lda_out_params)); out.vrho = vrho; out.v2rho2 = v2rho2; out.v3rho3 = v3rho3; @@ -200,7 +200,7 @@ void xc_lda_vxc(const xc_func_type *p, size_t np, const double *rho, double *vrho) { xc_lda_out_params out; - libxc_memset(&out, 0, sizeof(xc_lda_out_params)); + memset(&out, 0, sizeof(xc_lda_out_params)); out.vrho = vrho; xc_lda_new(p, 1, np, rho, &out); @@ -210,7 +210,7 @@ void xc_lda_fxc(const xc_func_type *p, size_t np, const double *rho, double *v2rho2) { xc_lda_out_params out; - libxc_memset(&out, 0, sizeof(xc_lda_out_params)); + memset(&out, 0, sizeof(xc_lda_out_params)); out.v2rho2 = v2rho2; xc_lda_new(p, 2, np, rho, &out); @@ -220,7 +220,7 @@ void xc_lda_kxc(const xc_func_type *p, size_t np, const double *rho, double *v3rho3) { xc_lda_out_params out; - libxc_memset(&out, 0, sizeof(xc_lda_out_params)); + memset(&out, 0, sizeof(xc_lda_out_params)); out.v3rho3 = v3rho3; xc_lda_new(p, 3, np, rho, &out); @@ -230,7 +230,7 @@ void xc_lda_lxc(const xc_func_type *p, size_t np, const double *rho, double *v4rho4) { xc_lda_out_params out; - libxc_memset(&out, 0, sizeof(xc_lda_out_params)); + memset(&out, 0, sizeof(xc_lda_out_params)); out.v4rho4 = v4rho4; xc_lda_new(p, 4, np, rho, &out); diff --git a/src/lda_c_1d_csc.c b/src/lda_c_1d_csc.c index 5f1b69f29..1237eb0b4 100644 --- a/src/lda_c_1d_csc.c +++ b/src/lda_c_1d_csc.c @@ -40,7 +40,8 @@ static void lda_c_1d_csc_init(xc_func_type *p) { assert(p != NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(lda_c_1d_csc_params)); + p->params = malloc(sizeof(lda_c_1d_csc_params)); + p->params_size = sizeof(lda_c_1d_csc_params); } #include "maple2c/lda_exc/lda_c_1d_csc.c" diff --git a/src/lda_c_2d_prm.c b/src/lda_c_2d_prm.c index e5dbcad2b..9a652da2e 100644 --- a/src/lda_c_2d_prm.c +++ b/src/lda_c_2d_prm.c @@ -28,7 +28,8 @@ lda_c_2d_prm_init(xc_func_type *p) { assert(p != NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(lda_c_2d_prm_params)); + p->params = malloc(sizeof(lda_c_2d_prm_params)); + p->params_size = sizeof(lda_c_2d_prm_params); } #include "maple2c/lda_exc/lda_c_2d_prm.c" diff --git a/src/lda_c_chachiyo.c b/src/lda_c_chachiyo.c index f58b993fc..e732d9e8b 100644 --- a/src/lda_c_chachiyo.c +++ b/src/lda_c_chachiyo.c @@ -27,7 +27,8 @@ static void lda_c_chachiyo_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(lda_c_chachiyo_params)); + p->params = malloc(sizeof(lda_c_chachiyo_params)); + p->params_size = sizeof(lda_c_chachiyo_params); } #include "maple2c/lda_exc/lda_c_chachiyo.c" diff --git a/src/lda_c_chachiyo_mod.c b/src/lda_c_chachiyo_mod.c index 6695001c8..3a3233e17 100644 --- a/src/lda_c_chachiyo_mod.c +++ b/src/lda_c_chachiyo_mod.c @@ -28,7 +28,8 @@ static void lda_c_chachiyo_mod_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(lda_c_chachiyo_mod_params)); + p->params = malloc(sizeof(lda_c_chachiyo_mod_params)); + p->params_size = sizeof(lda_c_chachiyo_mod_params); } #include "maple2c/lda_exc/lda_c_chachiyo_mod.c" diff --git a/src/lda_c_epc17.c b/src/lda_c_epc17.c index bfa0ff719..71c6682a2 100644 --- a/src/lda_c_epc17.c +++ b/src/lda_c_epc17.c @@ -26,7 +26,8 @@ static void lda_c_epc17_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(lda_c_epc17_params)); + p->params = malloc(sizeof(lda_c_epc17_params)); + p->params_size = sizeof(lda_c_epc17_params); } #include "maple2c/lda_exc/lda_c_epc17.c" diff --git a/src/lda_c_epc18.c b/src/lda_c_epc18.c index 6d2ce1c6e..1f7ce6f66 100644 --- a/src/lda_c_epc18.c +++ b/src/lda_c_epc18.c @@ -26,7 +26,8 @@ static void lda_c_epc18_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(lda_c_epc18_params)); + p->params = malloc(sizeof(lda_c_epc18_params)); + p->params_size = sizeof(lda_c_epc18_params); } #include "maple2c/lda_exc/lda_c_epc18.c" diff --git a/src/lda_c_hl.c b/src/lda_c_hl.c index 328fb16aa..394f6eb61 100644 --- a/src/lda_c_hl.c +++ b/src/lda_c_hl.c @@ -30,7 +30,8 @@ static const double par_vbh[N_PAR] = {30.0, 75.0, 0.0252, 0.0127}; static void lda_c_hl_init(xc_func_type *p) { assert(p != NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(lda_c_hl_params)); + p->params = malloc(sizeof(lda_c_hl_params)); + p->params_size = sizeof(lda_c_hl_params); } #include "maple2c/lda_exc/lda_c_hl.c" diff --git a/src/lda_c_lp96.c b/src/lda_c_lp96.c index 72c202f40..b912fb703 100644 --- a/src/lda_c_lp96.c +++ b/src/lda_c_lp96.c @@ -30,7 +30,8 @@ static void lda_c_lp96_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(lda_c_lp96_params)); + p->params = malloc(sizeof(lda_c_lp96_params)); + p->params_size = sizeof(lda_c_lp96_params); } #include "maple2c/lda_exc/lda_c_lp96.c" diff --git a/src/lda_c_ml1.c b/src/lda_c_ml1.c index 409e971ce..251433803 100644 --- a/src/lda_c_ml1.c +++ b/src/lda_c_ml1.c @@ -28,7 +28,8 @@ static void lda_c_ml1_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(lda_c_ml1_params)); + p->params = malloc(sizeof(lda_c_ml1_params)); + p->params_size = sizeof(lda_c_ml1_params); } #include "maple2c/lda_exc/lda_c_ml1.c" diff --git a/src/lda_c_pw.c b/src/lda_c_pw.c index d0cf711d9..0bca40315 100644 --- a/src/lda_c_pw.c +++ b/src/lda_c_pw.c @@ -111,7 +111,8 @@ static void lda_c_pw_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(lda_c_pw_params)); + p->params = malloc(sizeof(lda_c_pw_params)); + p->params_size = sizeof(lda_c_pw_params); } #include "maple2c/lda_exc/lda_c_pw.c" diff --git a/src/lda_c_pz.c b/src/lda_c_pz.c index 1c28081ab..c2c1ac126 100644 --- a/src/lda_c_pz.c +++ b/src/lda_c_pz.c @@ -83,7 +83,8 @@ static void lda_c_pz_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(lda_c_pz_params)); + p->params = malloc(sizeof(lda_c_pz_params)); + p->params_size = sizeof(lda_c_pz_params); } #include "maple2c/lda_exc/lda_c_pz.c" diff --git a/src/lda_c_wigner.c b/src/lda_c_wigner.c index 1f67598da..1a0526304 100644 --- a/src/lda_c_wigner.c +++ b/src/lda_c_wigner.c @@ -36,7 +36,8 @@ static void lda_c_wigner_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(lda_c_wigner_params)); + p->params = malloc(sizeof(lda_c_wigner_params)); + p->params_size = sizeof(lda_c_wigner_params); } #include "maple2c/lda_exc/lda_c_wigner.c" diff --git a/src/lda_k_gds08_worker.c b/src/lda_k_gds08_worker.c index 6f003fb00..76b074a8e 100644 --- a/src/lda_k_gds08_worker.c +++ b/src/lda_k_gds08_worker.c @@ -19,7 +19,8 @@ static void lda_k_gds08_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(lda_k_gds08_params)); + p->params = malloc(sizeof(lda_k_gds08_params)); + p->params_size = sizeof(lda_k_gds08_params); } #define GDS08_N_PAR 3 diff --git a/src/lda_k_tf.c b/src/lda_k_tf.c index 9c2d99bf6..1b2e0b00d 100644 --- a/src/lda_k_tf.c +++ b/src/lda_k_tf.c @@ -22,7 +22,8 @@ lda_k_tf_init(xc_func_type *p) lda_k_tf_params *params; assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(lda_k_tf_params)); + p->params = malloc(sizeof(lda_k_tf_params)); + p->params_size = sizeof(lda_k_tf_params); params = (lda_k_tf_params *) (p->params); switch(p->info->number){ diff --git a/src/lda_x.c b/src/lda_x.c index 876be4f39..69c9af38c 100644 --- a/src/lda_x.c +++ b/src/lda_x.c @@ -42,7 +42,8 @@ lda_x_init(xc_func_type *p) lda_x_params *params; assert(p != NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(lda_x_params)); + p->params = malloc(sizeof(lda_x_params)); + p->params_size = sizeof(lda_x_params); params = (lda_x_params *) (p->params); params->alpha = 1.0; diff --git a/src/lda_x_1d_exponential.c b/src/lda_x_1d_exponential.c index 0323b77a6..57779613e 100644 --- a/src/lda_x_1d_exponential.c +++ b/src/lda_x_1d_exponential.c @@ -19,7 +19,8 @@ static void lda_x_1d_exponential_init(xc_func_type *p) { assert(p->params == NULL); - p->params = libxc_malloc(sizeof(lda_x_1d_exponential_params)); + p->params = malloc(sizeof(lda_x_1d_exponential_params)); + p->params_size = sizeof(lda_x_1d_exponential_params); } GPU_FUNCTION diff --git a/src/lda_x_1d_soft.c b/src/lda_x_1d_soft.c index 17e61bd3b..587506099 100644 --- a/src/lda_x_1d_soft.c +++ b/src/lda_x_1d_soft.c @@ -19,7 +19,8 @@ static void lda_x_1d_exponential_init(xc_func_type *p) { assert(p->params == NULL); - p->params = libxc_malloc(sizeof(lda_x_1d_exponential_params)); + p->params = malloc(sizeof(lda_x_1d_exponential_params)); + p->params_size = sizeof(lda_x_1d_exponential_params); } GPU_FUNCTION diff --git a/src/lda_x_sloc.c b/src/lda_x_sloc.c index 7b980c422..5ccd8ecc4 100644 --- a/src/lda_x_sloc.c +++ b/src/lda_x_sloc.c @@ -20,7 +20,8 @@ static void lda_x_sloc_init(xc_func_type *p) { assert(p != NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(lda_x_sloc_params)); + p->params = malloc(sizeof(lda_x_sloc_params)); + p->params_size = sizeof(lda_x_sloc_params); } #include "maple2c/lda_exc/lda_x_sloc.c" diff --git a/src/lda_xc_1d_ehwlrg.c b/src/lda_xc_1d_ehwlrg.c index da57fb68e..827819874 100644 --- a/src/lda_xc_1d_ehwlrg.c +++ b/src/lda_xc_1d_ehwlrg.c @@ -25,7 +25,8 @@ lda_xc_1d_ehwlrg_init(xc_func_type *p) lda_xc_1d_ehwlrg_params *params; assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(lda_xc_1d_ehwlrg_params)); + p->params = malloc(sizeof(lda_xc_1d_ehwlrg_params)); + p->params_size = sizeof(lda_xc_1d_ehwlrg_params); params = (lda_xc_1d_ehwlrg_params *) (p->params); switch(p->info->number){ diff --git a/src/lda_xc_ksdt.c b/src/lda_xc_ksdt.c index 246d1ba4d..8762a7fe1 100644 --- a/src/lda_xc_ksdt.c +++ b/src/lda_xc_ksdt.c @@ -88,7 +88,8 @@ lda_xc_ksdt_init(xc_func_type *p) lda_xc_ksdt_params *params; assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(lda_xc_ksdt_params)); + p->params = malloc(sizeof(lda_xc_ksdt_params)); + p->params_size = sizeof(lda_xc_ksdt_params); params = (lda_xc_ksdt_params *)(p->params); switch(p->info->number){ diff --git a/src/mgga.c b/src/mgga.c index 6b05e65d7..dcd528054 100644 --- a/src/mgga.c +++ b/src/mgga.c @@ -24,7 +24,7 @@ xc_mgga_sanity_check(const xc_func_info_type *info, int order, xc_mgga_out_param order); exit(1); } - + /* sanity check */ if(out->zk != NULL && !(info->flags & XC_FLAGS_HAVE_EXC)){ fprintf(stderr, "Functional '%s' does not provide an implementation of Exc\n", @@ -53,7 +53,7 @@ xc_mgga_sanity_check(const xc_func_info_type *info, int order, xc_mgga_out_param info->name); exit(1); } - check_out_var(v2rhosigma); + check_out_var(v2rhosigma); check_out_var(v2sigma2); if(info->flags & XC_FLAGS_NEEDS_LAPLACIAN){ check_out_var(v2rholapl); @@ -147,7 +147,7 @@ xc_mgga_sanity_check(const xc_func_info_type *info, int order, xc_mgga_out_param check_out_var(v4sigmalapltau2); check_out_var(v4lapl3tau); check_out_var(v4lapl2tau2); - check_out_var(v4lapltau3); + check_out_var(v4lapltau3); } } } @@ -183,13 +183,13 @@ xc_mgga_initalize(const xc_func_type *func, size_t np, xc_mgga_out_params *out) libxc_memset(out->v2sigmalapl, 0, dim->v2sigmalapl*np*sizeof(double)); libxc_memset(out->v2lapl2, 0, dim->v2lapl2 *np*sizeof(double)); } - + if(func->info->flags & XC_FLAGS_NEEDS_TAU){ libxc_memset(out->v2rhotau, 0, dim->v2rhotau *np*sizeof(double)); libxc_memset(out->v2sigmatau, 0, dim->v2sigmatau *np*sizeof(double)); libxc_memset(out->v2tau2, 0, dim->v2tau2 *np*sizeof(double)); } - + if((func->info->flags & XC_FLAGS_NEEDS_LAPLACIAN) && (func->info->flags & XC_FLAGS_NEEDS_TAU)) { libxc_memset(out->v2lapltau, 0, dim->v2lapltau *np*sizeof(double)); } @@ -293,7 +293,7 @@ void xc_mgga_new(const xc_func_type *func, int order, size_t np, func->info->mgga->pol[order](func, np, rho, sigma, lapl, tau, out); } } - + if(func->mix_coef != NULL) xc_mix_func(func, np, rho, sigma, lapl, tau, out->zk, out->vrho, out->vsigma, out->vlapl, out->vtau, @@ -434,7 +434,7 @@ xc_mgga(const xc_func_type *p, size_t np, if(order < 0) return; xc_mgga_out_params out; - libxc_memset(&out, 0, sizeof(xc_mgga_out_params)); + memset(&out, 0, sizeof(xc_mgga_out_params)); SET_ORDER_0; SET_ORDER_1; @@ -454,7 +454,7 @@ xc_mgga_exc(const xc_func_type *p, size_t np, double *zk) { xc_mgga_out_params out; - libxc_memset(&out, 0, sizeof(xc_mgga_out_params)); + memset(&out, 0, sizeof(xc_mgga_out_params)); SET_ORDER_0; xc_mgga_new(p, 0, np, rho, sigma, lapl, tau, &out); @@ -466,7 +466,7 @@ xc_mgga_exc_vxc(const xc_func_type *p, size_t np, double *zk, double *vrho, double *vsigma, double *vlapl, double *vtau) { xc_mgga_out_params out; - libxc_memset(&out, 0, sizeof(xc_mgga_out_params)); + memset(&out, 0, sizeof(xc_mgga_out_params)); SET_ORDER_0; SET_ORDER_1; @@ -481,7 +481,7 @@ void xc_mgga_exc_vxc_fxc(const xc_func_type *p, size_t np, double *v2lapltau, double *v2tau2) { xc_mgga_out_params out; - libxc_memset(&out, 0, sizeof(xc_mgga_out_params)); + memset(&out, 0, sizeof(xc_mgga_out_params)); SET_ORDER_0; SET_ORDER_1; SET_ORDER_2; @@ -497,7 +497,7 @@ void xc_mgga_vxc_fxc(const xc_func_type *p, size_t np, double *v2lapltau, double *v2tau2) { xc_mgga_out_params out; - libxc_memset(&out, 0, sizeof(xc_mgga_out_params)); + memset(&out, 0, sizeof(xc_mgga_out_params)); SET_ORDER_1; SET_ORDER_2; @@ -518,7 +518,7 @@ void xc_mgga_exc_vxc_fxc_kxc(const xc_func_type *p, size_t np, double *v3tau3) { xc_mgga_out_params out; - libxc_memset(&out, 0, sizeof(xc_mgga_out_params)); + memset(&out, 0, sizeof(xc_mgga_out_params)); SET_ORDER_0; SET_ORDER_1; SET_ORDER_2; @@ -541,7 +541,7 @@ void xc_mgga_vxc_fxc_kxc(const xc_func_type *p, size_t np, double *v3tau3) { xc_mgga_out_params out; - libxc_memset(&out, 0, sizeof(xc_mgga_out_params)); + memset(&out, 0, sizeof(xc_mgga_out_params)); SET_ORDER_1; SET_ORDER_2; SET_ORDER_3; @@ -556,7 +556,7 @@ xc_mgga_vxc(const xc_func_type *p, size_t np, double *vrho, double *vsigma, double *vlapl, double *vtau) { xc_mgga_out_params out; - libxc_memset(&out, 0, sizeof(xc_mgga_out_params)); + memset(&out, 0, sizeof(xc_mgga_out_params)); SET_ORDER_1; xc_mgga_new(p, 1, np, rho, sigma, lapl, tau, &out); @@ -570,7 +570,7 @@ xc_mgga_fxc(const xc_func_type *p, size_t np, double *v2lapltau, double *v2tau2) { xc_mgga_out_params out; - libxc_memset(&out, 0, sizeof(xc_mgga_out_params)); + memset(&out, 0, sizeof(xc_mgga_out_params)); SET_ORDER_2; xc_mgga_new(p, 2, np, rho, sigma, lapl, tau, &out); @@ -586,7 +586,7 @@ void xc_mgga_kxc(const xc_func_type *p, size_t np, double *v3lapl3, double *v3lapl2tau, double *v3lapltau2, double *v3tau3) { xc_mgga_out_params out; - libxc_memset(&out, 0, sizeof(xc_mgga_out_params)); + memset(&out, 0, sizeof(xc_mgga_out_params)); SET_ORDER_3; xc_mgga_new(p, 3, np, rho, sigma, lapl, tau, &out); @@ -605,7 +605,7 @@ void xc_mgga_lxc(const xc_func_type *p, size_t np, double *v4lapl2tau2, double *v4lapltau3, double *v4tau4) { xc_mgga_out_params out; - libxc_memset(&out, 0, sizeof(xc_mgga_out_params)); + memset(&out, 0, sizeof(xc_mgga_out_params)); SET_ORDER_4; xc_mgga_new(p, 4, np, rho, sigma, lapl, tau, &out); diff --git a/src/mgga_c_b94.c b/src/mgga_c_b94.c index fd85db41b..839899c5c 100644 --- a/src/mgga_c_b94.c +++ b/src/mgga_c_b94.c @@ -32,7 +32,8 @@ static void mgga_c_b94_init(xc_func_type *p) { assert(p != NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_c_b94_params)); + p->params = malloc(sizeof(mgga_c_b94_params)); + p->params_size = sizeof(mgga_c_b94_params); } #ifdef __cplusplus diff --git a/src/mgga_c_bc95.c b/src/mgga_c_bc95.c index c9d6abd6c..e2a432ff9 100644 --- a/src/mgga_c_bc95.c +++ b/src/mgga_c_bc95.c @@ -20,7 +20,8 @@ static void mgga_c_bc95_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_c_bc95_params)); + p->params = malloc(sizeof(mgga_c_bc95_params)); + p->params_size = sizeof(mgga_c_bc95_params); } #define BC95_N_PAR 2 diff --git a/src/mgga_c_ccalda.c b/src/mgga_c_ccalda.c index e8ec2a246..3a6a491fd 100644 --- a/src/mgga_c_ccalda.c +++ b/src/mgga_c_ccalda.c @@ -28,7 +28,8 @@ static void mgga_c_ccalda_init(xc_func_type *p) { assert(p != NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_c_ccalda_params)); + p->params = malloc(sizeof(mgga_c_ccalda_params)); + p->params_size = sizeof(mgga_c_ccalda_params); } #ifdef __cplusplus diff --git a/src/mgga_c_ltapw.c b/src/mgga_c_ltapw.c index 0299fcb93..dea30240b 100644 --- a/src/mgga_c_ltapw.c +++ b/src/mgga_c_ltapw.c @@ -19,7 +19,8 @@ static void mgga_c_ltapw_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_c_ltapw_params)); + p->params = malloc(sizeof(mgga_c_ltapw_params)); + p->params_size = sizeof(mgga_c_ltapw_params); } #define N_PAR 1 diff --git a/src/mgga_c_m05.c b/src/mgga_c_m05.c index 569ede6d7..dce9ef781 100644 --- a/src/mgga_c_m05.c +++ b/src/mgga_c_m05.c @@ -23,7 +23,8 @@ static void mgga_c_vsxc_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_c_m05_params)); + p->params = malloc(sizeof(mgga_c_m05_params)); + p->params_size = sizeof(mgga_c_m05_params); } #define M05_N_PAR 13 diff --git a/src/mgga_c_m06l.c b/src/mgga_c_m06l.c index 1fa69f989..44a12daa5 100644 --- a/src/mgga_c_m06l.c +++ b/src/mgga_c_m06l.c @@ -30,13 +30,14 @@ mgga_c_m06l_init(xc_func_type *p) assert(p != NULL); p->n_func_aux = 1; - p->func_aux = (xc_func_type **) libxc_malloc(1*sizeof(xc_func_type *)); - p->func_aux[0] = (xc_func_type *) libxc_malloc( sizeof(xc_func_type)); + p->func_aux = (xc_func_type **) malloc(1*sizeof(xc_func_type *)); + p->func_aux[0] = (xc_func_type *) malloc( sizeof(xc_func_type)); xc_func_init(p->func_aux[0], XC_LDA_C_PW_MOD, XC_POLARIZED); assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_c_m06l_params)); + p->params = malloc(sizeof(mgga_c_m06l_params)); + p->params_size = sizeof(mgga_c_m06l_params); } #define M06L_N_PAR 27 diff --git a/src/mgga_c_m08.c b/src/mgga_c_m08.c index 3d5a4e07d..2ebfb8e88 100644 --- a/src/mgga_c_m08.c +++ b/src/mgga_c_m08.c @@ -104,7 +104,8 @@ static void mgga_c_m08_init(xc_func_type *p) { assert(p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_c_m08_params)); + p->params = malloc(sizeof(mgga_c_m08_params)); + p->params_size = sizeof(mgga_c_m08_params); } #include "maple2c/mgga_exc/mgga_c_m08.c" diff --git a/src/mgga_c_r2scan.c b/src/mgga_c_r2scan.c index b18f5b0d5..7f94ea3e7 100644 --- a/src/mgga_c_r2scan.c +++ b/src/mgga_c_r2scan.c @@ -31,7 +31,8 @@ static void mgga_c_r2scan_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_c_r2scan_params)); + p->params = malloc(sizeof(mgga_c_r2scan_params)); + p->params_size = sizeof(mgga_c_r2scan_params); } #ifdef __cplusplus diff --git a/src/mgga_c_revtpss.c b/src/mgga_c_revtpss.c index 76f5f58d0..2d34b756d 100644 --- a/src/mgga_c_revtpss.c +++ b/src/mgga_c_revtpss.c @@ -21,7 +21,8 @@ static void mgga_c_revtpss_init(xc_func_type *p) { assert(p != NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_c_revtpss_params)); + p->params = malloc(sizeof(mgga_c_revtpss_params)); + p->params_size = sizeof(mgga_c_revtpss_params); } #define REVTPSS_N_PAR 5 diff --git a/src/mgga_c_rppscan.c b/src/mgga_c_rppscan.c index e0fce3159..e8030cb4a 100644 --- a/src/mgga_c_rppscan.c +++ b/src/mgga_c_rppscan.c @@ -30,7 +30,8 @@ static void mgga_c_rppscan_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_c_rppscan_params)); + p->params = malloc(sizeof(mgga_c_rppscan_params)); + p->params_size = sizeof(mgga_c_rppscan_params); } #ifdef __cplusplus diff --git a/src/mgga_c_tpss.c b/src/mgga_c_tpss.c index dfae05f4e..005631a11 100644 --- a/src/mgga_c_tpss.c +++ b/src/mgga_c_tpss.c @@ -22,7 +22,8 @@ static void mgga_c_tpss_init(xc_func_type *p) { assert(p != NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_c_tpss_params)); + p->params = malloc(sizeof(mgga_c_tpss_params)); + p->params_size = sizeof(mgga_c_tpss_params); } #define TPSS_N_PAR 6 diff --git a/src/mgga_c_vsxc.c b/src/mgga_c_vsxc.c index 49557fc87..1717fc95b 100644 --- a/src/mgga_c_vsxc.c +++ b/src/mgga_c_vsxc.c @@ -30,7 +30,8 @@ static void mgga_c_vsxc_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_c_vsxc_params)); + p->params = malloc(sizeof(mgga_c_vsxc_params)); + p->params_size = sizeof(mgga_c_vsxc_params); } #include "maple2c/mgga_exc/mgga_c_vsxc.c" diff --git a/src/mgga_k_csk.c b/src/mgga_k_csk.c index f85e08e84..382b409f4 100644 --- a/src/mgga_k_csk.c +++ b/src/mgga_k_csk.c @@ -25,7 +25,8 @@ static void mgga_k_csk_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_k_csk_params)); + p->params = malloc(sizeof(mgga_k_csk_params)); + p->params_size = sizeof(mgga_k_csk_params); } #include "maple2c/mgga_exc/mgga_k_csk.c" diff --git a/src/mgga_k_csk_loc.c b/src/mgga_k_csk_loc.c index 6d023ca12..81413eb24 100644 --- a/src/mgga_k_csk_loc.c +++ b/src/mgga_k_csk_loc.c @@ -26,7 +26,8 @@ static void mgga_k_csk_loc_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_k_csk_loc_params)); + p->params = malloc(sizeof(mgga_k_csk_loc_params)); + p->params_size = sizeof(mgga_k_csk_loc_params); } #include "maple2c/mgga_exc/mgga_k_csk_loc.c" diff --git a/src/mgga_k_lk.c b/src/mgga_k_lk.c index 7d2afb40a..ab88416b4 100644 --- a/src/mgga_k_lk.c +++ b/src/mgga_k_lk.c @@ -19,7 +19,8 @@ static void mgga_k_lk_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_k_lk_params)); + p->params = malloc(sizeof(mgga_k_lk_params)); + p->params_size = sizeof(mgga_k_lk_params); } #define N_PAR 1 diff --git a/src/mgga_k_pc07.c b/src/mgga_k_pc07.c index 0cee1c504..9d0295819 100644 --- a/src/mgga_k_pc07.c +++ b/src/mgga_k_pc07.c @@ -19,7 +19,8 @@ static void mgga_k_pc07_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_k_pc07_params)); + p->params = malloc(sizeof(mgga_k_pc07_params)); + p->params_size = sizeof(mgga_k_pc07_params); } #define PC07_N_PAR 2 diff --git a/src/mgga_k_pgslb.c b/src/mgga_k_pgslb.c index 7e7918244..4e7a19389 100644 --- a/src/mgga_k_pgslb.c +++ b/src/mgga_k_pgslb.c @@ -18,7 +18,8 @@ static void mgga_k_pgslb_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_k_pgslb_params)); + p->params = malloc(sizeof(mgga_k_pgslb_params)); + p->params_size = sizeof(mgga_k_pgslb_params); } #define N_PAR 2 diff --git a/src/mgga_k_rda.c b/src/mgga_k_rda.c index dee209f76..39602c8fa 100644 --- a/src/mgga_k_rda.c +++ b/src/mgga_k_rda.c @@ -20,7 +20,8 @@ static void mgga_k_rda_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_k_rda_params)); + p->params = malloc(sizeof(mgga_k_rda_params)); + p->params_size = sizeof(mgga_k_rda_params); } #define N_PAR 10 diff --git a/src/mgga_x_br89.c b/src/mgga_x_br89.c index 97a9b4037..4f4b5cbac 100644 --- a/src/mgga_x_br89.c +++ b/src/mgga_x_br89.c @@ -29,7 +29,8 @@ static void mgga_x_br89_init(xc_func_type *p) { assert(p != NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_br89_params)); + p->params = malloc(sizeof(mgga_x_br89_params)); + p->params_size = sizeof(mgga_x_br89_params); } GPU_FUNCTION static double diff --git a/src/mgga_x_br89_explicit.c b/src/mgga_x_br89_explicit.c index d9d1fbad9..6a6374e81 100644 --- a/src/mgga_x_br89_explicit.c +++ b/src/mgga_x_br89_explicit.c @@ -26,7 +26,8 @@ static void mgga_x_br89_init(xc_func_type *p) { assert(p != NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_br89_params)); + p->params = malloc(sizeof(mgga_x_br89_params)); + p->params_size = sizeof(mgga_x_br89_params); } #include "maple2c/mgga_exc/mgga_x_br89_explicit.c" diff --git a/src/mgga_x_eel.c b/src/mgga_x_eel.c index b829fa2cf..b7597918d 100644 --- a/src/mgga_x_eel.c +++ b/src/mgga_x_eel.c @@ -26,7 +26,8 @@ static void mgga_x_eel_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_eel_params)); + p->params = malloc(sizeof(mgga_x_eel_params)); + p->params_size = sizeof(mgga_x_eel_params); } #include "maple2c/mgga_exc/mgga_x_eel.c" diff --git a/src/mgga_x_ft98.c b/src/mgga_x_ft98.c index 98ae3d838..caf85542d 100644 --- a/src/mgga_x_ft98.c +++ b/src/mgga_x_ft98.c @@ -31,7 +31,8 @@ static void mgga_x_ft98_init(xc_func_type *p) { assert(p != NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_ft98_params)); + p->params = malloc(sizeof(mgga_x_ft98_params)); + p->params_size = sizeof(mgga_x_ft98_params); } #include "maple2c/mgga_exc/mgga_x_ft98.c" diff --git a/src/mgga_x_gdme.c b/src/mgga_x_gdme.c index 2a350836a..0470e9c98 100644 --- a/src/mgga_x_gdme.c +++ b/src/mgga_x_gdme.c @@ -24,7 +24,8 @@ static void mgga_x_gdme_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_gdme_params)); + p->params = malloc(sizeof(mgga_x_gdme_params)); + p->params_size = sizeof(mgga_x_gdme_params); } #define GDME_N_PAR 3 diff --git a/src/mgga_x_gx.c b/src/mgga_x_gx.c index d86f686d3..f61aec1cb 100644 --- a/src/mgga_x_gx.c +++ b/src/mgga_x_gx.c @@ -19,7 +19,8 @@ static void mgga_x_gx_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_gx_params)); + p->params = malloc(sizeof(mgga_x_gx_params)); + p->params_size = sizeof(mgga_x_gx_params); } #include "maple2c/mgga_exc/mgga_x_gx.c" diff --git a/src/mgga_x_jk.c b/src/mgga_x_jk.c index 2057fa5ef..4cce80347 100644 --- a/src/mgga_x_jk.c +++ b/src/mgga_x_jk.c @@ -20,7 +20,8 @@ static void mgga_x_jk_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_jk_params)); + p->params = malloc(sizeof(mgga_x_jk_params)); + p->params_size = sizeof(mgga_x_jk_params); } #define N_PAR 2 diff --git a/src/mgga_x_ktbm.c b/src/mgga_x_ktbm.c index 6deba4974..645d4966d 100644 --- a/src/mgga_x_ktbm.c +++ b/src/mgga_x_ktbm.c @@ -74,7 +74,8 @@ static void mgga_x_ktbm_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_ktbm_params)); + p->params = malloc(sizeof(mgga_x_ktbm_params)); + p->params_size = sizeof(mgga_x_ktbm_params); } #include "maple2c/mgga_exc/mgga_x_ktbm.c" diff --git a/src/mgga_x_lta.c b/src/mgga_x_lta.c index 248e7ce55..68c0b7a6a 100644 --- a/src/mgga_x_lta.c +++ b/src/mgga_x_lta.c @@ -20,7 +20,8 @@ static void mgga_x_lta_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_lta_params)); + p->params = malloc(sizeof(mgga_x_lta_params)); + p->params_size = sizeof(mgga_x_lta_params); } #define LTA_N_PAR 1 diff --git a/src/mgga_x_m06l.c b/src/mgga_x_m06l.c index b3c324ce1..93e5172e0 100644 --- a/src/mgga_x_m06l.c +++ b/src/mgga_x_m06l.c @@ -143,7 +143,8 @@ static void mgga_x_m06l_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_m06l_params)); + p->params = malloc(sizeof(mgga_x_m06l_params)); + p->params_size = sizeof(mgga_x_m06l_params); switch(p->info->number) { case(XC_HYB_MGGA_X_M06): diff --git a/src/mgga_x_m08.c b/src/mgga_x_m08.c index ae62d5cc3..737652f19 100644 --- a/src/mgga_x_m08.c +++ b/src/mgga_x_m08.c @@ -42,7 +42,8 @@ static void mgga_x_m08_init(xc_func_type *p) { assert(p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_m08_params)); + p->params = malloc(sizeof(mgga_x_m08_params)); + p->params_size = sizeof(mgga_x_m08_params); xc_hyb_init_hybrid(p, 0.0); } diff --git a/src/mgga_x_m11.c b/src/mgga_x_m11.c index 11d19f4b5..6994536cd 100644 --- a/src/mgga_x_m11.c +++ b/src/mgga_x_m11.c @@ -41,7 +41,8 @@ static void mgga_x_m11_init(xc_func_type *p) { assert(p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_m11_params)); + p->params = malloc(sizeof(mgga_x_m11_params)); + p->params_size = sizeof(mgga_x_m11_params); xc_hyb_init_cam(p, 0.0, 0.0, 0.0); } diff --git a/src/mgga_x_m11_l.c b/src/mgga_x_m11_l.c index b59193b0a..763b3e45e 100644 --- a/src/mgga_x_m11_l.c +++ b/src/mgga_x_m11_l.c @@ -59,7 +59,8 @@ static void mgga_x_m11_l_init(xc_func_type *p) { assert(p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_m11_l_params)); + p->params = malloc(sizeof(mgga_x_m11_l_params)); + p->params_size = sizeof(mgga_x_m11_l_params); xc_hyb_init_hybrid(p, 0.0); } diff --git a/src/mgga_x_mbr.c b/src/mgga_x_mbr.c index 1d3652c46..8258281be 100644 --- a/src/mgga_x_mbr.c +++ b/src/mgga_x_mbr.c @@ -18,7 +18,8 @@ static void mgga_x_mbr_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_mbr_params)); + p->params = malloc(sizeof(mgga_x_mbr_params)); + p->params_size = sizeof(mgga_x_mbr_params); } #define MBR_N_PAR 3 diff --git a/src/mgga_x_mn12.c b/src/mgga_x_mn12.c index 56003a285..6f8c331cf 100644 --- a/src/mgga_x_mn12.c +++ b/src/mgga_x_mn12.c @@ -186,7 +186,8 @@ static void mgga_x_mn12_init(xc_func_type *p) { assert(p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_mn12_params)); + p->params = malloc(sizeof(mgga_x_mn12_params)); + p->params_size = sizeof(mgga_x_mn12_params); if(p->info->number == XC_HYB_MGGA_X_MN12_SX) xc_hyb_init_cam(p, 0.0, 0.0, 0.0); diff --git a/src/mgga_x_ms.c b/src/mgga_x_ms.c index 44caa3763..4c879dd0e 100644 --- a/src/mgga_x_ms.c +++ b/src/mgga_x_ms.c @@ -23,7 +23,8 @@ static void mgga_x_ms_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_ms_params)); + p->params = malloc(sizeof(mgga_x_ms_params)); + p->params_size = sizeof(mgga_x_ms_params); } #define MS0_N_PAR 3 diff --git a/src/mgga_x_msb.c b/src/mgga_x_msb.c index a507d30f1..a6cc85f74 100644 --- a/src/mgga_x_msb.c +++ b/src/mgga_x_msb.c @@ -23,7 +23,8 @@ mgga_x_msb_init(xc_func_type *p) mgga_x_msb_params *params; assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_msb_params)); + p->params = malloc(sizeof(mgga_x_msb_params)); + p->params_size = sizeof(mgga_x_msb_params); params = (mgga_x_msb_params *)p->params; switch(p->info->number){ diff --git a/src/mgga_x_mvs.c b/src/mgga_x_mvs.c index 6676b09d0..094d1d5e8 100644 --- a/src/mgga_x_mvs.c +++ b/src/mgga_x_mvs.c @@ -19,7 +19,8 @@ static void mgga_x_mvs_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_mvs_params)); + p->params = malloc(sizeof(mgga_x_mvs_params)); + p->params_size = sizeof(mgga_x_mvs_params); } #define MVS_N_PAR 4 diff --git a/src/mgga_x_mvsb.c b/src/mgga_x_mvsb.c index 6862b4202..1f765b277 100644 --- a/src/mgga_x_mvsb.c +++ b/src/mgga_x_mvsb.c @@ -20,7 +20,8 @@ static void mgga_x_mvsb_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_mvsb_params)); + p->params = malloc(sizeof(mgga_x_mvsb_params)); + p->params_size = sizeof(mgga_x_mvsb_params); } #define MVSB_N_PAR 4 diff --git a/src/mgga_x_r2scan.c b/src/mgga_x_r2scan.c index 71e277348..77742cdfd 100644 --- a/src/mgga_x_r2scan.c +++ b/src/mgga_x_r2scan.c @@ -29,7 +29,8 @@ static void mgga_x_r2scan_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_r2scan_params)); + p->params = malloc(sizeof(mgga_x_r2scan_params)); + p->params_size = sizeof(mgga_x_r2scan_params); } diff --git a/src/mgga_x_r4scan.c b/src/mgga_x_r4scan.c index 2cb5233b4..e8b5efc3b 100644 --- a/src/mgga_x_r4scan.c +++ b/src/mgga_x_r4scan.c @@ -27,7 +27,8 @@ static void mgga_x_r4scan_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_r4scan_params)); + p->params = malloc(sizeof(mgga_x_r4scan_params)); + p->params_size = sizeof(mgga_x_r4scan_params); } #include "maple2c/mgga_exc/mgga_x_r4scan.c" diff --git a/src/mgga_x_rlda.c b/src/mgga_x_rlda.c index 49fbc452f..3c6af57bf 100644 --- a/src/mgga_x_rlda.c +++ b/src/mgga_x_rlda.c @@ -23,7 +23,8 @@ static void mgga_x_rlda_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_rlda_params)); + p->params = malloc(sizeof(mgga_x_rlda_params)); + p->params_size = sizeof(mgga_x_rlda_params); } #define RLDA_N_PAR 1 diff --git a/src/mgga_x_rppscan.c b/src/mgga_x_rppscan.c index cfca2cf82..dafef5c0b 100644 --- a/src/mgga_x_rppscan.c +++ b/src/mgga_x_rppscan.c @@ -26,7 +26,8 @@ static void mgga_x_rppscan_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_rppscan_params)); + p->params = malloc(sizeof(mgga_x_rppscan_params)); + p->params_size = sizeof(mgga_x_rppscan_params); } #include "maple2c/mgga_exc/mgga_x_rppscan.c" diff --git a/src/mgga_x_rscan.c b/src/mgga_x_rscan.c index b33090d52..aefd7a3f2 100644 --- a/src/mgga_x_rscan.c +++ b/src/mgga_x_rscan.c @@ -27,7 +27,8 @@ static void mgga_x_rscan_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_rscan_params)); + p->params = malloc(sizeof(mgga_x_rscan_params)); + p->params_size = sizeof(mgga_x_rscan_params); } #include "maple2c/mgga_exc/mgga_x_rscan.c" diff --git a/src/mgga_x_rtpss.c b/src/mgga_x_rtpss.c index b27834e95..03dd17d22 100644 --- a/src/mgga_x_rtpss.c +++ b/src/mgga_x_rtpss.c @@ -20,7 +20,8 @@ static void mgga_x_rtpss_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_rtpss_params)); + p->params = malloc(sizeof(mgga_x_rtpss_params)); + p->params_size = sizeof(mgga_x_rtpss_params); } #define RTPSS_N_PAR 5 diff --git a/src/mgga_x_scan.c b/src/mgga_x_scan.c index 39c21e5cb..62caaf9b9 100644 --- a/src/mgga_x_scan.c +++ b/src/mgga_x_scan.c @@ -30,7 +30,8 @@ static void mgga_x_scan_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_scan_params)); + p->params = malloc(sizeof(mgga_x_scan_params)); + p->params_size = sizeof(mgga_x_scan_params); } #include "maple2c/mgga_exc/mgga_x_scan.c" @@ -93,7 +94,8 @@ static void hyb_mgga_x_scan0_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_scan_params)); + p->params = malloc(sizeof(mgga_x_scan_params)); + p->params_size = sizeof(mgga_x_scan_params); static int funcs_id [1] = {XC_MGGA_X_SCAN}; static double funcs_coef[1] = {0.0}; /* set by ext_params */ @@ -122,7 +124,8 @@ static void hyb_mgga_x_revscan0_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_scan_params)); + p->params = malloc(sizeof(mgga_x_scan_params)); + p->params_size = sizeof(mgga_x_scan_params); static int funcs_id [1] = {XC_MGGA_X_REVSCAN}; static double funcs_coef[1] = {0.0}; /* set by ext_params */ diff --git a/src/mgga_x_task.c b/src/mgga_x_task.c index 0d1fedf31..478c8c23a 100644 --- a/src/mgga_x_task.c +++ b/src/mgga_x_task.c @@ -22,7 +22,8 @@ static void mgga_x_task_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_task_params)); + p->params = malloc(sizeof(mgga_x_task_params)); + p->params_size = sizeof(mgga_x_task_params); } #define TASK_N_PAR 11 diff --git a/src/mgga_x_tau_hcth.c b/src/mgga_x_tau_hcth.c index 9995ce8e1..ecae990c7 100644 --- a/src/mgga_x_tau_hcth.c +++ b/src/mgga_x_tau_hcth.c @@ -34,7 +34,8 @@ static void mgga_x_tau_hcth_init(xc_func_type *p) { assert(p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_tau_hcth_params)); + p->params = malloc(sizeof(mgga_x_tau_hcth_params)); + p->params_size = sizeof(mgga_x_tau_hcth_params); if(p->info->number == XC_HYB_MGGA_X_BMK || p->info->number == XC_HYB_MGGA_X_TAU_HCTH) xc_hyb_init_hybrid(p, 0.0); } diff --git a/src/mgga_x_tb09.c b/src/mgga_x_tb09.c index 6d9d3af92..e3d5b1738 100644 --- a/src/mgga_x_tb09.c +++ b/src/mgga_x_tb09.c @@ -22,7 +22,8 @@ static void mgga_x_tb09_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_tb09_params)); + p->params = malloc(sizeof(mgga_x_tb09_params)); + p->params_size = sizeof(mgga_x_tb09_params); } #define XC_NO_EXC diff --git a/src/mgga_x_tpss.c b/src/mgga_x_tpss.c index 9055e2b8c..57d0cc452 100644 --- a/src/mgga_x_tpss.c +++ b/src/mgga_x_tpss.c @@ -31,7 +31,8 @@ static void mgga_x_tpss_init(xc_func_type *p) { assert(p!=NULL && p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_x_tpss_params)); + p->params = malloc(sizeof(mgga_x_tpss_params)); + p->params_size = sizeof(mgga_x_tpss_params); } #define TPSS_N_PAR 7 diff --git a/src/mgga_xc_b97mv.c b/src/mgga_xc_b97mv.c index b68dea598..cf5db7298 100644 --- a/src/mgga_xc_b97mv.c +++ b/src/mgga_xc_b97mv.c @@ -48,7 +48,8 @@ static void mgga_xc_b97mv_init(xc_func_type *p) { assert(p->params == NULL); - p->params = libxc_malloc(sizeof(mgga_xc_b97_mv_params)); + p->params = malloc(sizeof(mgga_xc_b97_mv_params)); + p->params_size = sizeof(mgga_xc_b97_mv_params); /* Non-local correlation parameters */ p->nlc_b = 6.0; p->nlc_C = 0.01; diff --git a/src/mix_func.c b/src/mix_func.c index 31153b63f..1e43b3274 100644 --- a/src/mix_func.c +++ b/src/mix_func.c @@ -22,12 +22,12 @@ xc_mix_init(xc_func_type *p, int n_funcs, const int *funcs_id, const double *mix /* allocate structures needed for mixed functional */ p->n_func_aux = n_funcs; - p->mix_coef = (double *) libxc_malloc(n_funcs*sizeof(double)); - p->func_aux = (xc_func_type **) libxc_malloc(n_funcs*sizeof(xc_func_type *)); + p->mix_coef = (double *) malloc(n_funcs*sizeof(double)); + p->func_aux = (xc_func_type **) malloc(n_funcs*sizeof(xc_func_type *)); for(ii=0; iimix_coef[ii] = mix_coef[ii]; - p->func_aux[ii] = (xc_func_type *) libxc_malloc(sizeof(xc_func_type)); + p->func_aux[ii] = (xc_func_type *) malloc(sizeof(xc_func_type)); xc_func_init (p->func_aux[ii], funcs_id[ii], p->nspin); } @@ -60,7 +60,7 @@ static void add_to_mix(size_t np, double * dst, double coeff, const double *src) #define is_mgga(id) ((id) == XC_FAMILY_MGGA || (id) == XC_FAMILY_HYB_MGGA) #define is_gga(id) ((id) == XC_FAMILY_GGA || (id) == XC_FAMILY_HYB_GGA || is_mgga(id)) #define is_lda(id) ((id) == XC_FAMILY_LDA || (id) == XC_FAMILY_HYB_LDA || is_gga(id)) -#define safe_free(pt) if(pt != NULL) libxc_free(pt) +#define safe_free(pt) if(pt != NULL) free(pt) #define sum_var(VAR) add_to_mix(np*dim->VAR, VAR, func->mix_coef[ii], x ## VAR); void diff --git a/src/string_f.h b/src/string_f.h index 988537d26..bb287d581 100644 --- a/src/string_f.h +++ b/src/string_f.h @@ -17,7 +17,7 @@ fc = _fcdtocp(f); \ for(slen=_fcdlen(f)-1; slen>=0 && fc[slen]==' '; slen--); \ slen++; \ - c = (char *)libxc_malloc(slen+1); \ + c = (char *)malloc(slen+1); \ strncpy(c, _fcdtocp(f), slen); \ c[slen] = '\0'; \ } @@ -52,7 +52,7 @@ for(ll--; ll>=0; ll--) \ if(f[ll] != ' ') break; \ ll++; \ - c = (char *)libxc_malloc((ll+1)*sizeof(char)); \ + c = (char *)malloc((ll+1)*sizeof(char)); \ for(i=0; i= U[i+p+1]) { @@ -934,7 +934,7 @@ xc_bspline(int i, int p, double u, int nderiv, const double *U, double *ders) { /* Array of normalized B splines, use dense storage for simpler code */ double N[PMAX][PMAX]; - libxc_memset(N, 0, PMAX*PMAX*sizeof(double)); + memset(N, 0, PMAX*PMAX*sizeof(double)); /* Initialize zeroth-degree functions: piecewise constants */ for(int j=0; j<=p; j++) { @@ -972,7 +972,7 @@ xc_bspline(int i, int p, double u, int nderiv, const double *U, double *ders) { /* Compute derivatives */ for(int k=1; k<=maxk; k++) { /* Load appropriate column */ - libxc_memset(ND, 0, (nderiv+1)*sizeof(double)); + memset(ND, 0, (nderiv+1)*sizeof(double)); for(int j=0; j<=k; j++) ND[j] = N[p-k][j]; diff --git a/src/util.h b/src/util.h index 6a712a7bd..8290e0c34 100644 --- a/src/util.h +++ b/src/util.h @@ -186,7 +186,7 @@ typedef void integr_fn(double *x, int n, void *ex); GPU_FUNCTION double xc_integrate(integr_fn func, void *ex, double a, double b); GPU_FUNCTION -void xc_rdqagse(integr_fn f, void *ex, double *a, double *b, +void xc_rdqagse(integr_fn f, void *ex, double *a, double *b, double *epsabs, double *epsrel, int *limit, double *result, double *abserr, int *neval, int *ier, double *alist__, double *blist, double *rlist, double *elist, int *iord, int *last); @@ -342,14 +342,14 @@ void libxc_free(void *ptr); template void * libxc_malloc(const int_type size){ void * mem; - cudaMallocManaged(&mem, size); + cudaMalloc((void **)&mem, size); return mem; } template void * libxc_calloc(const int_type1 size1, const int_type2 size2){ void * mem; - cudaMallocManaged(&mem, size1*size2); + cudaMalloc((void **)&mem, size1*size2); cudaMemset(mem, 0, size1*size2); return mem; } @@ -363,4 +363,5 @@ void libxc_memcpy(void *dest, void const *src, const int_type size){ #endif + #endif diff --git a/src/work_gga_inc.c b/src/work_gga_inc.c index e0e92fcf9..16bdcf4a2 100644 --- a/src/work_gga_inc.c +++ b/src/work_gga_inc.c @@ -51,7 +51,7 @@ WORK_GGA(ORDER_TXT, SPIN_TXT) dens = (p->nspin == XC_POLARIZED) ? VAR(rho, ip, 0) + VAR(rho, ip, 1) : VAR(rho, ip, 0); if(dens < p->dens_threshold) continue; - + /* sanity check of input parameters */ my_rho[0] = m_max(p->dens_threshold, VAR(rho, ip, 0)); my_sigma[0] = m_max(p->sigma_threshold * p->sigma_threshold, VAR(sigma, ip, 0)); @@ -70,7 +70,7 @@ WORK_GGA(ORDER_TXT, SPIN_TXT) } FUNC(ORDER_TXT, SPIN_TXT)(p, ip, my_rho, my_sigma, out); - + /* check for NaNs */ #ifdef XC_DEBUG { @@ -147,23 +147,58 @@ const double *rho, const double *sigma, xc_gga_out_params *out) static void WORK_GGA(ORDER_TXT, SPIN_TXT) (const XC(func_type) *p, size_t np, const double *rho, const double *sigma, - xc_gga_out_params *out) + xc_gga_out_params *out) { //make a copy of 'p' and 'out' since they might be in host-only memory - XC(func_type) *pcuda = (XC(func_type) *) libxc_malloc(sizeof(XC(func_type))); - xc_gga_out_params *outcuda = (xc_gga_out_params *) libxc_malloc(sizeof(xc_gga_out_params)); + XC(func_type) *pcuda; + XC(func_type) *pcopy; + xc_gga_out_params *outcuda; + xc_func_info_type *info; + + pcopy = (XC(func_type) *) malloc(sizeof(XC(func_type))); + memcpy(pcopy, p, sizeof(XC(func_type))); + cudaMalloc((void**)&pcuda, sizeof(XC(func_type))); + cudaMalloc((void**)&outcuda, sizeof(xc_gga_out_params)); + cudaMalloc((void**)&info, sizeof(xc_func_info_type)); + + cudaMemcpy(info, p->info, sizeof(xc_func_info_type), cudaMemcpyHostToDevice); + pcopy->info = info; + + // move params to GPU first + void *params; + void *params_cuda; + if (p->params_size > 0){ + params = (void *) pcopy->params; + cudaMalloc((void**)¶ms_cuda, p->params_size); + cudaMemcpy(params_cuda, params, p->params_size, cudaMemcpyHostToDevice); + pcopy->params = params_cuda; + } - cudaMemcpy(pcuda, p, sizeof(XC(func_type)), cudaMemcpyHostToDevice); + // move xc_func to GPU + cudaMemcpy(pcuda, pcopy, sizeof(XC(func_type)), cudaMemcpyHostToDevice); cudaMemcpy(outcuda, out, sizeof(xc_gga_out_params), cudaMemcpyHostToDevice); size_t nblocks = np/CUDA_BLOCK_SIZE; if(np != nblocks*CUDA_BLOCK_SIZE) nblocks++; - WORK_GGA_GPU(ORDER_TXT, SPIN_TXT)<<>> + WORK_GGA_GPU(ORDER_TXT, SPIN_TXT)<<>> (pcuda, np, rho, sigma, outcuda); - libxc_free(pcuda); - libxc_free(outcuda); + free(pcopy); + + cudaFree(pcuda); + cudaFree(outcuda); + cudaFree(info); + + if (p->params_size > 0){ + cudaFree(params_cuda); + } + + cudaError_t err = cudaGetLastError(); + if (err != cudaSuccess) { + fprintf(stderr, "CUDA Error of work_gga: %s\n", cudaGetErrorString(err)); + exit(EXIT_FAILURE); + } } #endif diff --git a/src/work_lda_inc.c b/src/work_lda_inc.c index 0ed200e00..be857a6a0 100644 --- a/src/work_lda_inc.c +++ b/src/work_lda_inc.c @@ -49,7 +49,7 @@ WORK_LDA(ORDER_TXT, SPIN_TXT) dens = (p->nspin == XC_POLARIZED) ? VAR(rho, ip, 0) + VAR(rho, ip, 1) : VAR(rho, ip, 0); if(dens < p->dens_threshold) continue; - + /* sanity check of input parameters */ my_rho[0] = m_max(p->dens_threshold, VAR(rho, ip, 0)); if(p->nspin == XC_POLARIZED){ @@ -119,23 +119,58 @@ WORK_LDA_GPU(ORDER_TXT, SPIN_TXT) static void WORK_LDA(ORDER_TXT, SPIN_TXT) -(const XC(func_type) *p, size_t np, const double *rho, xc_lda_out_params *out) + (const XC(func_type) *p, size_t np, const double *rho, xc_lda_out_params *out) { //make a copy of 'p' and 'out' since they might be in host-only memory - XC(func_type) *pcuda = (XC(func_type) *) libxc_malloc(sizeof(XC(func_type))); - xc_lda_out_params *outcuda = (xc_lda_out_params *) libxc_malloc(sizeof(xc_lda_out_params)); + XC(func_type) *pcuda; + XC(func_type) *pcopy; + xc_lda_out_params *outcuda; + xc_func_info_type *info; + + pcopy = (XC(func_type) *) malloc(sizeof(XC(func_type))); + memcpy(pcopy, p, sizeof(XC(func_type))); + cudaMalloc((void**)&pcuda, sizeof(XC(func_type))); + cudaMalloc((void**)&outcuda, sizeof(xc_lda_out_params)); + cudaMalloc((void**)&info, sizeof(xc_func_info_type)); + + cudaMemcpy(info, p->info, sizeof(xc_func_info_type), cudaMemcpyHostToDevice); + pcopy->info = info; + + // move params to GPU first + void *params; + void *params_cuda; + if (p->params_size > 0){ + params = (void *) pcopy->params; + cudaMalloc((void**)¶ms_cuda, p->params_size); + cudaMemcpy(params_cuda, params, p->params_size, cudaMemcpyHostToDevice); + pcopy->params = params_cuda; + } - cudaMemcpy(pcuda, p, sizeof(XC(func_type)), cudaMemcpyHostToDevice); + // move xc_func to GPU + cudaMemcpy(pcuda, pcopy, sizeof(XC(func_type)), cudaMemcpyHostToDevice); cudaMemcpy(outcuda, out, sizeof(xc_lda_out_params), cudaMemcpyHostToDevice); size_t nblocks = np/CUDA_BLOCK_SIZE; if(np != nblocks*CUDA_BLOCK_SIZE) nblocks++; - WORK_LDA_GPU(ORDER_TXT, SPIN_TXT)<<>> + WORK_LDA_GPU(ORDER_TXT, SPIN_TXT)<<>> (pcuda, np, rho, outcuda); - libxc_free(pcuda); - libxc_free(outcuda); + free(pcopy); + + cudaFree(pcuda); + cudaFree(outcuda); + cudaFree(info); + + if (p->params_size > 0){ + cudaFree(params_cuda); + } + + cudaError_t err = cudaGetLastError(); + if (err != cudaSuccess) { + fprintf(stderr, "CUDA Error of work_lda: %s\n", cudaGetErrorString(err)); + exit(EXIT_FAILURE); + } } #endif diff --git a/src/work_mgga_inc.c b/src/work_mgga_inc.c index febef1001..83779d8f6 100644 --- a/src/work_mgga_inc.c +++ b/src/work_mgga_inc.c @@ -82,7 +82,7 @@ WORK_MGGA(ORDER_TXT, SPIN_TXT) my_sigma[2] = m_min(my_sigma[2], 8.0*my_rho[1]*my_tau[1]); #endif } - + my_sigma[1] = VAR(sigma, ip, 1); s_ave = 0.5*(my_sigma[0] + my_sigma[2]); /* | grad n |^2 = |grad n_up + grad n_down|^2 > 0 */ @@ -179,7 +179,7 @@ WORK_MGGA_GPU(ORDER_TXT, SPIN_TXT) /* sanity check of input parameters */ my_rho[0] = m_max(p->dens_threshold, VAR(rho, ip, 0)); my_sigma[0] = m_max(p->sigma_threshold * p->sigma_threshold, VAR(sigma, ip, 0)); - + /* Many functionals shamelessly divide by tau, so we set a reasonable threshold */ if(p->info->flags & XC_FLAGS_NEEDS_TAU){ my_tau[0] = m_max(p->tau_threshold, VAR(tau, ip, 0)); @@ -220,20 +220,55 @@ WORK_MGGA(ORDER_TXT, SPIN_TXT) xc_mgga_out_params *out) { //make a copy of 'p' and 'out' since they might be in host-only memory - XC(func_type) *pcuda = (XC(func_type) *) libxc_malloc(sizeof(XC(func_type))); - xc_mgga_out_params *outcuda = (xc_mgga_out_params *) libxc_malloc(sizeof(xc_mgga_out_params)); - - cudaMemcpy(pcuda, p, sizeof(XC(func_type)), cudaMemcpyHostToDevice); + XC(func_type) *pcuda; + XC(func_type) *pcopy; + xc_mgga_out_params *outcuda; + xc_func_info_type *info; + + pcopy = (XC(func_type) *) malloc(sizeof(XC(func_type))); + memcpy(pcopy, p, sizeof(XC(func_type))); + cudaMalloc((void**)&pcuda, sizeof(XC(func_type))); + cudaMalloc((void**)&outcuda, sizeof(xc_mgga_out_params)); + cudaMalloc((void**)&info, sizeof(xc_func_info_type)); + + cudaMemcpy(info, p->info, sizeof(xc_func_info_type), cudaMemcpyHostToDevice); + pcopy->info = info; + + // move params to GPU first + void *params; + void *params_cuda; + if (p->params_size > 0){ + params = (void *) pcopy->params; + cudaMalloc((void**)¶ms_cuda, p->params_size); + cudaMemcpy(params_cuda, params, p->params_size, cudaMemcpyHostToDevice); + pcopy->params = params_cuda; + } + + // move xc_func to GPU + cudaMemcpy(pcuda, pcopy, sizeof(XC(func_type)), cudaMemcpyHostToDevice); cudaMemcpy(outcuda, out, sizeof(xc_mgga_out_params), cudaMemcpyHostToDevice); size_t nblocks = np/CUDA_BLOCK_SIZE; if(np != nblocks*CUDA_BLOCK_SIZE) nblocks++; - WORK_MGGA_GPU(ORDER_TXT, SPIN_TXT)<<>> + WORK_MGGA_GPU(ORDER_TXT, SPIN_TXT)<<>> (pcuda, np, rho, sigma, lapl, tau, outcuda); - libxc_free(pcuda); - libxc_free(outcuda); + free(pcopy); + + cudaFree(pcuda); + cudaFree(outcuda); + cudaFree(info); + + if (p->params_size > 0){ + cudaFree(params_cuda); + } + + cudaError_t err = cudaGetLastError(); + if (err != cudaSuccess) { + fprintf(stderr, "CUDA Error of work_mgga: %s\n", cudaGetErrorString(err)); + exit(EXIT_FAILURE); + } } #endif diff --git a/src/xc.h b/src/xc.h index a4c6b35eb..203adf11f 100644 --- a/src/xc.h +++ b/src/xc.h @@ -233,17 +233,17 @@ typedef void (*xc_lda_funcs) (const struct xc_func_type *p, size_t np, const double *rho, xc_lda_out_params *out); - + typedef struct { const xc_lda_funcs unpol[5], pol[5]; } xc_lda_funcs_variants; - + /* type of the gga function */ typedef void (*xc_gga_funcs) (const struct xc_func_type *p, size_t np, const double *rho, const double *sigma, xc_gga_out_params *out); - + typedef struct { const xc_gga_funcs unpol[5], pol[5]; } xc_gga_funcs_variants; @@ -339,6 +339,8 @@ struct xc_func_type{ double *ext_params; /* This is a placeholder for structs of parameters that are used in the Maple generated sources */ void *params; + /* This is sizeof structs of parameters*/ + int params_size; double dens_threshold; /* functional is put to zero for spin-densities smaller than this */ double zeta_threshold; /* idem for the absolute value of zeta */