CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
std::chrono::time_point< std::chrono::high_resolution_clock > t_dispatch_
Definition: SonicAcquirer.h:50
tuple cfg
Definition: looper.py:296
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
void produce(edm::Event &iEvent, edm::EventSetup const &iSetup) final
int iEvent
Definition: GenABIO.cc:224
static constexpr int verbose
Client::Output Output
SonicEDProducer(edm::ParameterSet const &cfg, const std::string &debugName, bool verbose=true)
void printDebugTime(std::string_view debugName, std::string_view msg, const TimePoint &t0)
Definition: sonic_utils.cc:8
~SonicEDProducer() override=default