CMS 3D CMS Logo

EcalPhase2DigiToGPUProducer.cc
Go to the documentation of this file.
5 
9 
12 
13 #include "DeclsForKernelsPhase2.h"
14 
16 public:
18  ~EcalPhase2DigiToGPUProducer() override = default;
19  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
20 
21  void produce(edm::Event& evt, edm::EventSetup const& setup) override;
22 
23 private:
27 };
28 
31 
32  desc.add<edm::InputTag>("BarrelDigis", edm::InputTag("simEcalUnsuppressedDigis", ""));
33  desc.add<std::string>("digisLabelEB", "ebDigis");
34 
35  descriptions.addWithDefaultLabel(desc);
36 }
37 
39  : digiCollectionToken_(consumes<EBDigiCollectionPh2>(ps.getParameter<edm::InputTag>("BarrelDigis"))),
40  digisCollectionToken_(produces<cms::cuda::Product<ecal::DigisCollection<calo::common::DevStoragePolicy>>>(
41  ps.getParameter<std::string>("digisLabelEB"))) {}
42 
44  cms::cuda::ScopedContextProduce ctx{event.streamID()};
45 
46  //input data from event
47  const auto& pdigis = event.get(digiCollectionToken_);
48 
49  const uint32_t size = pdigis.size();
50 
52  digis.size = size;
53 
54  //allocate device pointers for output
55  digis.ids = cms::cuda::make_device_unique<uint32_t[]>(size, ctx.stream());
56  digis.data = cms::cuda::make_device_unique<uint16_t[]>(size * EcalDataFrame_Ph2::MAXSAMPLES, ctx.stream());
57 
58  //allocate host pointers for holding product data and id vectors
59  auto idstmp = cms::cuda::make_host_unique<uint32_t[]>(size, ctx.stream());
60  auto datatmp = cms::cuda::make_host_unique<uint16_t[]>(size * EcalDataFrame_Ph2::MAXSAMPLES, ctx.stream());
61 
62  //iterate over digis
63  uint32_t i = 0;
64  for (const auto& pdigi : pdigis) {
65  const int nSamples = pdigi.size();
66  //assign id to output vector
67  idstmp.get()[i] = pdigi.id();
68  //iterate over sample in digi
69  for (int sample = 0; sample < nSamples; ++sample) {
70  //get samples from input digi
71  EcalLiteDTUSample thisSample = pdigi[sample];
72  //assign adc data to output
73  datatmp.get()[i * nSamples + sample] = thisSample.raw();
74  }
75  ++i;
76  }
77 
78  //copy output vectors into member variable device pointers for the output struct
79  cudaCheck(
80  cudaMemcpyAsync(digis.ids.get(), idstmp.get(), size * sizeof(uint32_t), cudaMemcpyHostToDevice, ctx.stream()));
81  cudaCheck(cudaMemcpyAsync(digis.data.get(),
82  datatmp.get(),
83  size * EcalDataFrame_Ph2::MAXSAMPLES * sizeof(uint16_t),
84  cudaMemcpyHostToDevice,
85  ctx.stream()));
86 
87  //emplace output in the context
88  ctx.emplace(event, digisCollectionToken_, std::move(digis));
89 }
90 
size
Write out results.
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
StoragePolicy::template StorageSelector< uint16_t >::type data
uint16_t raw() const
get the raw word
StoragePolicy::template StorageSelector< uint32_t >::type ids
const edm::EDPutTokenT< cms::cuda::Product< ecal::DigisCollection< calo::common::DevStoragePolicy > > > digisCollectionToken_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const edm::EDGetTokenT< EBDigiCollectionPh2 > digiCollectionToken_
static constexpr int MAXSAMPLES
Namespace of DDCMS conversion namespace.
Definition: common.py:1
~EcalPhase2DigiToGPUProducer() override=default
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void produce(edm::Event &evt, edm::EventSetup const &setup) override
HLT enums.
EcalPhase2DigiToGPUProducer(const edm::ParameterSet &ps)
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:69
const T & get(const Product< T > &data)
Definition: ScopedContext.h:58
def move(src, dest)
Definition: eostools.py:511
Definition: Common.h:9
Definition: event.py:1