2#define TBB_USE_CAPTURED_EXCEPTION 0
15#include "tbb/task_arena.h"
16#define TBB_PREVIEW_GLOBAL_CONTROL 1
17#include "tbb/global_control.h"
57 Error(
"ROOT::Internal::LogicalCPUBandwidthControl()",
58 "cannot parse number in environment variable ROOT_MAX_THREADS; ignoring.");
60 Error(
"ROOT::Internal::LogicalCPUBandwidthControl()",
61 "environment variable ROOT_MAX_THREADS must be >= 1, but set to %ld; ignoring.",
69 std::ifstream
f(
"/sys/fs/cgroup/cpuacct/cpu.cfs_quota_us");
75 f.open(
"/sys/fs/cgroup/cpuacct/cpu.cfs_period_us");
83 return std::thread::hardware_concurrency();
100 Warning(
"RTaskArenaWrapper",
"CPU Bandwith Control Active. Proceeding with %d threads accordingly",
bcCpus);
103 if (
maxConcurrency > tbb::global_control::active_value(tbb::global_control::max_allowed_parallelism)) {
104 Warning(
"RTaskArenaWrapper",
"tbb::global_control is active, limiting the number of parallel workers"
105 "from this task arena available for execution.");
121 fTBBArena->initialize(tbb::task_arena::attach{});
145std::shared_ptr<ROOT::Internal::RTaskArenaWrapper>
148 static std::weak_ptr<ROOT::Internal::RTaskArenaWrapper>
weak_GTAWrapper;
151 const std::lock_guard<std::mutex> lock{
m};
154 Warning(
"RTaskArenaWrapper",
"There's already an active task arena. Proceeding with the current %d threads",
155 sp->TaskArenaSize());
159 std::shared_ptr<ROOT::Internal::RTaskArenaWrapper>
sp;
175 ::Fatal(
"ROOT::Internal::GetGlobalTaskArena",
176 "Unsupported enum value %d", (
int)config);
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
void Fatal(const char *location, const char *msgfmt,...)
Use this function in case of a fatal error. It will abort the program.
R__EXTERN TSystem * gSystem
ROOT::ROpaqueTaskArena & Access()
Provides access to the wrapped tbb::task_arena.
RTaskArenaWrapper(unsigned maxConcurrency=0)
Initializes the tbb::task_arena within RTaskArenaWrapper.
static unsigned fNWorkers
static unsigned TaskArenaSize()
std::unique_ptr< ROOT::ROpaqueTaskArena > fTBBArena
virtual const char * Getenv(const char *env)
Get environment variable.
int LogicalCPUBandwidthControl()
Returns the available number of logical cores.
std::shared_ptr< ROOT::Internal::RTaskArenaWrapper > GetGlobalTaskArena(unsigned maxConcurrency=0)
Factory function returning a shared pointer to the instance of the global RTaskArenaWrapper.
Namespace for new ROOT classes and functions.
void EnableThreadSafety()
Enable support for multi-threading within the ROOT code in particular, enables the global mutex to ma...
@ kWholeMachine
Default configuration.
@ kNumConfigs
Number of support IMT semantic configurations.
@ kExistingTBBArena
Use the existing TBB arena.
Marker for attaching to an existing tbb::task_arena.