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, debugName) {}
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->debugName_, "dispatch() time: ", this->t_dispatch_);
28 
30  produce(iEvent, iSetup, this->client_->output());
31  sonic_utils::printDebugTime(this->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:15
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:48
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
SonicEDProducer::SonicEDProducer
SonicEDProducer(edm::ParameterSet const &cfg, const std::string &debugName)
Definition: SonicEDProducer.h:19
FrontierCondition_GT_autoExpress_cfi.t0
t0
Definition: FrontierCondition_GT_autoExpress_cfi.py:149
SonicEDProducer::~SonicEDProducer
~SonicEDProducer() override=default
SonicEDProducer::Output
Client::Output Output
Definition: SonicEDProducer.h:17
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::stream::EDProducer< edm::ExternalWork, Capabilities... >::EDProducer
EDProducer()=default
SonicAcquirer.h
edm::ParameterSet
Definition: ParameterSet.h:47
iEvent
int iEvent
Definition: GenABIO.cc:224
SonicAcquirer< Client, edm::stream::EDProducer< edm::ExternalWork, Capabilities... > >::client_
std::unique_ptr< Client > client_
Definition: SonicAcquirer.h:46
edm::EventSetup
Definition: EventSetup.h:58
looper.cfg
cfg
Definition: looper.py:297
SonicEDProducer
Definition: SonicEDProducer.h:14
edm::Event
Definition: Event.h:73
SonicAcquirer< Client, edm::stream::EDProducer< edm::ExternalWork, Capabilities... > >::debugName_
std::string debugName_
Definition: SonicAcquirer.h:47