Dune Core Modules (unstable)

mpihelper.hh File Reference

Helpers for dealing with MPI. More...

#include <cassert>
#include <mutex>
#include <mpi.h>
#include <dune/common/exceptions.hh>
#include <dune/common/visibility.hh>
#include <dune/common/parallel/communication.hh>
#include <dune/common/parallel/mpicommunication.hh>
#include <dune/common/stdstreams.hh>

Go to the source code of this file.


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


namespace  Dune
 Dune namespace.

Detailed Description

Helpers for dealing with MPI.

Basically there are two helpers available:

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.
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){
typedef Dune::MPIHelper MPIHelper;
MPIHelper::instance(argc, argv);
typename MPIHelper::MPICommunicator world =
A real mpi helper.
Definition: mpihelper.hh:181

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!)

Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 22, 22:30, 2024)