Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TImplicitMT.cxx
Go to the documentation of this file.
1// @(#)root/thread:$Id$
2// // Author: Enric Tejedor Saavedra 03/12/15
3//
4/*************************************************************************
5 * Copyright (C) 1995-2015, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12//////////////////////////////////////////////////////////////////////////
13// //
14// TImplicitMT //
15// //
16// This file implements the methods to enable, disable and check the //
17// status of the global implicit multi-threading in ROOT. //
18// //
19//////////////////////////////////////////////////////////////////////////
20
21#include "TROOT.h"
22#include "TError.h"
23#include "ROOT/RTaskArena.hxx"
24#include <atomic>
25
26static std::shared_ptr<ROOT::Internal::RTaskArenaWrapper> &R__GetTaskArena4IMT()
27{
28 static std::shared_ptr<ROOT::Internal::RTaskArenaWrapper> globalTaskArena;
29 return globalTaskArena;
30}
31
36
37static bool &GetImplicitMTFlag()
38{
39 static bool enabled = false;
40 return enabled;
41}
42
43static std::atomic_int &GetParBranchProcessingCount()
44{
45 static std::atomic_int count(0);
46 return count;
47}
48
50{
51 if (!GetImplicitMTFlag()) {
53 GetImplicitMTFlag() = true;
54 } else {
55 ::Warning("ROOT_TImplicitMT_EnableImplicitMT", "Implicit multi-threading is already enabled");
56 }
57};
58
60{
61 if (!GetImplicitMTFlag()) {
62 if (config < ROOT::EIMTConfig::kNumConfigs) {
64 } else {
65 ::Warning("ROOT_TImplicitMT_EnableImplicitMT_Config",
66 "Unknown enum value %d defaulting to EIMTCconfig::kWholeMachine", (int)config);
68 }
69 GetImplicitMTFlag() = true;
70 } else {
71 ::Warning("ROOT_TImplicitMT_EnableImplicitMT_Config", "Implicit multi-threading is already enabled");
72 }
73};
74
76{
77 if (GetImplicitMTFlag()) {
78 GetImplicitMTFlag() = false;
79 R__GetTaskArena4IMT().reset();
80 } else {
81 ::Warning("ROOT_TImplicitMT_DisableImplicitMT", "Implicit multi-threading is already disabled");
82 }
83};
84
89
94
unsigned int UInt_t
Definition RtypesCore.h:46
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:229
bool ROOT_TImplicitMT_IsParBranchProcessingEnabled()
void ROOT_TImplicitMT_EnableImplicitMT_Config(ROOT::EIMTConfig config)
static std::atomic_int & GetParBranchProcessingCount()
void ROOT_TImplicitMT_DisableParBranchProcessing()
static bool & GetImplicitMTFlag()
void ROOT_TImplicitMT_EnableImplicitMT(UInt_t numthreads)
void ROOT_TImplicitMT_DisableImplicitMT()
static std::shared_ptr< ROOT::Internal::RTaskArenaWrapper > & R__GetTaskArena4IMT()
void ROOT_TImplicitMT_EnableParBranchProcessing()
UInt_t ROOT_MT_GetThreadPoolSize()
std::shared_ptr< ROOT::Internal::RTaskArenaWrapper > GetGlobalTaskArena(unsigned maxConcurrency=0)
Factory function returning a shared pointer to the instance of the global RTaskArenaWrapper.
EIMTConfig
Definition TROOT.h:83
@ kNumConfigs
Number of support IMT semantic configurations.