dune-common  2.7.0
Classes | Namespaces | Typedefs
mpihelper.hh File Reference

Helpers for dealing with MPI. More...

#include <dune/common/parallel/communication.hh>
#include <dune/common/visibility.hh>

Go to the source code of this file.

Classes

class  Dune::FakeMPIHelper
 A fake mpi helper. More...
 

Namespaces

 Dune
 Dune namespace.
 

Typedefs

typedef FakeMPIHelper Dune::MPIHelper
 If no MPI is available FakeMPIHelper becomes the MPIHelper. More...
 

Detailed Description

Helpers for dealing with MPI.

Basically there are two helpers available:

FakeMPIHelper
A class adhering to the interface of MPIHelper that does not need MPI at all. This can be used to create a sequential program even if MPI is used to compile it.
MPIHelper
A real MPI helper. When the singleton gets instantiated MPI_Init will be called and before the program exits MPI_Finalize will be called.

Example of who to use these classes:

A program that is parallel if compiled with MPI and sequential otherwise:

int main(int argc, char** argv){
MPIHelper::instance(argc, argv);
typename MPIHelper::MPICommunicator world =
MPIHelper::getCommunicator();
...

If one wants to have sequential program even if the code is compiled with mpi then one simply has to exchange the typedef with

typedef Dune::MPIHelper FakeMPIHelper;

.

For checking whether we really use MPI or just fake please use MPIHelper::isFake (this is also possible at compile time!)

Dune::MPIHelper
FakeMPIHelper MPIHelper
If no MPI is available FakeMPIHelper becomes the MPIHelper.
Definition: mpihelper.hh:301
Dune::FakeMPIHelper
A fake mpi helper.
Definition: mpihelper.hh:69
main
int main(int argc, char **argv)
Definition: mpi_collective_benchmark.cc:291