2#define TBB_USE_CAPTURED_EXCEPTION 0
14#include "tbb/task_arena.h"
15#define TBB_PREVIEW_GLOBAL_CONTROL 1
16#include "tbb/global_control.h"
56 Error(
"ROOT::Internal::LogicalCPUBandwidthControl()",
57 "cannot parse number in environment variable ROOT_MAX_THREADS; ignoring.");
59 Error(
"ROOT::Internal::LogicalCPUBandwidthControl()",
60 "environment variable ROOT_MAX_THREADS must be >= 1, but set to %ld; ignoring.",
68 std::ifstream
f(
"/sys/fs/cgroup/cpuacct/cpu.cfs_quota_us");
74 f.open(
"/sys/fs/cgroup/cpuacct/cpu.cfs_period_us");
82 return std::thread::hardware_concurrency();
99 Warning(
"RTaskArenaWrapper",
"CPU Bandwith Control Active. Proceeding with %d threads accordingly",
bcCpus);
102 if (
maxConcurrency > tbb::global_control::active_value(tbb::global_control::max_allowed_parallelism)) {
103 Warning(
"RTaskArenaWrapper",
"tbb::global_control is active, limiting the number of parallel workers"
104 "from this task arena available for execution.");
132 static std::weak_ptr<ROOT::Internal::RTaskArenaWrapper>
weak_GTAWrapper;
135 const std::lock_guard<std::mutex> lock{
m};
138 Warning(
"RTaskArenaWrapper",
"There's already an active task arena. Proceeding with the current %d threads",
139 sp->TaskArenaSize());
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.
R__EXTERN TSystem * gSystem
Wrapper for tbb::task_arena.
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.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
void EnableThreadSafety()
Enable support for multi-threading within the ROOT code in particular, enables the global mutex to ma...