Skip to content

Commit

Permalink
JobReport now supports concurrent opening of output files
Browse files Browse the repository at this point in the history
Switched to using a concurrent_vector to handle the different output file data. This allows concurrent opening of new output files.
The code still assumes that one output module will only report new lumis and runs sequentially.
  • Loading branch information
Dr15Jones committed Apr 12, 2017
1 parent 8c4e21e commit ec103b2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion FWCore/MessageLogger/interface/JobReport.h
Expand Up @@ -250,7 +250,7 @@ namespace edm {

std::vector<InputFile> inputFiles_;
tbb::concurrent_vector<InputFile> inputFilesSecSource_;
std::vector<OutputFile> outputFiles_;
tbb::concurrent_vector<OutputFile> outputFiles_;
std::map<std::string, long long> readBranches_;
std::map<std::string, long long> readBranchesSecFile_;
tbb::concurrent_unordered_map<std::string, AtomicLongLong> readBranchesSecSource_;
Expand Down
23 changes: 10 additions & 13 deletions FWCore/MessageLogger/src/JobReport.cc
Expand Up @@ -277,7 +277,7 @@ namespace edm {
}

void JobReport::JobReportImpl::associateRun(JobReport::Token token, unsigned int runNumber) {
std::map<RunNumber, RunReport>& theMap = outputFiles_.at(token).runReports;
auto& theMap = outputFiles_.at(token).runReports;
std::map<RunNumber, RunReport>::iterator iter(theMap.lower_bound(runNumber));
if(iter == theMap.end() || runNumber < iter->first) { // not found
theMap.emplace_hint(iter, runNumber, JobReport::RunReport{ runNumber, {}}); // insert it
Expand All @@ -297,7 +297,7 @@ namespace edm {
}

void JobReport::JobReportImpl::associateLumiSection(JobReport::Token token, unsigned int runNumber, unsigned int lumiSect, unsigned long nEvents) {
std::map<RunNumber, RunReport>& theMap = outputFiles_.at(token).runReports;
auto& theMap = outputFiles_.at(token).runReports;
std::map<RunNumber, RunReport>::iterator iter(theMap.lower_bound(runNumber));
if(iter == theMap.end() || runNumber < iter->first) { // not found
theMap.emplace_hint(iter, runNumber, JobReport::RunReport{ runNumber, {{{lumiSect,nEvents}}}}); // insert it
Expand Down Expand Up @@ -477,8 +477,8 @@ namespace edm {
std::string const& dataType,
std::string const& branchHash,
std::vector<std::string> const& branchNames) {
impl_->outputFiles_.emplace_back();
JobReport::OutputFile& r = impl_->outputFiles_.back();
auto itr = impl_->outputFiles_.emplace_back();
JobReport::OutputFile& r = *itr;

r.logicalFileName = logicalFileName;
r.physicalFileName = physicalFileName;
Expand All @@ -504,7 +504,7 @@ namespace edm {
r.contributingInputsSecSource.push_back(i);
}
}
return impl_->outputFiles_.size()-1;
return itr - impl_->outputFiles_.begin();
}

void
Expand Down Expand Up @@ -781,24 +781,21 @@ namespace edm {
JobReport::dumpFiles(void) {
std::ostringstream msg;

typedef std::vector<JobReport::OutputFile>::iterator iterator;

for(iterator f = impl_->outputFiles_.begin(), fEnd = impl_->outputFiles_.end(); f != fEnd; ++f) {
for(auto const& f :impl_->outputFiles_) {

msg << "\n<File>";
msg << *f;
msg << f;

msg << "\n<LumiSections>";
msg << "\n<Inputs>";
typedef std::vector<JobReport::Token>::iterator iterator;
for(iterator iInput = f->contributingInputs.begin(),
iInputEnd = f->contributingInputs.end();
iInput != iInputEnd; ++iInput) {
JobReport::InputFile inpFile = impl_->inputFiles_[*iInput];
for(auto const& iInput : f.contributingInputs) {
auto const& inpFile = impl_->inputFiles_[iInput];
msg << "\n<Input>";
msg << "\n <LFN>" << TiXmlText(inpFile.logicalFileName) << "</LFN>";
msg << "\n <PFN>" << TiXmlText(inpFile.physicalFileName) << "</PFN>";
msg << "\n <FastCopying>" << findOrDefault(f->fastCopyingInputs, inpFile.physicalFileName) << "</FastCopying>";
msg << "\n <FastCopying>" << findOrDefault(f.fastCopyingInputs, inpFile.physicalFileName) << "</FastCopying>";
msg << "\n</Input>";
}
msg << "\n</Inputs>";
Expand Down

0 comments on commit ec103b2

Please sign in to comment.