5 #ifndef DUNE_COMMON_PARALLEL_MPIHELPER_HH 6 #define DUNE_COMMON_PARALLEL_MPIHELPER_HH 135 [[maybe_unused]]
char** argv)
149 int rank ()
const {
return 0; }
153 int size ()
const {
return 1; }
157 FakeMPIHelper(
const FakeMPIHelper&);
158 FakeMPIHelper& operator=(
const FakeMPIHelper);
190 return MPI_COMM_WORLD;
201 return MPI_COMM_SELF;
262 assert((argc ==
nullptr) == (argv ==
nullptr));
270 int rank ()
const {
return rank_; }
274 int size ()
const {
return size_; }
279 int wasFinalized = -1;
280 MPI_Finalized( &wasFinalized );
281 if(!wasFinalized && initializedHere_)
284 dverb <<
"Called MPI_Finalize on p=" << rank_ <<
"!" <<std::endl;
292 bool initializedHere_;
293 void prevent_warning(
int){}
296 MPIHelper(
int* argc,
char*** argv)
297 : initializedHere_(false)
299 int wasInitialized = -1;
300 MPI_Initialized( &wasInitialized );
305 static int is_initialized = MPI_Init(argc, argv);
306 prevent_warning(is_initialized);
307 initializedHere_ =
true;
310 MPI_Comm_rank(MPI_COMM_WORLD,&rank_);
311 MPI_Comm_size(MPI_COMM_WORLD,&size_);
313 assert( rank_ >= 0 );
314 assert( size_ >= 1 );
316 dverb <<
"Called MPI_Init on p=" << rank_ <<
"!" << std::endl;
319 MPIHelper(
const MPIHelper&);
320 MPIHelper& operator=(
const MPIHelper);
329 typedef FakeMPIHelper MPIHelper;
335 #endif // DUNE_COMMON_PARALLEL_MPIHELPER_HH int rank() const
return rank of process
Definition: mpihelper.hh:270
static DUNE_EXPORT MPIHelper & instance(int &argc, char **&argv)
Get the singleton instance of the helper.
Definition: mpihelper.hh:228
static constexpr bool isFake
Are we fake (i. e. pretend to have MPI support but are compiled without.
Definition: mpihelper.hh:175
int rank() const
return rank of process, i.e. zero
Definition: mpihelper.hh:149
Implements an utility class that provides MPI's collective communication methods. ...
static Communication< MPICommunicator > getCommunication()
Definition: mpihelper.hh:114
static DUNE_EXPORT MPICommunicator getCommunicator()
get the default communicator
Definition: mpihelper.hh:95
static MPICommunicator getLocalCommunicator()
get a local communicator
Definition: mpihelper.hh:107
static MPICommunicator getCommunicator()
get the default communicator
Definition: mpihelper.hh:188
Definition of macros controlling symbol visibility at the ABI level.
DVerbType dverb(std::cout)
Singleton of verbose debug stream.
Definition: stdstreams.hh:117
int size() const
return number of processes
Definition: mpihelper.hh:274
static constexpr bool isFake
Are we fake (i.e. pretend to have MPI support but are compiled without.)
Definition: mpihelper.hh:82
#define DUNE_EXPORT
Export a symbol as part of the public ABI.
Definition: visibility.hh:20
static DUNE_EXPORT FakeMPIHelper & instance([[maybe_unused]] int argc, [[maybe_unused]] char **argv)
Get the singleton instance of the helper.
Definition: mpihelper.hh:134
No_Comm MPICommunicator
The type of the mpi communicator.
Definition: mpihelper.hh:87
int size() const
return rank of process, i.e. one
Definition: mpihelper.hh:153
Collective communication interface and sequential default implementation.
Definition: communication.hh:99
Dune namespace
Definition: alignedallocator.hh:12
A real mpi helper.This helper should be used for parallel programs.
Definition: mpihelper.hh:168
~MPIHelper()
calls MPI_Finalize
Definition: mpihelper.hh:277
static Communication< MPICommunicator > getCommunication()
Definition: mpihelper.hh:205
static MPICommunicator getLocalCommunicator()
get a local communicator
Definition: mpihelper.hh:199
static DUNE_EXPORT FakeMPIHelper & instance()
Definition: mpihelper.hh:140
A few common exception classes.
Standard Dune debug streams.
Definition: communication.hh:46
static DUNE_EXPORT MPIHelper & instance(int *argc=nullptr, char ***argv=nullptr)
Get the singleton instance of the helper.
Definition: mpihelper.hh:260
Implements an utility class that provides collective communication methods for sequential programs...
A fake mpi helper.
Definition: mpihelper.hh:75
MPI_Comm MPICommunicator
The type of the mpi communicator.
Definition: mpihelper.hh:180