Skip to content

Commit f3eafd0

Browse files
committed
fix malloc error
1 parent 6638968 commit f3eafd0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

source/module_hamilt_pw/hamilt_pwdft/forces.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ void Forces<FPTYPE, Device>::cal_force_loc(const UnitCell& ucell,
556556
}
557557

558558
// calculate vloc_factors for all atom types
559-
std::vector<FPTYPE> vloc_per_type_host(ucell.ntype * rho_basis->npw);
559+
std::vector<FPTYPE> vloc_per_type_host(this->nat * rho_basis->npw);
560560
for (int iat = 0; iat < this->nat; iat++) {
561561
int it = ucell.iat2it[iat];
562562
for (int ig = 0; ig < rho_basis->npw; ig++) {
@@ -585,13 +585,13 @@ void Forces<FPTYPE, Device>::cal_force_loc(const UnitCell& ucell,
585585

586586
resmem_var_op()(this->ctx, d_gcar, rho_basis->npw * 3);
587587
resmem_var_op()(this->ctx, d_tau, this->nat * 3);
588-
resmem_var_op()(this->ctx, d_vloc_per_type, ucell.ntype * rho_basis->npw);
588+
resmem_var_op()(this->ctx, d_vloc_per_type, this->nat * rho_basis->npw);
589589
resmem_complex_op()(this->ctx, d_aux, rho_basis->npw);
590590
resmem_var_op()(this->ctx, d_force, this->nat * 3);
591591

592592
syncmem_var_h2d_op()(this->ctx, this->cpu_ctx, d_gcar, gcar_flat.data(), rho_basis->npw * 3);
593593
syncmem_var_h2d_op()(this->ctx, this->cpu_ctx, d_tau, tau_flat.data(), this->nat * 3);
594-
syncmem_var_h2d_op()(this->ctx, this->cpu_ctx, d_vloc_per_type, vloc_per_type_host.data(), ucell.ntype * rho_basis->npw);
594+
syncmem_var_h2d_op()(this->ctx, this->cpu_ctx, d_vloc_per_type, vloc_per_type_host.data(), this->nat * rho_basis->npw);
595595
syncmem_complex_h2d_op()(this->ctx, this->cpu_ctx, d_aux, aux_fptype.data(), rho_basis->npw);
596596

597597
base_device::memory::set_memory_op<FPTYPE, Device>()(this->ctx, d_force, 0.0, this->nat * 3);
@@ -609,7 +609,7 @@ void Forces<FPTYPE, Device>::cal_force_loc(const UnitCell& ucell,
609609
this->ctx,
610610
this->nat,
611611
rho_basis->npw,
612-
ucell.ntype,
612+
this->nat,
613613
d_gcar,
614614
d_tau,
615615
d_vloc_per_type,

0 commit comments

Comments
 (0)