ORB5X 1.0.0
Performance-portable global electromagnetic gyrokinetic PIC code
orb5x::Pputil Class Reference

Process topology, collective communication, guard exchange, and timing. More...

#include "pputil.hpp"

Static Public Member Functions

static void barrier ()
 Synchronize all ranks in MPI_COMM_WORLD.
 
static void guard (Kokkos::View< Real ** > &f, int nidbas)
 Fill periodic poloidal guard cells of a two-dimensional mesh field.
 
static void guard (Kokkos::View< Real ***, Kokkos::LayoutStride > f, int nidbas, int flag)
 Exchange toroidal guard planes of a three-dimensional mesh field.
 
static void heapcheck (const std::string &message)
 Compatibility hook for reporting heap use.
 
static void mpiabort ()
 Abort MPI_COMM_WORLD with error code -1.
 
static void ppbcast (int &f, int icomm)
 Broadcast a real scalar from rank zero of a communicator.
 
static void ppbcast (Real &f, int icomm)
 Broadcast a real scalar from rank zero of a communicator.
 
static void ppbcast (std::vector< int > &f, int icomm)
 Broadcast an integer vector from communicator rank zero.
 
static void ppbcast (std::vector< Real > &f, int icomm)
 Broadcast a real vector from communicator rank zero.
 
static void ppexit ()
 Synchronize all world ranks at the end of the run.
 
static void ppinit ()
 Initialize MPI when the caller has not already done so.
 
static void ppmax (int &f, int icomm)
 Replace a real scalar with its communicator-wide maximum.
 
static void ppmax (Real &f, int icomm)
 Replace a real scalar with its communicator-wide maximum.
 
static void ppmax (std::vector< int > &f, int icomm)
 Replace each integer vector element with its collective maximum.
 
static void ppmax (std::vector< Real > &f, int icomm)
 Replace each real vector element with its collective maximum.
 
static void ppmin (int &f, int icomm)
 Replace a real scalar with its communicator-wide minimum.
 
static void ppmin (Real &f, int icomm)
 Replace a real scalar with its communicator-wide minimum.
 
static void ppmin (std::vector< int > &f, int icomm)
 Replace each integer vector element with its collective minimum.
 
static void ppmin (std::vector< Real > &f, int icomm)
 Replace each real vector element with its collective minimum.
 
static void ppsum (int &f, int icomm)
 Sum a scalar in place across the selected communicator.
 
static void ppsum (Real &f, int icomm)
 Sum a scalar in place across the selected communicator.
 
static void ppsum (Real *f, int count, int icomm)
 Sum a contiguous real buffer in place across a communicator.
 
static void ppsum (std::vector< int > &f, int icomm)
 Sum every integer element in place across a communicator.
 
static void ppsum (std::vector< Real > &f, int icomm)
 Sum every real element in place across a communicator.
 
static void pptopology (bool bycol=false)
 Construct the spatial-domain and clone process topology.
 
static void timera (int icntrl, const std::string &string, Real *eltime=nullptr, bool do_barrier=true)
 Start or stop one of the ten named wall-clock timers.
 

Detailed Description

Process topology, collective communication, guard exchange, and timing.

Pputil is the MPI compatibility layer used by the rest of ORB5X. It owns no MPI resources itself; communicator handles and ranks are stored in the global Parallel state. Call ppinit() before pptopology(), and keep MPI alive until all collectives and guard exchanges have completed.

Communicator selectors used by the collective routines are:

  • 1: MPI_COMM_WORLD;
  • 2: the toroidal spatial-domain communicator (comm_sd);
  • 3: the clone communicator (comm_clones);
  • 4: the radial-column communicator (comm_krcol);
  • 5: the conjugate-gradient communicator (comm_cg).

Any other selector currently falls back to MPI_COMM_WORLD for compatibility with the original ORB5 utility module.

Member Function Documentation

◆ barrier()

static void orb5x::Pputil::barrier ( )
static

Synchronize all ranks in MPI_COMM_WORLD.

◆ guard() [1/2]

static void orb5x::Pputil::guard ( Kokkos::View< Real ** > &  f,
int  nidbas 
)
static

Fill periodic poloidal guard cells of a two-dimensional mesh field.

Parameters
[in,out]fField indexed by radial and poloidal mesh coordinates.
[in]nidbasB-spline degree: 1 (linear), 2 (quadratic), or 3 (cubic).

The physical poloidal extent is obtained from the global field state; no inter-process communication is performed by this overload.

◆ guard() [2/2]

static void orb5x::Pputil::guard ( Kokkos::View< Real ***, Kokkos::LayoutStride >  f,
int  nidbas,
int  flag 
)
static

Exchange toroidal guard planes of a three-dimensional mesh field.

Parameters
[in,out]fMesh values whose third extent contains toroidal guards.
[in]nidbasB-spline degree: 1 (linear), 2 (quadratic), or 3 (cubic).
[in]flagExchange mode: 0 folds deposited ghost values into the physical edge and clears the ghosts; 1 copies physical edge values into ghost planes.

Neighbor communication uses the periodic comm_sd topology. For a single spatial subdomain the equivalent periodic update is performed locally. In copy mode, compatible poloidal (chi) guards are also filled.

◆ heapcheck()

static void orb5x::Pputil::heapcheck ( const std::string &  message)
static

Compatibility hook for reporting heap use.

Parameters
[in]messageContext label retained for source compatibility.
Note
The current C++ implementation is intentionally a no-op.

◆ mpiabort()

static void orb5x::Pputil::mpiabort ( )
static

Abort MPI_COMM_WORLD with error code -1.

◆ ppbcast() [1/4]

static void orb5x::Pputil::ppbcast ( int &  f,
int  icomm 
)
static

Broadcast a real scalar from rank zero of a communicator.

Parameters
[in,out]fRoot value on entry and the broadcast value on return.
[in]icommCommunicator selector documented by Pputil.

◆ ppbcast() [2/4]

static void orb5x::Pputil::ppbcast ( Real &  f,
int  icomm 
)
static

Broadcast a real scalar from rank zero of a communicator.

Parameters
[in,out]fRoot value on entry and the broadcast value on return.
[in]icommCommunicator selector documented by Pputil.

◆ ppbcast() [3/4]

static void orb5x::Pputil::ppbcast ( std::vector< int > &  f,
int  icomm 
)
static

Broadcast an integer vector from communicator rank zero.

Parameters
[in,out]fRoot vector on entry and broadcast vector on return.
[in]icommCommunicator selector documented by Pputil.

◆ ppbcast() [4/4]

static void orb5x::Pputil::ppbcast ( std::vector< Real > &  f,
int  icomm 
)
static

Broadcast a real vector from communicator rank zero.

Parameters
[in,out]fRoot vector on entry and broadcast vector on return.
[in]icommCommunicator selector documented by Pputil.

◆ ppexit()

static void orb5x::Pputil::ppexit ( )
static

Synchronize all world ranks at the end of the run.

This compatibility routine deliberately does not call MPI_Finalize; main finalizes Kokkos before finalizing MPI.

◆ ppinit()

static void orb5x::Pputil::ppinit ( )
static

Initialize MPI when the caller has not already done so.

Records the world size and rank in the global parallel state and starts timer slot 2. It is safe to call after MPI has been initialized.

◆ ppmax() [1/4]

static void orb5x::Pputil::ppmax ( int &  f,
int  icomm 
)
static

Replace a real scalar with its communicator-wide maximum.

Parameters
[in,out]fLocal value on entry and maximum on return.
[in]icommCommunicator selector documented by Pputil.

◆ ppmax() [2/4]

static void orb5x::Pputil::ppmax ( Real &  f,
int  icomm 
)
static

Replace a real scalar with its communicator-wide maximum.

Parameters
[in,out]fLocal value on entry and maximum on return.
[in]icommCommunicator selector documented by Pputil.

◆ ppmax() [3/4]

static void orb5x::Pputil::ppmax ( std::vector< int > &  f,
int  icomm 
)
static

Replace each integer vector element with its collective maximum.

Parameters
[in,out]fValues reduced element by element in place.
[in]icommCommunicator selector documented by Pputil.

◆ ppmax() [4/4]

static void orb5x::Pputil::ppmax ( std::vector< Real > &  f,
int  icomm 
)
static

Replace each real vector element with its collective maximum.

Parameters
[in,out]fValues reduced element by element in place.
[in]icommCommunicator selector documented by Pputil.

◆ ppmin() [1/4]

static void orb5x::Pputil::ppmin ( int &  f,
int  icomm 
)
static

Replace a real scalar with its communicator-wide minimum.

Parameters
[in,out]fLocal value on entry and minimum on return.
[in]icommCommunicator selector documented by Pputil.

◆ ppmin() [2/4]

static void orb5x::Pputil::ppmin ( Real &  f,
int  icomm 
)
static

Replace a real scalar with its communicator-wide minimum.

Parameters
[in,out]fLocal value on entry and minimum on return.
[in]icommCommunicator selector documented by Pputil.

◆ ppmin() [3/4]

static void orb5x::Pputil::ppmin ( std::vector< int > &  f,
int  icomm 
)
static

Replace each integer vector element with its collective minimum.

Parameters
[in,out]fValues reduced element by element in place.
[in]icommCommunicator selector documented by Pputil.

◆ ppmin() [4/4]

static void orb5x::Pputil::ppmin ( std::vector< Real > &  f,
int  icomm 
)
static

Replace each real vector element with its collective minimum.

Parameters
[in,out]fValues reduced element by element in place.
[in]icommCommunicator selector documented by Pputil.

◆ ppsum() [1/5]

static void orb5x::Pputil::ppsum ( int &  f,
int  icomm 
)
static

Sum a scalar in place across the selected communicator.

Parameters
[in,out]fLocal value on entry and global sum on return.
[in]icommCommunicator selector documented by Pputil.

◆ ppsum() [2/5]

static void orb5x::Pputil::ppsum ( Real &  f,
int  icomm 
)
static

Sum a scalar in place across the selected communicator.

Parameters
[in,out]fLocal value on entry and global sum on return.
[in]icommCommunicator selector documented by Pputil.

◆ ppsum() [3/5]

static void orb5x::Pputil::ppsum ( Real *  f,
int  count,
int  icomm 
)
static

Sum a contiguous real buffer in place across a communicator.

Parameters
[in,out]fPointer to at least count local values, replaced by sums.
[in]countNumber of elements in f.
[in]icommCommunicator selector documented by Pputil.

◆ ppsum() [4/5]

static void orb5x::Pputil::ppsum ( std::vector< int > &  f,
int  icomm 
)
static

Sum every integer element in place across a communicator.

Parameters
[in,out]fLocal vector on entry and element-wise sums on return.
[in]icommCommunicator selector documented by Pputil.

◆ ppsum() [5/5]

static void orb5x::Pputil::ppsum ( std::vector< Real > &  f,
int  icomm 
)
static

Sum every real element in place across a communicator.

Parameters
[in,out]fLocal vector on entry and element-wise sums on return.
[in]icommCommunicator selector documented by Pputil.

◆ pptopology()

static void orb5x::Pputil::pptopology ( bool  bycol = false)
static

Construct the spatial-domain and clone process topology.

Parameters
[in]bycolIf true, exchange the coordinate ordering used to split world ranks between spatial domains and clones.

The routine populates nsd, comm_sd, comm_clones, their local ranks, and the available thread count in the global parallel state. The spatial communicator is periodic in the toroidal direction. A non-positive or incompatible clone count is replaced by one.

◆ timera()

static void orb5x::Pputil::timera ( int  icntrl,
const std::string &  string,
Real *  eltime = nullptr,
bool  do_barrier = true 
)
static

Start or stop one of the ten named wall-clock timers.

Parameters
[in]icntrlTimer selector. -N or 0 starts timer |N|, while +N stops it; valid absolute timer numbers are 1–10.
[in]stringHuman-readable timer label used when elapsed time is printed by the world root.
[out]eltimeOptional time result in seconds. On start this is the MPI wall-clock timestamp; on stop it is elapsed time.
[in]do_barrierIf true, synchronize MPI_COMM_WORLD before reading the clock.

The documentation for this class was generated from the following file: