Skip to content

Commit

Permalink
Merge pull request #19366 from Dr15Jones/asyncGlobalEndTransitions
Browse files Browse the repository at this point in the history
Implement async global end transitions
  • Loading branch information
cmsbuild committed Jun 26, 2017
2 parents fc51b5b + d9263a0 commit d18eb61
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 55 deletions.
2 changes: 2 additions & 0 deletions FWCore/Framework/interface/SubProcess.h
Expand Up @@ -79,11 +79,13 @@ namespace edm {
void doBeginRunAsync(WaitingTaskHolder iHolder, RunPrincipal const& principal, IOVSyncValue const& ts);

void doEndRun(RunPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException);
void doEndRunAsync(WaitingTaskHolder iHolder, RunPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException);

void doBeginLuminosityBlock(LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts);
void doBeginLuminosityBlockAsync(WaitingTaskHolder iHolder, LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts);

void doEndLuminosityBlock(LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException);
void doEndLuminosityBlockAsync(WaitingTaskHolder iHolder, LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException);


void doBeginStream(unsigned int);
Expand Down
16 changes: 14 additions & 2 deletions FWCore/Framework/src/EventProcessor.cc
Expand Up @@ -1726,10 +1726,22 @@ namespace edm {
//looper_->doStreamEndRun(schedule_->streamID(),runPrincipal, es);
}
{
auto globalWaitTask = make_empty_waiting_task();
globalWaitTask->increment_ref_count();

runPrincipal.setAtEndTransition(true);
typedef OccurrenceTraits<RunPrincipal, BranchActionGlobalEnd> Traits;
schedule_->processOneGlobal<Traits>(runPrincipal, es, cleaningUpAfterException);
for_all(subProcesses_, [&runPrincipal, &ts, cleaningUpAfterException](auto& subProcess){subProcess.doEndRun(runPrincipal, ts, cleaningUpAfterException); });
endGlobalTransitionAsync<Traits>(WaitingTaskHolder(globalWaitTask.get()),
*schedule_,
runPrincipal,
ts,
es,
subProcesses_,
cleaningUpAfterException);
globalWaitTask->wait_for_all();
if(globalWaitTask->exceptionPtr() != nullptr) {
std::rethrow_exception(* (globalWaitTask->exceptionPtr()) );
}
}
FDEBUG(1) << "\tendRun " << run.runNumber() << "\n";
if(looper_) {
Expand Down
36 changes: 36 additions & 0 deletions FWCore/Framework/src/SubProcess.cc
Expand Up @@ -480,6 +480,25 @@ namespace edm {
for_all(subProcesses_, [&rp, &ts, cleaningUpAfterException](auto& subProcess){ subProcess.doEndRun(rp, ts, cleaningUpAfterException); });
}

void
SubProcess::doEndRunAsync(WaitingTaskHolder iHolder,
RunPrincipal const& principal,
IOVSyncValue const& ts,
bool cleaningUpAfterException) {
RunPrincipal& rp = *principalCache_.runPrincipalPtr();
rp.setComplete();
propagateProducts(InRun, principal, rp);
typedef OccurrenceTraits<RunPrincipal, BranchActionGlobalEnd> Traits;
rp.setAtEndTransition(true);
endGlobalTransitionAsync<Traits>(std::move(iHolder),
*schedule_,
rp,
ts,
esp_->eventSetupForInstance(ts),
subProcesses_,
cleaningUpAfterException);
}

void
SubProcess::writeRun(ProcessHistoryID const& parentPhID, int runNumber) {
ServiceRegistry::Operate operate(serviceToken_);
Expand Down Expand Up @@ -562,6 +581,23 @@ namespace edm {
for_all(subProcesses_, [&lbp, &ts, cleaningUpAfterException](auto& subProcess){ subProcess.doEndLuminosityBlock(lbp, ts, cleaningUpAfterException); });
}

void
SubProcess::doEndLuminosityBlockAsync(WaitingTaskHolder iHolder,LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException) {
LuminosityBlockPrincipal& lbp = *principalCache_.lumiPrincipalPtr();
lbp.setComplete();
propagateProducts(InLumi, principal, lbp);
typedef OccurrenceTraits<LuminosityBlockPrincipal, BranchActionGlobalEnd> Traits;
lbp.setAtEndTransition(true);
endGlobalTransitionAsync<Traits>(std::move(iHolder),
*schedule_,
lbp,
ts,
esp_->eventSetupForInstance(ts),
subProcesses_,
cleaningUpAfterException);
}


void
SubProcess::writeLumi(ProcessHistoryID const& parentPhID, int runNumber, int lumiNumber) {
ServiceRegistry::Operate operate(serviceToken_);
Expand Down
2 changes: 0 additions & 2 deletions FWCore/Framework/src/globalTransitionAsync.h
Expand Up @@ -43,15 +43,13 @@ namespace edm {
iSubProcess.doBeginRunAsync(std::move(iHolder),iPrincipal, iTS);
}

/*Not implemented yet
inline void subProcessDoGlobalEndTransitionAsync(WaitingTaskHolder iHolder, SubProcess& iSubProcess, LuminosityBlockPrincipal& iPrincipal, IOVSyncValue const& iTS, bool cleaningUpAfterException) {
iSubProcess.doEndLuminosityBlockAsync(std::move(iHolder),iPrincipal, iTS,cleaningUpAfterException);
}

inline void subProcessDoGlobalEndTransitionAsync(WaitingTaskHolder iHolder, SubProcess& iSubProcess, RunPrincipal& iPrincipal, IOVSyncValue const& iTS, bool cleaningUpAfterException) {
iSubProcess.doEndRunAsync(std::move(iHolder), iPrincipal, iTS, cleaningUpAfterException);
}
*/

template<typename Traits, typename P, typename SC >
void beginGlobalTransitionAsync(WaitingTaskHolder iWait,
Expand Down
102 changes: 51 additions & 51 deletions FWCore/Integration/test/unit_test_outputs/testSubProcess.grep2.txt
Expand Up @@ -2397,23 +2397,6 @@
++++ starting: global end run 1 : time = 0
++++ finished: global end run 1 : time = 0
++++ starting: global end run 1 : time = 0
++++++ starting: global end run for module: label = 'thingWithMergeProducer' id = 10
++++++ finished: global end run for module: label = 'thingWithMergeProducer' id = 10
++++++ starting: global end run for module: label = 'test' id = 11
++++++ finished: global end run for module: label = 'test' id = 11
++++++ starting: global end run for module: label = 'testmerge' id = 12
++++++ finished: global end run for module: label = 'testmerge' id = 12
++++++ starting: global end run for module: label = 'get' id = 13
++++++ finished: global end run for module: label = 'get' id = 13
++++++ starting: global end run for module: label = 'getInt' id = 14
++++++ finished: global end run for module: label = 'getInt' id = 14
++++++ starting: global end run for module: label = 'dependsOnNoPut' id = 15
++++++ finished: global end run for module: label = 'dependsOnNoPut' id = 15
++++++ starting: global end run for module: label = 'out' id = 16
++++++ finished: global end run for module: label = 'out' id = 16
++++++ starting: global end run for module: label = 'TriggerResults' id = 9
++++++ finished: global end run for module: label = 'TriggerResults' id = 9
++++ finished: global end run 1 : time = 0
++++ starting: global end run 1 : time = 0
++++++ starting: global end run for module: label = 'thingWithMergeProducer' id = 18
++++++ finished: global end run for module: label = 'thingWithMergeProducer' id = 18
Expand All @@ -2432,6 +2415,23 @@
++++++ starting: global end run for module: label = 'TriggerResults' id = 17
++++++ finished: global end run for module: label = 'TriggerResults' id = 17
++++ finished: global end run 1 : time = 0
++++++ starting: global end run for module: label = 'thingWithMergeProducer' id = 10
++++++ finished: global end run for module: label = 'thingWithMergeProducer' id = 10
++++++ starting: global end run for module: label = 'test' id = 11
++++++ finished: global end run for module: label = 'test' id = 11
++++++ starting: global end run for module: label = 'testmerge' id = 12
++++++ finished: global end run for module: label = 'testmerge' id = 12
++++++ starting: global end run for module: label = 'get' id = 13
++++++ finished: global end run for module: label = 'get' id = 13
++++++ starting: global end run for module: label = 'getInt' id = 14
++++++ finished: global end run for module: label = 'getInt' id = 14
++++++ starting: global end run for module: label = 'dependsOnNoPut' id = 15
++++++ finished: global end run for module: label = 'dependsOnNoPut' id = 15
++++++ starting: global end run for module: label = 'out' id = 16
++++++ finished: global end run for module: label = 'out' id = 16
++++++ starting: global end run for module: label = 'TriggerResults' id = 9
++++++ finished: global end run for module: label = 'TriggerResults' id = 9
++++ finished: global end run 1 : time = 0
++++ starting: source run
++++ finished: source run
++++ starting: global begin run 2 : time = 55000001
Expand Down Expand Up @@ -4677,23 +4677,6 @@
++++ starting: global end run 2 : time = 0
++++ finished: global end run 2 : time = 0
++++ starting: global end run 2 : time = 0
++++++ starting: global end run for module: label = 'thingWithMergeProducer' id = 10
++++++ finished: global end run for module: label = 'thingWithMergeProducer' id = 10
++++++ starting: global end run for module: label = 'test' id = 11
++++++ finished: global end run for module: label = 'test' id = 11
++++++ starting: global end run for module: label = 'testmerge' id = 12
++++++ finished: global end run for module: label = 'testmerge' id = 12
++++++ starting: global end run for module: label = 'get' id = 13
++++++ finished: global end run for module: label = 'get' id = 13
++++++ starting: global end run for module: label = 'getInt' id = 14
++++++ finished: global end run for module: label = 'getInt' id = 14
++++++ starting: global end run for module: label = 'dependsOnNoPut' id = 15
++++++ finished: global end run for module: label = 'dependsOnNoPut' id = 15
++++++ starting: global end run for module: label = 'out' id = 16
++++++ finished: global end run for module: label = 'out' id = 16
++++++ starting: global end run for module: label = 'TriggerResults' id = 9
++++++ finished: global end run for module: label = 'TriggerResults' id = 9
++++ finished: global end run 2 : time = 0
++++ starting: global end run 2 : time = 0
++++++ starting: global end run for module: label = 'thingWithMergeProducer' id = 18
++++++ finished: global end run for module: label = 'thingWithMergeProducer' id = 18
Expand All @@ -4712,6 +4695,23 @@
++++++ starting: global end run for module: label = 'TriggerResults' id = 17
++++++ finished: global end run for module: label = 'TriggerResults' id = 17
++++ finished: global end run 2 : time = 0
++++++ starting: global end run for module: label = 'thingWithMergeProducer' id = 10
++++++ finished: global end run for module: label = 'thingWithMergeProducer' id = 10
++++++ starting: global end run for module: label = 'test' id = 11
++++++ finished: global end run for module: label = 'test' id = 11
++++++ starting: global end run for module: label = 'testmerge' id = 12
++++++ finished: global end run for module: label = 'testmerge' id = 12
++++++ starting: global end run for module: label = 'get' id = 13
++++++ finished: global end run for module: label = 'get' id = 13
++++++ starting: global end run for module: label = 'getInt' id = 14
++++++ finished: global end run for module: label = 'getInt' id = 14
++++++ starting: global end run for module: label = 'dependsOnNoPut' id = 15
++++++ finished: global end run for module: label = 'dependsOnNoPut' id = 15
++++++ starting: global end run for module: label = 'out' id = 16
++++++ finished: global end run for module: label = 'out' id = 16
++++++ starting: global end run for module: label = 'TriggerResults' id = 9
++++++ finished: global end run for module: label = 'TriggerResults' id = 9
++++ finished: global end run 2 : time = 0
++++ starting: source run
++++ finished: source run
++++ starting: global begin run 3 : time = 105000001
Expand Down Expand Up @@ -6957,23 +6957,6 @@
++++ starting: global end run 3 : time = 0
++++ finished: global end run 3 : time = 0
++++ starting: global end run 3 : time = 0
++++++ starting: global end run for module: label = 'thingWithMergeProducer' id = 10
++++++ finished: global end run for module: label = 'thingWithMergeProducer' id = 10
++++++ starting: global end run for module: label = 'test' id = 11
++++++ finished: global end run for module: label = 'test' id = 11
++++++ starting: global end run for module: label = 'testmerge' id = 12
++++++ finished: global end run for module: label = 'testmerge' id = 12
++++++ starting: global end run for module: label = 'get' id = 13
++++++ finished: global end run for module: label = 'get' id = 13
++++++ starting: global end run for module: label = 'getInt' id = 14
++++++ finished: global end run for module: label = 'getInt' id = 14
++++++ starting: global end run for module: label = 'dependsOnNoPut' id = 15
++++++ finished: global end run for module: label = 'dependsOnNoPut' id = 15
++++++ starting: global end run for module: label = 'out' id = 16
++++++ finished: global end run for module: label = 'out' id = 16
++++++ starting: global end run for module: label = 'TriggerResults' id = 9
++++++ finished: global end run for module: label = 'TriggerResults' id = 9
++++ finished: global end run 3 : time = 0
++++ starting: global end run 3 : time = 0
++++++ starting: global end run for module: label = 'thingWithMergeProducer' id = 18
++++++ finished: global end run for module: label = 'thingWithMergeProducer' id = 18
Expand All @@ -6992,6 +6975,23 @@
++++++ starting: global end run for module: label = 'TriggerResults' id = 17
++++++ finished: global end run for module: label = 'TriggerResults' id = 17
++++ finished: global end run 3 : time = 0
++++++ starting: global end run for module: label = 'thingWithMergeProducer' id = 10
++++++ finished: global end run for module: label = 'thingWithMergeProducer' id = 10
++++++ starting: global end run for module: label = 'test' id = 11
++++++ finished: global end run for module: label = 'test' id = 11
++++++ starting: global end run for module: label = 'testmerge' id = 12
++++++ finished: global end run for module: label = 'testmerge' id = 12
++++++ starting: global end run for module: label = 'get' id = 13
++++++ finished: global end run for module: label = 'get' id = 13
++++++ starting: global end run for module: label = 'getInt' id = 14
++++++ finished: global end run for module: label = 'getInt' id = 14
++++++ starting: global end run for module: label = 'dependsOnNoPut' id = 15
++++++ finished: global end run for module: label = 'dependsOnNoPut' id = 15
++++++ starting: global end run for module: label = 'out' id = 16
++++++ finished: global end run for module: label = 'out' id = 16
++++++ starting: global end run for module: label = 'TriggerResults' id = 9
++++++ finished: global end run for module: label = 'TriggerResults' id = 9
++++ finished: global end run 3 : time = 0
++++ starting: end stream for module: stream = 0 label = 'thingWithMergeProducer' id = 2
++++ finished: end stream for module: stream = 0 label = 'thingWithMergeProducer' id = 2
++++ starting: end stream for module: stream = 0 label = 'get' id = 3
Expand Down

0 comments on commit d18eb61

Please sign in to comment.