CMS 3D CMS Logo

SonicEDProducer.h
Go to the documentation of this file.
1 #ifndef HeterogeneousCore_SonicCore_SonicEDProducer
2 #define HeterogeneousCore_SonicCore_SonicEDProducer
3 
7 
8 #include <string>
9 #include <chrono>
10 
11 //this is a stream producer because client operations are not multithread-safe in general
12 //it is designed such that the user never has to interact with the client or the acquire() callback directly
13 template <typename Client, typename... Capabilities>
14 class SonicEDProducer : public SonicAcquirer<Client, edm::stream::EDProducer<edm::ExternalWork, Capabilities...>> {
15 public:
16  //typedef to simplify usage
17  typedef typename Client::Output Output;
18  //constructor
20  : SonicAcquirer<Client, edm::stream::EDProducer<edm::ExternalWork, Capabilities...>>(cfg) {}
21  //destructor
22  ~SonicEDProducer() override = default;
23 
24  //derived classes use a dedicated produce() interface that incorporates client_.output()
25  void produce(edm::Event& iEvent, edm::EventSetup const& iSetup) final {
26  //measure time between acquire and produce
27  sonic_utils::printDebugTime(this->client_.debugName(), "dispatch() time: ", this->t_dispatch_);
28 
30  produce(iEvent, iSetup, this->client_.output());
31  sonic_utils::printDebugTime(this->client_.debugName(), "produce() time: ", t0);
32 
33  //reset client data
34  this->client_.reset();
35  }
36  virtual void produce(edm::Event& iEvent, edm::EventSetup const& iSetup, Output const& iOutput) = 0;
37 };
38 
39 #endif
SonicAcquirer
Definition: SonicAcquirer.h:13
sonic_utils.h
submitPVValidationJobs.now
now
Definition: submitPVValidationJobs.py:639
edm
HLT enums.
Definition: AlignableModifier.h:19
cms::cuda::stream
cudaStream_t stream
Definition: HistoContainer.h:57
SonicAcquirer< Client, edm::stream::EDProducer< edm::ExternalWork, Capabilities... > >::t_dispatch_
std::chrono::time_point< std::chrono::high_resolution_clock > t_dispatch_
Definition: SonicAcquirer.h:38
EDProducer.h
sonic_utils::printDebugTime
void printDebugTime(std::string_view debugName, std::string_view msg, const TimePoint &t0)
Definition: sonic_utils.cc:8
GetRecoTauVFromDQM_MC_cff.Output
Output
Definition: GetRecoTauVFromDQM_MC_cff.py:12
SonicEDProducer::produce
void produce(edm::Event &iEvent, edm::EventSetup const &iSetup) final
Definition: SonicEDProducer.h:25
FrontierCondition_GT_autoExpress_cfi.t0
t0
Definition: FrontierCondition_GT_autoExpress_cfi.py:148
SonicEDProducer::SonicEDProducer
SonicEDProducer(edm::ParameterSet const &cfg)
Definition: SonicEDProducer.h:19
SonicEDProducer::~SonicEDProducer
~SonicEDProducer() override=default
SonicEDProducer::Output
Client::Output Output
Definition: SonicEDProducer.h:17
edm::stream::EDProducer< edm::ExternalWork, Capabilities... >::EDProducer
EDProducer()=default
SonicAcquirer.h
edm::ParameterSet
Definition: ParameterSet.h:47
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
looper.cfg
cfg
Definition: looper.py:297
SonicEDProducer
Definition: SonicEDProducer.h:14
SonicAcquirer< Client, edm::stream::EDProducer< edm::ExternalWork, Capabilities... > >::client_
Client client_
Definition: SonicAcquirer.h:37
edm::Event
Definition: Event.h:73