Skip to content

Commit 1450f32

Browse files
committed
Reduce H/S re-application frequency in PPCG block subspace
The Rayleigh-Ritz rotation already keeps hpsi_/spsi_ consistent with the rotated psi up to rounding, so re-applying H/S exactly every iteration is redundant. Re-apply every rr_step_ iterations to reset the accumulated rounding drift instead, removing one full-block H/S application on most iterations (~1.5x wall-time speedup).
1 parent 4d3889a commit 1450f32

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

source/source_hsolver/diago_ppcg.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,8 +1636,15 @@ double DiagoPPCG<T, Device>::diag(const HPsiFunc& hpsi_func,
16361636
// can otherwise drift into an ill-conditioned basis before the next
16371637
// Ritz rotation.
16381638
rayleigh_ritz(psi_in, eigenvalue_in, active_cols, ethr_band);
1639-
apply_h(hpsi_func, psi_in, hpsi_.data(), ncol);
1640-
apply_s_current(psi_in, spsi_.data(), ncol);
1639+
// The Rayleigh-Ritz rotation already keeps hpsi_/spsi_ consistent
1640+
// with the rotated psi up to rounding; re-applying H/S exactly is
1641+
// only needed every rr_step_ iterations to reset the accumulated
1642+
// rounding drift.
1643+
if ((iter % rr_step_) == 0)
1644+
{
1645+
apply_h(hpsi_func, psi_in, hpsi_.data(), ncol);
1646+
apply_s_current(psi_in, spsi_.data(), ncol);
1647+
}
16411648
record_residual(iter, "rayleigh_ritz");
16421649

16431650
++iter;

tests/01_PW/817_PW_PPCG/result.ref

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
etotref -4862.3309719757144194
1+
etotref -4862.3309719757116909
22
etotperatomref -2431.1654859879
33
totalforceref 9.131552
44
totalstressref 37222.701329
55
pointgroupref C_1
66
spacegroupref C_1
77
nksibzref 2
8-
totaltimeref 3.99
8+
totaltimeref 2.57

0 commit comments

Comments
 (0)