Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:28:59

0001 //
0002 //  ThreadsInfo.cc
0003 //  CMSSW
0004 //
0005 //  Created by Chris Jones on 7/24/20.
0006 //
0007 #include "FWCore/ParameterSet/interface/ThreadsInfo.h"
0008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0009 
0010 namespace edm {
0011   ThreadsInfo threadOptions(edm::ParameterSet const& pset) {
0012     // default values
0013     ThreadsInfo threadsInfo;
0014 
0015     if (pset.existsAs<edm::ParameterSet>("options", false)) {
0016       auto const& ops = pset.getUntrackedParameterSet("options");
0017       if (ops.existsAs<unsigned int>("numberOfThreads", false)) {
0018         threadsInfo.nThreads_ = ops.getUntrackedParameter<unsigned int>("numberOfThreads");
0019       }
0020       if (ops.existsAs<unsigned int>("sizeOfStackForThreadsInKB", false)) {
0021         threadsInfo.stackSize_ = ops.getUntrackedParameter<unsigned int>("sizeOfStackForThreadsInKB");
0022       }
0023     }
0024     return threadsInfo;
0025   }
0026 
0027   void setThreadOptions(ThreadsInfo const& threadsInfo, edm::ParameterSet& pset) {
0028     edm::ParameterSet newOp;
0029     if (pset.existsAs<edm::ParameterSet>("options", false)) {
0030       newOp = pset.getUntrackedParameterSet("options");
0031     }
0032     newOp.addUntrackedParameter<unsigned int>("numberOfThreads", threadsInfo.nThreads_);
0033     newOp.addUntrackedParameter<unsigned int>("sizeOfStackForThreadsInKB", threadsInfo.stackSize_);
0034     pset.insertParameterSet(true, "options", edm::ParameterSetEntry(newOp, false));
0035   }
0036 }  // namespace edm