Reference documentation for deal.II version Git 3ecc854 2017-02-27 14:34:24 -0500
|MPI_InitFinalize (int &argc, char **&argv, const unsigned int max_num_threads=numbers::invalid_unsigned_int)|
If deal.II is configured with PETSc, the library will be initialized in the beginning and destroyed at the end automatically (internally by calling PetscInitialize() and PetscFinalize()).
If deal.II is configured with p4est, that library will also be initialized in the beginning, and destroyed at the end automatically (internally by calling sc_init(), p4est_init(), and sc_finalize()).
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.
|const unsigned int||max_num_threads =
Initialize MPI (and, if deal.II was configured to use it, PETSc) and set the number of threads used by deal.II (via the underlying Threading Building Blocks library) to the given parameter.
|[in,out]||argc||A reference to the 'argc' argument passed to main. This argument is used to initialize MPI (and, possibly, PETSc) as they read arguments from the command line.|
|[in,out]||argv||A reference to the 'argv' argument passed to main.|
|[in]||max_num_threads||The maximal number of threads this MPI process should utilize. If this argument is set to numbers::invalid_unsigned_int (the default value), then the number of threads is determined automatically in the following way: the number of threads to run on this MPI process is set in such a way that all of the cores in your node are spoken for. In other words, if you have started one MPI process per node, setting this argument is equivalent to setting it to the number of cores present in the node this MPI process runs on. If you have started as many MPI processes per node as there are cores on each node, then this is equivalent to passing 1 as the argument. On the other hand, if, for example, you start 4 MPI processes on each 16-core node, then this option will start 4 worker threads for each node. If you start 3 processes on an 8 core node, then they will start 3, 3 and 2 threads, respectively.|
max_num_threadsor, following the discussion above, a number of threads equal to the number of cores allocated to this MPI process. However, MultithreadInfo::set_thread_limit() in turn also evaluates the environment variable DEAL_II_NUM_THREADS. Finally, the worker threads can only be created on cores to which the current MPI process has access to; some MPI implementations limit the number of cores each process has access to to one or a subset of cores in order to ensure better cache behavior. Consequently, the number of threads that will really be created will be the minimum of the argument passed here, the environment variable (if set), and the number of cores accessible to the thread.
main(). Consequently, this extends to the current class: the best place to create an object of this type is also at or close to the top of