Skip to content

Commit 2c78030

Browse files
committed
fix loop pattern, reset lb vars
1 parent 64a023e commit 2c78030

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/mesh/amr_loadbalance.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ Real DistributeTrial(std::vector<Real> const &cost, std::vector<int> &start,
368368
double CalculateNewBalance(std::vector<double> const &cost, std::vector<int> &start,
369369
std::vector<int> &nb, const double avg_cost,
370370
const double max_block_cost) {
371+
PARTHENON_INSTRUMENT
371372
const int nblocks = cost.size();
372373
const int max_rank = std::min(nblocks, Globals::nranks);
373374

@@ -689,7 +690,10 @@ bool Mesh::RedistributeAndRefineMeshBlocks(ParameterInput *pin, ApplicationInput
689690
double new_max =
690691
CalculateNewBalance(costlist, start_trial, nb_trial, avg_cost, max_block_cost);
691692
// if the improvement isn't large enough, just return because we're done
692-
if ((max_rank_cost - new_max) / max_rank_cost < lb_tolerance_) return false;
693+
if ((max_rank_cost - new_max) / max_rank_cost < lb_tolerance_) {
694+
ResetLoadBalanceVariables();
695+
return false;
696+
}
693697
newrank.resize(ntot);
694698
AssignBlocks(start_trial, nb_trial, newrank);
695699
nslist = std::move(start_trial);

src/mesh/mesh.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,7 @@ void Mesh::Initialize(bool init_problem, ParameterInput *pin, ApplicationInput *
11471147
block_cost_host[i] = 1.0;
11481148
#ifdef ENABLE_LB_TIMERS
11491149
parthenon::par_for(
1150-
DEFAULT_LOOP_PATTERN, PARTHENON_AUTO_LABEL, DevExecSpace(), 0, nmb - 1,
1150+
loop_pattern_flatrange_tag, PARTHENON_AUTO_LABEL, DevExecSpace(), 0, nmb - 1,
11511151
KOKKOS_LAMBDA(const int b) { block_cost(b) = 1.0; });
11521152
#endif
11531153
LoadBalancingAndAdaptiveMeshRefinement(pin, app_in);

0 commit comments

Comments
 (0)