CMS 3D CMS Logo

CAHitNtupletCUDA.cc
Go to the documentation of this file.
1 #include <cuda_runtime.h>
2 
23 
25 
26 template <typename TrackerTraits>
31 
34 
36 
37 public:
38  explicit CAHitNtupletCUDAT(const edm::ParameterSet& iConfig);
39  ~CAHitNtupletCUDAT() override = default;
40 
41  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
42 
43 private:
44  void beginJob() override;
45  void endJob() override;
46 
47  void produce(edm::StreamID streamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const override;
48 
49  bool onGPU_;
50 
56 
58 };
59 
60 template <typename TrackerTraits>
62  : onGPU_(iConfig.getParameter<bool>("onGPU")), tokenField_(esConsumes()), gpuAlgo_(iConfig, consumesCollector()) {
63  if (onGPU_) {
64  tokenHitGPU_ = consumes(iConfig.getParameter<edm::InputTag>("pixelRecHitSrc"));
65  tokenTrackGPU_ = produces<cms::cuda::Product<TrackSoADevice>>();
66  } else {
67  tokenHitCPU_ = consumes(iConfig.getParameter<edm::InputTag>("pixelRecHitSrc"));
68  tokenTrackCPU_ = produces<TrackSoAHost>();
69  }
70 }
71 
72 template <typename TrackerTraits>
75 
76  desc.add<bool>("onGPU", true);
77  desc.add<edm::InputTag>("pixelRecHitSrc", edm::InputTag("siPixelRecHitsPreSplittingCUDA"));
78 
80  descriptions.addWithDefaultLabel(desc);
81 }
82 
83 template <typename TrackerTraits>
85  gpuAlgo_.beginJob();
86 }
87 
88 template <typename TrackerTraits>
90  gpuAlgo_.endJob();
91 }
92 
93 template <typename TrackerTraits>
96  const edm::EventSetup& es) const {
97  auto bf = 1. / es.getData(tokenField_).inverseBzAtOriginInGeV();
98 
99  if (onGPU_) {
100  auto const& hits = iEvent.get(tokenHitGPU_);
101 
103  auto& hits_d = ctx.get(hits);
104  ctx.emplace(iEvent, tokenTrackGPU_, gpuAlgo_.makeTuplesAsync(hits_d, bf, ctx.stream()));
105  } else {
106  auto& hits_h = iEvent.get(tokenHitCPU_);
107  iEvent.emplace(tokenTrackCPU_, gpuAlgo_.makeTuples(hits_h, bf));
108  }
109 }
110 
113 
116 
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
void produce(edm::StreamID streamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > tokenField_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< HitsOnHost > tokenHitCPU_
TrackingRecHitSoAConstView< TrackerTraits > HitsConstView
void beginJob() override
CAHitNtupletCUDAT(const edm::ParameterSet &iConfig)
void endJob() override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
~CAHitNtupletCUDAT() override=default
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
typename TrackingRecHitSoA< TrackerTraits >::template TrackingRecHitSoALayout<>::ConstView TrackingRecHitSoAConstView
edm::EDGetTokenT< cms::cuda::Product< HitsOnDevice > > tokenHitGPU_
edm::EDPutTokenT< cms::cuda::Product< TrackSoADevice > > tokenTrackGPU_
edm::EDPutTokenT< TrackSoAHost > tokenTrackCPU_