Skip to content

Commit

Permalink
Fix deallocation issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
ohearnk committed Aug 22, 2024
1 parent e2b3f9b commit b15e410
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 26 deletions.
19 changes: 6 additions & 13 deletions src/gpu/cuda/gpu_libxc.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ gpu_libxc_info** init_gpu_libxc(int * const num_of_funcs, int * arr_func_id,
num_of_funcs_ = *num_of_funcs;
arr_func_id_ = arr_func_id;
arr_mix_coeffs_ = (double*) malloc(sizeof(double) * num_of_funcs_);

for (int i = 0; i < num_of_funcs_; i++) {
arr_mix_coeffs_[i] = 1.0;
}
Expand All @@ -74,6 +75,7 @@ gpu_libxc_info** init_gpu_libxc(int * const num_of_funcs, int * arr_func_id,
num_of_funcs_ = *num_of_funcs;
arr_func_id_ = arr_func_id;
arr_mix_coeffs_ = (double*) malloc(sizeof(double) * num_of_funcs_);

for (int i = 0; i < num_of_funcs_; i++) {
arr_mix_coeffs_[i] = 1.0;
}
Expand Down Expand Up @@ -132,20 +134,11 @@ gpu_libxc_info** init_gpu_libxc(int * const num_of_funcs, int * arr_func_id,
xc_func_end(&func);
}

if (*num_of_funcs == 1) {
if (hyb_func.info->family == XC_FAMILY_HYB_GGA) {
if (hyb_func.n_func_aux > 0) {
free(arr_func_id_);
free(arr_mix_coeffs_);
} else {
free(arr_mix_coeffs_);
}
} else {
free(arr_mix_coeffs_);
}
} else {
free(arr_mix_coeffs_);
if (arr_func_id_ != arr_func_id)
{
free(arr_func_id_);
}
free(arr_mix_coeffs_);

return h_glinfo_array;
}
Expand Down
17 changes: 4 additions & 13 deletions src/gpu/hip/gpu_libxc.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,11 @@ gpu_libxc_info** init_gpu_libxc(int * const num_of_funcs, int * arr_func_id,
xc_func_end(&func);
}

if (*num_of_funcs == 1) {
if (hyb_func.info->family == XC_FAMILY_HYB_GGA) {
if (hyb_func.n_func_aux > 0) {
free(arr_func_id_);
free(arr_mix_coeffs_);
} else {
free(arr_mix_coeffs_);
}
} else {
free(arr_mix_coeffs_);
}
} else {
free(arr_mix_coeffs_);
if (arr_func_id_ != arr_func_id)
{
free(arr_func_id_);
}
free(arr_mix_coeffs_);

return h_glinfo_array;
}
Expand Down

0 comments on commit b15e410

Please sign in to comment.