Skip to content

Commit 6d035e7

Browse files
authored
Perf: support GPU version of cal_force_cc with LCAO basis (#6392)
* support GPU version of cal_force_cc with LCAO basis * fix a bug
1 parent 7edc682 commit 6d035e7

File tree

2 files changed

+33
-19
lines changed

2 files changed

+33
-19
lines changed

source/source_lcao/FORCE_STRESS.cpp

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "source_lcao/module_operator_lcao/nonlocal_new.h"
2424

2525
template <typename T>
26-
Force_Stress_LCAO<T>::Force_Stress_LCAO(Record_adj& ra, const int nat_in) : RA(&ra), f_pw(nat_in), nat(nat_in)
26+
Force_Stress_LCAO<T>::Force_Stress_LCAO(Record_adj& ra, const int nat_in) : RA(&ra), nat(nat_in)
2727
{
2828
}
2929
template <typename T>
@@ -811,24 +811,39 @@ void Force_Stress_LCAO<T>::calForcePwPart(UnitCell& ucell,
811811
const Structure_Factor& sf)
812812
{
813813
ModuleBase::TITLE("Force_Stress_LCAO", "calForcePwPart");
814-
//--------------------------------------------------------
815-
// local pseudopotential force:
816-
// use charge density; plane wave; local pseudopotential;
817-
//--------------------------------------------------------
818-
f_pw.cal_force_loc(ucell, fvl_dvl, rhopw, locpp.vloc, chr);
819-
//--------------------------------------------------------
820-
// ewald force: use plane wave only.
821-
//--------------------------------------------------------
822-
f_pw.cal_force_ew(ucell, fewalds, rhopw, &sf); // remain problem
814+
#ifdef __CUDA
815+
if(PARAM.inp.device == "gpu")
816+
{
817+
Forces<double, base_device::DEVICE_GPU> f_pw(nat);
818+
819+
//--------------------------------------------------------
820+
// local pseudopotential force:
821+
// use charge density; plane wave; local pseudopotential;
822+
//--------------------------------------------------------
823+
f_pw.cal_force_loc(ucell, fvl_dvl, rhopw, locpp.vloc, chr);
824+
//--------------------------------------------------------
825+
// ewald force: use plane wave only.
826+
//--------------------------------------------------------
827+
f_pw.cal_force_ew(ucell, fewalds, rhopw, &sf); // remain problem
828+
829+
//--------------------------------------------------------
830+
// force due to core correlation.
831+
//--------------------------------------------------------
832+
f_pw.cal_force_cc(fcc, rhopw, chr, locpp.numeric, ucell);
833+
//--------------------------------------------------------
834+
// force due to self-consistent charge.
835+
//--------------------------------------------------------
836+
f_pw.cal_force_scc(fscc, rhopw, vnew, vnew_exist, locpp.numeric, ucell);
837+
} else
838+
#endif
839+
{
840+
Forces<double, base_device::DEVICE_CPU> f_pw(nat);
841+
f_pw.cal_force_loc(ucell, fvl_dvl, rhopw, locpp.vloc, chr);
842+
f_pw.cal_force_ew(ucell, fewalds, rhopw, &sf); // remain problem
843+
f_pw.cal_force_cc(fcc, rhopw, chr, locpp.numeric, ucell);
844+
f_pw.cal_force_scc(fscc, rhopw, vnew, vnew_exist, locpp.numeric, ucell);
845+
}
823846

824-
//--------------------------------------------------------
825-
// force due to core correlation.
826-
//--------------------------------------------------------
827-
f_pw.cal_force_cc(fcc, rhopw, chr, locpp.numeric, ucell);
828-
//--------------------------------------------------------
829-
// force due to self-consistent charge.
830-
//--------------------------------------------------------
831-
f_pw.cal_force_scc(fscc, rhopw, vnew, vnew_exist, locpp.numeric, ucell);
832847
return;
833848
}
834849

source/source_lcao/FORCE_STRESS.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ class Force_Stress_LCAO
6363
Record_adj* RA;
6464
Force_LCAO<T> flk;
6565
Stress_Func<double> sc_pw;
66-
Forces<double> f_pw;
6766

6867
void forceSymmetry(const UnitCell& ucell, ModuleBase::matrix& fcs, ModuleSymmetry::Symmetry* symm);
6968

0 commit comments

Comments
 (0)