PlayaMPISession.hpp
Go to the documentation of this file.
00001 // @HEADER
00002 
00003 // @HEADER
00004 
00005 #ifndef PLAYA_MPISESSION_H
00006 #define PLAYA_MPISESSION_H
00007 
00008 /*! \file Playa_MPISession.hpp
00009   \brief A MPI utilities class, providing methods for initializing,
00010   finalizing, and querying the global MPI session
00011 */
00012 #include "PlayaDefs.hpp"
00013 #include "Teuchos_GlobalMPISession.hpp"
00014 
00015 #ifdef HAVE_MPI
00016 #include "mpi.h"
00017 #endif
00018 
00019 namespace Playa
00020 {
00021 /**
00022  * \brief This class provides methods for initializing, finalizing, 
00023  * and querying the global MPI session. 
00024  */
00025 class MPISession
00026 {
00027 public:
00028   //! Initializer, calls MPI_Init() if necessary
00029   static void init(int* argc, void*** argv);
00030 
00031   //! Initializer, calls MPI_Init() if necessary
00032   static void init(int* argc, char*** argv);
00033 
00034   //! Returns the process rank relative to MPI_COMM_WORLD
00035   static int getRank() {return rank_;}
00036 
00037   //! Returns the number of processors in MPI_COMM_WORLD 
00038   static int getNProc() {return nProc_;}
00039 
00040   //! Finalizer, calls MPI_Finalize() if necessary
00041   static void finalize();
00042 
00043   /** Set to true if a message should be written by each processor
00044    * at startup. */
00045   static bool& showStartupMessage() {static bool rtn=false; return rtn;}
00046 
00047 private:
00048   static int rank_;
00049   static int nProc_;
00050 
00051   /** private ctor, to be called only by init() */
00052   MPISession(int* argc, char*** argv);
00053 
00054 public:
00055   /** dtor calls MPI finalize */
00056   ~MPISession();
00057 };
00058 }
00059 
00060 #endif

Site Contact