HOPS
HOPS class reference
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
hops::MHO_MPIInterface Class Reference

interface functions for initialization of a MPI environment More...

#include <MHO_MPIInterface.hh>

Public Member Functions

void BeginSequentialProcess ()
 Isolates a section of code for sequential processing by each process one at a time. More...
 
void BroadcastString (std::string &msg)
 Broadcasts a string message to all processes from root/master process. More...
 
bool Check () const
 Checks if global process ID is non-negative and number of processes is greater than zero. More...
 
void EndSequentialProcess ()
 Sends a flag to the next process and waits for all processes to finish. More...
 
void Finalize ()
 Finalizes MPI by calling MPI_Finalize if not already finalized. More...
 
MPI_Comm * GetEvenCommunicator ()
 
MPI_Group * GetEvenGroup ()
 
int GetGlobalProcessID () const
 Getter for global process id. More...
 
std::string GetHostName () const
 Getter for host name. More...
 
int GetLocalProcessID () const
 Getter for local process id. More...
 
int GetNProcesses () const
 Getter for N processes. More...
 
int GetNSubGroupProcesses ()
 Getter for nsub group processes. More...
 
MPI_Comm * GetOddCommunicator ()
 
MPI_Group * GetOddGroup ()
 
int GetPartnerProcessID ()
 Getter for partner process id. More...
 
MPI_Group * GetSubGroup ()
 Getter for sub group. More...
 
MPI_Comm * GetSubGroupCommunicator ()
 
int GetSubGroupRank ()
 Getter for sub group rank. More...
 
void GlobalBarrier () const
 Waits for all processes in MPI_COMM_WORLD to reach this barrier. More...
 
void Initialize (int *argc, char ***argv, bool split_mode=true)
 Initializes MPI environment and sets up process groups/communicators. More...
 
bool IsEvenGroupMember ()
 Checks if the current process is a member of the even subgroup. More...
 
bool IsSplitValid ()
 Checks if even/odd split is valid. More...
 
void PrintMessage (std::string msg)
 Collects and prints messages from all processes in a MPI parallel environment. when called, this function must be encountered by all processes or the program will lock up, treat it as a global barrier use it to safely print messages from each process without clobbering the ouput. More...
 
bool SplitMode ()
 Checks if processes are split into two groups based on even/odd ranks. More...
 

Static Public Member Functions

static MHO_MPIInterfaceGetInstance ()
 Getter for instance. More...
 

Protected Member Functions

 MHO_MPIInterface ()
 
virtual ~MHO_MPIInterface ()
 
void DetermineLocalRank ()
 
void SetupSubGroups ()
 

Protected Attributes

std::vector< int > fCoHostedProcessIDs
 
MPI_Comm fEvenCommunicator
 
MPI_Group fEvenGroup
 
int fGlobalProcessID
 
std::string fHostName
 
bool fIsEvenGroupMember
 
int fLocalProcessID
 
int fNProcesses
 
int fNSubGroupProcesses
 
MPI_Comm fOddCommunicator
 
MPI_Group fOddGroup
 
int fPartnerProcessID
 
bool fSplitMode
 
MPI_Status fStatus
 
int fSubGroupRank
 
bool fValidSplit
 

Static Protected Attributes

static MHO_MPIInterfacefMPIInterface = nullptr
 

Detailed Description

interface functions for initialization of a MPI environment

Date
Sat Mar 11 18:35:02 2023 -0500
Author
J. Barrett - barre.nosp@m.ttj@.nosp@m.mit.e.nosp@m.du

Constructor & Destructor Documentation

◆ MHO_MPIInterface()

hops::MHO_MPIInterface::MHO_MPIInterface ( )
protected

◆ ~MHO_MPIInterface()

hops::MHO_MPIInterface::~MHO_MPIInterface ( )
protectedvirtualdefault

Member Function Documentation

◆ BeginSequentialProcess()

void hops::MHO_MPIInterface::BeginSequentialProcess ( )

Isolates a section of code for sequential processing by each process one at a time.

◆ BroadcastString()

void hops::MHO_MPIInterface::BroadcastString ( std::string &  msg)

Broadcasts a string message to all processes from root/master process.

Parameters
msgReference to string message to be broadcasted.

◆ Check()

bool hops::MHO_MPIInterface::Check ( ) const
inline

Checks if global process ID is non-negative and number of processes is greater than zero.

Returns
True if conditions are met, false otherwise.

◆ DetermineLocalRank()

void hops::MHO_MPIInterface::DetermineLocalRank ( )
protected

◆ EndSequentialProcess()

void hops::MHO_MPIInterface::EndSequentialProcess ( )

Sends a flag to the next process and waits for all processes to finish.

◆ Finalize()

void hops::MHO_MPIInterface::Finalize ( )

Finalizes MPI by calling MPI_Finalize if not already finalized.

◆ GetEvenCommunicator()

MPI_Comm* hops::MHO_MPIInterface::GetEvenCommunicator ( )
inline

◆ GetEvenGroup()

MPI_Group* hops::MHO_MPIInterface::GetEvenGroup ( )
inline

◆ GetGlobalProcessID()

int hops::MHO_MPIInterface::GetGlobalProcessID ( ) const
inline

Getter for global process id.

Returns
The global process ID as an integer.

◆ GetHostName()

std::string hops::MHO_MPIInterface::GetHostName ( ) const
inline

Getter for host name.

Returns
Host name as a string

◆ GetInstance()

MHO_MPIInterface * hops::MHO_MPIInterface::GetInstance ( )
static

Getter for instance.

Returns
MHO_MPIInterface* singleton instance
Note
This is a static function.

◆ GetLocalProcessID()

int hops::MHO_MPIInterface::GetLocalProcessID ( ) const
inline

Getter for local process id.

Returns
Local process ID as an integer.

◆ GetNProcesses()

int hops::MHO_MPIInterface::GetNProcesses ( ) const
inline

Getter for N processes.

Returns
The number of processes as an integer.

◆ GetNSubGroupProcesses()

int hops::MHO_MPIInterface::GetNSubGroupProcesses ( )
inline

Getter for nsub group processes.

Returns
Number of subgroup processes.

◆ GetOddCommunicator()

MPI_Comm* hops::MHO_MPIInterface::GetOddCommunicator ( )
inline

◆ GetOddGroup()

MPI_Group* hops::MHO_MPIInterface::GetOddGroup ( )
inline

◆ GetPartnerProcessID()

int hops::MHO_MPIInterface::GetPartnerProcessID ( )
inline

Getter for partner process id.

Returns
ID of the partner process as an integer.

◆ GetSubGroup()

MPI_Group* hops::MHO_MPIInterface::GetSubGroup ( )
inline

Getter for sub group.

Returns
MPI_Group* representing the sub-group rank

◆ GetSubGroupCommunicator()

MPI_Comm* hops::MHO_MPIInterface::GetSubGroupCommunicator ( )
inline

◆ GetSubGroupRank()

int hops::MHO_MPIInterface::GetSubGroupRank ( )
inline

Getter for sub group rank.

Returns
The subgroup rank as an integer.

◆ GlobalBarrier()

void hops::MHO_MPIInterface::GlobalBarrier ( ) const
inline

Waits for all processes in MPI_COMM_WORLD to reach this barrier.

◆ Initialize()

void hops::MHO_MPIInterface::Initialize ( int *  argc,
char ***  argv,
bool  split_mode = true 
)

Initializes MPI environment and sets up process groups/communicators.

Parameters
argcPointer to integer for command line argument count
argvDouble pointer to character array for command line arguments
split_modeBoolean flag indicating whether to split processes

◆ IsEvenGroupMember()

bool hops::MHO_MPIInterface::IsEvenGroupMember ( )
inline

Checks if the current process is a member of the even subgroup.

Returns
True if it's an even group member, false otherwise.

◆ IsSplitValid()

bool hops::MHO_MPIInterface::IsSplitValid ( )
inline

Checks if even/odd split is valid.

Returns
True if split is valid, false otherwise.

◆ PrintMessage()

void hops::MHO_MPIInterface::PrintMessage ( std::string  msg)

Collects and prints messages from all processes in a MPI parallel environment. when called, this function must be encountered by all processes or the program will lock up, treat it as a global barrier use it to safely print messages from each process without clobbering the ouput.

Parameters
msgMessage to be printed by all processes.

◆ SetupSubGroups()

void hops::MHO_MPIInterface::SetupSubGroups ( )
protected

◆ SplitMode()

bool hops::MHO_MPIInterface::SplitMode ( )
inline

Checks if processes are split into two groups based on even/odd ranks.

Returns
True if in split mode, false otherwise.

Member Data Documentation

◆ fCoHostedProcessIDs

std::vector< int > hops::MHO_MPIInterface::fCoHostedProcessIDs
protected

◆ fEvenCommunicator

MPI_Comm hops::MHO_MPIInterface::fEvenCommunicator
protected

◆ fEvenGroup

MPI_Group hops::MHO_MPIInterface::fEvenGroup
protected

◆ fGlobalProcessID

int hops::MHO_MPIInterface::fGlobalProcessID
protected

◆ fHostName

std::string hops::MHO_MPIInterface::fHostName
protected

◆ fIsEvenGroupMember

bool hops::MHO_MPIInterface::fIsEvenGroupMember
protected

◆ fLocalProcessID

int hops::MHO_MPIInterface::fLocalProcessID
protected

◆ fMPIInterface

MHO_MPIInterface * hops::MHO_MPIInterface::fMPIInterface = nullptr
staticprotected

◆ fNProcesses

int hops::MHO_MPIInterface::fNProcesses
protected

◆ fNSubGroupProcesses

int hops::MHO_MPIInterface::fNSubGroupProcesses
protected

◆ fOddCommunicator

MPI_Comm hops::MHO_MPIInterface::fOddCommunicator
protected

◆ fOddGroup

MPI_Group hops::MHO_MPIInterface::fOddGroup
protected

◆ fPartnerProcessID

int hops::MHO_MPIInterface::fPartnerProcessID
protected

◆ fSplitMode

bool hops::MHO_MPIInterface::fSplitMode
protected

◆ fStatus

MPI_Status hops::MHO_MPIInterface::fStatus
protected

◆ fSubGroupRank

int hops::MHO_MPIInterface::fSubGroupRank
protected

◆ fValidSplit

bool hops::MHO_MPIInterface::fValidSplit
protected

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