CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
CAHitNtupletGeneratorOnGPU Class Reference

#include <CAHitNtupletGeneratorOnGPU.h>

Public Types

using Counters = cAHitNtupletGenerator::Counters
 
using hindex_type = TrackingRecHit2DSOAView::hindex_type
 
using HitContainer = pixelTrack::HitContainer
 
using HitsOnCPU = TrackingRecHit2DGPU
 
using HitsOnGPU = TrackingRecHit2DSOAView
 
using OutputSoA = pixelTrack::TrackSoA
 
using Params = cAHitNtupletGenerator::Params
 
using Quality = pixelTrack::Quality
 
using QualityCuts = cAHitNtupletGenerator::QualityCuts
 
using Tuple = HitContainer
 

Public Member Functions

void beginJob ()
 
 CAHitNtupletGeneratorOnGPU (const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
 
 CAHitNtupletGeneratorOnGPU (const edm::ParameterSet &cfg, edm::ConsumesCollector &iC)
 
void endJob ()
 
PixelTrackHeterogeneous makeTuples (TrackingRecHit2DCPU const &hits_d, float bfield) const
 
PixelTrackHeterogeneous makeTuplesAsync (TrackingRecHit2DGPU const &hits_d, float bfield, cudaStream_t stream) const
 

Static Public Member Functions

static void fillDescriptions (edm::ParameterSetDescription &desc)
 
static const char * fillDescriptionsLabel ()
 

Private Member Functions

void buildDoublets (HitsOnCPU const &hh, cudaStream_t stream) const
 
void hitNtuplets (HitsOnCPU const &hh, const edm::EventSetup &es, bool useRiemannFit, cudaStream_t cudaStream)
 
void launchKernels (HitsOnCPU const &hh, bool useRiemannFit, cudaStream_t cudaStream) const
 

Private Attributes

Countersm_counters = nullptr
 
Params m_params
 

Detailed Description

Definition at line 24 of file CAHitNtupletGeneratorOnGPU.h.

Member Typedef Documentation

◆ Counters

Definition at line 37 of file CAHitNtupletGeneratorOnGPU.h.

◆ hindex_type

Definition at line 28 of file CAHitNtupletGeneratorOnGPU.h.

◆ HitContainer

Definition at line 32 of file CAHitNtupletGeneratorOnGPU.h.

◆ HitsOnCPU

Definition at line 27 of file CAHitNtupletGeneratorOnGPU.h.

◆ HitsOnGPU

Definition at line 26 of file CAHitNtupletGeneratorOnGPU.h.

◆ OutputSoA

Definition at line 31 of file CAHitNtupletGeneratorOnGPU.h.

◆ Params

Definition at line 36 of file CAHitNtupletGeneratorOnGPU.h.

◆ Quality

Definition at line 30 of file CAHitNtupletGeneratorOnGPU.h.

◆ QualityCuts

Definition at line 35 of file CAHitNtupletGeneratorOnGPU.h.

◆ Tuple

Definition at line 33 of file CAHitNtupletGeneratorOnGPU.h.

Constructor & Destructor Documentation

◆ CAHitNtupletGeneratorOnGPU() [1/2]

CAHitNtupletGeneratorOnGPU::CAHitNtupletGeneratorOnGPU ( const edm::ParameterSet cfg,
edm::ConsumesCollector &&  iC 
)
inline

Definition at line 40 of file CAHitNtupletGeneratorOnGPU.h.

CAHitNtupletGeneratorOnGPU(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)

◆ CAHitNtupletGeneratorOnGPU() [2/2]

CAHitNtupletGeneratorOnGPU::CAHitNtupletGeneratorOnGPU ( const edm::ParameterSet cfg,
edm::ConsumesCollector iC 
)

Definition at line 60 of file CAHitNtupletGeneratorOnGPU.cc.

61  : m_params(cfg.getParameter<bool>("onGPU"),
62  cfg.getParameter<unsigned int>("minHitsPerNtuplet"),
63  cfg.getParameter<unsigned int>("maxNumberOfDoublets"),
64  cfg.getParameter<unsigned int>("minHitsForSharingCut"),
65  cfg.getParameter<bool>("useRiemannFit"),
66  cfg.getParameter<bool>("fitNas4"),
67  cfg.getParameter<bool>("includeJumpingForwardDoublets"),
68  cfg.getParameter<bool>("earlyFishbone"),
69  cfg.getParameter<bool>("lateFishbone"),
70  cfg.getParameter<bool>("idealConditions"),
71  cfg.getParameter<bool>("fillStatistics"),
72  cfg.getParameter<bool>("doClusterCut"),
73  cfg.getParameter<bool>("doZ0Cut"),
74  cfg.getParameter<bool>("doPtCut"),
75  cfg.getParameter<bool>("doSharedHitCut"),
76  cfg.getParameter<bool>("dupPassThrough"),
77  cfg.getParameter<bool>("useSimpleTripletCleaner"),
78  cfg.getParameter<double>("ptmin"),
79  cfg.getParameter<double>("CAThetaCutBarrel"),
80  cfg.getParameter<double>("CAThetaCutForward"),
81  cfg.getParameter<double>("hardCurvCut"),
82  cfg.getParameter<double>("dcaCutInnerTriplet"),
83  cfg.getParameter<double>("dcaCutOuterTriplet"),
84  makeQualityCuts(cfg.getParameterSet("trackQualityCuts"))) {
85 #ifdef DUMP_GPU_TK_TUPLES
86  printf("TK: %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s\n",
87  "tid",
88  "qual",
89  "nh",
90  "nl",
91  "charge",
92  "pt",
93  "eta",
94  "phi",
95  "tip",
96  "zip",
97  "chi2",
98  "h1",
99  "h2",
100  "h3",
101  "h4",
102  "h5",
103  "hn");
104 #endif
105 }

Member Function Documentation

◆ beginJob()

void CAHitNtupletGeneratorOnGPU::beginJob ( void  )

Definition at line 154 of file CAHitNtupletGeneratorOnGPU.cc.

References callgraph::cs, cudaCheck, m_counters, m_params, and cAHitNtupletGenerator::Params::onGPU_.

Referenced by CAHitNtupletCUDA::beginJob().

154  {
155  if (m_params.onGPU_) {
156  // allocate pinned host memory only if CUDA is available
158  if (cs and cs->enabled()) {
159  cudaCheck(cudaMalloc(&m_counters, sizeof(Counters)));
160  cudaCheck(cudaMemset(m_counters, 0, sizeof(Counters)));
161  }
162  } else {
163  m_counters = new Counters();
164  memset(m_counters, 0, sizeof(Counters));
165  }
166 }
cAHitNtupletGenerator::Counters Counters
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:69

◆ buildDoublets()

void CAHitNtupletGeneratorOnGPU::buildDoublets ( HitsOnCPU const &  hh,
cudaStream_t  stream 
) const
private

◆ endJob()

void CAHitNtupletGeneratorOnGPU::endJob ( void  )

Definition at line 168 of file CAHitNtupletGeneratorOnGPU.cc.

References callgraph::cs, cAHitNtupletGenerator::Params::doStats_, m_counters, m_params, cAHitNtupletGenerator::Params::onGPU_, and CAHitNtupletGeneratorKernels< TTraits >::printCounters().

Referenced by CAHitNtupletCUDA::endJob().

168  {
169  if (m_params.onGPU_) {
170  // print the gpu statistics and free pinned host memory only if CUDA is available
172  if (cs and cs->enabled()) {
173  if (m_params.doStats_) {
174  // crash on multi-gpu processes
176  }
177  cudaFree(m_counters);
178  }
179  } else {
180  if (m_params.doStats_) {
182  }
183  delete m_counters;
184  }
185 }
static void printCounters(Counters const *counters)

◆ fillDescriptions()

void CAHitNtupletGeneratorOnGPU::fillDescriptions ( edm::ParameterSetDescription desc)
static

Definition at line 107 of file CAHitNtupletGeneratorOnGPU.cc.

References submitPVResolutionJobs::desc, caConstants::maxNumberOfDoublets, and HLT_2022v11_cff::trackQualityCuts.

Referenced by CAHitNtupletCUDA::fillDescriptions().

107  {
108  // 87 cm/GeV = 1/(3.8T * 0.3)
109  // take less than radius given by the hardPtCut and reject everything below
110  // auto hardCurvCut = 1.f/(0.35 * 87.f);
111  desc.add<double>("ptmin", 0.9f)->setComment("Cut on minimum pt");
112  desc.add<double>("CAThetaCutBarrel", 0.002f)->setComment("Cut on RZ alignement for Barrel");
113  desc.add<double>("CAThetaCutForward", 0.003f)->setComment("Cut on RZ alignment for Forward");
114  desc.add<double>("hardCurvCut", 1.f / (0.35 * 87.f))->setComment("Cut on minimum curvature");
115  desc.add<double>("dcaCutInnerTriplet", 0.15f)->setComment("Cut on origin radius when the inner hit is on BPix1");
116  desc.add<double>("dcaCutOuterTriplet", 0.25f)->setComment("Cut on origin radius when the outer hit is on BPix1");
117  desc.add<bool>("earlyFishbone", true);
118  desc.add<bool>("lateFishbone", false);
119  desc.add<bool>("idealConditions", true);
120  desc.add<bool>("fillStatistics", false);
121  desc.add<unsigned int>("minHitsPerNtuplet", 4);
122  desc.add<unsigned int>("maxNumberOfDoublets", caConstants::maxNumberOfDoublets);
123  desc.add<unsigned int>("minHitsForSharingCut", 10)
124  ->setComment("Maximum number of hits in a tuple to clean also if the shared hit is on bpx1");
125  desc.add<bool>("includeJumpingForwardDoublets", false);
126  desc.add<bool>("fitNas4", false)->setComment("fit only 4 hits out of N");
127  desc.add<bool>("doClusterCut", true);
128  desc.add<bool>("doZ0Cut", true);
129  desc.add<bool>("doPtCut", true);
130  desc.add<bool>("useRiemannFit", false)->setComment("true for Riemann, false for BrokenLine");
131  desc.add<bool>("doSharedHitCut", true)->setComment("Sharing hit nTuples cleaning");
132  desc.add<bool>("dupPassThrough", false)->setComment("Do not reject duplicate");
133  desc.add<bool>("useSimpleTripletCleaner", true)->setComment("use alternate implementation");
134 
136  trackQualityCuts.add<double>("chi2MaxPt", 10.)->setComment("max pT used to determine the pT-dependent chi2 cut");
137  trackQualityCuts.add<std::vector<double>>("chi2Coeff", {0.9, 1.8})->setComment("chi2 at 1GeV and at ptMax above");
138  trackQualityCuts.add<double>("chi2Scale", 8.)
139  ->setComment(
140  "Factor to multiply the pT-dependent chi2 cut (currently: 8 for the broken line fit, ?? for the Riemann "
141  "fit)");
142  trackQualityCuts.add<double>("tripletMinPt", 0.5)->setComment("Min pT for triplets, in GeV");
143  trackQualityCuts.add<double>("tripletMaxTip", 0.3)->setComment("Max |Tip| for triplets, in cm");
144  trackQualityCuts.add<double>("tripletMaxZip", 12.)->setComment("Max |Zip| for triplets, in cm");
145  trackQualityCuts.add<double>("quadrupletMinPt", 0.3)->setComment("Min pT for quadruplets, in GeV");
146  trackQualityCuts.add<double>("quadrupletMaxTip", 0.5)->setComment("Max |Tip| for quadruplets, in cm");
147  trackQualityCuts.add<double>("quadrupletMaxZip", 12.)->setComment("Max |Zip| for quadruplets, in cm");
148  desc.add<edm::ParameterSetDescription>("trackQualityCuts", trackQualityCuts)
149  ->setComment(
150  "Quality cuts based on the results of the track fit:\n - apply a pT-dependent chi2 cut;\n - apply \"region "
151  "cuts\" based on the fit results (pT, Tip, Zip).");
152 }
constexpr uint32_t maxNumberOfDoublets
Definition: CAConstants.h:37

◆ fillDescriptionsLabel()

static const char* CAHitNtupletGeneratorOnGPU::fillDescriptionsLabel ( )
inlinestatic

Definition at line 45 of file CAHitNtupletGeneratorOnGPU.h.

45 { return "caHitNtupletOnGPU"; }

◆ hitNtuplets()

void CAHitNtupletGeneratorOnGPU::hitNtuplets ( HitsOnCPU const &  hh,
const edm::EventSetup es,
bool  useRiemannFit,
cudaStream_t  cudaStream 
)
private

◆ launchKernels()

void CAHitNtupletGeneratorOnGPU::launchKernels ( HitsOnCPU const &  hh,
bool  useRiemannFit,
cudaStream_t  cudaStream 
) const
private

◆ makeTuples()

PixelTrackHeterogeneous CAHitNtupletGeneratorOnGPU::makeTuples ( TrackingRecHit2DCPU const &  hits_d,
float  bfield 
) const

Definition at line 220 of file CAHitNtupletGeneratorOnGPU.cc.

References HelixFitOnGPU::allocateOnGPU(), CAHitNtupletGeneratorKernels< TTraits >::allocateOnGPU(), cms::cuda::assert(), CAHitNtupletGeneratorKernels< TTraits >::buildDoublets(), CAHitNtupletGeneratorKernels< TTraits >::classifyTuples(), gather_cfg::cout, cAHitNtupletGenerator::Params::fitNas4_, HelixFitOnGPU::launchBrokenLineKernelsOnCPU(), CAHitNtupletGeneratorKernels< TTraits >::launchKernels(), HelixFitOnGPU::launchRiemannKernelsOnCPU(), m_counters, m_params, caConstants::maxNumberOfQuadruplets, TrackingRecHit2DHeterogeneous< Traits >::nHits(), CAHitNtupletGeneratorKernels< TTraits >::setCounters(), gpuVertexFinder::soa, tracks, CAHitNtupletGeneratorKernels< TTraits >::tupleMultiplicity(), cAHitNtupletGenerator::Params::useRiemannFit_, and TrackingRecHit2DHeterogeneous< Traits >::view().

Referenced by CAHitNtupletCUDA::produce().

220  {
221  PixelTrackHeterogeneous tracks(std::make_unique<pixelTrack::TrackSoA>());
222 
223  auto* soa = tracks.get();
224  assert(soa);
225 
227  kernels.setCounters(m_counters);
228  kernels.allocateOnGPU(hits_d.nHits(), nullptr);
229 
230  kernels.buildDoublets(hits_d, nullptr);
231  kernels.launchKernels(hits_d, soa, nullptr);
232 
233  if (0 == hits_d.nHits())
234  return tracks;
235 
236  // now fit
237  HelixFitOnGPU fitter(bfield, m_params.fitNas4_);
238  fitter.allocateOnGPU(&(soa->hitIndices), kernels.tupleMultiplicity(), soa);
239 
240  if (m_params.useRiemannFit_) {
241  fitter.launchRiemannKernelsOnCPU(hits_d.view(), hits_d.nHits(), caConstants::maxNumberOfQuadruplets);
242  } else {
243  fitter.launchBrokenLineKernelsOnCPU(hits_d.view(), hits_d.nHits(), caConstants::maxNumberOfQuadruplets);
244  }
245 
246  kernels.classifyTuples(hits_d, soa, nullptr);
247 
248 #ifdef GPU_DEBUG
249  std::cout << "finished building pixel tracks on CPU" << std::endl;
250 #endif
251 
252  return tracks;
253 }
constexpr uint32_t maxNumberOfQuadruplets
Definition: CAConstants.h:42
assert(be >=bs)
ZVertexSoA * soa
auto const & tracks
cannot be loose

◆ makeTuplesAsync()

PixelTrackHeterogeneous CAHitNtupletGeneratorOnGPU::makeTuplesAsync ( TrackingRecHit2DGPU const &  hits_d,
float  bfield,
cudaStream_t  stream 
) const

Definition at line 187 of file CAHitNtupletGeneratorOnGPU.cc.

References HelixFitOnGPU::allocateOnGPU(), CAHitNtupletGeneratorKernels< TTraits >::allocateOnGPU(), cms::cuda::assert(), CAHitNtupletGeneratorKernels< TTraits >::buildDoublets(), CAHitNtupletGeneratorKernels< TTraits >::classifyTuples(), gather_cfg::cout, cudaCheck, cAHitNtupletGenerator::Params::fitNas4_, HelixFitOnGPU::launchBrokenLineKernels(), CAHitNtupletGeneratorKernels< TTraits >::launchKernels(), HelixFitOnGPU::launchRiemannKernels(), m_counters, m_params, caConstants::maxNumberOfQuadruplets, TrackingRecHit2DHeterogeneous< Traits >::nHits(), CAHitNtupletGeneratorKernels< TTraits >::setCounters(), gpuVertexFinder::soa, cms::cuda::stream, tracks, CAHitNtupletGeneratorKernels< TTraits >::tupleMultiplicity(), cAHitNtupletGenerator::Params::useRiemannFit_, and TrackingRecHit2DHeterogeneous< Traits >::view().

Referenced by CAHitNtupletCUDA::produce().

189  {
190  PixelTrackHeterogeneous tracks(cms::cuda::make_device_unique<pixelTrack::TrackSoA>(stream));
191 
192  auto* soa = tracks.get();
193  assert(soa);
194 
196  kernels.setCounters(m_counters);
197  kernels.allocateOnGPU(hits_d.nHits(), stream);
198 
199  kernels.buildDoublets(hits_d, stream);
200  kernels.launchKernels(hits_d, soa, stream);
201 
202  HelixFitOnGPU fitter(bfield, m_params.fitNas4_);
203  fitter.allocateOnGPU(&(soa->hitIndices), kernels.tupleMultiplicity(), soa);
204  if (m_params.useRiemannFit_) {
205  fitter.launchRiemannKernels(hits_d.view(), hits_d.nHits(), caConstants::maxNumberOfQuadruplets, stream);
206  } else {
207  fitter.launchBrokenLineKernels(hits_d.view(), hits_d.nHits(), caConstants::maxNumberOfQuadruplets, stream);
208  }
209  kernels.classifyTuples(hits_d, soa, stream);
210 
211 #ifdef GPU_DEBUG
212  cudaDeviceSynchronize();
213  cudaCheck(cudaGetLastError());
214  std::cout << "finished building pixel tracks on GPU" << std::endl;
215 #endif
216 
217  return tracks;
218 }
constexpr uint32_t maxNumberOfQuadruplets
Definition: CAConstants.h:42
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
assert(be >=bs)
ZVertexSoA * soa
auto const & tracks
cannot be loose
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:69

Member Data Documentation

◆ m_counters

Counters* CAHitNtupletGeneratorOnGPU::m_counters = nullptr
private

Definition at line 63 of file CAHitNtupletGeneratorOnGPU.h.

Referenced by beginJob(), endJob(), makeTuples(), and makeTuplesAsync().

◆ m_params

Params CAHitNtupletGeneratorOnGPU::m_params
private

Definition at line 61 of file CAHitNtupletGeneratorOnGPU.h.

Referenced by beginJob(), endJob(), makeTuples(), and makeTuplesAsync().