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

adc_cpp: include/pops/parallel/comm.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
comm.hpp File Reference

Parallel seam: minimal MPI abstraction (rank/size + collectives) with serial fallback. More...

+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  pops
 

Functions

bool pops::comm_active ()
 
void pops::comm_init (int *=nullptr, char ***=nullptr)
 
void pops::comm_finalize ()
 
int pops::my_rank ()
 
int pops::n_ranks ()
 
void pops::barrier ()
 
double pops::all_reduce_sum (double x)
 
double pops::all_reduce_max (double x)
 
double pops::all_reduce_min (double x)
 
long pops::all_reduce_sum (long x)
 
void pops::all_reduce_sum_inplace (double *, int)
 
void pops::all_reduce_or_inplace (char *, int)
 

Detailed Description

Parallel seam: minimal MPI abstraction (rank/size + collectives) with serial fallback.

Layer: include/pops/parallel. Role: expose my_rank()/n_ranks() and a fixed set of global reductions (sum/min/max on double and long, in-place sum on a double array, in-place OR on a marker array) behind a single facade. Without POPS_HAS_MPI everything compiles to a serial identity; the rest of the code never sees MPI_COMM_WORLD nor mpi.h directly. Contract: every collective operates on MPI_COMM_WORLD; each rank must call them in the same order (otherwise deadlock). The sum_inplace / or_inplace bricks feed respectively the multi-patch AMR reflux and the gathering of regrid tags before clustering; all_reduce_min guarantees a global dt identical on all ranks.

Invariants:

  • even compiled with MPI, if MPI is not initialized my_rank()=0 / n_ranks()=1 (comm_active() tests Initialized && !Finalized); call comm_init() at the start of main() for a distributed run;
  • the all_reduce_* functions are COLLECTIVE: all ranks participate or none;
  • in serial mode each function is the identity (no-op or returns the argument).