File indexing completed on 2024-04-06 12:12:57
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 ->setComment(
0037 "If zero or greater than the number of concurrent luminosity blocks, this will be reset to "
0038 "be the same as the number of concurrent luminosity blocks.");
0039
0040 edm::ParameterSetDescription eventSetupDescription;
0041 eventSetupDescription.addUntracked<unsigned int>("numberOfConcurrentIOVs", 0)
0042 ->setComment(
0043 "If zero, use the Framework default which currently means the same as the "
0044 "number of concurrent luminosity blocks. Can be overridden by a hard coded "
0045 "static in a record C++ definition or by forceNumberOfConcurrentIOVs. "
0046 "In all cases, the number of concurrent IOVs will be reset to be the "
0047 "same as the number of concurrent luminosity blocks if greater than the "
0048 "number of concurrent luminosity blocks.");
0049 edm::ParameterSetDescription nestedDescription;
0050 nestedDescription.addWildcardUntracked<unsigned int>("*")->setComment(
0051 "Parameter names should be record names and the values are the number of concurrent IOVS for each record."
0052 " Overrides all other methods of setting number of concurrent IOVs.");
0053 eventSetupDescription.addUntracked<edm::ParameterSetDescription>("forceNumberOfConcurrentIOVs", nestedDescription);
0054 description.addUntracked<edm::ParameterSetDescription>("eventSetup", eventSetupDescription);
0055
0056 description.addUntracked<std::vector<std::string>>("accelerators", {"*"})
0057 ->setComment(
0058 "Specify the set of compute accelerator(s) the job is allowed to use. The values can contain the direct "
0059 "names of accelerators supported by the ProcessAccelerators defined in the configuration, or patterns "
0060 "matching to them (patterns use '*' and '?' wildcards similar to shell). The actual set of accelerators to "
0061 "be used is determined on the worker node based on the available hardware. A CPU fallback with the name "
0062 "'cpu' is always included in the set of available accelerators. If no accelerator matching to the patterns "
0063 "are available on the worker node, the job is terminated with a specific error code. Same happens if an "
0064 "empty value is given in the configuration. Default value is pattern '*', which implies use of any "
0065 "supported and available hardware (including the CPU fallback).");
0066 description.addUntracked<bool>("wantSummary", false)
0067 ->setComment("Set true to print a report on the trigger decisions and timing of modules");
0068 description.addUntracked<std::string>("fileMode", "FULLMERGE")
0069 ->setComment("Legal values are 'NOMERGE' and 'FULLMERGE'");
0070 description.addUntracked<bool>("forceEventSetupCacheClearOnNewRun", false);
0071 description.addUntracked<bool>("throwIfIllegalParameter", true)
0072 ->setComment("Set false to disable exception throws when configuration validation detects illegal parameters");
0073 description.addUntracked<bool>("printDependencies", false)->setComment("Print data dependencies between modules");
0074 description.addUntracked<bool>("deleteNonConsumedUnscheduledModules", true)
0075 ->setComment(
0076 "Delete modules that are unscheduled, i.e. only in Tasks, whose products are not consumed by any other "
0077 "otherwise-running module");
0078
0079
0080
0081
0082 description.addOptionalUntracked<unsigned int>("sizeOfStackForThreadsInKB");
0083
0084 std::vector<std::string> emptyVector;
0085
0086 description.addUntracked<std::vector<std::string>>("Rethrow", emptyVector);
0087 description.addUntracked<std::vector<std::string>>("TryToContinue", emptyVector);
0088 description.addUntracked<std::vector<std::string>>("IgnoreCompletely", emptyVector);
0089
0090 description.addUntracked<std::vector<std::string>>("modulesToCallForTryToContinue", emptyVector)
0091 ->setComment("Labels of modules which should still be called when an exception in TryToContinue list happens.");
0092
0093 description.addUntracked<std::vector<std::string>>("canDeleteEarly", emptyVector)
0094 ->setComment("Branch names of products that the Framework can try to delete before the end of the Event");
0095
0096 {
0097 edm::ParameterSetDescription validator;
0098 validator.add<std::string>("product");
0099 validator.add<std::vector<std::string>>("references")
0100 ->setComment("All the branch names for products to which 'product' contains a reference.");
0101 description.addVPSetUntracked("holdsReferencesToDeleteEarly", validator, std::vector<edm::ParameterSet>{})
0102 ->setComment(
0103 "The 'product' branch name of product which internally hold references to data in another product");
0104 }
0105 description.addUntracked<std::vector<std::string>>("modulesToIgnoreForDeleteEarly", emptyVector)
0106 ->setComment(
0107 "labels of modules whose consumes information will be ingored when determing lifetime for delete early "
0108 "data products");
0109 description.addUntracked<bool>("dumpOptions", false)
0110 ->setComment(
0111 "Print values of selected Framework parameters. The Framework might modify the values "
0112 "in the options parameter set and this prints the values after that modification.");
0113
0114 description.addOptionalUntracked<bool>("allowUnscheduled")
0115 ->setComment(
0116 "Obsolete. Has no effect. Allowed only for backward compatibility for old Python configuration files.");
0117 description.addOptionalUntracked<std::string>("emptyRunLumiMode")
0118 ->setComment(
0119 "Obsolete. Has no effect. Allowed only for backward compatibility for old Python configuration files.");
0120 description.addOptionalUntracked<bool>("makeTriggerResults")
0121 ->setComment(
0122 "Obsolete. Has no effect. Allowed only for backward compatibility for old Python configuration files.");
0123 }
0124
0125 void fillMaxEventsDescription(ParameterSetDescription& description) {
0126 description.addUntracked<int>("input", -1)->setComment("Default of -1 implies no limit.");
0127
0128 ParameterSetDescription nestedDescription;
0129 nestedDescription.addWildcardUntracked<int>("*");
0130 description.addOptionalNode(ParameterDescription<int>("output", false) xor
0131 ParameterDescription<ParameterSetDescription>("output", nestedDescription, false),
0132 false);
0133 }
0134
0135 void fillMaxLuminosityBlocksDescription(ParameterSetDescription& description) {
0136 description.addUntracked<int>("input", -1)->setComment("Default of -1 implies no limit.");
0137 }
0138
0139 void fillMaxSecondsUntilRampdownDescription(ParameterSetDescription& description) {
0140 description.addUntracked<int>("input", -1)->setComment("Default of -1 implies no limit.");
0141 }
0142
0143 void validateTopLevelParameterSets(ParameterSet* processParameterSet) {
0144 std::string processName = processParameterSet->getParameter<std::string>("@process_name");
0145
0146 std::vector<std::string> psetNames{"options", "maxEvents", "maxLuminosityBlocks", "maxSecondsUntilRampdown"};
0147
0148 for (auto const& psetName : psetNames) {
0149 bool isTracked{false};
0150 ParameterSet* pset = processParameterSet->getPSetForUpdate(psetName, isTracked);
0151 if (pset == nullptr) {
0152 ParameterSet emptyPset;
0153 processParameterSet->addUntrackedParameter<ParameterSet>(psetName, emptyPset);
0154 pset = processParameterSet->getPSetForUpdate(psetName, isTracked);
0155 }
0156 if (isTracked) {
0157 throw Exception(errors::Configuration) << "In the configuration the top level parameter set named \'"
0158 << psetName << "\' in process \'" << processName << "\' is tracked.\n"
0159 << "It must be untracked";
0160 }
0161
0162 ParameterSetDescription description;
0163 if (psetName == "options") {
0164 fillOptionsDescription(description);
0165 } else if (psetName == "maxEvents") {
0166 fillMaxEventsDescription(description);
0167 } else if (psetName == "maxLuminosityBlocks") {
0168 fillMaxLuminosityBlocksDescription(description);
0169 } else if (psetName == "maxSecondsUntilRampdown") {
0170 fillMaxSecondsUntilRampdownDescription(description);
0171 }
0172
0173 try {
0174 description.validate(*pset);
0175 } catch (cms::Exception& ex) {
0176 std::ostringstream ost;
0177 ost << "Validating top level \'" << psetName << "\' ParameterSet for process \'" << processName << "\'";
0178 ex.addContext(ost.str());
0179 throw;
0180 }
0181 }
0182 }
0183
0184 void dumpOptionsToLogFile(unsigned int nThreads,
0185 unsigned int nStreams,
0186 unsigned int nConcurrentLumis,
0187 unsigned int nConcurrentRuns) {
0188 LogAbsolute("Options") << "Number of Threads = " << nThreads << "\nNumber of Streams = " << nStreams
0189 << "\nNumber of Concurrent Lumis = " << nConcurrentLumis
0190 << "\nNumber of Concurrent Runs = " << nConcurrentRuns;
0191 }
0192 }