![]() |
|
|||
File indexing completed on 2025-07-05 09:08:09
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 /// tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow 0039 /// to forward declare tbb::task_arena without forward declaring tbb::interface7 0040 0041 namespace ROOT { 0042 0043 class ROpaqueTaskArena; 0044 0045 namespace Internal { 0046 0047 //////////////////////////////////////////////////////////////////////////////// 0048 /// Returns the available number of logical cores. 0049 /// 0050 /// - Checks if there is CFS bandwidth control in place (linux, via cgroups, 0051 /// assuming standard paths) 0052 /// - Otherwise, returns the number of logical cores provided by 0053 /// std::thread::hardware_concurrency() 0054 //////////////////////////////////////////////////////////////////////////////// 0055 int LogicalCPUBandwidthControl(); 0056 0057 0058 //////////////////////////////////////////////////////////////////////////////// 0059 /// Wrapper for tbb::task_arena. 0060 /// 0061 /// Necessary in order to keep tbb away from ROOT headers. 0062 /// This class is thought out to be used as a singleton. 0063 //////////////////////////////////////////////////////////////////////////////// 0064 class RTaskArenaWrapper { 0065 public: 0066 ~RTaskArenaWrapper(); // necessary to set size back to zero 0067 static unsigned TaskArenaSize(); // A static getter lets us check for RTaskArenaWrapper's existence 0068 ROOT::ROpaqueTaskArena &Access(); 0069 struct Attach {}; ///< Marker for attaching to an existing tbb::task_arena 0070 0071 RTaskArenaWrapper(unsigned maxConcurrency = 0); 0072 RTaskArenaWrapper(Attach); 0073 0074 private: 0075 friend std::shared_ptr<ROOT::Internal::RTaskArenaWrapper> GetGlobalTaskArena(unsigned, ROOT::EIMTConfig); 0076 std::unique_ptr<ROOT::ROpaqueTaskArena> fTBBArena; 0077 static unsigned fNWorkers; 0078 }; 0079 0080 0081 //////////////////////////////////////////////////////////////////////////////// 0082 /// Factory function returning a shared pointer to the instance of the global 0083 /// RTaskArenaWrapper. 0084 /// 0085 /// Allows for reinstantiation of the global RTaskArenaWrapper once all the 0086 /// references to the previous one are gone and the object destroyed. 0087 //////////////////////////////////////////////////////////////////////////////// 0088 std::shared_ptr<ROOT::Internal::RTaskArenaWrapper> GetGlobalTaskArena(unsigned maxConcurrency = 0); 0089 std::shared_ptr<ROOT::Internal::RTaskArenaWrapper> GetGlobalTaskArena(ROOT::EIMTConfig config); 0090 0091 } // namespace Internal 0092 } // namespace ROOT 0093 0094 #endif // R__USE_IMT 0095 #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 |
![]() ![]() |