include/pops/parallel/load_balance.hpp File ReferenceΒΆ

adc_cpp: include/pops/parallel/load_balance.hpp File Reference
adc_cpp 0.3.0
Model-free C++23 core for coupled hyperbolic-elliptic systems on adaptive (AMR) meshes, with MPI and GPU (Kokkos) backends
load_balance.hpp File Reference

AMR load balancing: builds a DistributionMapping (box -> rank) from a BoxArray, using a Z-order space-filling curve (SFC) or LPT knapsack. More...

#include <pops/mesh/layout/box_array.hpp>
#include <pops/mesh/layout/distribution_mapping.hpp>
#include <algorithm>
#include <cstdint>
#include <numeric>
#include <vector>
+ Include dependency graph for load_balance.hpp:

Go to the source code of this file.

Namespaces

namespace  pops
 

Functions

std::uint64_t pops::part1by1 (std::uint64_t x)
 
std::uint64_t pops::morton_key (std::uint32_t x, std::uint32_t y)
 
std::vector< int > pops::morton_order (const BoxArray &ba)
 
DistributionMapping pops::make_sfc_distribution (const BoxArray &ba, int nranks)
 
DistributionMapping pops::make_knapsack_distribution (const BoxArray &ba, int nranks)
 
double pops::load_imbalance (const BoxArray &ba, const DistributionMapping &dm, int nranks)
 

Detailed Description

AMR load balancing: builds a DistributionMapping (box -> rank) from a BoxArray, using a Z-order space-filling curve (SFC) or LPT knapsack.

Layer: include/pops/parallel. Role: distribute boxes over ranks with replicated metadata (AMReX style). Two strategies: make_sfc_distribution (contiguous segments of equal load along the Morton curve -> spatial locality) and make_knapsack_distribution (heaviest box to the least loaded rank -> minimizes the maximum imbalance). load_imbalance measures the max load / average load ratio. Morton tooling exposed: part1by1, morton_key, morton_order. Contract: a box weight is its cell count (proxy for compute cost).

Invariants:

  • PURE functions, no MPI: testable in serial; they will feed the comm seam once an MPI backend is wired in;
  • SFC guarantees that with nboxes >= nranks each rank receives at least one box;
  • degenerate cases (n == 0, nranks <= 1): everything is assigned to rank 0.