CMS 3D CMS Logo

EcalUncalibRecHitPhase2WeightsProducerGPU.cc
Go to the documentation of this file.
5 
8 
10 
12 #include "DeclsForKernelsPhase2.h"
13 
15 public:
17  ~EcalUncalibRecHitPhase2WeightsProducerGPU() override = default;
19 
20 private:
21  void produce(edm::Event &, edm::EventSetup const &) override;
22 
23 private:
24  const std::vector<double, cms::cuda::HostAllocator<double>> weights_;
25 
30 
31  // event data
33 };
34 
35 // constructor with initialisation of elements
37  : // use lambda to initialise the vector with CUDA::HostAllocator from a normal vector
38  weights_([tmp = ps.getParameter<std::vector<double>>("weights")] {
39  return std::vector<double, cms::cuda::HostAllocator<double>>(tmp.begin(), tmp.end());
40  }()),
41  digisToken_{consumes<InputProduct>(ps.getParameter<edm::InputTag>("digisLabelEB"))},
42  recHitsToken_{produces<OutputProduct>(ps.getParameter<std::string>("recHitsLabelEB"))} {}
43 
46 
47  desc.add<std::string>("recHitsLabelEB", "EcalUncalibRecHitsEB");
48  //The below weights values should be kept up to date with those on the CPU version of this module
49  desc.add<std::vector<double>>("weights",
50  {-0.121016,
51  -0.119899,
52  -0.120923,
53  -0.0848959,
54  0.261041,
55  0.509881,
56  0.373591,
57  0.134899,
58  -0.0233605,
59  -0.0913195,
60  -0.112452,
61  -0.118596,
62  -0.121737,
63  -0.121737,
64  -0.121737,
65  -0.121737});
66 
67  desc.add<edm::InputTag>("digisLabelEB", edm::InputTag("simEcalUnsuppressedDigis", ""));
68 
69  descriptions.addWithDefaultLabel(desc);
70 }
71 
73  // cuda products
74  auto const &digisProduct = event.get(digisToken_);
75  // raii
76  cms::cuda::ScopedContextProduce ctx{digisProduct};
77 
78  // get actual obj
79  auto const &digis = ctx.get(digisProduct);
80 
81  const uint32_t size = digis.size;
82 
83  // do not run the algo if there are no digis
84  if (size > 0) {
85  auto weights_d = cms::cuda::make_device_unique<double[]>(EcalDataFrame_Ph2::MAXSAMPLES, ctx.stream());
86 
87  cudaCheck(cudaMemcpyAsync(weights_d.get(),
88  weights_.data(),
89  EcalDataFrame_Ph2::MAXSAMPLES * sizeof(double),
90  cudaMemcpyHostToDevice,
91  ctx.stream()));
92 
93  // output on GPU
94  eventOutputDataGPU_.allocate(size, ctx.stream());
95 
96  ecal::weights::phase2Weights(digis, eventOutputDataGPU_, weights_d, ctx.stream());
97  }
98 
99  // set the size of digis
101 
102  // put into the event
104 }
105 
size
Write out results.
static void fillDescriptions(edm::ConfigurationDescriptions &)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
const std::vector< double, cms::cuda::HostAllocator< double > > weights_
UncalibratedRecHit<::calo::common::DevStoragePolicy > recHits
~EcalUncalibRecHitPhase2WeightsProducerGPU() override=default
void produce(edm::Event &, edm::EventSetup const &) override
void phase2Weights(ecal::DigisCollection< calo::common::DevStoragePolicy > const &, EventOutputDataGPU &, cms::cuda::device::unique_ptr< double[]> &, cudaStream_t)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
static constexpr int MAXSAMPLES
void allocate(uint32_t digi_size, cudaStream_t cudaStream)
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:69
tmp
align.sh
Definition: createJobs.py:716
const T & get(const Product< T > &data)
Definition: ScopedContext.h:58
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1