Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: fix cusolver error under multi-k situation #4278

Merged
merged 2 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions source/module_hsolver/diago_cusolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,18 @@ namespace hsolver
distributePsi(this->ParaV->desc_wfc, psi.get_pointer(), psi_g.data());
}
else
{
this->dc.Dngvd(h_mat.row, h_mat.col, h_mat.p, s_mat.p, eigen.data(), psi.get_pointer());
{
// Be careful that h_mat.row * h_mat.col != psi.get_nbands() * psi.get_nbasis() under multi-k situation
std::vector<T> eigenvectors(h_mat.row * h_mat.col);
this->dc.Dngvd(h_mat.row, h_mat.col, h_mat.p, s_mat.p, eigen.data(), eigenvectors.data());
const int size = psi.get_nbands() * psi.get_nbasis();
BlasConnector::copy(size, eigenvectors.data(), 1, psi.get_pointer(), 1);
}
#else
// Call the dense diagonalization routine
this->dc.Dngvd(h_mat.row, h_mat.col, h_mat.p, s_mat.p, eigen.data(), psi.get_pointer());
std::vector<T> eigenvectors(h_mat.row * h_mat.col);
this->dc.Dngvd(h_mat.row, h_mat.col, h_mat.p, s_mat.p, eigen.data(), eigenvectors.data());
const int size = psi.get_nbands() * psi.get_nbasis();
BlasConnector::copy(size, eigenvectors.data(), 1, psi.get_pointer(), 1);
#endif
// Stop the timer for the cusolver operation
ModuleBase::timer::tick("DiagoCusolver", "cusolver");
Expand Down
28 changes: 28 additions & 0 deletions tests/integrate/935_NO_Si2_tzdp_ns2_k_GPU/INPUT
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
INPUT_PARAMETERS
#Parameters (1.General)
suffix autotest
calculation scf

#nbands 8
symmetry 1

#Parameters (2.Iteration)
ecutwfc 50
scf_thr 1e-7
scf_nmax 100
cal_force 1
cal_stress 1
#Parameters (3.Basis)
basis_type lcao

#Parameters (4.Smearing)
smearing_method gauss
smearing_sigma 0.002

#Parameters (5.Mixing)
mixing_type broyden
mixing_beta 0.3
gamma_only 0
ks_solver cusolver
device cpu
nspin 2
4 changes: 4 additions & 0 deletions tests/integrate/935_NO_Si2_tzdp_ns2_k_GPU/KPT
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
K_POINTS
0
Gamma
1 1 1 0 0 0
21 changes: 21 additions & 0 deletions tests/integrate/935_NO_Si2_tzdp_ns2_k_GPU/STRU
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ATOMIC_SPECIES
Si 14.000 ../../PP_ORB/Si_ONCV_PBE-1.0.upf

NUMERICAL_ORBITAL
../../PP_ORB/Si_gga_8au_100Ry_3s3p2d.orb

LATTICE_CONSTANT
10.2

LATTICE_VECTORS
0.5 0.5 0.0 #Lattice vector 1
0.5 0.0 0.5 #Lattice vector 2
0.0 0.5 0.5 #Lattice vector 3

ATOMIC_POSITIONS
Cartesian #Cartesian(Unit is LATTICE_CONSTANT)
Si #Name of element
0.0 #Magnetic for this element.
2 #Number of atoms
0.00 0.00 0.00 0 0 0 #x,y,z, move_x, move_y, move_z
0.25 0.25 0.25 1 1 1
8 changes: 8 additions & 0 deletions tests/integrate/935_NO_Si2_tzdp_ns2_k_GPU/result.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
etotref -197.1470535849854855
etotperatomref -98.5735267925
totalforceref 0.000000
totalstressref 1377.912414
pointgroupref T_d
spacegroupref O_h
nksibzref 1
totaltimeref 5.39
3 changes: 2 additions & 1 deletion tests/integrate/CASES_GPU.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@
934_NO_Si2_tzdp_GPU
934_NO_Si2_tzdp_neq_GPU
934_NO_Si2_tzdp_neq_ns2_GPU
934_NO_Si2_tzdp_ns2_GPU
934_NO_Si2_tzdp_ns2_GPU
935_NO_Si2_tzdp_ns2_k_GPU