CMS 3D CMS Logo

BrokenLineFitOnGPU.cc
Go to the documentation of this file.
1 #include "BrokenLineFitOnGPU.h"
2 
3 template <typename TrackerTraits>
5  uint32_t hitsInFit,
6  uint32_t maxNumberOfTuples) {
7  assert(tuples_);
8 
9 #ifdef BROKENLINE_DEBUG
10  setlinebuf(stdout);
11 #endif
12 
13  // Fit internals
14  auto tkidGPU = std::make_unique<typename TrackerTraits::tindex_type[]>(maxNumberOfConcurrentFits_);
15  auto hitsGPU =
16  std::make_unique<double[]>(maxNumberOfConcurrentFits_ * sizeof(riemannFit::Matrix3xNd<6>) / sizeof(double));
17  auto hits_geGPU =
18  std::make_unique<float[]>(maxNumberOfConcurrentFits_ * sizeof(riemannFit::Matrix6xNf<6>) / sizeof(float));
19  auto fast_fit_resultsGPU =
20  std::make_unique<double[]>(maxNumberOfConcurrentFits_ * sizeof(riemannFit::Vector4d) / sizeof(double));
21 
22  for (uint32_t offset = 0; offset < maxNumberOfTuples; offset += maxNumberOfConcurrentFits_) {
23  // fit triplets
24  kernel_BLFastFit<3, TrackerTraits>(tuples_,
25  tupleMultiplicity_,
26  hv,
27  tkidGPU.get(),
28  hitsGPU.get(),
29  hits_geGPU.get(),
30  fast_fit_resultsGPU.get(),
31  3,
32  3,
33  offset);
34 
35  kernel_BLFit<3, TrackerTraits>(tupleMultiplicity_,
36  bField_,
37  outputSoa_,
38  tkidGPU.get(),
39  hitsGPU.get(),
40  hits_geGPU.get(),
41  fast_fit_resultsGPU.get());
42  if (fitNas4_) {
43  riemannFit::rolling_fits<4, TrackerTraits::maxHitsOnTrack, 1>(
44  [this, &hv, &tkidGPU, &hitsGPU, &hits_geGPU, &fast_fit_resultsGPU, &offset](auto i) {
45  kernel_BLFastFit<4, TrackerTraits>(tuples_,
46  tupleMultiplicity_,
47  hv,
48  tkidGPU.get(),
49  hitsGPU.get(),
50  hits_geGPU.get(),
51  fast_fit_resultsGPU.get(),
52  4,
53  i,
54  offset);
55 
56  kernel_BLFit<4, TrackerTraits>(tupleMultiplicity_,
57  bField_,
58  outputSoa_,
59  tkidGPU.get(),
60  hitsGPU.get(),
61  hits_geGPU.get(),
62  fast_fit_resultsGPU.get());
63  });
64 
65  } else {
66  //Fit these using all the hits they have
67  riemannFit::rolling_fits<4, TrackerTraits::maxHitsOnTrackForFullFit, 1>(
68  [this, &hv, &tkidGPU, &hitsGPU, &hits_geGPU, &fast_fit_resultsGPU, &offset](auto i) {
69  kernel_BLFastFit<i, TrackerTraits>(tuples_,
70  tupleMultiplicity_,
71  hv,
72  tkidGPU.get(),
73  hitsGPU.get(),
74  hits_geGPU.get(),
75  fast_fit_resultsGPU.get(),
76  i,
77  i,
78  offset);
79 
80  kernel_BLFit<i, TrackerTraits>(tupleMultiplicity_,
81  bField_,
82  outputSoa_,
83  tkidGPU.get(),
84  hitsGPU.get(),
85  hits_geGPU.get(),
86  fast_fit_resultsGPU.get());
87  });
88 
89  static_assert(TrackerTraits::maxHitsOnTrackForFullFit < TrackerTraits::maxHitsOnTrack);
90 
91  //Fit all the rest using the maximum from previous call
92 
93  kernel_BLFastFit<TrackerTraits::maxHitsOnTrackForFullFit, TrackerTraits>(tuples_,
94  tupleMultiplicity_,
95  hv,
96  tkidGPU.get(),
97  hitsGPU.get(),
98  hits_geGPU.get(),
99  fast_fit_resultsGPU.get(),
100  TrackerTraits::maxHitsOnTrackForFullFit,
101  TrackerTraits::maxHitsOnTrack - 1,
102  offset);
103 
104  kernel_BLFit<TrackerTraits::maxHitsOnTrackForFullFit, TrackerTraits>(tupleMultiplicity_,
105  bField_,
106  outputSoa_,
107  tkidGPU.get(),
108  hitsGPU.get(),
109  hits_geGPU.get(),
110  fast_fit_resultsGPU.get());
111  }
112 
113  } // loop on concurrent fits
114 }
115 
assert(be >=bs)
Eigen::Matrix< float, 6, N > Matrix6xNf
Definition: HelixFitOnGPU.h:27
Eigen::Matrix< double, 3, N > Matrix3xNd
Definition: HelixFitOnGPU.h:22
void launchBrokenLineKernelsOnCPU(const HitConstView &hv, uint32_t nhits, uint32_t maxNumberOfTuples)
typename TrackingRecHitSoA< TrackerTraits >::template TrackingRecHitSoALayout<>::ConstView TrackingRecHitSoAConstView
Eigen::Vector4d Vector4d
Definition: FitResult.h:15