![]() |
Peano
|
#include <Core.h>
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 Core & | getInstance () |
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. | |
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.
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().
numberOfThreads | Number 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. |
Definition at line 61 of file Core.cpp.
Referenced by main(), and swift2::parseCommandLineArguments().
int tarch::multicore::Core::getCoreNumber | ( | ) | const |
|
static |
Definition at line 56 of file Core.cpp.
Referenced by tarch::multicore::orchestration::GeneticOptimisation::createInitialConfigurations(), examples::regulargridupscaling::MyObserver::enterCell(), tarch::logging::Log::error(), toolbox::loadbalancing::strategies::Hardcoded::finishStep(), toolbox::loadbalancing::strategies::SpreadOutHierarchically::getAction(), toolbox::loadbalancing::strategies::SpreadOutHierarchically::getNumberOfSplitsOnLocalRank(), tarch::multicore::orchestration::GeneticOptimisation::getNumberOfTasksToFuseAndTargetDevice(), toolbox::loadbalancing::strategies::SpreadOut::getNumberOfTreesPerRank(), toolbox::loadbalancing::strategies::SpreadOutOnceGridStagnates::getNumberOfTreesPerRank(), toolbox::loadbalancing::strategies::SplitOversizedTree::getTargetTreeCost(), tarch::logging::CommandLineLogger::indent(), tarch::logging::Log::info(), peano4::initParallelEnvironment(), swift2::TaskEnumerator::lockResources(), main(), swift2::parseCommandLineArguments(), peano4::grid::TraversalVTKPlotter::plotCell(), tarch::multicore::taskfusion::ProcessReadyTask::run(), runParallel(), peano4::shutdownParallelEnvironment(), tarch::multicore::native::spawnAndWaitAsTaskLoop(), step(), peano4::parallel::tests::PingPongTest::testMultithreadedPingPongWithBlockingReceives(), peano4::parallel::tests::PingPongTest::testMultithreadedPingPongWithBlockingSends(), peano4::parallel::tests::PingPongTest::testMultithreadedPingPongWithBlockingSendsAndReceives(), peano4::parallel::tests::PingPongTest::testMultithreadedPingPongWithNonblockingReceives(), peano4::parallel::tests::PingPongTest::testMultithreadedPingPongWithNonblockingSends(), peano4::parallel::tests::PingPongTest::testMultithreadedPingPongWithNonblockingSendsAndReceives(), exahype2::LoadBalancingConfiguration::translateSetMaxNumberOfTreesIntoRealNumberOfTrees(), toolbox::loadbalancing::strategies::SpreadOutHierarchically::updateLoadBalancing(), toolbox::loadbalancing::strategies::SpreadOutHierarchically::updateState(), tarch::logging::Log::warning(), and peano4::writeCopyrightMessage().
int tarch::multicore::Core::getNumberOfThreads | ( | ) | const |
Returns the number of threads that is used.
Definition at line 67 of file Core.cpp.
Referenced by examples::regulargridupscaling::MyObserver::enterCell(), toolbox::loadbalancing::strategies::Hardcoded::finishStep(), toolbox::loadbalancing::strategies::SpreadOutHierarchically::getAction(), toolbox::loadbalancing::strategies::SpreadOutHierarchically::getNumberOfSplitsOnLocalRank(), toolbox::loadbalancing::strategies::SpreadOut::getNumberOfTreesPerRank(), toolbox::loadbalancing::strategies::SplitOversizedTree::getTargetTreeCost(), main(), runParallel(), step(), peano4::parallel::tests::PingPongTest::testMultithreadedPingPongWithBlockingReceives(), peano4::parallel::tests::PingPongTest::testMultithreadedPingPongWithBlockingSends(), peano4::parallel::tests::PingPongTest::testMultithreadedPingPongWithBlockingSendsAndReceives(), peano4::parallel::tests::PingPongTest::testMultithreadedPingPongWithNonblockingReceives(), peano4::parallel::tests::PingPongTest::testMultithreadedPingPongWithNonblockingSends(), peano4::parallel::tests::PingPongTest::testMultithreadedPingPongWithNonblockingSendsAndReceives(), and exahype2::LoadBalancingConfiguration::translateSetMaxNumberOfTreesIntoRealNumberOfTrees().
int tarch::multicore::Core::getThreadNumber | ( | ) | const |
bool tarch::multicore::Core::isInitialised | ( | ) | const |
void tarch::multicore::Core::shutdown | ( | ) |
Shutdown parallel environment.
Definition at line 63 of file Core.cpp.
Referenced by peano4::shutdownParallelEnvironment().
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.
Definition at line 80 of file Core.cpp.
Referenced by swift2::TaskEnumerator::lockResources(), tarch::multicore::taskfusion::ProcessReadyTask::run(), and tarch::multicore::native::spawnAndWaitAsTaskLoop().
|
staticprivate |
|
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.
Referenced by main(), and swift2::parseCommandLineArguments().