Skip to content

Commit f010a25

Browse files
author
Agent
committed
fix(hsolver): replace std::vector<bool> with std::vector<int> in Davidson convergence flags
std::vector<bool> packs bits and is not thread-safe under concurrent parallel writes from OpenMP, causing non-deterministic hangs/crashes (e.g. 01_PW/035_PW_15_SO with many threads). Use std::vector<int> for independent per-element writes in diago_david and diago_dav_subspace.
1 parent d27e745 commit f010a25

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

source/source_hsolver/diago_dav_subspace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ int Diago_DavSubspace<T, Device>::diag_once(const HPsiFunc& hpsi_func,
121121
std::vector<Real> eigenvalue_iter(this->nbase_x, 0.0);
122122

123123
// convflag[m] = true if the m th band is convergent
124-
std::vector<bool> convflag(this->n_band, false);
124+
std::vector<int> convflag(this->n_band, 0);
125125

126126
// unconv[m] store the number of the m th unconvergent band
127127
std::vector<int> unconv(this->n_band);

source/source_hsolver/diago_david.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ int DiagoDavid<T, Device>::diag_once(const HPsiFunc& hpsi_func,
139139
DiagoTrace trace("Davidson");
140140

141141
// convflag[m] = true if the m th band is converged
142-
std::vector<bool> convflag(nband, false);
142+
std::vector<int> convflag(nband, 0);
143143
// unconv[m] store the number of the m th unconverged band
144144
std::vector<int> unconv(nband);
145145

0 commit comments

Comments
 (0)