Teuchos Package Browser (Single Doxygen Collection) Version of the Day
Static Private Member Functions | Static Private Attributes
Teuchos::GlobalMPISession Class Reference

This class provides methods for initializing, finalizing, and querying the global MPI session. More...

#include <Teuchos_GlobalMPISession.hpp>

List of all members.

Static Private Member Functions

static void initialize (std::ostream *out)

Static Private Attributes

static bool haveMPIState_ = false
static bool mpiIsFinalized_ = false
static int rank_ = 0
static int nProc_ = 1

Public constructor and destructor

 GlobalMPISession (int *argc, char ***argv, std::ostream *out=&std::cout)
 Calls MPI_Init() if MPI is enabled.
 ~GlobalMPISession ()
 Call MPI_Finalize() if MPI is enabled.

Static functions

static bool mpiIsInitialized ()
 Return whether MPI was initialized.
static bool mpiIsFinalized ()
 Return whether MPI was already finalized.
static int getRank ()
 Returns the process rank relative to MPI_COMM_WORLD
static int getNProc ()
 Returns the number of processors relative to MPI_COMM_WORLD

Detailed Description

This class provides methods for initializing, finalizing, and querying the global MPI session.

This class is primarilly designed to insulate basic main() program type of code from having to know if MPI is enabled or not.

ToDo: Give examples!

Definition at line 65 of file Teuchos_GlobalMPISession.hpp.


Constructor & Destructor Documentation

Teuchos::GlobalMPISession::GlobalMPISession ( int *  argc,
char ***  argv,
std::ostream *  out = &std::cout 
)

Calls MPI_Init() if MPI is enabled.

Parameters:
argc[in] Argment passed into main(argc,argv)
argv[in] Argment passed into main(argc,argv)
out[in] If out!=NULL, then a small message on each processor will be printed to this stream. The default is &std::cout.

If the option --teuchos-suppress-startup-banner is found, the this option will be removed from argv[] before being passed to MPI_Init(...) and the startup output message to *out will be suppressed.

If Teuchos was not built with MPI support, the constructor just prints a startup banner (unless the banner was suppressed -- see previous paragraph). You can always use this class, whether or not Teuchos was built with MPI.

Warning:
This constructor can only be called once per executable. Otherwise, an error is printed to *out and an std::exception will be thrown!

Definition at line 52 of file Teuchos_GlobalMPISession.cpp.

Teuchos::GlobalMPISession::~GlobalMPISession ( )

Call MPI_Finalize() if MPI is enabled.

Definition at line 113 of file Teuchos_GlobalMPISession.cpp.


Member Function Documentation

bool Teuchos::GlobalMPISession::mpiIsInitialized ( ) [static]

Return whether MPI was initialized.

Definition at line 127 of file Teuchos_GlobalMPISession.cpp.

bool Teuchos::GlobalMPISession::mpiIsFinalized ( ) [static]

Return whether MPI was already finalized.

Definition at line 133 of file Teuchos_GlobalMPISession.cpp.

int Teuchos::GlobalMPISession::getRank ( ) [static]

Returns the process rank relative to MPI_COMM_WORLD

Returns 0 if MPI is not enabled.

Note, this function can be called even if the above constructor was never called so it is safe to use no matter how MPI_Init() got called (but it must have been called somewhere).

Definition at line 138 of file Teuchos_GlobalMPISession.cpp.

int Teuchos::GlobalMPISession::getNProc ( ) [static]

Returns the number of processors relative to MPI_COMM_WORLD

Returns 1 if MPI is not enabled.

Note, this function can be called even if the above constructor was never called so it is safe to use no matter how MPI_Init() got called (but it must have been called somewhere).

Definition at line 145 of file Teuchos_GlobalMPISession.cpp.

void Teuchos::GlobalMPISession::initialize ( std::ostream *  out) [static, private]

Definition at line 153 of file Teuchos_GlobalMPISession.cpp.


Member Data Documentation

bool Teuchos::GlobalMPISession::haveMPIState_ = false [static, private]

Definition at line 135 of file Teuchos_GlobalMPISession.hpp.

bool Teuchos::GlobalMPISession::mpiIsFinalized_ = false [static, private]

Definition at line 136 of file Teuchos_GlobalMPISession.hpp.

int Teuchos::GlobalMPISession::rank_ = 0 [static, private]

Definition at line 137 of file Teuchos_GlobalMPISession.hpp.

int Teuchos::GlobalMPISession::nProc_ = 1 [static, private]

Definition at line 138 of file Teuchos_GlobalMPISession.hpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines