Skip to content

Commit

Permalink
Merge pull request #681 from wmtan/TwoFrameworkImprovementsForMultith…
Browse files Browse the repository at this point in the history
…reading

Make history registry non-singleton and also fix read calls to not use p...
  • Loading branch information
davidlt committed Sep 1, 2013
2 parents 6d0984b + 32475cb commit 991df7e
Show file tree
Hide file tree
Showing 100 changed files with 996 additions and 967 deletions.
7 changes: 4 additions & 3 deletions DQMServices/FwkIO/plugins/DQMRootOutputModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ class DQMRootOutputModule : public edm::OutputModule {
TTree* m_indicesTree;

std::vector<edm::ProcessHistoryID> m_seenHistories;
edm::ProcessHistoryRegistry m_processHistoryRegistry;
edm::JobReport::Token m_jrToken;
};

Expand Down Expand Up @@ -395,6 +396,7 @@ DQMRootOutputModule::writeLuminosityBlock(edm::LuminosityBlockPrincipal const& i
edm::ProcessHistoryID id = iLumi.processHistoryID();
std::vector<edm::ProcessHistoryID>::iterator itFind = std::find(m_seenHistories.begin(),m_seenHistories.end(),id);
if(itFind == m_seenHistories.end()) {
m_processHistoryRegistry.registerProcessHistory(iLumi.processHistory());
m_presentHistoryIndex = m_seenHistories.size();
m_seenHistories.push_back(id);
} else {
Expand Down Expand Up @@ -455,6 +457,7 @@ void DQMRootOutputModule::writeRun(edm::RunPrincipal const& iRun, edm::ModuleCal
edm::ProcessHistoryID id = iRun.processHistoryID();
std::vector<edm::ProcessHistoryID>::iterator itFind = std::find(m_seenHistories.begin(),m_seenHistories.end(),id);
if(itFind == m_seenHistories.end()) {
m_processHistoryRegistry.registerProcessHistory(iRun.processHistory());
m_presentHistoryIndex = m_seenHistories.size();
m_seenHistories.push_back(id);
} else {
Expand Down Expand Up @@ -506,12 +509,10 @@ void DQMRootOutputModule::startEndFile() {
std::string passID;
processHistoryTree->Branch(kProcessConfigurationPassID,&passID);

edm::ProcessHistoryRegistry* phr = edm::ProcessHistoryRegistry::instance();
assert(0!=phr);
for(std::vector<edm::ProcessHistoryID>::iterator it = m_seenHistories.begin(), itEnd = m_seenHistories.end();
it !=itEnd;
++it) {
const edm::ProcessHistory* history = phr->getMapped(*it);
const edm::ProcessHistory* history = m_processHistoryRegistry.getMapped(*it);
assert(0!=history);
index = 0;
for(edm::ProcessHistory::collection_type::const_iterator itPC = history->begin(), itPCEnd = history->end();
Expand Down
44 changes: 20 additions & 24 deletions DQMServices/FwkIO/plugins/DQMRootSource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,9 @@ class DQMRootSource : public edm::InputSource
//NOTE: the following is really read next run auxiliary
virtual boost::shared_ptr<edm::RunAuxiliary> readRunAuxiliary_() override ;
virtual boost::shared_ptr<edm::LuminosityBlockAuxiliary> readLuminosityBlockAuxiliary_() override ;
virtual boost::shared_ptr<edm::RunPrincipal> readRun_(boost::shared_ptr<edm::RunPrincipal> rpCache) override;
virtual boost::shared_ptr<edm::LuminosityBlockPrincipal> readLuminosityBlock_( boost::shared_ptr<edm::LuminosityBlockPrincipal> lbCache) override;
virtual edm::EventPrincipal* readEvent_(edm::EventPrincipal&) override ;
virtual void readRun_(edm::RunPrincipal& rpCache) override;
virtual void readLuminosityBlock_(edm::LuminosityBlockPrincipal& lbCache) override;
virtual void readEvent_(edm::EventPrincipal&) override ;

virtual std::unique_ptr<edm::FileBlock> readFile_() override;
virtual void closeFile_() override;
Expand Down Expand Up @@ -482,9 +482,8 @@ DQMRootSource::~DQMRootSource()
//
// member functions
//
edm::EventPrincipal* DQMRootSource::readEvent_(edm::EventPrincipal&)
void DQMRootSource::readEvent_(edm::EventPrincipal&)
{
return 0;
}

edm::InputSource::ItemType DQMRootSource::getNextItemType()
Expand Down Expand Up @@ -524,14 +523,14 @@ DQMRootSource::readLuminosityBlockAuxiliary_()
return boost::shared_ptr<edm::LuminosityBlockAuxiliary>(new edm::LuminosityBlockAuxiliary(m_lumiAux));
}

boost::shared_ptr<edm::RunPrincipal>
DQMRootSource::readRun_(boost::shared_ptr<edm::RunPrincipal> rpCache)
void
DQMRootSource::readRun_(edm::RunPrincipal& rpCache)
{
assert(m_presentIndexItr != m_orderedIndices.end());
RunLumiToRange runLumiRange = m_runlumiToRange[*m_presentIndexItr];

m_justOpenedFileSoNeedToGenerateRunTransition = false;
unsigned int runID =rpCache->id().run();
unsigned int runID =rpCache.id().run();
assert(runID == runLumiRange.m_run);

m_shouldReadMEs = (m_filterOnRun == 0 ||
Expand Down Expand Up @@ -575,19 +574,18 @@ DQMRootSource::readRun_(boost::shared_ptr<edm::RunPrincipal> rpCache)
}

edm::Service<edm::JobReport> jr;
jr->reportInputRunNumber(rpCache->id().run());
jr->reportInputRunNumber(rpCache.id().run());

rpCache->fillRunPrincipal();
return rpCache;
rpCache.fillRunPrincipal(processHistoryRegistryForUpdate());
}

boost::shared_ptr<edm::LuminosityBlockPrincipal>
DQMRootSource::readLuminosityBlock_( boost::shared_ptr<edm::LuminosityBlockPrincipal> lbCache)
void
DQMRootSource::readLuminosityBlock_( edm::LuminosityBlockPrincipal& lbCache)
{
assert(m_presentIndexItr != m_orderedIndices.end());
RunLumiToRange runLumiRange = m_runlumiToRange[*m_presentIndexItr];
assert(runLumiRange.m_run == lbCache->id().run());
assert(runLumiRange.m_lumi == lbCache->id().luminosityBlock());
assert(runLumiRange.m_run == lbCache.id().run());
assert(runLumiRange.m_lumi == lbCache.id().luminosityBlock());

//NOTE: need to reset all lumi block elements at this point
if( ( m_lastSeenLumi2 != runLumiRange.m_lumi ||
Expand All @@ -613,10 +611,9 @@ DQMRootSource::readLuminosityBlock_( boost::shared_ptr<edm::LuminosityBlockPrinc
readElements();

edm::Service<edm::JobReport> jr;
jr->reportInputLumiSection(lbCache->id().run(),lbCache->id().luminosityBlock());
jr->reportInputLumiSection(lbCache.id().run(),lbCache.id().luminosityBlock());

lbCache->fillLuminosityBlockPrincipal();
return lbCache;
lbCache.fillLuminosityBlockPrincipal(processHistoryRegistryForUpdate());
}

std::unique_ptr<edm::FileBlock>
Expand Down Expand Up @@ -821,8 +818,7 @@ DQMRootSource::setupFile(unsigned int iIndex)
std::string* pPassID = &passID;
processHistoryTree->SetBranchAddress(kProcessConfigurationPassID,&pPassID);

edm::ProcessHistoryRegistry* phr = edm::ProcessHistoryRegistry::instance();
assert(nullptr != phr);
edm::ProcessHistoryRegistry& phr = processHistoryRegistryUpdate();
std::vector<edm::ProcessConfiguration> configs;
configs.reserve(5);
m_historyIDs.clear();
Expand All @@ -833,8 +829,8 @@ DQMRootSource::setupFile(unsigned int iIndex)
if(not configs.empty()) {
edm::ProcessHistory ph(configs);
m_historyIDs.push_back(ph.id());
registerProcessHistory(ph);
m_reducedHistoryIDs.push_back(phr->extra().reducedProcessHistoryID(ph.id()));
phr.registerProcessHistory(ph);
m_reducedHistoryIDs.push_back(phr.reducedProcessHistoryID(ph.id()));
}
configs.clear();
}
Expand All @@ -845,8 +841,8 @@ DQMRootSource::setupFile(unsigned int iIndex)
if(not configs.empty()) {
edm::ProcessHistory ph(configs);
m_historyIDs.push_back(ph.id());
registerProcessHistory(ph);
m_reducedHistoryIDs.push_back(phr->extra().reducedProcessHistoryID(ph.id()));
phr.registerProcessHistory(ph);
m_reducedHistoryIDs.push_back(phr.reducedProcessHistoryID(ph.id()));
//std::cout <<"inserted "<<ph.id()<<std::endl;
}
}
Expand Down
1 change: 1 addition & 0 deletions DataFormats/FWLite/src/DataGetterHelper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//

// system include files
#include <cassert>
#include <iostream>

// user include files
Expand Down
1 change: 0 additions & 1 deletion DataFormats/Provenance/interface/BranchDescription.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ This description also applies to every product instance on the branch.
#include "DataFormats/Provenance/interface/BranchID.h"
#include "DataFormats/Provenance/interface/BranchType.h"
#include "DataFormats/Provenance/interface/ParameterSetID.h"
#include "DataFormats/Provenance/interface/ProcessConfigurationID.h"
#include "DataFormats/Provenance/interface/ProductID.h"
#include "DataFormats/Provenance/interface/ProvenanceFwd.h"
#include "FWCore/Utilities/interface/TypeID.h"
Expand Down
40 changes: 0 additions & 40 deletions DataFormats/Provenance/interface/FullHistoryToReducedHistoryMap.h

This file was deleted.

3 changes: 2 additions & 1 deletion DataFormats/Provenance/interface/IndexIntoFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ The interface is too complex for general use.

namespace edm {

class ProcessHistoryRegistry;
class RootFile;

class IndexIntoFile {
Expand Down Expand Up @@ -983,7 +984,7 @@ namespace edm {
/// Used for backward compatibility to convert objects created with releases
/// that used the full ProcessHistoryID in IndexIntoFile to use the reduced
/// ProcessHistoryID.
void reduceProcessHistoryIDs();
void reduceProcessHistoryIDs(ProcessHistoryRegistry const& processHistoryRegistry);

//*****************************************************************************
//*****************************************************************************
Expand Down
1 change: 0 additions & 1 deletion DataFormats/Provenance/interface/ModuleDescription.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ ModuleDescription: The description of a producer module.
----------------------------------------------------------------------*/
#include "DataFormats/Provenance/interface/ParameterSetID.h"
#include "DataFormats/Provenance/interface/ProcessConfiguration.h"
#include "DataFormats/Provenance/interface/ProcessConfigurationID.h"

#include "boost/shared_ptr.hpp"

Expand Down
2 changes: 1 addition & 1 deletion DataFormats/Provenance/interface/ProcessHistory.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace edm {
phid() = ProcessHistoryID();
}

void reduce();
ProcessHistory& reduce();

void initializeTransients() {transient_.reset();}

Expand Down
41 changes: 34 additions & 7 deletions DataFormats/Provenance/interface/ProcessHistoryRegistry.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,44 @@
#ifndef DataFormats_Provenance_ProcessHistoryRegistry_h
#define DataFormats_Provenance_ProcessHistoryRegistry_h

#include "FWCore/Utilities/interface/ThreadSafeRegistry.h"
/** \class edm::ProcessHistoryRegistry
\author Bill Tanenbaum, modified 23 August, 2013
*/

#include <map>
#include <vector>

#include "DataFormats/Provenance/interface/ProcessHistory.h"
#include "DataFormats/Provenance/interface/ProcessHistoryID.h"
#include "DataFormats/Provenance/interface/FullHistoryToReducedHistoryMap.h"

namespace edm {
typedef edm::detail::ThreadSafeRegistry<edm::ProcessHistoryID,edm::ProcessHistory,edm::FullHistoryToReducedHistoryMap> ProcessHistoryRegistry;
typedef ProcessHistoryRegistry::collection_type ProcessHistoryMap;
typedef ProcessHistoryRegistry::vector_type ProcessHistoryVector;
typedef std::map<ProcessHistoryID, ProcessHistory> ProcessHistoryMap;
typedef std::vector<ProcessHistory> ProcessHistoryVector;

bool registerProcessHistory(ProcessHistory const& processHistory);
}
class ProcessHistoryRegistry {
public:
typedef ProcessHistory value_type;
typedef ProcessHistoryMap collection_type;
typedef ProcessHistoryVector vector_type;

ProcessHistoryRegistry();
#ifndef __GCCXML__
ProcessHistoryRegistry(ProcessHistoryRegistry const&) = delete; // Disallow copying and moving
ProcessHistoryRegistry& operator=(ProcessHistoryRegistry const&) = delete; // Disallow copying and moving
#endif
bool registerProcessHistory(ProcessHistory const& processHistory);
bool getMapped(ProcessHistoryID const& key, ProcessHistory& value) const;
ProcessHistory const* getMapped(ProcessHistoryID const& key) const;
ProcessHistoryID const& reducedProcessHistoryID(ProcessHistoryID const& fullID) const;
ProcessHistoryMap::const_iterator begin() const {
return data_.begin();
}
ProcessHistoryMap::const_iterator end() const {
return data_.end();
}
private:
ProcessHistoryMap data_;
std::map<ProcessHistoryID, ProcessHistoryID> extra_;
};
}
#endif
9 changes: 4 additions & 5 deletions DataFormats/Provenance/interface/Provenance.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ existence.
#include "DataFormats/Provenance/interface/BranchDescription.h"
#include "DataFormats/Provenance/interface/BranchMapper.h"
#include "DataFormats/Provenance/interface/ParameterSetID.h"
#include "DataFormats/Provenance/interface/ProcessConfigurationID.h"
#include "DataFormats/Provenance/interface/ProcessHistoryID.h"
#include "DataFormats/Provenance/interface/ProcessHistory.h"
#include "DataFormats/Provenance/interface/Parentage.h"
#include "DataFormats/Provenance/interface/ProductID.h"
#include "DataFormats/Provenance/interface/ReleaseVersion.h"
Expand Down Expand Up @@ -63,7 +62,7 @@ namespace edm {
std::string const& productInstanceName() const {return product().productInstanceName();}
std::string const& friendlyClassName() const {return product().friendlyClassName();}
boost::shared_ptr<BranchMapper> const& store() const {return store_;}
ProcessHistoryID const& processHistoryID() const {return *processHistoryID_;}
ProcessHistory const& processHistory() const {return *processHistory_;}
bool getProcessConfiguration(ProcessConfiguration& pc) const;
ReleaseVersion releaseVersion() const;
std::set<std::string> const& branchAliases() const {return product().branchAliases();}
Expand All @@ -74,7 +73,7 @@ namespace edm {

void setStore(boost::shared_ptr<BranchMapper> store) const {store_ = store;}

void setProcessHistoryID(ProcessHistoryID const& phid) {processHistoryID_ = &phid;}
void setProcessHistory(ProcessHistory const& ph) {processHistory_ = &ph;}

ProductID const& productID() const {return productID_;}

Expand All @@ -95,7 +94,7 @@ namespace edm {
private:
boost::shared_ptr<BranchDescription const> branchDescription_;
ProductID productID_;
ProcessHistoryID const* processHistoryID_; // Owned by Auxiliary
ProcessHistory const* processHistory_; // We don't own this
mutable bool productProvenanceValid_;
mutable boost::shared_ptr<ProductProvenance> productProvenancePtr_;
mutable boost::shared_ptr<BranchMapper> store_;
Expand Down
27 changes: 0 additions & 27 deletions DataFormats/Provenance/src/FullHistoryToReducedHistoryMap.cc

This file was deleted.

7 changes: 2 additions & 5 deletions DataFormats/Provenance/src/IndexIntoFile.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "DataFormats/Provenance/interface/IndexIntoFile.h"
#include "DataFormats/Provenance/interface/FullHistoryToReducedHistoryMap.h"
#include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"
#include "FWCore/Utilities/interface/Algorithms.h"
#include "FWCore/Utilities/interface/EDMException.h"
Expand Down Expand Up @@ -321,9 +320,7 @@ namespace edm {
}

void
IndexIntoFile::reduceProcessHistoryIDs() {

FullHistoryToReducedHistoryMap const& phidConverter(ProcessHistoryRegistry::instance()->extra());
IndexIntoFile::reduceProcessHistoryIDs(ProcessHistoryRegistry const& processHistoryRegistry) {

std::vector<ProcessHistoryID> reducedPHIDs;

Expand All @@ -334,7 +331,7 @@ namespace edm {
std::vector<int> phidIndexConverter;
for(auto const& phid : processHistoryIDs_) {

ProcessHistoryID const& reducedPHID = phidConverter.reducedProcessHistoryID(phid);
ProcessHistoryID const& reducedPHID = processHistoryRegistry.reducedProcessHistoryID(phid);
mapEntry.first = reducedPHID;
insertResult = reducedPHIDToIndex.insert(mapEntry);

Expand Down
3 changes: 2 additions & 1 deletion DataFormats/Provenance/src/ProcessHistory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@ namespace edm {
return false;
}

void
ProcessHistory&
ProcessHistory::reduce() {
phid() = ProcessHistoryID();
for(auto& item : data_) {
item.reduce();
}
return *this;
}

bool
Expand Down
Loading

0 comments on commit 991df7e

Please sign in to comment.