CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ThreadsInfo.cc
Go to the documentation of this file.
1 //
2 // ThreadsInfo.cc
3 // CMSSW
4 //
5 // Created by Chris Jones on 7/24/20.
6 //
9 
10 namespace edm {
12  // default values
13  ThreadsInfo threadsInfo;
14 
15  if (pset.existsAs<edm::ParameterSet>("options", false)) {
16  auto const& ops = pset.getUntrackedParameterSet("options");
17  if (ops.existsAs<unsigned int>("numberOfThreads", false)) {
18  threadsInfo.nThreads_ = ops.getUntrackedParameter<unsigned int>("numberOfThreads");
19  }
20  if (ops.existsAs<unsigned int>("sizeOfStackForThreadsInKB", false)) {
21  threadsInfo.stackSize_ = ops.getUntrackedParameter<unsigned int>("sizeOfStackForThreadsInKB");
22  }
23  }
24  return threadsInfo;
25  }
26 
27  void setThreadOptions(ThreadsInfo const& threadsInfo, edm::ParameterSet& pset) {
28  edm::ParameterSet newOp;
29  if (pset.existsAs<edm::ParameterSet>("options", false)) {
30  newOp = pset.getUntrackedParameterSet("options");
31  }
32  newOp.addUntrackedParameter<unsigned int>("numberOfThreads", threadsInfo.nThreads_);
33  newOp.addUntrackedParameter<unsigned int>("sizeOfStackForThreadsInKB", threadsInfo.stackSize_);
34  pset.insertParameterSet(true, "options", edm::ParameterSetEntry(newOp, false));
35  }
36 } // namespace edm
void setThreadOptions(ThreadsInfo const &threadsInfo, edm::ParameterSet &pset)
Definition: ThreadsInfo.cc:27
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
unsigned int stackSize_
Definition: ThreadsInfo.h:14
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:192
void insertParameterSet(bool okay_to_replace, std::string const &name, ParameterSetEntry const &entry)
ThreadsInfo threadOptions(edm::ParameterSet const &pset)
Definition: ThreadsInfo.cc:11
unsigned int nThreads_
Definition: ThreadsInfo.h:13