Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:12:57

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     // Note: it is important to not check the type or trackedness in
0016     // exists() call to ensure that the getUntrackedParameter() calls
0017     // will fail if the parameters have an incorrect type
0018     if (pset.exists("options")) {
0019       auto const& ops = pset.getUntrackedParameterSet("options");
0020       if (ops.exists("numberOfThreads")) {
0021         threadsInfo.nThreads_ = ops.getUntrackedParameter<unsigned int>("numberOfThreads");
0022       }
0023       if (ops.exists("sizeOfStackForThreadsInKB")) {
0024         threadsInfo.stackSize_ = ops.getUntrackedParameter<unsigned int>("sizeOfStackForThreadsInKB");
0025       }
0026     }
0027     return threadsInfo;
0028   }
0029 
0030   void setThreadOptions(ThreadsInfo const& threadsInfo, edm::ParameterSet& pset) {
0031     edm::ParameterSet newOp;
0032     if (pset.exists("options")) {
0033       newOp = pset.getUntrackedParameterSet("options");
0034     }
0035     newOp.addUntrackedParameter<unsigned int>("numberOfThreads", threadsInfo.nThreads_);
0036     newOp.addUntrackedParameter<unsigned int>("sizeOfStackForThreadsInKB", threadsInfo.stackSize_);
0037     pset.insertParameterSet(true, "options", edm::ParameterSetEntry(newOp, false));
0038   }
0039 }  // namespace edm