Cache GSL in SyncPlan and apply async Sync to Z4c_class
Major optimization: Pre-build grid segment lists (GSLs) once per Step() call via SyncPreparePlan(), then reuse them across all 4 RK4 substep SyncBegin calls via SyncBeginWithPlan(). This eliminates the O(cpusize * blocks^2) GSL rebuild cost that was incurred on every ghost zone exchange. Applied async SyncBegin/SyncEnd overlap pattern to Z4c_class.C (ABEtype==2, the default configuration), which was still using blocking Parallel::Sync. Both the regular and CPBC variants of Z4c Step() are now optimized. Co-authored-by: copilot-swe-agent[bot] <198982749+copilot@users.noreply.github.com>
This commit is contained in:
@@ -98,6 +98,7 @@ namespace Parallel
|
||||
MyList<var> *VarList1;
|
||||
MyList<var> *VarList2;
|
||||
int Symmetry;
|
||||
bool owns_gsl; // true if this state owns and should free the GSLs
|
||||
};
|
||||
struct SyncHandle
|
||||
{
|
||||
@@ -107,6 +108,26 @@ namespace Parallel
|
||||
SyncHandle *SyncBegin(Patch *Pat, MyList<var> *VarList, int Symmetry);
|
||||
SyncHandle *SyncBegin(MyList<Patch> *PatL, MyList<var> *VarList, int Symmetry);
|
||||
void SyncEnd(SyncHandle *handle);
|
||||
|
||||
// Cached GSL plan: pre-build grid segment lists once, reuse across multiple Sync calls
|
||||
struct SyncPlanEntry
|
||||
{
|
||||
int cpusize;
|
||||
MyList<gridseg> **transfer_src;
|
||||
MyList<gridseg> **transfer_dst;
|
||||
MyList<gridseg> **src;
|
||||
MyList<gridseg> *dst;
|
||||
};
|
||||
struct SyncPlan
|
||||
{
|
||||
SyncPlanEntry *entries;
|
||||
int num_entries;
|
||||
int Symmetry;
|
||||
};
|
||||
SyncPlan *SyncPreparePlan(MyList<Patch> *PatL, int Symmetry);
|
||||
void SyncFreePlan(SyncPlan *plan);
|
||||
SyncHandle *SyncBeginWithPlan(SyncPlan *plan, MyList<var> *VarList);
|
||||
SyncHandle *SyncBeginWithPlan(SyncPlan *plan, MyList<var> *VarList1, MyList<var> *VarList2);
|
||||
void OutBdLow2Hi(Patch *Patc, Patch *Patf,
|
||||
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
|
||||
int Symmetry);
|
||||
|
||||
Reference in New Issue
Block a user