CMS 3D CMS Logo

SiPixelDigisSoAFromCUDA.cc
Go to the documentation of this file.
13 
14 class SiPixelDigisSoAFromCUDA : public edm::stream::EDProducer<edm::ExternalWork> {
15 public:
16  explicit SiPixelDigisSoAFromCUDA(const edm::ParameterSet& iConfig);
17  ~SiPixelDigisSoAFromCUDA() override = default;
18 
19  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
20 
21 private:
22  void acquire(const edm::Event& iEvent,
23  const edm::EventSetup& iSetup,
24  edm::WaitingTaskWithArenaHolder waitingTaskHolder) override;
25  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
26 
29 
34 
35  int nDigis_;
36 };
37 
39  : digiGetToken_(consumes<cms::cuda::Product<SiPixelDigisCUDA>>(iConfig.getParameter<edm::InputTag>("src"))),
40  digiPutToken_(produces<SiPixelDigisSoA>()) {}
41 
44  desc.add<edm::InputTag>("src", edm::InputTag("siPixelClustersCUDA"));
45  descriptions.addWithDefaultLabel(desc);
46 }
47 
49  const edm::EventSetup& iSetup,
50  edm::WaitingTaskWithArenaHolder waitingTaskHolder) {
51  // Do the transfer in a CUDA stream parallel to the computation CUDA stream
52  cms::cuda::ScopedContextAcquire ctx{iEvent.streamID(), std::move(waitingTaskHolder)};
53 
54  const auto& gpuDigis = ctx.get(iEvent, digiGetToken_);
55 
56  nDigis_ = gpuDigis.nDigis();
57  pdigi_ = gpuDigis.pdigiToHostAsync(ctx.stream());
58  rawIdArr_ = gpuDigis.rawIdArrToHostAsync(ctx.stream());
59  adc_ = gpuDigis.adcToHostAsync(ctx.stream());
60  clus_ = gpuDigis.clusToHostAsync(ctx.stream());
61 }
62 
64  // The following line copies the data from the pinned host memory to
65  // regular host memory. In principle that feels unnecessary (why not
66  // just use the pinned host memory?). There are a few arguments for
67  // doing it though
68  // - Now can release the pinned host memory back to the (caching) allocator
69  // * if we'd like to keep the pinned memory, we'd need to also
70  // keep the CUDA stream around as long as that, or allow pinned
71  // host memory to be allocated without a CUDA stream
72  // - What if a CPU algorithm would produce the same SoA? We can't
73  // use cudaMallocHost without a GPU...
74  iEvent.emplace(digiPutToken_, nDigis_, pdigi_.get(), rawIdArr_.get(), adc_.get(), clus_.get());
75 
76  pdigi_.reset();
77  rawIdArr_.reset();
78  adc_.reset();
79  clus_.reset();
80 }
81 
82 // define as framework plugin
ConfigurationDescriptions.h
SiPixelDigisSoAFromCUDA::~SiPixelDigisSoAFromCUDA
~SiPixelDigisSoAFromCUDA() override=default
SiPixelDigisSoAFromCUDA::acquire
void acquire(const edm::Event &iEvent, const edm::EventSetup &iSetup, edm::WaitingTaskWithArenaHolder waitingTaskHolder) override
Definition: SiPixelDigisSoAFromCUDA.cc:48
SiPixelDigisSoAFromCUDA::adc_
cms::cuda::host::unique_ptr< uint16_t[]> adc_
Definition: SiPixelDigisSoAFromCUDA.cc:32
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::EDPutTokenT< SiPixelDigisSoA >
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
EDProducer.h
SiPixelDigisSoAFromCUDA::pdigi_
cms::cuda::host::unique_ptr< uint32_t[]> pdigi_
Definition: SiPixelDigisSoAFromCUDA.cc:30
SiPixelDigisSoAFromCUDA::SiPixelDigisSoAFromCUDA
SiPixelDigisSoAFromCUDA(const edm::ParameterSet &iConfig)
Definition: SiPixelDigisSoAFromCUDA.cc:38
SiPixelDigisSoAFromCUDA::digiPutToken_
edm::EDPutTokenT< SiPixelDigisSoA > digiPutToken_
Definition: SiPixelDigisSoAFromCUDA.cc:28
edm::WaitingTaskWithArenaHolder
Definition: WaitingTaskWithArenaHolder.h:34
MakerMacros.h
SiPixelDigisSoA.h
SiPixelDigisSoAFromCUDA::clus_
cms::cuda::host::unique_ptr< int32_t[]> clus_
Definition: SiPixelDigisSoAFromCUDA.cc:33
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
host_unique_ptr.h
ParameterSetDescription.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
SiPixelDigisCUDA
Definition: SiPixelDigisCUDA.h:10
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
iEvent
int iEvent
Definition: GenABIO.cc:224
SiPixelDigisSoA
Definition: SiPixelDigisSoA.h:14
edm::stream::EDProducer
Definition: EDProducer.h:36
SiPixelDigisSoAFromCUDA::produce
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition: SiPixelDigisSoAFromCUDA.cc:63
edm::EventSetup
Definition: EventSetup.h:58
SiPixelDigisCUDA.h
cms::cuda::ScopedContextAcquire
Definition: ScopedContext.h:101
Product.h
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
cms::cuda::host::unique_ptr
std::unique_ptr< T, impl::HostDeleter > unique_ptr
Definition: host_unique_ptr.h:21
SiPixelDigisSoAFromCUDA::rawIdArr_
cms::cuda::host::unique_ptr< uint32_t[]> rawIdArr_
Definition: SiPixelDigisSoAFromCUDA.cc:31
ScopedContext.h
SiPixelDigisSoAFromCUDA::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: SiPixelDigisSoAFromCUDA.cc:42
ecalDigis_cff.cuda
cuda
Definition: ecalDigis_cff.py:35
EventSetup.h
SiPixelDigisSoAFromCUDA::nDigis_
int nDigis_
Definition: SiPixelDigisSoAFromCUDA.cc:35
SiPixelDigisSoAFromCUDA
Definition: SiPixelDigisSoAFromCUDA.cc:14
SiPixelDigisSoAFromCUDA::digiGetToken_
edm::EDGetTokenT< cms::cuda::Product< SiPixelDigisCUDA > > digiGetToken_
Definition: SiPixelDigisSoAFromCUDA.cc:27
ParameterSet.h
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
edm::ConfigurationDescriptions::addWithDefaultLabel
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:87
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21