CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes | Static Private Attributes
HelixFitOnGPU< TrackerTraits > Class Template Reference

#include <HelixFitOnGPU.h>

Public Types

using HitConstView = TrackingRecHitSoAConstView< TrackerTraits >
 
using HitView = TrackingRecHitSoAView< TrackerTraits >
 
using OutputSoAView = TrackSoAView< TrackerTraits >
 
using TrackingRecHitSoAs = TrackingRecHitSoA< TrackerTraits >
 
using TupleMultiplicity = caStructures::TupleMultiplicityT< TrackerTraits >
 
using Tuples = typename TrackSoA< TrackerTraits >::HitContainer
 

Public Member Functions

void allocateOnGPU (TupleMultiplicity const *tupleMultiplicity, OutputSoAView &helix_fit_results)
 
void deallocateOnGPU ()
 
 HelixFitOnGPU (float bf, bool fitNas4)
 
void launchBrokenLineKernels (const HitConstView &hv, uint32_t nhits, uint32_t maxNumberOfTuples, cudaStream_t cudaStream)
 
void launchBrokenLineKernelsOnCPU (const HitConstView &hv, uint32_t nhits, uint32_t maxNumberOfTuples)
 
void launchRiemannKernels (const HitConstView &hv, uint32_t nhits, uint32_t maxNumberOfTuples, cudaStream_t cudaStream)
 
void launchRiemannKernelsOnCPU (const HitConstView &hv, uint32_t nhits, uint32_t maxNumberOfTuples)
 
void setBField (double bField)
 
 ~HelixFitOnGPU ()
 

Private Attributes

float bField_
 
const bool fitNas4_
 
OutputSoAView outputSoa_
 
TupleMultiplicity const * tupleMultiplicity_ = nullptr
 
Tuples const * tuples_ = nullptr
 

Static Private Attributes

static constexpr uint32_t maxNumberOfConcurrentFits_ = riemannFit::maxNumberOfConcurrentFits
 

Detailed Description

template<typename TrackerTraits>
class HelixFitOnGPU< TrackerTraits >

Definition at line 44 of file HelixFitOnGPU.h.

Member Typedef Documentation

◆ HitConstView

template<typename TrackerTraits >
using HelixFitOnGPU< TrackerTraits >::HitConstView = TrackingRecHitSoAConstView<TrackerTraits>

Definition at line 49 of file HelixFitOnGPU.h.

◆ HitView

template<typename TrackerTraits >
using HelixFitOnGPU< TrackerTraits >::HitView = TrackingRecHitSoAView<TrackerTraits>

Definition at line 48 of file HelixFitOnGPU.h.

◆ OutputSoAView

template<typename TrackerTraits >
using HelixFitOnGPU< TrackerTraits >::OutputSoAView = TrackSoAView<TrackerTraits>

Definition at line 52 of file HelixFitOnGPU.h.

◆ TrackingRecHitSoAs

template<typename TrackerTraits >
using HelixFitOnGPU< TrackerTraits >::TrackingRecHitSoAs = TrackingRecHitSoA<TrackerTraits>

Definition at line 46 of file HelixFitOnGPU.h.

◆ TupleMultiplicity

template<typename TrackerTraits >
using HelixFitOnGPU< TrackerTraits >::TupleMultiplicity = caStructures::TupleMultiplicityT<TrackerTraits>

Definition at line 54 of file HelixFitOnGPU.h.

◆ Tuples

template<typename TrackerTraits >
using HelixFitOnGPU< TrackerTraits >::Tuples = typename TrackSoA<TrackerTraits>::HitContainer

Definition at line 51 of file HelixFitOnGPU.h.

Constructor & Destructor Documentation

◆ HelixFitOnGPU()

template<typename TrackerTraits >
HelixFitOnGPU< TrackerTraits >::HelixFitOnGPU ( float  bf,
bool  fitNas4 
)
inlineexplicit

Definition at line 56 of file HelixFitOnGPU.h.

◆ ~HelixFitOnGPU()

template<typename TrackerTraits >
HelixFitOnGPU< TrackerTraits >::~HelixFitOnGPU ( )
inline

Definition at line 57 of file HelixFitOnGPU.h.

References HelixFitOnGPU< TrackerTraits >::deallocateOnGPU().

57 { deallocateOnGPU(); }
void deallocateOnGPU()

Member Function Documentation

◆ allocateOnGPU()

template<typename TrackerTraits >
void HelixFitOnGPU< TrackerTraits >::allocateOnGPU ( TupleMultiplicity const *  tupleMultiplicity,
OutputSoAView helix_fit_results 
)

Definition at line 5 of file HelixFitOnGPU.cc.

References cms::cuda::assert(), and tupleMultiplicity.

Referenced by CAHitNtupletGeneratorOnGPU< TrackerTraits >::makeTuples(), and CAHitNtupletGeneratorOnGPU< TrackerTraits >::makeTuplesAsync().

6  {
7  tuples_ = &helix_fit_results.hitIndices();
9  outputSoa_ = helix_fit_results;
10 
11  assert(tuples_);
13  assert(outputSoa_.chi2());
14  assert(outputSoa_.pt());
15 }
assert(be >=bs)
TupleMultiplicity< TrackerTraits > const *__restrict__ tupleMultiplicity
TupleMultiplicity const * tupleMultiplicity_
Definition: HelixFitOnGPU.h:77
Tuples const * tuples_
Definition: HelixFitOnGPU.h:76
OutputSoAView outputSoa_
Definition: HelixFitOnGPU.h:78

◆ deallocateOnGPU()

template<typename TrackerTraits >
void HelixFitOnGPU< TrackerTraits >::deallocateOnGPU ( )

Definition at line 18 of file HelixFitOnGPU.cc.

Referenced by HelixFitOnGPU< TrackerTraits >::~HelixFitOnGPU().

18 {}

◆ launchBrokenLineKernels()

template<typename TrackerTraits >
void HelixFitOnGPU< TrackerTraits >::launchBrokenLineKernels ( const HitConstView hv,
uint32_t  nhits,
uint32_t  maxNumberOfTuples,
cudaStream_t  cudaStream 
)

◆ launchBrokenLineKernelsOnCPU()

template<typename TrackerTraits >
void HelixFitOnGPU< TrackerTraits >::launchBrokenLineKernelsOnCPU ( const HitConstView hv,
uint32_t  nhits,
uint32_t  maxNumberOfTuples 
)

Definition at line 4 of file BrokenLineFitOnGPU.cc.

References cms::cuda::assert(), mps_fire::i, hltrates_dqm_sourceclient-live_cfg::offset, and mps_setup::stdout.

Referenced by CAHitNtupletGeneratorOnGPU< TrackerTraits >::makeTuples().

6  {
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_,
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_,
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_,
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_,
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 }
assert(be >=bs)
const bool fitNas4_
Definition: HelixFitOnGPU.h:81
Eigen::Matrix< float, 6, N > Matrix6xNf
Definition: HelixFitOnGPU.h:27
static constexpr uint32_t maxNumberOfConcurrentFits_
Definition: HelixFitOnGPU.h:73
Eigen::Matrix< double, 3, N > Matrix3xNd
Definition: HelixFitOnGPU.h:22
TupleMultiplicity const * tupleMultiplicity_
Definition: HelixFitOnGPU.h:77
Tuples const * tuples_
Definition: HelixFitOnGPU.h:76
Eigen::Vector4d Vector4d
Definition: FitResult.h:15
OutputSoAView outputSoa_
Definition: HelixFitOnGPU.h:78

◆ launchRiemannKernels()

template<typename TrackerTraits >
void HelixFitOnGPU< TrackerTraits >::launchRiemannKernels ( const HitConstView hv,
uint32_t  nhits,
uint32_t  maxNumberOfTuples,
cudaStream_t  cudaStream 
)

◆ launchRiemannKernelsOnCPU()

template<typename TrackerTraits >
void HelixFitOnGPU< TrackerTraits >::launchRiemannKernelsOnCPU ( const HitConstView hv,
uint32_t  nhits,
uint32_t  maxNumberOfTuples 
)

Definition at line 4 of file RiemannFitOnGPU.cc.

References cms::cuda::assert(), and hltrates_dqm_sourceclient-live_cfg::offset.

Referenced by CAHitNtupletGeneratorOnGPU< TrackerTraits >::makeTuples().

6  {
8 
9  // Fit internals
10  auto hitsGPU =
11  std::make_unique<double[]>(maxNumberOfConcurrentFits_ * sizeof(riemannFit::Matrix3xNd<4>) / sizeof(double));
12  auto hits_geGPU =
13  std::make_unique<float[]>(maxNumberOfConcurrentFits_ * sizeof(riemannFit::Matrix6x4f) / sizeof(float));
14  auto fast_fit_resultsGPU =
15  std::make_unique<double[]>(maxNumberOfConcurrentFits_ * sizeof(riemannFit::Vector4d) / sizeof(double));
16  auto circle_fit_resultsGPU_holder =
17  std::make_unique<char[]>(maxNumberOfConcurrentFits_ * sizeof(riemannFit::CircleFit));
18  riemannFit::CircleFit *circle_fit_resultsGPU = (riemannFit::CircleFit *)(circle_fit_resultsGPU_holder.get());
19 
20  for (uint32_t offset = 0; offset < maxNumberOfTuples; offset += maxNumberOfConcurrentFits_) {
21  // triplets
22  kernel_FastFit<3, TrackerTraits>(
23  tuples_, tupleMultiplicity_, 3, hv, hitsGPU.get(), hits_geGPU.get(), fast_fit_resultsGPU.get(), offset);
24 
25  kernel_CircleFit<3, TrackerTraits>(tupleMultiplicity_,
26  3,
27  bField_,
28  hitsGPU.get(),
29  hits_geGPU.get(),
30  fast_fit_resultsGPU.get(),
31  circle_fit_resultsGPU,
32  offset);
33 
34  kernel_LineFit<3, TrackerTraits>(tupleMultiplicity_,
35  3,
36  bField_,
37  outputSoa_,
38  hitsGPU.get(),
39  hits_geGPU.get(),
40  fast_fit_resultsGPU.get(),
41  circle_fit_resultsGPU,
42  offset);
43 
44  // quads
45  kernel_FastFit<4, TrackerTraits>(
46  tuples_, tupleMultiplicity_, 4, hv, hitsGPU.get(), hits_geGPU.get(), fast_fit_resultsGPU.get(), offset);
47 
48  kernel_CircleFit<4, TrackerTraits>(tupleMultiplicity_,
49  4,
50  bField_,
51  hitsGPU.get(),
52  hits_geGPU.get(),
53  fast_fit_resultsGPU.get(),
54  circle_fit_resultsGPU,
55  offset);
56 
57  kernel_LineFit<4, TrackerTraits>(tupleMultiplicity_,
58  4,
59  bField_,
60  outputSoa_,
61  hitsGPU.get(),
62  hits_geGPU.get(),
63  fast_fit_resultsGPU.get(),
64  circle_fit_resultsGPU,
65  offset);
66 
67  if (fitNas4_) {
68  // penta
69  kernel_FastFit<4, TrackerTraits>(
70  tuples_, tupleMultiplicity_, 5, hv, hitsGPU.get(), hits_geGPU.get(), fast_fit_resultsGPU.get(), offset);
71 
72  kernel_CircleFit<4, TrackerTraits>(tupleMultiplicity_,
73  5,
74  bField_,
75  hitsGPU.get(),
76  hits_geGPU.get(),
77  fast_fit_resultsGPU.get(),
78  circle_fit_resultsGPU,
79  offset);
80 
81  kernel_LineFit<4, TrackerTraits>(tupleMultiplicity_,
82  5,
83  bField_,
84  outputSoa_,
85  hitsGPU.get(),
86  hits_geGPU.get(),
87  fast_fit_resultsGPU.get(),
88  circle_fit_resultsGPU,
89  offset);
90 
91  } else {
92  // penta all 5
93  kernel_FastFit<5, TrackerTraits>(
94  tuples_, tupleMultiplicity_, 5, hv, hitsGPU.get(), hits_geGPU.get(), fast_fit_resultsGPU.get(), offset);
95 
96  kernel_CircleFit<5, TrackerTraits>(tupleMultiplicity_,
97  5,
98  bField_,
99  hitsGPU.get(),
100  hits_geGPU.get(),
101  fast_fit_resultsGPU.get(),
102  circle_fit_resultsGPU,
103  offset);
104 
105  kernel_LineFit<5, TrackerTraits>(tupleMultiplicity_,
106  5,
107  bField_,
108  outputSoa_,
109  hitsGPU.get(),
110  hits_geGPU.get(),
111  fast_fit_resultsGPU.get(),
112  circle_fit_resultsGPU,
113  offset);
114  }
115  }
116 }
assert(be >=bs)
const bool fitNas4_
Definition: HelixFitOnGPU.h:81
Eigen::Matrix< float, 6, 4 > Matrix6x4f
Definition: HelixFitOnGPU.h:17
static constexpr uint32_t maxNumberOfConcurrentFits_
Definition: HelixFitOnGPU.h:73
Eigen::Matrix< double, 3, N > Matrix3xNd
Definition: HelixFitOnGPU.h:22
TupleMultiplicity const * tupleMultiplicity_
Definition: HelixFitOnGPU.h:77
Tuples const * tuples_
Definition: HelixFitOnGPU.h:76
Eigen::Vector4d Vector4d
Definition: FitResult.h:15
OutputSoAView outputSoa_
Definition: HelixFitOnGPU.h:78

◆ setBField()

template<typename TrackerTraits >
void HelixFitOnGPU< TrackerTraits >::setBField ( double  bField)
inline

Member Data Documentation

◆ bField_

template<typename TrackerTraits >
float HelixFitOnGPU< TrackerTraits >::bField_
private

Definition at line 79 of file HelixFitOnGPU.h.

Referenced by HelixFitOnGPU< TrackerTraits >::setBField().

◆ fitNas4_

template<typename TrackerTraits >
const bool HelixFitOnGPU< TrackerTraits >::fitNas4_
private

Definition at line 81 of file HelixFitOnGPU.h.

◆ maxNumberOfConcurrentFits_

template<typename TrackerTraits >
constexpr uint32_t HelixFitOnGPU< TrackerTraits >::maxNumberOfConcurrentFits_ = riemannFit::maxNumberOfConcurrentFits
staticprivate

Definition at line 73 of file HelixFitOnGPU.h.

◆ outputSoa_

template<typename TrackerTraits >
OutputSoAView HelixFitOnGPU< TrackerTraits >::outputSoa_
private

Definition at line 78 of file HelixFitOnGPU.h.

◆ tupleMultiplicity_

template<typename TrackerTraits >
TupleMultiplicity const* HelixFitOnGPU< TrackerTraits >::tupleMultiplicity_ = nullptr
private

Definition at line 77 of file HelixFitOnGPU.h.

◆ tuples_

template<typename TrackerTraits >
Tuples const* HelixFitOnGPU< TrackerTraits >::tuples_ = nullptr
private

Definition at line 76 of file HelixFitOnGPU.h.