Skip to content

Commit 5723153

Browse files
committed
Add MPI compilation macro
1 parent ee7041b commit 5723153

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

source/module_hamilt_lcao/hamilt_lcaodft/spar_hsr.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "spar_exx.h"
88
#include "spar_u.h"
99

10+
#ifdef __MPI
1011
void sparse_format::sync_all_R_coor(std::set<Abfs::Vector3_Order<int>>& all_R_coor, MPI_Comm comm)
1112
{
1213
int my_rank, nproc;
@@ -64,6 +65,7 @@ void sparse_format::sync_all_R_coor(std::set<Abfs::Vector3_Order<int>>& all_R_co
6465
// Step 6: Update all processes' all_R_coor
6566
all_R_coor = std::move(global_R_coor);
6667
}
68+
#endif // __MPI
6769

6870
void sparse_format::cal_HSR(const UnitCell& ucell,
6971
const Parallel_Orbitals& pv,
@@ -94,8 +96,10 @@ void sparse_format::cal_HSR(const UnitCell& ucell,
9496

9597
HS_Arrays.all_R_coor = get_R_range(*(p_ham_lcao->getHR()));
9698

99+
#ifdef __MPI
97100
// Fix: Sync all_R_coor across processes
98101
sparse_format::sync_all_R_coor(HS_Arrays.all_R_coor, MPI_COMM_WORLD);
102+
#endif
99103

100104
if (TD_Velocity::tddft_velocity)
101105
{
@@ -124,8 +128,10 @@ void sparse_format::cal_HSR(const UnitCell& ucell,
124128

125129
HS_Arrays.all_R_coor = get_R_range(*(p_ham_lcao->getHR()));
126130

131+
#ifdef __MPI
127132
// Fix: Sync all_R_coor across processes
128133
sparse_format::sync_all_R_coor(HS_Arrays.all_R_coor, MPI_COMM_WORLD);
134+
#endif
129135

130136
sparse_format::cal_HContainer_cd(pv, current_spin, sparse_thr, *(p_ham_lcao->getHR()), HS_Arrays.HR_soc_sparse);
131137

source/module_hamilt_lcao/hamilt_lcaodft/spar_hsr.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55

66
namespace sparse_format
77
{
8+
#ifdef __MPI
89
// Synchronize all processes' R coordinates,
910
// otherwise HS_Arrays.all_R_coor would have different sizes on different processes,
1011
// causing MPI communication errors.
1112
void sync_all_R_coor(std::set<Abfs::Vector3_Order<int>>& all_R_coor, MPI_Comm comm);
13+
#endif
1214

1315
template <typename T>
1416
std::set<Abfs::Vector3_Order<int>> get_R_range(const hamilt::HContainer<T>& hR)

0 commit comments

Comments
 (0)