8#ifdef CompilerHasSysinfo
22 _numberOfThreads( omp_get_max_threads() ) {
36 if ( omp_get_num_procs() != omp_get_max_threads() ) {
37 logWarning(
"configure(int)",
"omp_get_num_procs reports " << omp_get_num_procs() <<
" while omp_get_max_threads reports " << omp_get_max_threads() <<
". Take smaller value to avoid overbooking" );
39 int maxThreads = std::min(omp_get_num_procs(), omp_get_max_threads());
41 if (numberOfThreads!=UseDefaultNumberOfThreads) {
42 if ( maxThreads!=numberOfThreads ) {
43 logWarning(
"configure(int)",
"number of threads configured (" << numberOfThreads <<
") does not match system thread level of " << maxThreads <<
". OpenMP may ignore manual thread count reset");
46 omp_set_num_threads(numberOfThreads);
47 _numberOfThreads = omp_get_max_threads();
48 logInfo(
"configure(int)",
"manually reset number of threads used to " << numberOfThreads );
50 omp_set_num_threads(maxThreads);
51 _numberOfThreads = omp_get_max_threads();
70 return _numberOfThreads;
75 return omp_get_thread_num();
80 #ifdef CompilerHasSysinfo
81 return sched_getcpu();
#define logWarning(methodName, logMacroMessageStream)
Wrapper macro around tarch::tarch::logging::Log to improve logging.
#define logInfo(methodName, logMacroMessageStream)
Wrapper macro around tarch::tarch::logging::Log to improve logging.
bool isInitialised() const
int getCoreNumber() const
static Core & getInstance()
int getNumberOfThreads() const
Returns the number of threads that is used.
static tarch::logging::Log _log
Logging device.
void configure(int numberOfThreads=UseDefaultNumberOfThreads)
Configure the whole node, i.e.
void shutdown()
Shutdown parallel environment.
int getThreadNumber() const
void yield()
Wrapper around backend-specific yield.
void processAllReadyTasks()
std::string printUnmaskedThreads()
Creates a string representation of those threads which are available to the processes.
int getNumberOfUnmaskedThreads()
This routine runs through the Unix thread mask and counts how many threads SLURM allows a code to use...