skip redundant MPI ghost cell syncs for stages 0, 1 & 2

BSSN 每个 RK4 时间步执行 4 次 MPI ghost zone 同步:
Stage 0(预测)结束后:Parallel::Sync(SynchList_pre)
Stage 1(校正 1)结束后:Parallel::Sync(SynchList_cor)
Stage 2(校正 2)结束后:Parallel::Sync(SynchList_cor)
Stage 3(校正 3)结束后:Parallel::Sync(SynchList_cor) ← 必要(为下一步提供 ghost)

bssnEM_class.C、Z4c_class.C 结构相同,一起修改了
This commit is contained in:
2026-02-26 16:16:33 +08:00
parent fb9f153662
commit f7ada421cf
3 changed files with 60 additions and 105 deletions

View File

@@ -485,25 +485,7 @@ void Z4c_class::Step(int lev, int YN)
}
#endif
Parallel::Sync(GH->PatL[lev], SynchList_pre, Symmetry);
#ifdef WithShell
if (lev == 0)
{
clock_t prev_clock, curr_clock;
if (myrank == 0)
curr_clock = clock();
SH->Synch(SynchList_pre, Symmetry);
if (myrank == 0)
{
prev_clock = curr_clock;
curr_clock = clock();
cout << " Shell stuff synchronization used "
<< (double)(curr_clock - prev_clock) / ((double)CLOCKS_PER_SEC)
<< " seconds! " << endl;
}
}
#endif
// CA-RK4: skip post-prediction sync (redundant; ghost cells computable locally)
// for black hole position
if (BH_num > 0 && lev == GH->levels - 1)
@@ -868,6 +850,8 @@ void Z4c_class::Step(int lev, int YN)
}
#endif
// CA-RK4: only sync after last corrector (iter_count == 3); stages 1 & 2 are redundant
if (iter_count == 3) {
Parallel::Sync(GH->PatL[lev], SynchList_cor, Symmetry);
#ifdef WithShell
@@ -887,6 +871,7 @@ void Z4c_class::Step(int lev, int YN)
}
}
#endif
} // end CA-RK4 guard
// for black hole position
if (BH_num > 0 && lev == GH->levels - 1)
{
@@ -1558,7 +1543,7 @@ void Z4c_class::Step(int lev, int YN)
}
}
Parallel::Sync(GH->PatL[lev], SynchList_pre, Symmetry);
// CA-RK4: skip post-prediction MPI ghost sync (redundant; ghost cells computable locally)
if (lev == 0)
{
@@ -2120,6 +2105,8 @@ void Z4c_class::Step(int lev, int YN)
}
}
// CA-RK4: only MPI sync after last corrector (iter_count == 3); stages 1 & 2 are redundant
if (iter_count == 3)
Parallel::Sync(GH->PatL[lev], SynchList_cor, Symmetry);
if (lev == 0)

View File

@@ -1221,25 +1221,7 @@ void bssnEM_class::Step(int lev, int YN)
}
#endif
Parallel::Sync(GH->PatL[lev], SynchList_pre, Symmetry);
#ifdef WithShell
if (lev == 0)
{
clock_t prev_clock, curr_clock;
if (myrank == 0)
curr_clock = clock();
SH->Synch(SynchList_pre, Symmetry);
if (myrank == 0)
{
prev_clock = curr_clock;
curr_clock = clock();
cout << " Shell stuff synchronization used "
<< (double)(curr_clock - prev_clock) / ((double)CLOCKS_PER_SEC)
<< " seconds! " << endl;
}
}
#endif
// CA-RK4: skip post-prediction sync (redundant; ghost cells computable locally)
// for black hole position
if (BH_num > 0 && lev == GH->levels - 1)
@@ -1683,6 +1665,8 @@ void bssnEM_class::Step(int lev, int YN)
}
#endif
// CA-RK4: only sync after last corrector (iter_count == 3); stages 1 & 2 are redundant
if (iter_count == 3) {
Parallel::Sync(GH->PatL[lev], SynchList_cor, Symmetry);
#ifdef WithShell
@@ -1702,6 +1686,7 @@ void bssnEM_class::Step(int lev, int YN)
}
}
#endif
} // end CA-RK4 guard
// for black hole position
if (BH_num > 0 && lev == GH->levels - 1)
{

View File

@@ -3349,27 +3349,7 @@ void bssn_class::Step(int lev, int YN)
}
#endif
Parallel::AsyncSyncState async_pre;
Parallel::Sync_start(GH->PatL[lev], SynchList_pre, Symmetry, sync_cache_pre[lev], async_pre);
#ifdef WithShell
if (lev == 0)
{
clock_t prev_clock, curr_clock;
if (myrank == 0)
curr_clock = clock();
SH->Synch(SynchList_pre, Symmetry);
if (myrank == 0)
{
prev_clock = curr_clock;
curr_clock = clock();
cout << " Shell stuff synchronization used "
<< (double)(curr_clock - prev_clock) / ((double)CLOCKS_PER_SEC)
<< " seconds! " << endl;
}
}
#endif
Parallel::Sync_finish(sync_cache_pre[lev], async_pre, SynchList_pre, Symmetry);
// CA-RK4: skip post-prediction sync (redundant; ghost cells computable locally)
#ifdef WithShell
// Complete non-blocking error reduction and check
@@ -3709,6 +3689,8 @@ void bssn_class::Step(int lev, int YN)
}
#endif
// CA-RK4: only sync after last corrector (iter_count == 3); stages 1 & 2 are redundant
if (iter_count == 3) {
Parallel::AsyncSyncState async_cor;
Parallel::Sync_start(GH->PatL[lev], SynchList_cor, Symmetry, sync_cache_cor[lev], async_cor);
@@ -3730,6 +3712,7 @@ void bssn_class::Step(int lev, int YN)
}
#endif
Parallel::Sync_finish(sync_cache_cor[lev], async_cor, SynchList_cor, Symmetry);
} // end CA-RK4 guard
#ifdef WithShell
// Complete non-blocking error reduction and check