Skip to content

Commit a866f4c

Browse files
committed
Move sync operation into get_R_range
1 parent e2f6629 commit a866f4c

File tree

2 files changed

+6
-29
lines changed

2 files changed

+6
-29
lines changed

source/module_hamilt_lcao/hamilt_lcaodft/spar_hsr.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@ void sparse_format::cal_HSR(const UnitCell& ucell,
8484
{
8585
ModuleBase::TITLE("sparse_format", "cal_HSR");
8686

87-
int my_rank = 0;
88-
int nproc = 1;
89-
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
90-
MPI_Comm_size(MPI_COMM_WORLD, &nproc);
91-
9287
// sparse_format::set_R_range(HS_Arrays.all_R_coor, grid);
9388

9489
const int nspin = PARAM.inp.nspin;
@@ -101,25 +96,6 @@ void sparse_format::cal_HSR(const UnitCell& ucell,
10196

10297
HS_Arrays.all_R_coor = get_R_range(*(p_ham_lcao->getHR()));
10398

104-
#ifdef __MPI
105-
// Fix: Sync all_R_coor across processes
106-
sparse_format::sync_all_R_coor(HS_Arrays.all_R_coor, MPI_COMM_WORLD);
107-
108-
//===================== MPI debug =====================//
109-
std::string debug_file = "debug_fix_rank_" + std::to_string(my_rank) + ".log";
110-
std::ofstream fout(debug_file, std::ios::app);
111-
112-
fout << "Process " << my_rank + 1 << "/" << nproc
113-
<< ": HS_Arrays.all_R_coor.size() = " << HS_Arrays.all_R_coor.size() << std::endl;
114-
for (const auto& R: HS_Arrays.all_R_coor)
115-
{
116-
fout << "R = (" << R.x << ", " << R.y << ", " << R.z << ")" << std::endl;
117-
}
118-
fout.close();
119-
MPI_Barrier(MPI_COMM_WORLD);
120-
//===================== debug end =====================//
121-
#endif
122-
12399
if (TD_Velocity::tddft_velocity)
124100
{
125101
sparse_format::cal_HContainer_td(pv,
@@ -147,11 +123,6 @@ void sparse_format::cal_HSR(const UnitCell& ucell,
147123

148124
HS_Arrays.all_R_coor = get_R_range(*(p_ham_lcao->getHR()));
149125

150-
#ifdef __MPI
151-
// Fix: Sync all_R_coor across processes
152-
sparse_format::sync_all_R_coor(HS_Arrays.all_R_coor, MPI_COMM_WORLD);
153-
#endif
154-
155126
sparse_format::cal_HContainer_cd(pv, current_spin, sparse_thr, *(p_ham_lcao->getHR()), HS_Arrays.HR_soc_sparse);
156127

157128
sparse_format::cal_HContainer_cd(pv, current_spin, sparse_thr, *(p_ham_lcao->getSR()), HS_Arrays.SR_soc_sparse);

source/module_hamilt_lcao/hamilt_lcaodft/spar_hsr.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ std::set<Abfs::Vector3_Order<int>> get_R_range(const hamilt::HContainer<T>& hR)
2626
all_R_coor.insert(dR);
2727
}
2828
}
29+
30+
#ifdef __MPI
31+
// Fix: Sync all_R_coor across processes
32+
sparse_format::sync_all_R_coor(all_R_coor, MPI_COMM_WORLD);
33+
#endif
34+
2935
return all_R_coor;
3036
};
3137

0 commit comments

Comments
 (0)