File indexing completed on 2022-02-24 02:12:44
0001 #include "FWCore/ParameterSet/interface/validateTopLevelParameterSets.h"
0002
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0007 #include "FWCore/ParameterSet/interface/ThreadsInfo.h"
0008
0009 #include "FWCore/Utilities/interface/EDMException.h"
0010
0011 #include <sstream>
0012 #include <vector>
0013 #include <string>
0014
0015 namespace edm {
0016
0017
0018
0019
0020
0021
0022 void fillOptionsDescription(ParameterSetDescription& description) {
0023 description.addUntracked<unsigned int>("numberOfThreads", s_defaultNumberOfThreads)
0024 ->setComment("If zero, let TBB use its default which is normally the number of CPUs on the machine");
0025 description.addUntracked<unsigned int>("numberOfStreams", 0)
0026 ->setComment(
0027 "If zero, then set the number of streams to be the same as the number of "
0028 "Threads (except always 1 if there is a looper)");
0029 description.addUntracked<unsigned int>("numberOfConcurrentLuminosityBlocks", 0)
0030 ->setComment(
0031 "If zero, use Framework default (currently 2 when the number of streams >= 2, otherwise 1). "
0032 "In all cases, the number of concurrent luminosity blocks will be reset to "
0033 "be the same as the number of streams if it is greater than the "
0034 "numbers of streams.");
0035 description.addUntracked<unsigned int>("numberOfConcurrentRuns", 1);
0036
0037 edm::ParameterSetDescription eventSetupDescription;
0038 eventSetupDescription.addUntracked<unsigned int>("numberOfConcurrentIOVs", 0)
0039 ->setComment(
0040 "If zero, use the Framework default which currently means the same as the "
0041 "number of concurrent luminosity blocks. Can be overridden by a hard coded "
0042 "static in a record C++ definition or by forceNumberOfConcurrentIOVs. "
0043 "In all cases, the number of concurrent IOVs will be reset to be the "
0044 "same as the number of concurrent luminosity blocks if greater than the "
0045 "number of concurrent luminosity blocks.");
0046 edm::ParameterSetDescription nestedDescription;
0047 nestedDescription.addWildcardUntracked<unsigned int>("*")->setComment(
0048 "Parameter names should be record names and the values are the number of concurrent IOVS for each record."
0049 " Overrides all other methods of setting number of concurrent IOVs.");
0050 eventSetupDescription.addUntracked<edm::ParameterSetDescription>("forceNumberOfConcurrentIOVs", nestedDescription);
0051 description.addUntracked<edm::ParameterSetDescription>("eventSetup", eventSetupDescription);
0052
0053 description.addUntracked<std::vector<std::string>>("accelerators", {"*"})
0054 ->setComment(
0055 "Specify the set of compute accelerator(s) the job is allowed to use. The values can contain the direct "
0056 "names of accelerators supported by the ProcessAccelerators defined in the configuration, or patterns "
0057 "matching to them (patterns use '*' and '?' wildcards similar to shell). The actual set of accelerators to "
0058 "be used is determined on the worker node based on the available hardware. A CPU fallback with the name "
0059 "'cpu' is always included in the set of available accelerators. If no accelerator matching to the patterns "
0060 "are available on the worker node, the job is terminated with a specific error code. Same happens if an "
0061 "empty value is given in the configuration. Default value is pattern '*', which implies use of any "
0062 "supported and available hardware (including the CPU fallback).");
0063 description.addUntracked<bool>("wantSummary", false)
0064 ->setComment("Set true to print a report on the trigger decisions and timing of modules");
0065 description.addUntracked<std::string>("fileMode", "FULLMERGE")
0066 ->setComment("Legal values are 'NOMERGE' and 'FULLMERGE'");
0067 description.addUntracked<bool>("forceEventSetupCacheClearOnNewRun", false);
0068 description.addUntracked<bool>("throwIfIllegalParameter", true)
0069 ->setComment("Set false to disable exception throws when configuration validation detects illegal parameters");
0070 description.addUntracked<bool>("printDependencies", false)->setComment("Print data dependencies between modules");
0071 description.addUntracked<bool>("deleteNonConsumedUnscheduledModules", true)
0072 ->setComment(
0073 "Delete modules that are unscheduled, i.e. only in Tasks, whose products are not consumed by any other "
0074 "otherwise-running module");
0075
0076
0077
0078
0079 description.addOptionalUntracked<unsigned int>("sizeOfStackForThreadsInKB");
0080
0081 std::vector<std::string> emptyVector;
0082
0083 description.addUntracked<std::vector<std::string>>("Rethrow", emptyVector);
0084 description.addUntracked<std::vector<std::string>>("SkipEvent", emptyVector);
0085 description.addUntracked<std::vector<std::string>>("FailPath", emptyVector);
0086 description.addUntracked<std::vector<std::string>>("IgnoreCompletely", emptyVector);
0087
0088 description.addUntracked<std::vector<std::string>>("canDeleteEarly", emptyVector)
0089 ->setComment("Branch names of products that the Framework can try to delete before the end of the Event");
0090
0091 description.addUntracked<bool>("dumpOptions", false)
0092 ->setComment(
0093 "Print values of selected Framework parameters. The Framework might modify the values "
0094 "in the options parameter set and this prints the values after that modification.");
0095
0096 description.addOptionalUntracked<bool>("allowUnscheduled")
0097 ->setComment(
0098 "Obsolete. Has no effect. Allowed only for backward compatibility for old Python configuration files.");
0099 description.addOptionalUntracked<std::string>("emptyRunLumiMode")
0100 ->setComment(
0101 "Obsolete. Has no effect. Allowed only for backward compatibility for old Python configuration files.");
0102 description.addOptionalUntracked<bool>("makeTriggerResults")
0103 ->setComment(
0104 "Obsolete. Has no effect. Allowed only for backward compatibility for old Python configuration files.");
0105 }
0106
0107 void fillMaxEventsDescription(ParameterSetDescription& description) {
0108 description.addUntracked<int>("input", -1)->setComment("Default of -1 implies no limit.");
0109
0110 ParameterSetDescription nestedDescription;
0111 nestedDescription.addWildcardUntracked<int>("*");
0112 description.addOptionalNode(ParameterDescription<int>("output", false) xor
0113 ParameterDescription<ParameterSetDescription>("output", nestedDescription, false),
0114 false);
0115 }
0116
0117 void fillMaxLuminosityBlocksDescription(ParameterSetDescription& description) {
0118 description.addUntracked<int>("input", -1)->setComment("Default of -1 implies no limit.");
0119 }
0120
0121 void fillMaxSecondsUntilRampdownDescription(ParameterSetDescription& description) {
0122 description.addUntracked<int>("input", -1)->setComment("Default of -1 implies no limit.");
0123 }
0124
0125 void validateTopLevelParameterSets(ParameterSet* processParameterSet) {
0126 std::string processName = processParameterSet->getParameter<std::string>("@process_name");
0127
0128 std::vector<std::string> psetNames{"options", "maxEvents", "maxLuminosityBlocks", "maxSecondsUntilRampdown"};
0129
0130 for (auto const& psetName : psetNames) {
0131 bool isTracked{false};
0132 ParameterSet* pset = processParameterSet->getPSetForUpdate(psetName, isTracked);
0133 if (pset == nullptr) {
0134 ParameterSet emptyPset;
0135 processParameterSet->addUntrackedParameter<ParameterSet>(psetName, emptyPset);
0136 pset = processParameterSet->getPSetForUpdate(psetName, isTracked);
0137 }
0138 if (isTracked) {
0139 throw Exception(errors::Configuration) << "In the configuration the top level parameter set named \'"
0140 << psetName << "\' in process \'" << processName << "\' is tracked.\n"
0141 << "It must be untracked";
0142 }
0143
0144 ParameterSetDescription description;
0145 if (psetName == "options") {
0146 fillOptionsDescription(description);
0147 } else if (psetName == "maxEvents") {
0148 fillMaxEventsDescription(description);
0149 } else if (psetName == "maxLuminosityBlocks") {
0150 fillMaxLuminosityBlocksDescription(description);
0151 } else if (psetName == "maxSecondsUntilRampdown") {
0152 fillMaxSecondsUntilRampdownDescription(description);
0153 }
0154
0155 try {
0156 description.validate(*pset);
0157 } catch (cms::Exception& ex) {
0158 std::ostringstream ost;
0159 ost << "Validating top level \'" << psetName << "\' ParameterSet for process \'" << processName << "\'";
0160 ex.addContext(ost.str());
0161 throw;
0162 }
0163 }
0164 }
0165
0166 void dumpOptionsToLogFile(unsigned int nThreads,
0167 unsigned int nStreams,
0168 unsigned int nConcurrentLumis,
0169 unsigned int nConcurrentRuns) {
0170 LogAbsolute("Options") << "Number of Threads = " << nThreads << "\nNumber of Streams = " << nStreams
0171 << "\nNumber of Concurrent Lumis = " << nConcurrentLumis
0172 << "\nNumber of Concurrent Runs = " << nConcurrentRuns;
0173 }
0174 }