Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added stream based transitions #72

Merged
merged 7 commits into from
Jul 13, 2013
6 changes: 4 additions & 2 deletions FWCore/Framework/interface/BranchActionType.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ BranchActionType: BranchAction

namespace edm {
enum BranchActionType {
BranchActionBegin = 0,
BranchActionEnd = 1
BranchActionGlobalBegin = 0,
BranchActionStreamBegin = 1,
BranchActionStreamEnd = 2,
BranchActionGlobalEnd = 3
};
}
#endif
144 changes: 128 additions & 16 deletions FWCore/Framework/interface/OccurrenceTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace edm {
template <typename T, BranchActionType B> class OccurrenceTraits;

template <>
class OccurrenceTraits<EventPrincipal, BranchActionBegin> {
class OccurrenceTraits<EventPrincipal, BranchActionStreamBegin> {
public:
typedef EventPrincipal MyPrincipal;
static BranchType const branchType_ = InEvent;
Expand Down Expand Up @@ -51,7 +51,7 @@ namespace edm {
};

template <>
class OccurrenceTraits<RunPrincipal, BranchActionBegin> {
class OccurrenceTraits<RunPrincipal, BranchActionGlobalBegin> {
public:
typedef RunPrincipal MyPrincipal;
static BranchType const branchType_ = InRun;
Expand Down Expand Up @@ -79,63 +79,175 @@ namespace edm {
};

template <>
class OccurrenceTraits<RunPrincipal, BranchActionEnd> {
class OccurrenceTraits<RunPrincipal, BranchActionStreamBegin> {
public:
typedef RunPrincipal MyPrincipal;
static BranchType const branchType_ = InRun;
static bool const begin_ = true;
static bool const isEvent_ = false;
static void preScheduleSignal(ActivityRegistry *a, RunPrincipal const* ep) {
//a->preBeginRunSignal_(ep->id(), ep->beginTime());
}
static void postScheduleSignal(ActivityRegistry *a, RunPrincipal* ep, EventSetup const* es) {
Run run(*ep, ModuleDescription());
//a->postBeginRunSignal_(run, *es);
}
static void prePathSignal(ActivityRegistry *a, std::string const& s) {
//a->prePathBeginRunSignal_(s);
}
static void postPathSignal(ActivityRegistry *a, std::string const& s, HLTPathStatus const& status) {
//a->postPathBeginRunSignal_(s, status);
}
static void preModuleSignal(ActivityRegistry *a, ModuleDescription const* md) {
//a->preModuleBeginRunSignal_(*md);
}
static void postModuleSignal(ActivityRegistry *a, ModuleDescription const* md) {
//a->postModuleBeginRunSignal_(*md);
}
};

template <>
class OccurrenceTraits<RunPrincipal, BranchActionStreamEnd> {
public:
typedef RunPrincipal MyPrincipal;
static BranchType const branchType_ = InRun;
static bool const begin_ = false;
static bool const isEvent_ = false;
static void preScheduleSignal(ActivityRegistry *a, RunPrincipal const* ep) {
a->preEndRunSignal_(ep->id(), ep->endTime());
//a->preEndRunSignal_(ep->id(), ep->endTime());
}
static void postScheduleSignal(ActivityRegistry *a, RunPrincipal* ep, EventSetup const* es) {
//Run run(*ep, ModuleDescription());
//a->postEndRunSignal_(run, *es);
}
static void prePathSignal(ActivityRegistry *a, std::string const& s) {
//a->prePathEndRunSignal_(s);
}
static void postPathSignal(ActivityRegistry *a, std::string const& s, HLTPathStatus const& status) {
//a->postPathEndRunSignal_(s, status);
}
static void preModuleSignal(ActivityRegistry *a, ModuleDescription const* md) {
//a->preModuleEndRunSignal_(*md);
}
static void postModuleSignal(ActivityRegistry *a, ModuleDescription const* md) {
//a->postModuleEndRunSignal_(*md);
}
};

template <>
class OccurrenceTraits<RunPrincipal, BranchActionGlobalEnd> {
public:
typedef RunPrincipal MyPrincipal;
static BranchType const branchType_ = InRun;
static bool const begin_ = false;
static bool const isEvent_ = false;
static void preScheduleSignal(ActivityRegistry *a, RunPrincipal const* ep) {
a->preEndRunSignal_(ep->id(), ep->endTime());
}
static void postScheduleSignal(ActivityRegistry *a, RunPrincipal* ep, EventSetup const* es) {
Run run(*ep, ModuleDescription());
a->postEndRunSignal_(run, *es);
}
static void prePathSignal(ActivityRegistry *a, std::string const& s) {
a->prePathEndRunSignal_(s);
a->prePathEndRunSignal_(s);
}
static void postPathSignal(ActivityRegistry *a, std::string const& s, HLTPathStatus const& status) {
a->postPathEndRunSignal_(s, status);
a->postPathEndRunSignal_(s, status);
}
static void preModuleSignal(ActivityRegistry *a, ModuleDescription const* md) {
a->preModuleEndRunSignal_(*md);
a->preModuleEndRunSignal_(*md);
}
static void postModuleSignal(ActivityRegistry *a, ModuleDescription const* md) {
a->postModuleEndRunSignal_(*md);
a->postModuleEndRunSignal_(*md);
}
};

template <>
class OccurrenceTraits<LuminosityBlockPrincipal, BranchActionBegin> {
class OccurrenceTraits<LuminosityBlockPrincipal, BranchActionGlobalBegin> {
public:
typedef LuminosityBlockPrincipal MyPrincipal;
static BranchType const branchType_ = InLumi;
static bool const begin_ = true;
static bool const isEvent_ = false;
static void preScheduleSignal(ActivityRegistry *a, LuminosityBlockPrincipal const* ep) {
a->preBeginLumiSignal_(ep->id(), ep->beginTime());
a->preBeginLumiSignal_(ep->id(), ep->beginTime());
}
static void postScheduleSignal(ActivityRegistry *a, LuminosityBlockPrincipal* ep, EventSetup const* es) {
LuminosityBlock lumi(*ep, ModuleDescription());
a->postBeginLumiSignal_(lumi, *es);
}
static void prePathSignal(ActivityRegistry *a, std::string const& s) {
a->prePathBeginLumiSignal_(s);
a->prePathBeginLumiSignal_(s);
}
static void postPathSignal(ActivityRegistry *a, std::string const& s, HLTPathStatus const& status) {
a->postPathBeginLumiSignal_(s, status);
}
static void preModuleSignal(ActivityRegistry *a, ModuleDescription const* md) {
a->preModuleBeginLumiSignal_(*md);
}
static void postModuleSignal(ActivityRegistry *a, ModuleDescription const* md) {
a->postModuleBeginLumiSignal_(*md);
}
};

template <>
class OccurrenceTraits<LuminosityBlockPrincipal, BranchActionStreamBegin> {
public:
typedef LuminosityBlockPrincipal MyPrincipal;
static BranchType const branchType_ = InLumi;
static bool const begin_ = true;
static bool const isEvent_ = false;
static void preScheduleSignal(ActivityRegistry *a, LuminosityBlockPrincipal const* ep) {
//a->preBeginLumiSignal_(ep->id(), ep->beginTime());
}
static void postScheduleSignal(ActivityRegistry *a, LuminosityBlockPrincipal* ep, EventSetup const* es) {
//LuminosityBlock lumi(*ep, ModuleDescription());
//a->postBeginLumiSignal_(lumi, *es);
}
static void prePathSignal(ActivityRegistry *a, std::string const& s) {
//a->prePathBeginLumiSignal_(s);
}
static void postPathSignal(ActivityRegistry *a, std::string const& s, HLTPathStatus const& status) {
//a->postPathBeginLumiSignal_(s, status);
}
static void preModuleSignal(ActivityRegistry *a, ModuleDescription const* md) {
//a->preModuleBeginLumiSignal_(*md);
}
static void postModuleSignal(ActivityRegistry *a, ModuleDescription const* md) {
//a->postModuleBeginLumiSignal_(*md);
}
};

template <>
class OccurrenceTraits<LuminosityBlockPrincipal, BranchActionStreamEnd> {
public:
typedef LuminosityBlockPrincipal MyPrincipal;
static BranchType const branchType_ = InLumi;
static bool const begin_ = false;
static bool const isEvent_ = false;
static void preScheduleSignal(ActivityRegistry *a, LuminosityBlockPrincipal const* ep) {
//a->preEndLumiSignal_(ep->id(), ep->beginTime());
}
static void postScheduleSignal(ActivityRegistry *a, LuminosityBlockPrincipal* ep, EventSetup const* es) {
//LuminosityBlock lumi(*ep, ModuleDescription());
//a->postEndLumiSignal_(lumi, *es);
}
static void prePathSignal(ActivityRegistry *a, std::string const& s) {
//a->prePathEndLumiSignal_(s);
}
static void postPathSignal(ActivityRegistry *a, std::string const& s, HLTPathStatus const& status) {
a->postPathBeginLumiSignal_(s, status);
//a->postPathEndLumiSignal_(s, status);
}
static void preModuleSignal(ActivityRegistry *a, ModuleDescription const* md) {
a->preModuleBeginLumiSignal_(*md);
//a->preModuleEndLumiSignal_(*md);
}
static void postModuleSignal(ActivityRegistry *a, ModuleDescription const* md) {
a->postModuleBeginLumiSignal_(*md);
//a->postModuleEndLumiSignal_(*md);
}
};

template <>
class OccurrenceTraits<LuminosityBlockPrincipal, BranchActionEnd> {
class OccurrenceTraits<LuminosityBlockPrincipal, BranchActionGlobalEnd> {
public:
typedef LuminosityBlockPrincipal MyPrincipal;
static BranchType const branchType_ = InLumi;
Expand Down
36 changes: 12 additions & 24 deletions FWCore/Framework/interface/Schedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
#include "FWCore/Utilities/interface/BranchType.h"
#include "FWCore/Utilities/interface/ConvertException.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "FWCore/Utilities/interface/StreamID.h"

#include "boost/shared_ptr.hpp"

Expand Down Expand Up @@ -122,7 +123,8 @@ namespace edm {
ActionTable const& actions,
boost::shared_ptr<ActivityRegistry> areg,
boost::shared_ptr<ProcessConfiguration> processConfiguration,
const ParameterSet* subProcPSet);
const ParameterSet* subProcPSet,
StreamID streamID);

enum State { Ready = 0, Running, Latched };

Expand Down Expand Up @@ -319,28 +321,10 @@ namespace edm {
int total_passed_;
RunStopwatch::StopwatchPointer stopwatch_;

StreamID streamID_;
volatile bool endpathsAreActive_;
};

// -----------------------------
// ProcessOneOccurrence is a functor that has bound a specific
// Principal and Event Setup, and can be called with a Path, to
// execute Path::processOneOccurrence for that event

template <typename T>
class ProcessOneOccurrence {
public:
typedef void result_type;
ProcessOneOccurrence(typename T::MyPrincipal& principal, EventSetup const& setup) :
ep(principal), es(setup) {};

void operator()(Path& p) {p.processOneOccurrence<T>(ep, es);}

private:
typename T::MyPrincipal& ep;
EventSetup const& es;
};

void
inline
Schedule::reportSkipped(EventPrincipal const& ep) const {
Expand All @@ -363,7 +347,7 @@ namespace edm {
RunStopwatch stopwatch(T::isEvent_ ? stopwatch_ : RunStopwatch::StopwatchPointer());

// This call takes care of the unscheduled processing.
workerManager_.processOneOccurrence<T>(ep, es, cleaningUpAfterException);
workerManager_.processOneOccurrence<T>(ep, es, streamID_, cleaningUpAfterException);

if (T::isEvent_) {
++total_events_;
Expand All @@ -389,7 +373,7 @@ namespace edm {

try {
CPUTimer timer;
if (results_inserter_.get()) results_inserter_->doWork<T>(ep, es, nullptr, &timer);
if (results_inserter_.get()) results_inserter_->doWork<T>(ep, es, nullptr, &timer,streamID_);
}
catch (cms::Exception & ex) {
if (T::isEvent_) {
Expand Down Expand Up @@ -427,7 +411,9 @@ namespace edm {
template <typename T>
bool
Schedule::runTriggerPaths(typename T::MyPrincipal& ep, EventSetup const& es) {
for_all(trig_paths_, ProcessOneOccurrence<T>(ep, es));
for(auto& p : trig_paths_) {
p.processOneOccurrence<T>(ep, es, streamID_);
}
return results_->accept();
}

Expand All @@ -436,7 +422,9 @@ namespace edm {
Schedule::runEndPaths(typename T::MyPrincipal& ep, EventSetup const& es) {
// Note there is no state-checking safety controlling the
// activation/deactivation of endpaths.
for_all(end_paths_, ProcessOneOccurrence<T>(ep, es));
for(auto& p : end_paths_) {
p.processOneOccurrence<T>(ep, es, streamID_);
}

// We could get rid of the functor ProcessOneOccurrence if we used
// boost::lambda, but the use of lambda with member functions
Expand Down
4 changes: 3 additions & 1 deletion FWCore/Framework/interface/ScheduleItems.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace edm {
class ProductRegistry;
class Schedule;
class SignallingProductRegistry;
class StreamID;

struct ScheduleItems {
ScheduleItems();
Expand All @@ -44,7 +45,8 @@ namespace edm {

std::auto_ptr<Schedule>
initSchedule(ParameterSet& parameterSet,
ParameterSet const* subProcessPSet);
ParameterSet const* subProcessPSet,
StreamID streamID);

void
clear();
Expand Down
6 changes: 3 additions & 3 deletions FWCore/Framework/interface/UnscheduledCallProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ namespace edm {
}

template <typename T>
void runNow(typename T::MyPrincipal& p, EventSetup const& es) {
void runNow(typename T::MyPrincipal& p, EventSetup const& es, StreamID streamID) {
//do nothing for event since we will run when requested
if(!T::isEvent_) {
for(std::map<std::string, Worker*>::iterator it = labelToWorkers_.begin(), itEnd=labelToWorkers_.end();
it != itEnd;
++it) {
CPUTimer timer;
try {
it->second->doWork<T>(p, es, nullptr, &timer);
it->second->doWork<T>(p, es, nullptr, &timer,streamID);
}
catch (cms::Exception & ex) {
std::ostringstream ost;
Expand Down Expand Up @@ -75,7 +75,7 @@ namespace edm {
if(itFound != labelToWorkers_.end()) {
CPUTimer timer;
try {
itFound->second->doWork<OccurrenceTraits<EventPrincipal, BranchActionBegin> >(event, eventSetup, iContext, &timer);
itFound->second->doWork<OccurrenceTraits<EventPrincipal, BranchActionStreamBegin> >(event, eventSetup, iContext, &timer,event.streamID());
}
catch (cms::Exception & ex) {
std::ostringstream ost;
Expand Down
6 changes: 5 additions & 1 deletion FWCore/Framework/interface/WorkerManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

namespace edm {
class ExceptionCollector;
class StreamID;

class WorkerManager {
public:
typedef std::vector<Worker*> AllWorkers;
Expand All @@ -40,6 +42,7 @@ namespace edm {
template <typename T>
void processOneOccurrence(typename T::MyPrincipal& principal,
EventSetup const& eventSetup,
StreamID streamID,
bool cleaningUpAfterException = false);

void beginJob(ProductRegistry const& iRegistry);
Expand Down Expand Up @@ -75,6 +78,7 @@ namespace edm {
void
WorkerManager::processOneOccurrence(typename T::MyPrincipal& ep,
EventSetup const& es,
StreamID streamID,
bool cleaningUpAfterException) {
this->resetAll();

Expand All @@ -85,7 +89,7 @@ namespace edm {
setupOnDemandSystem(dynamic_cast<EventPrincipal&>(ep), es);
} else {
//make sure the unscheduled items see this run or lumi rtansition
unscheduled_->runNow<T>(ep, es);
unscheduled_->runNow<T>(ep, es,streamID);
}
}
catch(cms::Exception& e) {
Expand Down
Loading