Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:11:56

0001 //
0002 //  setNThreads.cc
0003 //  CMSSW
0004 //
0005 //  Created by Chris Jones on 7/24/20.
0006 //
0007 #include "oneapi/tbb/task_arena.h"
0008 #include "FWCore/Concurrency/interface/setNThreads.h"
0009 
0010 namespace edm {
0011   unsigned int setNThreads(unsigned int iNThreads, unsigned int iStackSize, std::unique_ptr<ThreadsController>& oPtr) {
0012     //stack size is given in KB but passed in as bytes
0013     iStackSize *= 1024;
0014 
0015     oPtr.reset();
0016     if (0 == iNThreads) {
0017       //Allow TBB to decide how many threads. This is normally the number of CPUs in the machine.
0018       iNThreads = oneapi::tbb::this_task_arena::max_concurrency();
0019     }
0020     oPtr = std::make_unique<ThreadsController>(static_cast<int>(iNThreads), iStackSize);
0021 
0022     return iNThreads;
0023   }
0024 }  // namespace edm