Skip to content

MPICommunicator Class

Jacob Fields edited this page Jun 16, 2020 · 1 revision

The MPICommunicator class is a wrapper for MPI functionality in OOPS. While MPI, being a C library, is global and can be used directly in OOPS where necessary, MPICommunicator can be a simpler way to access some MPI functionality. The class is implemented as a singleton and cannot be created, copied, or destroyed directly.

Public Methods

Method Description
static MPICommunicator* getInstance() Get a pointer to the MPICommunicator object.
Result init() Initialize MPI. Returns SUCCESS or FAILURE. Does nothing if MPI is already initialized.
Result cleanup() Cleanup MPI. Returns UNINITIALIZED if MPI is not initialized, FAILURE if there's a problem during cleanup, and SUCCESS in all other instances.
Result broadcastParameter(int *par) On a root processor, take the pointer par and broadcast its value to all other processors. On all other processors, store the broadcasted value in par. Returns UNINITIALIZED if MPI hasn't been initialized, FAILURE if the broadcast fails, or SUCCESS.
Result broadcastParameters(unsigned int *par) See above.
Result broadcastParameters(double *par) See above.
Result broadcastParameters(std::string *par) See above.
Result findMax(double in, double &out) Compare in across all processors and store the maximum value in out. Returns UNINITIALIZED if MPI is uninitialized and SUCCESS otherwise.
Result findMin(double in, double &out) Compare in across all processors and store the minimum value in out. Returns UNINITIALIZED if MPI is uninitialized and SUCCESS otherwise.
int getRank() const Get the current processor's rank.
int getWorldSize() const Get the number of processors being used by OOPS-2D.
const std::string& getProcessorName() const Get the current processor's name.
bool getIsInitialized() const Find out whether or not MPI has been initialized.
int getRootRank() Get the rank for the root rank. Returns -1 if uninitialized.

Clone this wiki locally