MPI¶
Load Balancer¶
- class lambdapic.core.mpi.load_balancer.LoadBalancer(patches: Patches, mpi: MPIManager, threshold: float = 0.1, load_function: Callable[[Patch], float] | None = None)[source]¶
Handles dynamic load balancing of patches across MPI ranks.
Initialize with patches (called during simulation init).
- Parameters:
patches (Patches) – The patches to be load balanced.
mpi (MPIManager) – The MPI manager for communication.
threshold (float, optional) – Load imbalance threshold for triggering rebalance. Rebalance is triggered when (max_load - min_load) / avg_load > threshold.
load_function (callable | None, optional) – Custom function to calculate load for a single patch. The function should accept a Patch as its only parameter and return a float representing the load. If None, uses the default load calculation.