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<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  nDigis_ = digis_d.nDigis();
56  digis_h_ = cms::cuda::PortableHostCollection<SiPixelDigisSoALayout<>>(digis_d.view().metadata().size(), ctx.stream());
57  cudaCheck(cudaMemcpyAsync(digis_h_.buffer().get(),
58  digis_d.const_buffer().get(),
59  digis_d.bufferSize(),
60  cudaMemcpyDeviceToHost,
61  ctx.stream()));
62 }
63 
65  iEvent.emplace(digiPutToken_,
66  nDigis_,
67  digis_h_.view().pdigi(),
68  digis_h_.view().rawIdArr(),
69  digis_h_.view().adc(),
70  digis_h_.view().clus());
71 }
72 
73 // define as framework plugin
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
void acquire(const edm::Event &iEvent, const edm::EventSetup &iSetup, edm::WaitingTaskWithArenaHolder waitingTaskHolder) override
SiPixelDigisSoAFromCUDA(const edm::ParameterSet &iConfig)
edm::EDPutTokenT< SiPixelDigisSoA > digiPutToken_
int iEvent
Definition: GenABIO.cc:224
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
cms::cuda::PortableHostCollection< SiPixelDigisSoALayout<> > digis_h_
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