Reference documentation for deal.II version 8.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Static Private Member Functions | Private Attributes | List of all members

#include <multithread_info.h>

Public Member Functions

 MultithreadInfo ()
 
unsigned int n_threads () const
 
void set_thread_limit (const unsigned int max_threads=numbers::invalid_unsigned_int)
 
bool is_running_single_threaded ()
 
 DeclException0 (ExcProcNotPresent)
 

Static Public Member Functions

static std::size_t memory_consumption ()
 

Public Attributes

const unsigned int n_cpus
 
unsigned int n_default_threads DEAL_II_DEPRECATED
 

Static Private Member Functions

static unsigned int get_n_cpus ()
 

Private Attributes

unsigned int n_max_threads
 

Detailed Description

This class provides information about the system which may be of use in multithreaded programs. At the moment this is just the number of cpus. If deal.II is compiled with multithreading support, some functions will use multiple threads for their action. Currently the library supports both thread-based and task-based parallelism. Parallel computing with multiple processors accessing shared memory describes the different uses of each. Thread-based parallel methods will use the member variable n_default_threads of this class as a guide to the number of threads to start. This variable n_default_threads is set to the number of CPUs by default, but can be adjusted by the user to fit the requirements. The default number of threads used for task-based parallel methods is selected automatically by the Threading Building Blocks library. See Parallel computing with multiple processors accessing shared memory for more information on this. To set n_default_threads add the following at the start of your main(): multithread_info.n_default_threads=1;

Author
Thomas Richter, Wolfgang Bangerth, 2000

Definition at line 50 of file multithread_info.h.

Constructor & Destructor Documentation

MultithreadInfo::MultithreadInfo ( )

The constructor determines the number of CPUs in the system. At the moment detection of CPUs is only implemented on Linux computers with the /proc filesystem and on Sun machines. The number of CPUs present is set to one if detection failed or if detection is not supported.

Member Function Documentation

static std::size_t MultithreadInfo::memory_consumption ( )
static

Determine an estimate for the memory consumption (in bytes) of this object. Since sometimes the size of objects can not be determined exactly (for example: what is the memory consumption of an STL std::map type with a certain number of elements?), this is only an estimate. however often quite close to the true value.

void MultithreadInfo::set_thread_limit ( const unsigned int  max_threads = numbers::invalid_unsigned_int)

Sets the maximum number of threads to be used to the minimum of the environment variable DEAL_II_NUM_THREADS and the given parameter (if not the default value). This affects the initialization of the TBB. If neither is given, the default from TBB is used (based on the number of cores in the system).

This routine is called automatically by MPI_InitFinalize. Due to limitations in the way TBB can be controlled, only the first call to this method will have any effect. Use the parameter of the MPI_InitFinalize if you have an MPI based code.

bool MultithreadInfo::is_running_single_threaded ( )

Returns if the TBB is running using a single thread either because of thread affinity or because it is set via a call to set_thread_limit. This is used in the PETScWrappers to avoid using the interface that is not thread-safe.

MultithreadInfo::DeclException0 ( ExcProcNotPresent  )

Exception

static unsigned int MultithreadInfo::get_n_cpus ( )
staticprivate

Private function to determine the number of CPUs. Implementation for Linux, OSF, SGI, and Sun machines; if no detection of the number of CPUs is supported, or if detection fails, this function returns one.

Member Data Documentation

const unsigned int MultithreadInfo::n_cpus

The number of CPUs in the system. It is one if detection is not implemented or failed.

If it is one, although you are on a multi-processor machine, please refer to the documentation in multithread_info.cc near to the error directive.

Definition at line 80 of file multithread_info.h.

unsigned int n_default_threads MultithreadInfo::DEAL_II_DEPRECATED

The number of threads to use as a default value for all functions that support multithreading. At start time this is n_cpus or one, if detection of the number of CPUs is not possible.

Deprecated:
: use set_thread_limit() instead.

Definition at line 92 of file multithread_info.h.

unsigned int MultithreadInfo::n_max_threads
private

variable representing the maximum number of threads

Definition at line 163 of file multithread_info.h.


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