|
|
|||
File indexing completed on 2025-12-13 10:27:02
0001 // @(#)root/thread:$Id$ 0002 // // Author: Xavier Valls Pla 08/05/20 0003 // 0004 /************************************************************************* 0005 * Copyright (C) 1995-2020, Rene Brun and Fons Rademakers. * 0006 * All rights reserved. * 0007 * * 0008 * For the licensing terms see $ROOTSYS/LICENSE. * 0009 * For the list of contributors see $ROOTSYS/README/CREDITS. * 0010 *************************************************************************/ 0011 0012 ////////////////////////////////////////////////////////////////////////// 0013 // // 0014 // RTaskArena // 0015 // // 0016 // This file implements the method to initialize and retrieve ROOT's // 0017 // global task arena, together with a method to check for active // 0018 // CPU bandwith control, and a class to wrap the tbb task arena with // 0019 // the purpose of keeping tbb off the installed headers // 0020 // // 0021 ////////////////////////////////////////////////////////////////////////// 0022 0023 #ifndef ROOT_RTaskArena 0024 #define ROOT_RTaskArena 0025 0026 #include "RConfigure.h" 0027 #include "TROOT.h" // For ROOT::EIMTConfig 0028 #include <memory> 0029 0030 // exclude in case ROOT does not have IMT support 0031 #ifndef R__USE_IMT 0032 // No need to error out for dictionaries. 0033 # if !defined(__ROOTCLING__) && !defined(G__DICTIONARY) 0034 # error "Cannot use ROOT::Internal::RTaskArenaWrapper if build option imt=OFF." 0035 # endif 0036 #else 0037 0038 namespace ROOT { 0039 0040 class ROpaqueTaskArena; 0041 0042 namespace Internal { 0043 0044 //////////////////////////////////////////////////////////////////////////////// 0045 /// Returns the available number of logical cores. 0046 /// 0047 /// - Checks if there is CFS bandwidth control in place (linux, via cgroups, 0048 /// assuming standard paths) 0049 /// - Otherwise, returns the number of logical cores provided by 0050 /// std::thread::hardware_concurrency() 0051 //////////////////////////////////////////////////////////////////////////////// 0052 int LogicalCPUBandwidthControl(); 0053 0054 //////////////////////////////////////////////////////////////////////////////// 0055 /// Wrapper for tbb::task_arena. 0056 /// 0057 /// Necessary in order to keep tbb away from ROOT headers. 0058 /// This class is thought out to be used as a singleton. 0059 /// 0060 /// tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow 0061 /// to forward declare tbb::task_arena without forward declaring tbb::interface7 0062 //////////////////////////////////////////////////////////////////////////////// 0063 class RTaskArenaWrapper { 0064 public: 0065 ~RTaskArenaWrapper(); // necessary to set size back to zero 0066 static unsigned TaskArenaSize(); // A static getter lets us check for RTaskArenaWrapper's existence 0067 ROOT::ROpaqueTaskArena &Access(); 0068 struct Attach {}; ///< Marker for attaching to an existing tbb::task_arena 0069 0070 RTaskArenaWrapper(unsigned maxConcurrency = 0); 0071 RTaskArenaWrapper(Attach); 0072 0073 private: 0074 friend std::shared_ptr<ROOT::Internal::RTaskArenaWrapper> GetGlobalTaskArena(unsigned, ROOT::EIMTConfig); 0075 std::unique_ptr<ROOT::ROpaqueTaskArena> fTBBArena; 0076 static unsigned fNWorkers; 0077 }; 0078 0079 0080 //////////////////////////////////////////////////////////////////////////////// 0081 /// Factory function returning a shared pointer to the instance of the global 0082 /// RTaskArenaWrapper. 0083 /// 0084 /// Allows for reinstantiation of the global RTaskArenaWrapper once all the 0085 /// references to the previous one are gone and the object destroyed. 0086 //////////////////////////////////////////////////////////////////////////////// 0087 std::shared_ptr<ROOT::Internal::RTaskArenaWrapper> GetGlobalTaskArena(unsigned maxConcurrency = 0); 0088 std::shared_ptr<ROOT::Internal::RTaskArenaWrapper> GetGlobalTaskArena(ROOT::EIMTConfig config); 0089 0090 } // namespace Internal 0091 } // namespace ROOT 0092 0093 #endif // R__USE_IMT 0094 #endif // ROOT_RTaskArena
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|