CMS 3D CMS Logo

SiPixelDigisSoAFromCUDA.cc
Go to the documentation of this file.
14 
15 class SiPixelDigisSoAFromCUDA : public edm::stream::EDProducer<edm::ExternalWork> {
16 public:
17  explicit SiPixelDigisSoAFromCUDA(const edm::ParameterSet& iConfig);
18  ~SiPixelDigisSoAFromCUDA() override = default;
19 
20  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
21 
22 private:
23  void acquire(const edm::Event& iEvent,
24  const edm::EventSetup& iSetup,
25  edm::WaitingTaskWithArenaHolder waitingTaskHolder) override;
26  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
27 
30 
32 
33  int nDigis_;
34 };
35 
37  : digiGetToken_(consumes<cms::cuda::Product<SiPixelDigisCUDA>>(iConfig.getParameter<edm::InputTag>("src"))),
38  digiPutToken_(produces<legacy::SiPixelDigisSoA>()) {}
39 
42  desc.add<edm::InputTag>("src", edm::InputTag("siPixelClustersCUDA"));
43  descriptions.addWithDefaultLabel(desc);
44 }
45 
47  const edm::EventSetup& iSetup,
48  edm::WaitingTaskWithArenaHolder waitingTaskHolder) {
49  // Do the transfer in a CUDA stream parallel to the computation CUDA stream
50  cms::cuda::ScopedContextAcquire ctx{iEvent.streamID(), std::move(waitingTaskHolder)};
51 
52  const auto& digis_d = ctx.get(iEvent, digiGetToken_);
53 
54  nDigis_ = digis_d.nDigis();
55  digis_h_ = cms::cuda::PortableHostCollection<SiPixelDigisSoA>(digis_d.view().metadata().size(), ctx.stream());
56  cudaCheck(cudaMemcpyAsync(digis_h_.buffer().get(),
57  digis_d.const_buffer().get(),
58  digis_d.bufferSize(),
59  cudaMemcpyDeviceToHost,
60  ctx.stream()));
61 }
62 
64  iEvent.emplace(digiPutToken_,
65  nDigis_,
66  digis_h_.view().pdigi(),
67  digis_h_.view().rawIdArr(),
68  digis_h_.view().adc(),
69  digis_h_.view().clus());
70 }
71 
72 // define as framework plugin
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
void acquire(const edm::Event &iEvent, const edm::EventSetup &iSetup, edm::WaitingTaskWithArenaHolder waitingTaskHolder) override
edm::EDPutTokenT< legacy::SiPixelDigisSoA > digiPutToken_
SiPixelDigisSoAFromCUDA(const edm::ParameterSet &iConfig)
int iEvent
Definition: GenABIO.cc:224
cms::cuda::PortableHostCollection< SiPixelDigisSoA > digis_h_
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Namespace of DDCMS conversion namespace.
edm::EDGetTokenT< cms::cuda::Product< SiPixelDigisCUDA > > digiGetToken_
HLT enums.
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:69
~SiPixelDigisSoAFromCUDA() override=default
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
def move(src, dest)
Definition: eostools.py:511