CMS 3D CMS Logo

validateTopLevelParameterSets.cc
Go to the documentation of this file.
2 
4 
8 
10 
11 #include <sstream>
12 #include <vector>
13 #include <string>
14 
15 namespace edm {
16 
17  // NOTE: The defaults given here are not actually used when running cmsRun
18  // Those come from hard coded values in the Python code in Config.py
19  // The defaults here are used when running the edmPluginHelp utility so
20  // it is important the defaults in both places are consistent.
21 
23  description.addUntracked<unsigned int>("numberOfThreads", s_defaultNumberOfThreads)
24  ->setComment("If zero, let TBB use its default which is normally the number of CPUs on the machine");
25  description.addUntracked<unsigned int>("numberOfStreams", 0)
26  ->setComment(
27  "If zero, then set the number of streams to be the same as the number of "
28  "Threads (except always 1 if there is a looper)");
29  description.addUntracked<unsigned int>("numberOfConcurrentLuminosityBlocks", 0)
30  ->setComment(
31  "If zero, use Framework default (currently 2 when the number of streams >= 2, otherwise 1). "
32  "In all cases, the number of concurrent luminosity blocks will be reset to "
33  "be the same as the number of streams if it is greater than the "
34  "numbers of streams.");
35  description.addUntracked<unsigned int>("numberOfConcurrentRuns", 1)
36  ->setComment(
37  "If zero or greater than the number of concurrent luminosity blocks, this will be reset to "
38  "be the same as the number of concurrent luminosity blocks.");
39 
40  edm::ParameterSetDescription eventSetupDescription;
41  eventSetupDescription.addUntracked<unsigned int>("numberOfConcurrentIOVs", 0)
42  ->setComment(
43  "If zero, use the Framework default which currently means the same as the "
44  "number of concurrent luminosity blocks. Can be overridden by a hard coded "
45  "static in a record C++ definition or by forceNumberOfConcurrentIOVs. "
46  "In all cases, the number of concurrent IOVs will be reset to be the "
47  "same as the number of concurrent luminosity blocks if greater than the "
48  "number of concurrent luminosity blocks.");
49  edm::ParameterSetDescription nestedDescription;
50  nestedDescription.addWildcardUntracked<unsigned int>("*")->setComment(
51  "Parameter names should be record names and the values are the number of concurrent IOVS for each record."
52  " Overrides all other methods of setting number of concurrent IOVs.");
53  eventSetupDescription.addUntracked<edm::ParameterSetDescription>("forceNumberOfConcurrentIOVs", nestedDescription);
54  description.addUntracked<edm::ParameterSetDescription>("eventSetup", eventSetupDescription);
55 
56  description.addUntracked<std::vector<std::string>>("accelerators", {"*"})
57  ->setComment(
58  "Specify the set of compute accelerator(s) the job is allowed to use. The values can contain the direct "
59  "names of accelerators supported by the ProcessAccelerators defined in the configuration, or patterns "
60  "matching to them (patterns use '*' and '?' wildcards similar to shell). The actual set of accelerators to "
61  "be used is determined on the worker node based on the available hardware. A CPU fallback with the name "
62  "'cpu' is always included in the set of available accelerators. If no accelerator matching to the patterns "
63  "are available on the worker node, the job is terminated with a specific error code. Same happens if an "
64  "empty value is given in the configuration. Default value is pattern '*', which implies use of any "
65  "supported and available hardware (including the CPU fallback).");
66  description.addUntracked<bool>("wantSummary", false)
67  ->setComment("Set true to print a report on the trigger decisions and timing of modules");
68  description.addUntracked<std::string>("fileMode", "FULLMERGE")
69  ->setComment("Legal values are 'NOMERGE' and 'FULLMERGE'");
70  description.addUntracked<bool>("forceEventSetupCacheClearOnNewRun", false);
71  description.addUntracked<bool>("throwIfIllegalParameter", true)
72  ->setComment("Set false to disable exception throws when configuration validation detects illegal parameters");
73  description.addUntracked<bool>("printDependencies", false)->setComment("Print data dependencies between modules");
74  description.addUntracked<bool>("deleteNonConsumedUnscheduledModules", true)
75  ->setComment(
76  "Delete modules that are unscheduled, i.e. only in Tasks, whose products are not consumed by any other "
77  "otherwise-running module");
78 
79  // No default for this one because the parameter value is
80  // actually used in the main function in cmsRun.cpp before
81  // the parameter set is validated here.
82  description.addOptionalUntracked<unsigned int>("sizeOfStackForThreadsInKB");
83 
84  std::vector<std::string> emptyVector;
85 
86  description.addUntracked<std::vector<std::string>>("Rethrow", emptyVector);
87  description.addUntracked<std::vector<std::string>>("TryToContinue", emptyVector);
88  description.addUntracked<std::vector<std::string>>("IgnoreCompletely", emptyVector);
89 
90  description.addUntracked<std::vector<std::string>>("modulesToCallForTryToContinue", emptyVector)
91  ->setComment("Labels of modules which should still be called when an exception in TryToContinue list happens.");
92 
93  description.addUntracked<std::vector<std::string>>("canDeleteEarly", emptyVector)
94  ->setComment("Branch names of products that the Framework can try to delete before the end of the Event");
95 
96  {
98  validator.add<std::string>("product");
99  validator.add<std::vector<std::string>>("references")
100  ->setComment("All the branch names for products to which 'product' contains a reference.");
101  description.addVPSetUntracked("holdsReferencesToDeleteEarly", validator, std::vector<edm::ParameterSet>{})
102  ->setComment(
103  "The 'product' branch name of product which internally hold references to data in another product");
104  }
105  description.addUntracked<std::vector<std::string>>("modulesToIgnoreForDeleteEarly", emptyVector)
106  ->setComment(
107  "labels of modules whose consumes information will be ingored when determing lifetime for delete early "
108  "data products");
109  description.addUntracked<bool>("dumpOptions", false)
110  ->setComment(
111  "Print values of selected Framework parameters. The Framework might modify the values "
112  "in the options parameter set and this prints the values after that modification.");
113 
114  description.addOptionalUntracked<bool>("allowUnscheduled")
115  ->setComment(
116  "Obsolete. Has no effect. Allowed only for backward compatibility for old Python configuration files.");
117  description.addOptionalUntracked<std::string>("emptyRunLumiMode")
118  ->setComment(
119  "Obsolete. Has no effect. Allowed only for backward compatibility for old Python configuration files.");
120  description.addOptionalUntracked<bool>("makeTriggerResults")
121  ->setComment(
122  "Obsolete. Has no effect. Allowed only for backward compatibility for old Python configuration files.");
123  }
124 
126  description.addUntracked<int>("input", -1)->setComment("Default of -1 implies no limit.");
127 
128  ParameterSetDescription nestedDescription;
129  nestedDescription.addWildcardUntracked<int>("*");
130  description.addOptionalNode(ParameterDescription<int>("output", false) xor
131  ParameterDescription<ParameterSetDescription>("output", nestedDescription, false),
132  false);
133  }
134 
136  description.addUntracked<int>("input", -1)->setComment("Default of -1 implies no limit.");
137  }
138 
140  description.addUntracked<int>("input", -1)->setComment("Default of -1 implies no limit.");
141  }
142 
143  void validateTopLevelParameterSets(ParameterSet* processParameterSet) {
144  std::string processName = processParameterSet->getParameter<std::string>("@process_name");
145 
146  std::vector<std::string> psetNames{"options", "maxEvents", "maxLuminosityBlocks", "maxSecondsUntilRampdown"};
147 
148  for (auto const& psetName : psetNames) {
149  bool isTracked{false};
150  ParameterSet* pset = processParameterSet->getPSetForUpdate(psetName, isTracked);
151  if (pset == nullptr) {
152  ParameterSet emptyPset;
153  processParameterSet->addUntrackedParameter<ParameterSet>(psetName, emptyPset);
154  pset = processParameterSet->getPSetForUpdate(psetName, isTracked);
155  }
156  if (isTracked) {
157  throw Exception(errors::Configuration) << "In the configuration the top level parameter set named \'"
158  << psetName << "\' in process \'" << processName << "\' is tracked.\n"
159  << "It must be untracked";
160  }
161 
163  if (psetName == "options") {
165  } else if (psetName == "maxEvents") {
167  } else if (psetName == "maxLuminosityBlocks") {
169  } else if (psetName == "maxSecondsUntilRampdown") {
171  }
172 
173  try {
174  description.validate(*pset);
175  } catch (cms::Exception& ex) {
176  std::ostringstream ost;
177  ost << "Validating top level \'" << psetName << "\' ParameterSet for process \'" << processName << "\'";
178  ex.addContext(ost.str());
179  throw;
180  }
181  }
182  }
183 
184  void dumpOptionsToLogFile(unsigned int nThreads,
185  unsigned int nStreams,
186  unsigned int nConcurrentLumis,
187  unsigned int nConcurrentRuns) {
188  LogAbsolute("Options") << "Number of Threads = " << nThreads << "\nNumber of Streams = " << nStreams
189  << "\nNumber of Concurrent Lumis = " << nConcurrentLumis
190  << "\nNumber of Concurrent Runs = " << nConcurrentRuns;
191  }
192 } // namespace edm
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
ParameterWildcardBase * addWildcardUntracked(U const &pattern)
void validateTopLevelParameterSets(ParameterSet *processParameterSet)
void fillOptionsDescription(ParameterSetDescription &description)
void fillMaxEventsDescription(ParameterSetDescription &description)
constexpr unsigned int s_defaultNumberOfThreads
Definition: ThreadsInfo.h:9
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void fillMaxLuminosityBlocksDescription(ParameterSetDescription &description)
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:193
void addContext(std::string const &context)
Definition: Exception.cc:169
HLT enums.
void fillMaxSecondsUntilRampdownDescription(ParameterSetDescription &description)
Log< level::System, true > LogAbsolute
void dumpOptionsToLogFile(unsigned int nThreads, unsigned int nStreams, unsigned int nConcurrentLumis, unsigned int nConcurrentRuns)
ParameterSet * getPSetForUpdate(std::string const &name, bool &isTracked)