File indexing completed on 2024-04-06 12:11:55
0001 #ifndef FWCore_Concurrency_ThreadsController_h
0002 #define FWCore_Concurrency_ThreadsController_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #include "oneapi/tbb/global_control.h"
0023 #include "oneapi/tbb/task_arena.h"
0024 #include <memory>
0025
0026
0027
0028
0029
0030 namespace edm {
0031 class ThreadsController {
0032 public:
0033 ThreadsController() = delete;
0034 explicit ThreadsController(unsigned int iNThreads)
0035 : m_nThreads{oneapi::tbb::global_control::max_allowed_parallelism, iNThreads}, m_stackSize{} {}
0036 ThreadsController(unsigned int iNThreads, size_t iStackSize)
0037 : m_nThreads{oneapi::tbb::global_control::max_allowed_parallelism, iNThreads},
0038 m_stackSize{makeStackSize(iStackSize)} {}
0039
0040
0041 void setStackSize(size_t iStackSize) { m_stackSize = makeStackSize(iStackSize); }
0042
0043 private:
0044 static std::unique_ptr<oneapi::tbb::global_control> makeStackSize(size_t iStackSize);
0045
0046
0047 oneapi::tbb::global_control m_nThreads;
0048 std::unique_ptr<oneapi::tbb::global_control> m_stackSize;
0049 };
0050 }
0051
0052 #endif