Skip to content

Commit

Permalink
use MakeSimilarDM and also attempt to average dowm the costs
Browse files Browse the repository at this point in the history
  • Loading branch information
hklion authored and RevathiJambunathan committed Mar 20, 2024
1 parent 3feb26a commit 350b959
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
38 changes: 28 additions & 10 deletions Source/Parallelization/WarpXRegrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "Utils/WarpXAlgorithmSelection.H"
#include "Utils/WarpXProfilerWrapper.H"

#include <ablastr/coarsen/sample.H>

#include <AMReX.H>
#include <AMReX_BLassert.H>
#include <AMReX_Box.H>
Expand Down Expand Up @@ -69,6 +71,12 @@ WarpX::LoadBalance ()
int loadBalancedAnyLevel = false;

const int nLevels = finestLevel();
if (do_similar_dm_refpatch) {
for (int lev = nLevels; lev > 0; --lev) {
ablastr::coarsen::sample::Coarsen(*costs[lev-1], *costs[lev],0,0,1,0,WarpX::RefRatio(lev-1));
}
}

for (int lev = 0; lev <= nLevels; ++lev)
{
int doLoadBalance = false;
Expand All @@ -83,16 +91,26 @@ WarpX::LoadBalance ()
amrex::Real currentEfficiency = 0.0;
amrex::Real proposedEfficiency = 0.0;

newdm = (load_balance_with_sfc)
? DistributionMapping::makeSFC(*costs[lev],
currentEfficiency, proposedEfficiency,
false,
ParallelDescriptor::IOProcessorNumber())
: DistributionMapping::makeKnapSack(*costs[lev],
currentEfficiency, proposedEfficiency,
nmax,
false,
ParallelDescriptor::IOProcessorNumber());
if (lev == 0 || !do_similar_dm_refpatch) {
newdm = (load_balance_with_sfc)
? DistributionMapping::makeSFC(*costs[lev],
currentEfficiency, proposedEfficiency,
false,
ParallelDescriptor::IOProcessorNumber())
: DistributionMapping::makeKnapSack(*costs[lev],
currentEfficiency, proposedEfficiency,
nmax,
false,
ParallelDescriptor::IOProcessorNumber());
} else {
amrex::BoxArray coarse_ba = boxArray(lev-1);
amrex::DistributionMapping coarse_dm = DistributionMap(lev-1);
amrex::BoxArray ba = boxArray(lev);
ba.coarsen(WarpX::RefRatio(lev-1));
newdm = amrex::MakeSimilarDM(ba, coarse_ba, coarse_dm, getngEB());
}
Print() << "new dm on lev " << lev << ": \n";
Print() << newdm << std::endl;
// As specified in the above calls to makeSFC and makeKnapSack, the new
// distribution mapping is NOT communicated to all ranks; the loadbalanced
// dm is up-to-date only on root, and we can decide whether to broadcast
Expand Down
2 changes: 2 additions & 0 deletions Source/WarpX.H
Original file line number Diff line number Diff line change
Expand Up @@ -1641,6 +1641,8 @@ private:
* uniform plasma on a domain of size 128 by 128 by 128, from which the approximate
* time per iteration per particle is computed. */
amrex::Real costs_heuristic_particles_wt = amrex::Real(0);
/** Whether to use MakeSimilarDM when load balancing lev > 1 */
int do_similar_dm_refpatch = 0;

// Determines timesteps for override sync
utils::parser::IntervalsParser override_sync_intervals;
Expand Down
1 change: 1 addition & 0 deletions Source/WarpX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,7 @@ WarpX::ReadParameters ()
load_balance_intervals = utils::parser::IntervalsParser(
load_balance_intervals_string_vec);
pp_algo.query("load_balance_with_sfc", load_balance_with_sfc);
pp_algo.query("do_similar_dm_refpatch", do_similar_dm_refpatch);
// Knapsack factor only used with non-SFC strategy
if (!load_balance_with_sfc) {
pp_algo.query("load_balance_knapsack_factor", load_balance_knapsack_factor);
Expand Down

0 comments on commit 350b959

Please sign in to comment.