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
19  SonicEDProducer(edm::ParameterSet const& cfg, const std::string& debugName, bool verbose = true)
20  : SonicAcquirer<Client, edm::stream::EDProducer<edm::ExternalWork, Capabilities...>>(cfg, debugName, verbose) {}
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  if (this->verbose_)
28  sonic_utils::printDebugTime(this->debugName_, "dispatch() time: ", this->t_dispatch_);
29 
31  produce(iEvent, iSetup, this->client_->output());
32  if (this->verbose_)
33  sonic_utils::printDebugTime(this->debugName_, "produce() time: ", t0);
34 
35  //reset client data
36  this->client_->reset();
37  }
38  virtual void produce(edm::Event& iEvent, edm::EventSetup const& iSetup, Output const& iOutput) = 0;
39 };
40 
41 #endif
SonicAcquirer
Definition: SonicAcquirer.h:15
SonicEDProducer::SonicEDProducer
SonicEDProducer(edm::ParameterSet const &cfg, const std::string &debugName, bool verbose=true)
Definition: SonicEDProducer.h:19
sonic_utils.h
submitPVValidationJobs.now
now
Definition: submitPVValidationJobs.py:639
edm
HLT enums.
Definition: AlignableModifier.h:19
SonicAcquirer< Client, edm::stream::EDProducer< edm::ExternalWork, Capabilities... > >::t_dispatch_
std::chrono::time_point< std::chrono::high_resolution_clock > t_dispatch_
Definition: SonicAcquirer.h:50
cms::cuda::stream
uint32_t const T *__restrict__ const uint32_t *__restrict__ int32_t int Histo::index_type cudaStream_t stream
Definition: HistoContainer.h:51
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
SonicAcquirer< Client, edm::stream::EDProducer< edm::ExternalWork, Capabilities... > >::verbose_
bool verbose_
Definition: SonicAcquirer.h:49
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:149
SonicEDProducer::~SonicEDProducer
~SonicEDProducer() override=default
verbose
static constexpr int verbose
Definition: HLTExoticaSubAnalysis.cc:25
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
SonicAcquirer< Client, edm::stream::EDProducer< edm::ExternalWork, Capabilities... > >::client_
std::unique_ptr< Client > client_
Definition: SonicAcquirer.h:47
edm::EventSetup
Definition: EventSetup.h:58
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
looper.cfg
cfg
Definition: looper.py:296
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:48