Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:03:30

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   // NOTE: The defaults given here are not actually used when running cmsRun
0018   // Those come from hard coded values in the Python code in Config.py
0019   // The defaults here are used when running the edmPluginHelp utility so
0020   // it is important the defaults in both places are consistent.
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     // No default for this one because the parameter value is
0080     // actually used in the main function in cmsRun.cpp before
0081     // the parameter set is validated here.
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>>("SkipEvent", emptyVector);
0088     description.addUntracked<std::vector<std::string>>("FailPath", emptyVector);
0089     description.addUntracked<std::vector<std::string>>("IgnoreCompletely", emptyVector);
0090 
0091     description.addUntracked<std::vector<std::string>>("canDeleteEarly", emptyVector)
0092         ->setComment("Branch names of products that the Framework can try to delete before the end of the Event");
0093 
0094     {
0095       edm::ParameterSetDescription validator;
0096       validator.add<std::string>("product");
0097       validator.add<std::vector<std::string>>("references")
0098           ->setComment("All the branch names for products to which 'product' contains a reference.");
0099       description.addVPSetUntracked("holdsReferencesToDeleteEarly", validator, std::vector<edm::ParameterSet>{})
0100           ->setComment(
0101               "The 'product' branch name of product which internally hold references to data in another product");
0102     }
0103     description.addUntracked<std::vector<std::string>>("modulesToIgnoreForDeleteEarly", emptyVector)
0104         ->setComment(
0105             "labels of modules whose consumes information will be ingored when determing lifetime for delete early "
0106             "data products");
0107     description.addUntracked<bool>("dumpOptions", false)
0108         ->setComment(
0109             "Print values of selected Framework parameters. The Framework might modify the values "
0110             "in the options parameter set and this prints the values after that modification.");
0111 
0112     description.addOptionalUntracked<bool>("allowUnscheduled")
0113         ->setComment(
0114             "Obsolete. Has no effect. Allowed only for backward compatibility for old Python configuration files.");
0115     description.addOptionalUntracked<std::string>("emptyRunLumiMode")
0116         ->setComment(
0117             "Obsolete. Has no effect. Allowed only for backward compatibility for old Python configuration files.");
0118     description.addOptionalUntracked<bool>("makeTriggerResults")
0119         ->setComment(
0120             "Obsolete. Has no effect. Allowed only for backward compatibility for old Python configuration files.");
0121   }
0122 
0123   void fillMaxEventsDescription(ParameterSetDescription& description) {
0124     description.addUntracked<int>("input", -1)->setComment("Default of -1 implies no limit.");
0125 
0126     ParameterSetDescription nestedDescription;
0127     nestedDescription.addWildcardUntracked<int>("*");
0128     description.addOptionalNode(ParameterDescription<int>("output", false) xor
0129                                     ParameterDescription<ParameterSetDescription>("output", nestedDescription, false),
0130                                 false);
0131   }
0132 
0133   void fillMaxLuminosityBlocksDescription(ParameterSetDescription& description) {
0134     description.addUntracked<int>("input", -1)->setComment("Default of -1 implies no limit.");
0135   }
0136 
0137   void fillMaxSecondsUntilRampdownDescription(ParameterSetDescription& description) {
0138     description.addUntracked<int>("input", -1)->setComment("Default of -1 implies no limit.");
0139   }
0140 
0141   void validateTopLevelParameterSets(ParameterSet* processParameterSet) {
0142     std::string processName = processParameterSet->getParameter<std::string>("@process_name");
0143 
0144     std::vector<std::string> psetNames{"options", "maxEvents", "maxLuminosityBlocks", "maxSecondsUntilRampdown"};
0145 
0146     for (auto const& psetName : psetNames) {
0147       bool isTracked{false};
0148       ParameterSet* pset = processParameterSet->getPSetForUpdate(psetName, isTracked);
0149       if (pset == nullptr) {
0150         ParameterSet emptyPset;
0151         processParameterSet->addUntrackedParameter<ParameterSet>(psetName, emptyPset);
0152         pset = processParameterSet->getPSetForUpdate(psetName, isTracked);
0153       }
0154       if (isTracked) {
0155         throw Exception(errors::Configuration) << "In the configuration the top level parameter set named \'"
0156                                                << psetName << "\' in process \'" << processName << "\' is tracked.\n"
0157                                                << "It must be untracked";
0158       }
0159 
0160       ParameterSetDescription description;
0161       if (psetName == "options") {
0162         fillOptionsDescription(description);
0163       } else if (psetName == "maxEvents") {
0164         fillMaxEventsDescription(description);
0165       } else if (psetName == "maxLuminosityBlocks") {
0166         fillMaxLuminosityBlocksDescription(description);
0167       } else if (psetName == "maxSecondsUntilRampdown") {
0168         fillMaxSecondsUntilRampdownDescription(description);
0169       }
0170 
0171       try {
0172         description.validate(*pset);
0173       } catch (cms::Exception& ex) {
0174         std::ostringstream ost;
0175         ost << "Validating top level \'" << psetName << "\' ParameterSet for process \'" << processName << "\'";
0176         ex.addContext(ost.str());
0177         throw;
0178       }
0179     }
0180   }
0181 
0182   void dumpOptionsToLogFile(unsigned int nThreads,
0183                             unsigned int nStreams,
0184                             unsigned int nConcurrentLumis,
0185                             unsigned int nConcurrentRuns) {
0186     LogAbsolute("Options") << "Number of Threads = " << nThreads << "\nNumber of Streams = " << nStreams
0187                            << "\nNumber of Concurrent Lumis = " << nConcurrentLumis
0188                            << "\nNumber of Concurrent Runs = " << nConcurrentRuns;
0189   }
0190 }  // namespace edm