1 #ifndef AMREX_PARALLELCONTEXT_H
2 #define AMREX_PARALLELCONTEXT_H
3 #include <AMReX_Config.H>
26 [[nodiscard]]
int MyID () const noexcept {
return m_id; }
49 std::unique_ptr<std::ofstream>
m_out;
82 inline std::ofstream *
OFSPtrSub () noexcept {
return frames.back().get_ofs_ptr(); }
105 frames.back().set_ofs_name(filename);
#define AMREX_EXPORT
Definition: AMReX_Extension.H:191
static constexpr int MPI_GROUP_NULL
Definition: AMReX_ccse-mpi.H:56
int MPI_Comm
Definition: AMReX_ccse-mpi.H:47
int MPI_Group
Definition: AMReX_ccse-mpi.H:48
static constexpr int MPI_COMM_NULL
Definition: AMReX_ccse-mpi.H:55
Definition: AMReX_ParallelContext.H:15
MPI_Comm comm
sub-communicator associated with frame
Definition: AMReX_ParallelContext.H:39
static int local_to_global_rank(int lrank)
Definition: AMReX_ParallelContext.cpp:51
int m_mpi_tag
Definition: AMReX_ParallelContext.H:46
void set_ofs_name(std::string filename)
Definition: AMReX_ParallelContext.cpp:112
int IOProc() const noexcept
Definition: AMReX_ParallelContext.H:29
int m_io_rank
Definition: AMReX_ParallelContext.H:47
MPI_Group group
to avoid repeatedly creating groups in rank translation
Definition: AMReX_ParallelContext.H:40
int MyProc() const noexcept
Definition: AMReX_ParallelContext.H:27
int m_nranks
local # of ranks
Definition: AMReX_ParallelContext.H:45
std::string m_out_filename
Definition: AMReX_ParallelContext.H:48
Frame & operator=(Frame const &)=delete
int m_id
frame ID
Definition: AMReX_ParallelContext.H:43
~Frame()
Definition: AMReX_ParallelContext.cpp:41
Frame(Frame const &)=delete
std::unique_ptr< std::ofstream > m_out
Definition: AMReX_ParallelContext.H:49
int NProcs() const noexcept
Definition: AMReX_ParallelContext.H:28
static void global_to_local_rank(int *local, const int *global, int n)
Definition: AMReX_ParallelContext.cpp:85
int m_rank_me
local rank
Definition: AMReX_ParallelContext.H:44
std::ofstream * get_ofs_ptr()
Definition: AMReX_ParallelContext.cpp:119
int get_inc_mpi_tag()
Definition: AMReX_ParallelContext.cpp:103
Frame(MPI_Comm c, int id, int io_rank)
Definition: AMReX_ParallelContext.cpp:11
int MyID() const noexcept
Definition: AMReX_ParallelContext.H:26
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition: AMReX_Vector.H:27
Definition: AMReX_ParallelContext.cpp:7
void push(MPI_Comm c)
Definition: AMReX_ParallelContext.H:102
void BarrierSub() noexcept
Definition: AMReX_ParallelContext.H:88
MPI_Group GroupAll() noexcept
world group
Definition: AMReX_ParallelContext.H:57
int MyProcAll() noexcept
my rank in world communicator
Definition: AMReX_ParallelContext.H:61
MPI_Comm CommunicatorSub() noexcept
sub-communicator for current frame
Definition: AMReX_ParallelContext.H:70
int get_inc_mpi_tag() noexcept
get and increment mpi tag in current frame
Definition: AMReX_ParallelContext.H:93
bool IOProcessorAll() noexcept
Am IO processor for world communicator?
Definition: AMReX_ParallelContext.H:65
int MyProcSub() noexcept
my sub-rank in current frame
Definition: AMReX_ParallelContext.H:76
int NProcsAll() noexcept
number of ranks in world communicator
Definition: AMReX_ParallelContext.H:59
void pop()
Note that it's the user's responsibility to free the MPI_Comm.
Definition: AMReX_ParallelContext.H:108
int local_to_global_rank(int rank) noexcept
translate between local rank and global rank
Definition: AMReX_ParallelContext.H:95
Vector< Frame > frames
stack of communicator frames
Definition: AMReX_ParallelContext.cpp:9
int global_to_local_rank(int rank) noexcept
Definition: AMReX_ParallelContext.H:98
int NProcsSub() noexcept
number of ranks in current frame
Definition: AMReX_ParallelContext.H:74
std::ofstream * OFSPtrSub() noexcept
Pointer to ofstream.
Definition: AMReX_ParallelContext.H:82
void BarrierAll() noexcept
Definition: AMReX_ParallelContext.H:89
MPI_Group GroupSub() noexcept
sub-group for current frame
Definition: AMReX_ParallelContext.H:72
int IOProcessorNumberSub() noexcept
IO sub-rank in current frame.
Definition: AMReX_ParallelContext.H:78
std::ofstream * OFSPtrAll() noexcept
Pointer to ofstream.
Definition: AMReX_ParallelContext.H:67
int IOProcessorNumberAll() noexcept
IO rank in world communicator.
Definition: AMReX_ParallelContext.H:63
MPI_Comm CommunicatorAll() noexcept
world communicator
Definition: AMReX_ParallelContext.H:55
void set_last_frame_ofs(const std::string &filename)
Definition: AMReX_ParallelContext.H:104
bool IOProcessorSub() noexcept
Am IO processor for current frame?
Definition: AMReX_ParallelContext.H:80