CMS 3D CMS Logo

streamTransitionAsync.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_streamTransitionAsync_h
2 #define FWCore_Framework_streamTransitionAsync_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/Framework
6 // Function: streamTransitionAsync
7 //
16 //
17 // Original Author: Chris Jones
18 // Created: Tue, 06 Sep 2016 16:04:26 GMT
19 //
20 
26 
27 #include <vector>
28 
29 namespace edm {
30 
31  //This is code in common between beginStreamRun and beginStreamLuminosityBlock
33  SubProcess& iSubProcess,
34  unsigned int i,
35  LumiTransitionInfo const& iTransitionInfo) {
36  iSubProcess.doStreamBeginLuminosityBlockAsync(std::move(iHolder), i, iTransitionInfo);
37  }
38 
40  SubProcess& iSubProcess,
41  unsigned int i,
42  RunTransitionInfo const& iTransitionInfo) {
43  iSubProcess.doStreamBeginRunAsync(std::move(iHolder), i, iTransitionInfo);
44  }
45 
47  SubProcess& iSubProcess,
48  unsigned int i,
49  LumiTransitionInfo const& iTransitionInfo,
50  bool cleaningUpAfterException) {
51  iSubProcess.doStreamEndLuminosityBlockAsync(std::move(iHolder), i, iTransitionInfo, cleaningUpAfterException);
52  }
53 
55  SubProcess& iSubProcess,
56  unsigned int i,
57  RunTransitionInfo const& iTransitionInfo,
58  bool cleaningUpAfterException) {
59  iSubProcess.doStreamEndRunAsync(std::move(iHolder), i, iTransitionInfo, cleaningUpAfterException);
60  }
61 
62  template <typename Traits>
64  Schedule& iSchedule,
65  unsigned int iStreamIndex,
66  typename Traits::TransitionInfoType& transitionInfo,
67  ServiceToken const& token,
68  std::vector<SubProcess>& iSubProcesses) {
69  //When we are done processing the stream for this process,
70  // we need to run the stream for all SubProcesses
71  //NOTE: The subprocesses set their own service tokens
72  auto subs = make_waiting_task(
73  tbb::task::allocate_root(),
74  [&iSubProcesses, iWait, iStreamIndex, info = transitionInfo](std::exception_ptr const* iPtr) mutable {
75  if (iPtr) {
76  auto excpt = *iPtr;
77  auto delayError =
78  make_waiting_task(tbb::task::allocate_root(),
79  [iWait, excpt](std::exception_ptr const*) mutable { iWait.doneWaiting(excpt); });
80  WaitingTaskHolder h(delayError);
81  for (auto& subProcess : iSubProcesses) {
82  subProcessDoStreamBeginTransitionAsync(h, subProcess, iStreamIndex, info);
83  };
84  } else {
85  for (auto& subProcess : iSubProcesses) {
86  subProcessDoStreamBeginTransitionAsync(iWait, subProcess, iStreamIndex, info);
87  };
88  }
89  });
90 
91  WaitingTaskHolder h(subs);
92  iSchedule.processOneStreamAsync<Traits>(std::move(h), iStreamIndex, transitionInfo, token);
93  }
94 
95  template <typename Traits>
97  Schedule& iSchedule,
98  unsigned int iNStreams,
99  typename Traits::TransitionInfoType& transitionInfo,
100  ServiceToken const& token,
101  std::vector<SubProcess>& iSubProcesses) {
102  WaitingTaskHolder holdUntilAllStreamsCalled(iWait);
103  for (unsigned int i = 0; i < iNStreams; ++i) {
104  beginStreamTransitionAsync<Traits>(WaitingTaskHolder(iWait), iSchedule, i, transitionInfo, token, iSubProcesses);
105  }
106  }
107 
108  template <typename Traits>
110  Schedule& iSchedule,
111  unsigned int iStreamIndex,
112  typename Traits::TransitionInfoType& transitionInfo,
113  ServiceToken const& token,
114  std::vector<SubProcess>& iSubProcesses,
115  bool cleaningUpAfterException) {
116  //When we are done processing the stream for this process,
117  // we need to run the stream for all SubProcesses
118  //NOTE: The subprocesses set their own service tokens
119 
120  auto subs = make_waiting_task(
121  tbb::task::allocate_root(),
122  [&iSubProcesses, iWait, iStreamIndex, info = transitionInfo, cleaningUpAfterException](
123  std::exception_ptr const* iPtr) mutable {
124  if (iPtr) {
125  auto excpt = *iPtr;
126  auto delayError =
127  make_waiting_task(tbb::task::allocate_root(),
128  [iWait, excpt](std::exception_ptr const*) mutable { iWait.doneWaiting(excpt); });
129  WaitingTaskHolder h(delayError);
130  for (auto& subProcess : iSubProcesses) {
131  subProcessDoStreamEndTransitionAsync(h, subProcess, iStreamIndex, info, cleaningUpAfterException);
132  }
133  } else {
134  for (auto& subProcess : iSubProcesses) {
135  subProcessDoStreamEndTransitionAsync(iWait, subProcess, iStreamIndex, info, cleaningUpAfterException);
136  }
137  }
138  });
139 
140  iSchedule.processOneStreamAsync<Traits>(
141  WaitingTaskHolder(subs), iStreamIndex, transitionInfo, token, cleaningUpAfterException);
142  }
143 
144  template <typename Traits>
146  Schedule& iSchedule,
147  unsigned int iNStreams,
148  typename Traits::TransitionInfoType& transitionInfo,
149  ServiceToken const& iToken,
150  std::vector<SubProcess>& iSubProcesses,
151  bool cleaningUpAfterException) {
152  for (unsigned int i = 0; i < iNStreams; ++i) {
153  endStreamTransitionAsync<Traits>(
154  iWait, iSchedule, i, transitionInfo, iToken, iSubProcesses, cleaningUpAfterException);
155  }
156  }
157 }; // namespace edm
158 
159 #endif
mps_fire.i
i
Definition: mps_fire.py:428
edm::SubProcess
Definition: SubProcess.h:50
edm::subProcessDoStreamBeginTransitionAsync
void subProcessDoStreamBeginTransitionAsync(WaitingTaskHolder iHolder, SubProcess &iSubProcess, unsigned int i, LumiTransitionInfo const &iTransitionInfo)
Definition: streamTransitionAsync.h:32
edm::beginStreamTransitionAsync
void beginStreamTransitionAsync(WaitingTaskHolder iWait, Schedule &iSchedule, unsigned int iStreamIndex, typename Traits::TransitionInfoType &transitionInfo, ServiceToken const &token, std::vector< SubProcess > &iSubProcesses)
Definition: streamTransitionAsync.h:63
edm::LumiTransitionInfo
Definition: TransitionInfoTypes.h:42
edm::endStreamTransitionAsync
void endStreamTransitionAsync(WaitingTaskHolder iWait, Schedule &iSchedule, unsigned int iStreamIndex, typename Traits::TransitionInfoType &transitionInfo, ServiceToken const &token, std::vector< SubProcess > &iSubProcesses, bool cleaningUpAfterException)
Definition: streamTransitionAsync.h:109
WaitingTaskHolder.h
edm::SubProcess::doStreamEndRunAsync
void doStreamEndRunAsync(WaitingTaskHolder iHolder, unsigned int iID, RunTransitionInfo const &, bool cleaningUpAfterException)
Definition: SubProcess.cc:648
edm
HLT enums.
Definition: AlignableModifier.h:19
h
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Definition: L1TUtmAlgorithmRcd.h:4
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
edm::WaitingTaskHolder::doneWaiting
void doneWaiting(std::exception_ptr iExcept)
Definition: WaitingTaskHolder.h:75
edm::Schedule::processOneStreamAsync
void processOneStreamAsync(WaitingTaskHolder iTask, unsigned int iStreamID, typename T::TransitionInfoType &transitionInfo, ServiceToken const &token, bool cleaningUpAfterException=false)
Definition: Schedule.h:319
edm::RunTransitionInfo
Definition: TransitionInfoTypes.h:64
edm::ServiceToken
Definition: ServiceToken.h:40
edm::endStreamsTransitionAsync
void endStreamsTransitionAsync(WaitingTaskHolder iWait, Schedule &iSchedule, unsigned int iNStreams, typename Traits::TransitionInfoType &transitionInfo, ServiceToken const &iToken, std::vector< SubProcess > &iSubProcesses, bool cleaningUpAfterException)
Definition: streamTransitionAsync.h:145
edm::Schedule
Definition: Schedule.h:121
h
edm::make_waiting_task
FunctorWaitingTask< F > * make_waiting_task(ALLOC &&iAlloc, F f)
Definition: WaitingTask.h:87
edm::WaitingTaskHolder
Definition: WaitingTaskHolder.h:30
edm::subProcessDoStreamEndTransitionAsync
void subProcessDoStreamEndTransitionAsync(WaitingTaskHolder iHolder, SubProcess &iSubProcess, unsigned int i, LumiTransitionInfo const &iTransitionInfo, bool cleaningUpAfterException)
Definition: streamTransitionAsync.h:46
Schedule.h
edm::beginStreamsTransitionAsync
void beginStreamsTransitionAsync(WaitingTask *iWait, Schedule &iSchedule, unsigned int iNStreams, typename Traits::TransitionInfoType &transitionInfo, ServiceToken const &token, std::vector< SubProcess > &iSubProcesses)
Definition: streamTransitionAsync.h:96
edm::SubProcess::doStreamBeginLuminosityBlockAsync
void doStreamBeginLuminosityBlockAsync(WaitingTaskHolder iHolder, unsigned int iID, LumiTransitionInfo const &)
Definition: SubProcess.cc:660
WaitingTask.h
SubProcess.h
edm::WaitingTask
Definition: WaitingTask.h:36
edm::SubProcess::doStreamBeginRunAsync
void doStreamBeginRunAsync(WaitingTaskHolder iHolder, unsigned int iID, RunTransitionInfo const &)
Definition: SubProcess.cc:638
eostools.move
def move(src, dest)
Definition: eostools.py:511
TransitionInfoTypes.h
edm::SubProcess::doStreamEndLuminosityBlockAsync
void doStreamEndLuminosityBlockAsync(WaitingTaskHolder iHolder, unsigned int iID, LumiTransitionInfo const &, bool cleaningUpAfterException)
Definition: SubProcess.cc:672
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:318