![]() |
Reference documentation for deal.II version 8.1.0
|
#include <mpi.h>
Public Member Functions | |
MPI_InitFinalize (int &argc, char **&argv) | |
MPI_InitFinalize (int &argc, char **&argv, unsigned int max_num_threads) | |
~MPI_InitFinalize () | |
Private Member Functions | |
void | do_init (int &argc, char **&argv, unsigned int max_num_threads) |
Private Attributes | |
const bool | owns_mpi |
A class that is used to initialize the MPI system at the beginning of a program and to shut it down again at the end. It also allows you to control the number threads used in each MPI task.
If deal.II is configured with PETSc, the library will also be initialized in the beginning and destructed at the end automatically (internally by calling PetscInitialize() and PetscFinalize()).
If a program uses MPI one would typically just create an object of this type at the beginning of main()
. The constructor of this class then runs MPI_Init()
with the given arguments. At the end of the program, the compiler will invoke the destructor of this object which in turns calls MPI_Finalize
to shut down the MPI system.
This class is used in step-32, for example.
Utilities::MPI::MPI_InitFinalize::MPI_InitFinalize | ( | int & | argc, |
char **& | argv | ||
) |
Constructor. Takes the arguments from the command line (in case of MPI, the number of processes is specified there), and sets up a respective communicator by calling MPI_Init()
. This constructor can only be called once in a program, since MPI cannot be initialized twice.
This constructor sets max_num_threads to 1 (see other constructor).
Utilities::MPI::MPI_InitFinalize::MPI_InitFinalize | ( | int & | argc, |
char **& | argv, | ||
unsigned int | max_num_threads | ||
) |
Initialize MPI (and optionally PETSc) and set the number of threads used by deal.II (and TBB) to the given parameter. If set to numbers::invalid_unsigned_int, the number of threads is determined by TBB. When in doubt, set this value to 1.
Utilities::MPI::MPI_InitFinalize::~MPI_InitFinalize | ( | ) |
Destructor. Calls MPI_Finalize()
in case this class owns the MPI process.
|
private |
Called by the constructors.
|
private |