Peano
Loading...
Searching...
No Matches
tarch::multicore::Core Class Reference

Core. More...

#include <Core.h>

Collaboration diagram for tarch::multicore::Core:

Public Member Functions

 ~Core ()
 Destructor.
 
void configure (int numberOfThreads=UseDefaultNumberOfThreads)
 Configure the whole node, i.e.
 
void shutdown ()
 Shutdown parallel environment.
 
bool isInitialised () const
 
int getNumberOfThreads () const
 Returns the number of threads that is used.
 
int getCoreNumber () const
 
int getThreadNumber () const
 
void yield ()
 Wrapper around backend-specific yield.
 

Static Public Member Functions

static CoregetInstance ()
 

Static Public Attributes

static constexpr int UseDefaultNumberOfThreads = 0
 The default is what the system management typically gives you.
 

Private Member Functions

 Core ()
 

Private Attributes

int _numberOfThreads
 

Static Private Attributes

static tarch::logging::Log _log
 Logging device.
 

Detailed Description

Core.

Any shared memory implementation has to provide a singleton Core. Its full qualified name is tarch::multicore::Core. If no shared memory variant is switched on, Peano provides a default Core implementation that does nothing.

If you don't configure the core explicitly, it will try to use some meaningful default.

See also
configure()
Author
Tobias Weinzierl

Definition at line 50 of file Core.h.

Constructor & Destructor Documentation

◆ Core()

tarch::multicore::Core::Core ( )
private

◆ ~Core()

tarch::multicore::Core::~Core ( )

Destructor.

Member Function Documentation

◆ configure()

void tarch::multicore::Core::configure ( int numberOfThreads = UseDefaultNumberOfThreads)

Configure the whole node, i.e.

all cores available on a node. If numberOfThreads equals the default, the routine will use the hardware concurrency to determine the number of threads that should be used. On SLURM-based HPC platforms, this will be wrong if multiple MPI ranks are placed on one node. It is also a bad choice if hyperthreading should not/can not be used. Use the helper function getNumberOfUnmaskedThreads().

Parameters
numberOfThreadsNumber of threads that shall be used. This parameter either is greater than zero (which defines the number of threads) or it equals DefaultNumberOfThreads which means that the code should use the default number of threads.

◆ getCoreNumber()

int tarch::multicore::Core::getCoreNumber ( ) const
Returns
Physical core the process is running on

◆ getInstance()

static Core & tarch::multicore::Core::getInstance ( )
static
Returns
Singleton instance

◆ getNumberOfThreads()

int tarch::multicore::Core::getNumberOfThreads ( ) const

Returns the number of threads that is used.

Returns
Number of threads available.

◆ getThreadNumber()

int tarch::multicore::Core::getThreadNumber ( ) const
Returns
Logical thread number

◆ isInitialised()

bool tarch::multicore::Core::isInitialised ( ) const
Returns
Shared memory environment is up and running. Most shared memory implementations work properly with the defaults. They just return true always.

◆ shutdown()

void tarch::multicore::Core::shutdown ( )

Shutdown parallel environment.

◆ yield()

void tarch::multicore::Core::yield ( )

Wrapper around backend-specific yield.

For most backends, this should not really be a yield(). It should interrupt the current task, not the current thread, and tell the runtime to continue with another task.

Besides the yield, we should process pending fused tasks.

Field Documentation

◆ _log

tarch::logging::Log tarch::multicore::Core::_log
staticprivate

Logging device.

Definition at line 55 of file Core.h.

◆ _numberOfThreads

int tarch::multicore::Core::_numberOfThreads
private

Definition at line 59 of file Core.h.

◆ UseDefaultNumberOfThreads

constexpr int tarch::multicore::Core::UseDefaultNumberOfThreads = 0
staticconstexpr

The default is what the system management typically gives you.

So if you run four ranks on a 24 core node, then each MPI rank will get 6 threads if you choose this constant.

Multiply with two to exploit hyperthreading.

Definition at line 69 of file Core.h.


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