Reference documentation for deal.II version 9.6.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
InitFinalize Class Reference

#include <deal.II/base/init_finalize.h>

Inheritance diagram for InitFinalize:

Classes

struct  Signals
 

Public Member Functions

 InitFinalize (int &argc, char **&argv, const InitializeLibrary &libraries, const unsigned int max_num_threads=numbers::invalid_unsigned_int)
 
 ~InitFinalize ()
 
void finalize ()
 

Static Public Member Functions

static void register_request (MPI_Request &request)
 
static void unregister_request (MPI_Request &request)
 

Static Public Attributes

static Signals signals = InitFinalize::Signals()
 

Private Attributes

InitializeLibrary libraries
 
bool is_finalized = false
 
bool finalize_petscslepc
 

Static Private Attributes

static std::set< MPI_Request * > requests
 

Detailed Description

A class that is used to initialize and finalize deal.II and the external libraries requested by the user.

Definition at line 98 of file init_finalize.h.

Constructor & Destructor Documentation

◆ InitFinalize()

InitFinalize::InitFinalize ( int & argc,
char **& argv,
const InitializeLibrary & libraries,
const unsigned int max_num_threads = numbers::invalid_unsigned_int )

Initialize deal.II and the requested external libraries.

Note
This function calls MultithreadInfo::set_thread_limit() with either max_num_threads or, 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 may access 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.
MultithreadInfo::set_thread_limit() can only work if it is called before any threads are created. The safest place for a call to it is therefore at the beginning of 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 main().

Definition at line 63 of file init_finalize.cc.

◆ ~InitFinalize()

InitFinalize::~InitFinalize ( )

Destructor. Finalize deal.II and the external libraries initialize by deal.II.

Definition at line 449 of file init_finalize.cc.

Member Function Documentation

◆ finalize()

void InitFinalize::finalize ( )

Finalize deal.II and the external libraries initialize by deal.II.

Definition at line 334 of file init_finalize.cc.

◆ register_request()

void InitFinalize::register_request ( MPI_Request & request)
static

Register a reference to an MPI_Request on which we need to call MPI_Wait before calling MPI_Finalize.

The object request needs to exist when MPI_Finalize is called, which means the request is typically statically allocated. Otherwise, you need to call unregister_request() before the request goes out of scope. Note that it is acceptable for a request to be already waited on (and consequently reset to MPI_REQUEST_NULL).

It is acceptable to call this function more than once with the same instance (as it is done in the example below).

Typically, this function is used by CollectiveMutex and not directly, but it can also be used directly like this:

void my_fancy_communication()
{
static MPI_Request request = MPI_REQUEST_NULL;
MPI_InitFinalize::register_request(request);
MPI_Wait(&request, MPI_STATUS_IGNORE);
// [some algorithm that is not safe to be executed twice in a row.]
MPI_IBarrier(comm, &request);
}
*braid_SplitCommworld & comm

Definition at line 309 of file init_finalize.cc.

◆ unregister_request()

void InitFinalize::unregister_request ( MPI_Request & request)
static

Unregister a request previously added using register_request().

Definition at line 318 of file init_finalize.cc.

Member Data Documentation

◆ signals

InitFinalize::Signals InitFinalize::signals = InitFinalize::Signals()
static

Definition at line 202 of file init_finalize.h.

◆ libraries

InitializeLibrary InitFinalize::libraries
private

Definition at line 205 of file init_finalize.h.

◆ requests

std::set< MPI_Request * > InitFinalize::requests
staticprivate

Requests to MPI_Wait before finalizing

Definition at line 210 of file init_finalize.h.

◆ is_finalized

bool InitFinalize::is_finalized = false
private

Definition at line 212 of file init_finalize.h.

◆ finalize_petscslepc

bool InitFinalize::finalize_petscslepc
private

Definition at line 215 of file init_finalize.h.


The documentation for this class was generated from the following files: