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 acquire(edm::Event const &, edm::EventSetup const &, edm::WaitingTaskWithArenaHolder) override;
22  void produce(edm::Event &, edm::EventSetup const &) override;
23 
24 private:
25  const std::vector<double, cms::cuda::HostAllocator<double>> weights_;
26 
31 
32  // event data
34 
36 
37  uint32_t size_;
38 };
39 
40 // constructor with initialisation of elements
42  : // use lambda to initialise the vector with CUDA::HostAllocator from a normal vector
43  weights_([tmp = ps.getParameter<std::vector<double>>("weights")] {
44  return std::vector<double, cms::cuda::HostAllocator<double>>(tmp.begin(), tmp.end());
45  }()),
46  digisToken_{consumes<InputProduct>(ps.getParameter<edm::InputTag>("digisLabelEB"))},
47  recHitsToken_{produces<OutputProduct>(ps.getParameter<std::string>("recHitsLabelEB"))} {}
48 
51 
52  desc.add<std::string>("recHitsLabelEB", "EcalUncalibRecHitsEB");
53  //The below weights values should be kept up to date with those on the CPU version of this module
54  desc.add<std::vector<double>>("weights",
55  {-0.121016,
56  -0.119899,
57  -0.120923,
58  -0.0848959,
59  0.261041,
60  0.509881,
61  0.373591,
62  0.134899,
63  -0.0233605,
64  -0.0913195,
65  -0.112452,
66  -0.118596,
67  -0.121737,
68  -0.121737,
69  -0.121737,
70  -0.121737});
71 
72  desc.add<edm::InputTag>("digisLabelEB", edm::InputTag("simEcalUnsuppressedDigis", ""));
73 
74  descriptions.addWithDefaultLabel(desc);
75 }
76 
77 // aquire function which initislises objects on host and device to their actual objects and calls kernal
79  edm::EventSetup const &setup,
81  // cuda products
82  auto const &digisProduct = event.get(digisToken_);
83  // raii
84  cms::cuda::ScopedContextAcquire ctx{digisProduct, std::move(holder), cudaState_};
85 
86  // get actual obj
87  auto const &digis = ctx.get(digisProduct);
88 
89  size_ = digis.size;
90 
91  // if no digis stop here
92  if (size_ == 0)
93  return;
94 
95  auto weights_d = cms::cuda::make_device_unique<double[]>(EcalDataFrame_Ph2::MAXSAMPLES, ctx.stream());
96 
97  cudaCheck(cudaMemcpyAsync(weights_d.get(),
98  weights_.data(),
99  EcalDataFrame_Ph2::MAXSAMPLES * sizeof(double),
100  cudaMemcpyHostToDevice,
101  ctx.stream()));
102 
103  // output on GPU
104  eventOutputDataGPU_.allocate(size_, ctx.stream());
105 
106  ecal::weights::phase2Weights(digis, eventOutputDataGPU_, weights_d, ctx.stream());
107 }
108 
111 
112  // set the size of digis
114 
115  // put into the event
117 }
118 
static void fillDescriptions(edm::ConfigurationDescriptions &)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
const std::vector< double, cms::cuda::HostAllocator< double > > weights_
UncalibratedRecHit<::calo::common::DevStoragePolicy > recHits
void acquire(edm::Event const &, edm::EventSetup const &, edm::WaitingTaskWithArenaHolder) override
~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
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1