test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
JobReport.h
Go to the documentation of this file.
1 #ifndef FWCore_MessageLogger_JobReport_h
2 #define FWCore_MessageLogger_JobReport_h
3 // -*- C++ -*-
4 //
5 // Package: MessageLogger
6 // Class : JobReport
7 //
74 //
75 // Original Author: Marc Paterno
76 //
77 
78 /*
79 Changes Log 1: 2009/01/14 10:29:00, Natalia Garcia Nebot
80  Modified and added some methods to report CPU and memory information from /proc/cpuinfo
81  and /proc/meminfo files and Memory statistics
82 */
83 
85 
86 #include <atomic>
87 #include <cstddef>
88 #include <iosfwd>
89 #include <map>
90 #include <mutex>
91 #include <set>
92 #include <string>
93 #include <vector>
94 
95 #include "boost/scoped_ptr.hpp"
96 #include "tbb/concurrent_unordered_map.h"
97 #include "tbb/concurrent_vector.h"
98 
99 namespace edm {
100 
101  class JobReport {
102  public:
103 
104  typedef unsigned int RunNumber;
105  typedef std::size_t Token;
106 
107  struct RunReport {
109  std::set<unsigned int> lumiSections;
110  };
111 
121  struct InputFile {
122  typedef std::vector<std::string> StringVector;
123 
127  std::string inputType; // primaryFiles, secondaryFiles, mixingFiles
128  std::string inputSourceClassName; // class which created the file
129  std::string moduleLabel; // name of class instance
131  std::size_t numEventsRead;
133  std::map<RunNumber, RunReport> runReports;
135  std::set<std::string> fastClonedBranches;
136  };
137 
147  struct OutputFile {
148 
150 
155  std::string moduleLabel; // name of class instance
159  std::size_t numEventsWritten;
161  std::vector<Token> contributingInputs;
162  tbb::concurrent_vector<Token> contributingInputsSecSource;
163  std::map<std::string, bool> fastCopyingInputs;
164  std::map<RunNumber, RunReport> runReports;
166  };
167 
169  public:
172  std::atomic<long long>& value() { return value_; }
173  std::atomic<long long> const& value() const { return value_; }
174  private:
175  std::atomic<long long> value_;
176  };
177 
178  struct JobReportImpl {
179 
180  JobReportImpl& operator=(JobReportImpl const&) = delete;
181  JobReportImpl(JobReportImpl const&) = delete;
182 
185 
186  /*
187  * Add the input file token provided to every output
188  * file currently available.
189  * Used whenever a new input file is opened, it's token
190  * is added to all open output files as a contributor
191  */
192  void insertInputForOutputs(InputType inputType, Token t);
193 
194  /*
195  * Associate a Lumi Section to all open output files
196  *
197  */
198  void associateLumiSection(JobReport::Token token, unsigned int runNumber, unsigned int lumiSection);
199 
200  /*
201  * Associate a Lumi Section to all open input files
202  *
203  */
204  void associateInputLumiSection(unsigned int runNumber, unsigned int lumiSection);
205 
206  /*
207  * Associate a run to all open output files
208  */
209  void associateRun(JobReport::Token token, unsigned int runNumber);
210 
211  /*
212  * Associate a run to all open output files
213  */
214  void associateInputRun(unsigned int runNumber);
215 
216  /*
217  * Write an InputFile object to the Logger
218  * Generate XML string for InputFile instance and dispatch to
219  * job report via MessageLogger
220  */
221  void writeInputFile(InputFile const& f);
222 
223  /*
224  * Write an OutputFile object to the Logger
225  * Generate an XML string for the OutputFile provided and
226  * dispatch it to the logger
227  * Contributing input tokens are resolved to the input LFN and PFN
228  *
229  * TODO: We have not yet addressed the issue where we cleanup not
230  * contributing input files.
231  * Also, it is possible to get fake input to output file mappings
232  * if an input file is open already when a new output file is opened
233  * but the input gets closed without contributing events to the
234  * output file due to filtering etc.
235  *
236  */
237  void writeOutputFile(OutputFile const& f);
238 
239  /*
240  * Flush all open files to logger in event of a problem.
241  */
242  void flushFiles(void);
243 
244  JobReportImpl(std::ostream* iOst): printedReadBranches_(false), ost_(iOst) {}
245 
246  std::vector<InputFile> inputFiles_;
247  tbb::concurrent_vector<InputFile> inputFilesSecSource_;
248  std::vector<OutputFile> outputFiles_;
249  std::map<std::string, long long> readBranches_;
250  std::map<std::string, long long> readBranchesSecFile_;
251  tbb::concurrent_unordered_map<std::string, AtomicLongLong> readBranchesSecSource_;
254  std::ostream* ost_;
255  };
256 
257  JobReport();
258  //Does not take ownership of pointer
259  JobReport(std::ostream* outputStream);
260 
261  JobReport& operator=(JobReport const&) = delete;
262  JobReport(JobReport const&) = delete;
263 
264  ~JobReport();
265 
267  void childAfterFork(std::string const& jobReportFile, unsigned int childIndex, unsigned int numberOfChildren);
268 
269  void parentBeforeFork(std::string const& jobReportFile, unsigned int numberOfChildren);
270 
271  void parentAfterFork(std::string const& jobReportFile);
272 
276  Token inputFileOpened(std::string const& physicalFileName,
277  std::string const& logicalFileName,
278  std::string const& catalog,
279  std::string const& inputType,
280  std::string const& inputSourceClassName,
281  std::string const& moduleLabel,
282  std::string const& guid,
283  std::vector<std::string> const& branchNames);
284 
287  void eventReadFromFile(InputType inputType, Token fileToken);
288 
293  // CMS-THREADING Current implementation requires an instance of an
294  // OuputModule run on only one thread at a time.
295  void reportDataType(Token fileToken, std::string const& dataType);
296 
297 
301  void inputFileClosed(InputType inputType, Token fileToken);
302 
306  Token outputFileOpened(std::string const& physicalFileName,
307  std::string const& logicalFileName,
308  std::string const& catalog,
309  std::string const& outputModuleClassName,
310  std::string const& moduleLabel,
311  std::string const& guid,
312  std::string const& dataType,
313  std::string const& branchHash,
314  std::vector<std::string> const& branchNames);
315 
318  // CMS-THREADING Current implementation requires an instance of an
319  // OuputModule run on only one thread at a time.
320  void eventWrittenToFile(Token fileToken, unsigned int run, unsigned int event);
321 
325  void outputFileClosed(Token fileToken);
326 
327  void reportSkippedEvent(unsigned int run, unsigned int event);
328 
333  void reportRunNumber(JobReport::Token token, unsigned int run);
334 
339  void reportLumiSection(JobReport::Token token, unsigned int run, unsigned int lumiSectId);
340 
346  void reportInputLumiSection(unsigned int run, unsigned int lumiSectId);
347 
351  void reportInputRunNumber(unsigned int run);
352 
358  void reportError(std::string const& shortDesc,
359  std::string const& longDesc,
360  int const& exitCode);
361 
367  void reportSkippedFile(std::string const& pfn, std::string const& lfn);
368 
369  void reportFallbackAttempt(std::string const& pfn, std::string const& lfn, std::string const& err);
370 
372  std::map<std::string, std::string> const& fileData) ;
373 
380  void reportMemoryInfo(std::vector<std::string> const& memoryData);
381 
388  void reportMessageInfo(std::map<std::string, double> const& messageData);
389 
396  void reportReadBranches();
397 
399  void reportReadBranch(InputType inputType, std::string const& branchName);
400 
402  void reportFastClonedBranches(std::set<std::string> const& fastClonedBranches, long long nEvents);
403 
408 
409  /*
410  * Report information about fast copying. Called for each open output file
411  * whenever an input file is opened.
412  */
413  void reportFastCopyingStatus(Token t, std::string const& inputFileName, bool fastCopying);
414 
422  void reportPerformanceSummary(std::string const& metricClass,
423  std::map<std::string, std::string> const& metrics);
424 
425  void reportPerformanceForModule(std::string const& metricClass,
426  std::string const& moduleName,
427  std::map<std::string, std::string> const& metrics);
428 
430  std::string dumpFiles(void);
431 
432  protected:
433  boost::scoped_ptr<JobReportImpl>& impl() {return impl_;}
434 
435  private:
436  boost::scoped_ptr<JobReportImpl> impl_;
438  };
439 
440  std::ostream& operator<< (std::ostream& os, JobReport::InputFile const& f);
441  std::ostream& operator<< (std::ostream& os, JobReport::OutputFile const& f);
442 }
443 #endif
InputType
Definition: InputType.h:5
void reportSkippedFile(std::string const &pfn, std::string const &lfn)
Definition: JobReport.cc:597
std::string inputSourceClassName
Definition: JobReport.h:128
list pfn
Definition: dbtoconf.py:76
std::string outputModuleClassName
Definition: JobReport.h:154
std::string physicalFileName
Definition: JobReport.h:152
void associateRun(JobReport::Token token, unsigned int runNumber)
Definition: JobReport.cc:275
void reportMemoryInfo(std::vector< std::string > const &memoryData)
Definition: JobReport.cc:629
void associateLumiSection(JobReport::Token token, unsigned int runNumber, unsigned int lumiSection)
Definition: JobReport.cc:295
void reportInputRunNumber(unsigned int run)
Definition: JobReport.cc:554
void eventReadFromFile(InputType inputType, Token fileToken)
Definition: JobReport.cc:441
std::map< std::string, long long > readBranches_
Definition: JobReport.h:249
static boost::mutex mutex
Definition: LHEProxy.cc:11
std::mutex write_mutex
Definition: JobReport.h:437
void reportFallbackAttempt(std::string const &pfn, std::string const &lfn, std::string const &err)
Definition: JobReport.cc:613
std::string logicalFileName
Definition: JobReport.h:124
std::set< std::string > fastClonedBranches
Definition: JobReport.h:135
std::atomic< long long > & value()
Definition: JobReport.h:172
std::map< std::string, bool > fastCopyingInputs
Definition: JobReport.h:163
std::string logicalFileName
Definition: JobReport.h:151
void reportFastCopyingStatus(Token t, std::string const &inputFileName, bool fastCopying)
Definition: JobReport.cc:533
JobReportImpl(JobReportImpl const &)=delete
void reportRunNumber(JobReport::Token token, unsigned int run)
Definition: JobReport.cc:549
void reportRandomStateFile(std::string const &name)
Definition: JobReport.cc:719
JobReport & operator=(JobReport const &)=delete
std::vector< std::string > StringVector
Definition: JobReport.h:122
uint16_t size_type
Token inputFileOpened(std::string const &physicalFileName, std::string const &logicalFileName, std::string const &catalog, std::string const &inputType, std::string const &inputSourceClassName, std::string const &moduleLabel, std::string const &guid, std::vector< std::string > const &branchNames)
Definition: JobReport.cc:393
std::vector< InputFile > inputFiles_
Definition: JobReport.h:246
void reportPerformanceForModule(std::string const &metricClass, std::string const &moduleName, std::map< std::string, std::string > const &metrics)
Definition: JobReport.cc:754
std::map< RunNumber, RunReport > runReports
Definition: JobReport.h:133
std::vector< Token > contributingInputs
Definition: JobReport.h:161
std::string physicalFileName
Definition: JobReport.h:125
tbb::concurrent_unordered_map< std::string, AtomicLongLong > readBranchesSecSource_
Definition: JobReport.h:251
void insertInputForOutputs(InputType inputType, Token t)
Definition: JobReport.cc:176
InputFile::StringVector StringVector
Definition: JobReport.h:149
std::string moduleName(Provenance const &provenance)
Definition: Provenance.cc:27
std::size_t numEventsRead
Definition: JobReport.h:131
void writeInputFile(InputFile const &f)
Definition: JobReport.cc:193
StringVector branchNames
Definition: JobReport.h:160
JobReportImpl & operator=(JobReportImpl const &)=delete
void reportInputLumiSection(unsigned int run, unsigned int lumiSectId)
Definition: JobReport.cc:544
std::map< std::string, long long > readBranchesSecFile_
Definition: JobReport.h:250
def load
Definition: svgfig.py:546
std::map< RunNumber, RunReport > runReports
Definition: JobReport.h:164
void reportPerformanceSummary(std::string const &metricClass, std::map< std::string, std::string > const &metrics)
Definition: JobReport.cc:733
void childAfterFork(std::string const &jobReportFile, unsigned int childIndex, unsigned int numberOfChildren)
New output file for child.
Definition: JobReport.cc:383
std::set< unsigned int > lumiSections
Definition: JobReport.h:109
double f[11][100]
Token outputFileOpened(std::string const &physicalFileName, std::string const &logicalFileName, std::string const &catalog, std::string const &outputModuleClassName, std::string const &moduleLabel, std::string const &guid, std::string const &dataType, std::string const &branchHash, std::vector< std::string > const &branchNames)
Definition: JobReport.cc:467
AtomicLongLong(AtomicLongLong const &r)
Definition: JobReport.h:171
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
std::atomic< long long > const & value() const
Definition: JobReport.h:173
std::vector< OutputFile > outputFiles_
Definition: JobReport.h:248
void reportError(std::string const &shortDesc, std::string const &longDesc, int const &exitCode)
Definition: JobReport.cc:580
unsigned int RunNumber
Definition: JobReport.h:104
std::size_t Token
Definition: JobReport.h:105
void associateInputRun(unsigned int runNumber)
Definition: JobReport.cc:283
void reportReadBranch(InputType inputType, std::string const &branchName)
Inform the job report that a branch has been read.
Definition: JobReport.cc:694
std::size_t numEventsWritten
Definition: JobReport.h:159
void reportFastClonedBranches(std::set< std::string > const &fastClonedBranches, long long nEvents)
Inform the job report that branches have been fast Cloned.
Definition: JobReport.cc:709
boost::scoped_ptr< JobReportImpl > impl_
Definition: JobReport.h:436
tbb::concurrent_vector< InputFile > inputFilesSecSource_
Definition: JobReport.h:247
std::atomic< long long > value_
Definition: JobReport.h:175
void parentAfterFork(std::string const &jobReportFile)
Definition: JobReport.cc:379
void reportMessageInfo(std::map< std::string, double > const &messageData)
Definition: JobReport.cc:644
std::string dumpFiles(void)
debug/test util
Definition: JobReport.cc:777
void parentBeforeFork(std::string const &jobReportFile, unsigned int numberOfChildren)
Definition: JobReport.cc:361
boost::scoped_ptr< JobReportImpl > & impl()
Definition: JobReport.h:433
void reportAnalysisFile(std::string const &fileName, std::map< std::string, std::string > const &fileData)
Definition: JobReport.cc:559
std::vector< InputFile >::size_type lastOpenedPrimaryInputFile_
Definition: JobReport.h:253
void outputFileClosed(Token fileToken)
Definition: JobReport.cc:513
void eventWrittenToFile(Token fileToken, unsigned int run, unsigned int event)
Definition: JobReport.cc:507
void writeOutputFile(OutputFile const &f)
Definition: JobReport.cc:220
JobReportImpl(std::ostream *iOst)
Definition: JobReport.h:244
InputFile & getInputFileForToken(InputType inputType, Token t)
Definition: JobReport.cc:119
void reportLumiSection(JobReport::Token token, unsigned int run, unsigned int lumiSectId)
Definition: JobReport.cc:539
void reportDataType(Token fileToken, std::string const &dataType)
Definition: JobReport.cc:447
volatile std::atomic< bool > shutdown_flag false
UInt_t nEvents
Definition: hcalCalib.cc:42
tbb::concurrent_vector< Token > contributingInputsSecSource
Definition: JobReport.h:162
StringVector branchNames
Definition: JobReport.h:132
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
void inputFileClosed(InputType inputType, Token fileToken)
Definition: JobReport.cc:453
void associateInputLumiSection(unsigned int runNumber, unsigned int lumiSection)
Definition: JobReport.cc:305
void reportSkippedEvent(unsigned int run, unsigned int event)
Definition: JobReport.cc:520
void reportReadBranches()
Definition: JobReport.cc:660
OutputFile & getOutputFileForToken(Token t)
Definition: JobReport.cc:151