CMS 3D CMS Logo

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

#include <HelixFitOnGPU.h>

Public Types

using HitsView = TrackingRecHit2DSOAView
 
using OutputSoA = pixelTrack::TrackSoA
 
using TupleMultiplicity = caConstants::TupleMultiplicity
 
using Tuples = pixelTrack::HitContainer
 

Public Member Functions

void allocateOnGPU (Tuples const *tuples, TupleMultiplicity const *tupleMultiplicity, OutputSoA *outputSoA)
 
void deallocateOnGPU ()
 
 HelixFitOnGPU (float bf, bool fitNas4)
 
void launchBrokenLineKernels (HitsView const *hv, uint32_t nhits, uint32_t maxNumberOfTuples, cudaStream_t cudaStream)
 
void launchBrokenLineKernelsOnCPU (HitsView const *hv, uint32_t nhits, uint32_t maxNumberOfTuples)
 
void launchRiemannKernels (HitsView const *hv, uint32_t nhits, uint32_t maxNumberOfTuples, cudaStream_t cudaStream)
 
void launchRiemannKernelsOnCPU (HitsView const *hv, uint32_t nhits, uint32_t maxNumberOfTuples)
 
void setBField (double bField)
 
 ~HelixFitOnGPU ()
 

Private Attributes

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

Static Private Attributes

static constexpr uint32_t maxNumberOfConcurrentFits_ = riemannFit::maxNumberOfConcurrentFits
 

Detailed Description

Definition at line 34 of file HelixFitOnGPU.h.

Member Typedef Documentation

◆ HitsView

Definition at line 36 of file HelixFitOnGPU.h.

◆ OutputSoA

Definition at line 39 of file HelixFitOnGPU.h.

◆ TupleMultiplicity

Definition at line 41 of file HelixFitOnGPU.h.

◆ Tuples

Definition at line 38 of file HelixFitOnGPU.h.

Constructor & Destructor Documentation

◆ HelixFitOnGPU()

HelixFitOnGPU::HelixFitOnGPU ( float  bf,
bool  fitNas4 
)
inlineexplicit

Definition at line 43 of file HelixFitOnGPU.h.

◆ ~HelixFitOnGPU()

HelixFitOnGPU::~HelixFitOnGPU ( )
inline

Definition at line 44 of file HelixFitOnGPU.h.

References deallocateOnGPU().

44 { deallocateOnGPU(); }
void deallocateOnGPU()

Member Function Documentation

◆ allocateOnGPU()

void HelixFitOnGPU::allocateOnGPU ( Tuples const *  tuples,
TupleMultiplicity const *  tupleMultiplicity,
OutputSoA outputSoA 
)

Definition at line 4 of file HelixFitOnGPU.cc.

References cms::cuda::assert(), outputSoa_, tupleMultiplicity, tupleMultiplicity_, tuples, and tuples_.

Referenced by CAHitNtupletGeneratorOnGPU::makeTuples(), and CAHitNtupletGeneratorOnGPU::makeTuplesAsync().

6  {
7  tuples_ = tuples;
9  outputSoa_ = helix_fit_results;
10 
11  assert(tuples_);
14 }
caConstants::TupleMultiplicity const *__restrict__ tupleMultiplicity
TupleMultiplicity const * tupleMultiplicity_
Definition: HelixFitOnGPU.h:61
assert(be >=bs)
HitContainer const *__restrict__ tuples
OutputSoA * outputSoa_
Definition: HelixFitOnGPU.h:62
Tuples const * tuples_
Definition: HelixFitOnGPU.h:60

◆ deallocateOnGPU()

void HelixFitOnGPU::deallocateOnGPU ( )

Definition at line 16 of file HelixFitOnGPU.cc.

Referenced by ~HelixFitOnGPU().

16 {}

◆ launchBrokenLineKernels()

void HelixFitOnGPU::launchBrokenLineKernels ( HitsView const *  hv,
uint32_t  nhits,
uint32_t  maxNumberOfTuples,
cudaStream_t  cudaStream 
)

◆ launchBrokenLineKernelsOnCPU()

void HelixFitOnGPU::launchBrokenLineKernelsOnCPU ( HitsView const *  hv,
uint32_t  nhits,
uint32_t  maxNumberOfTuples 
)

Definition at line 3 of file BrokenLineFitOnGPU.cc.

References cms::cuda::assert(), bField_, fitNas4_, maxNumberOfConcurrentFits_, caConstants::maxNumberOfTuples, hltrates_dqm_sourceclient-live_cfg::offset, outputSoa_, mps_setup::stdout, tupleMultiplicity_, and tuples_.

Referenced by CAHitNtupletGeneratorOnGPU::makeTuples().

3  {
5 
6 #ifdef BROKENLINE_DEBUG
7  setlinebuf(stdout);
8 #endif
9 
10  // Fit internals
11  auto tkidGPU = std::make_unique<caConstants::tindex_type[]>(maxNumberOfConcurrentFits_);
12  auto hitsGPU =
13  std::make_unique<double[]>(maxNumberOfConcurrentFits_ * sizeof(riemannFit::Matrix3xNd<6>) / sizeof(double));
14  auto hits_geGPU =
15  std::make_unique<float[]>(maxNumberOfConcurrentFits_ * sizeof(riemannFit::Matrix6xNf<6>) / sizeof(float));
16  auto fast_fit_resultsGPU =
17  std::make_unique<double[]>(maxNumberOfConcurrentFits_ * sizeof(riemannFit::Vector4d) / sizeof(double));
18 
20  // fit triplets
21  kernel_BLFastFit<3>(tuples_,
23  hv,
24  tkidGPU.get(),
25  hitsGPU.get(),
26  hits_geGPU.get(),
27  fast_fit_resultsGPU.get(),
28  3,
29  3,
30  offset);
31 
32  kernel_BLFit<3>(tupleMultiplicity_,
33  bField_,
34  outputSoa_,
35  tkidGPU.get(),
36  hitsGPU.get(),
37  hits_geGPU.get(),
38  fast_fit_resultsGPU.get());
39 
40  if (fitNas4_) {
41  // fit all as 4
42  kernel_BLFastFit<4>(tuples_,
44  hv,
45  tkidGPU.get(),
46  hitsGPU.get(),
47  hits_geGPU.get(),
48  fast_fit_resultsGPU.get(),
49  4,
50  8,
51  offset);
52 
53  kernel_BLFit<4>(tupleMultiplicity_,
54  bField_,
55  outputSoa_,
56  tkidGPU.get(),
57  hitsGPU.get(),
58  hits_geGPU.get(),
59  fast_fit_resultsGPU.get());
60  } else {
61  // fit quads
62  kernel_BLFastFit<4>(tuples_,
64  hv,
65  tkidGPU.get(),
66  hitsGPU.get(),
67  hits_geGPU.get(),
68  fast_fit_resultsGPU.get(),
69  4,
70  4,
71  offset);
72 
73  kernel_BLFit<4>(tupleMultiplicity_,
74  bField_,
75  outputSoa_,
76  tkidGPU.get(),
77  hitsGPU.get(),
78  hits_geGPU.get(),
79  fast_fit_resultsGPU.get());
80  // fit penta (all 5)
81  kernel_BLFastFit<5>(tuples_,
83  hv,
84  tkidGPU.get(),
85  hitsGPU.get(),
86  hits_geGPU.get(),
87  fast_fit_resultsGPU.get(),
88  5,
89  5,
90  offset);
91 
92  kernel_BLFit<5>(tupleMultiplicity_,
93  bField_,
94  outputSoa_,
95  tkidGPU.get(),
96  hitsGPU.get(),
97  hits_geGPU.get(),
98  fast_fit_resultsGPU.get());
99  // fit sexta and above (as 6)
100  kernel_BLFastFit<6>(tuples_,
102  hv,
103  tkidGPU.get(),
104  hitsGPU.get(),
105  hits_geGPU.get(),
106  fast_fit_resultsGPU.get(),
107  6,
108  8,
109  offset);
110 
111  kernel_BLFit<6>(tupleMultiplicity_,
112  bField_,
113  outputSoa_,
114  tkidGPU.get(),
115  hitsGPU.get(),
116  hits_geGPU.get(),
117  fast_fit_resultsGPU.get());
118  }
119 
120  } // loop on concurrent fits
121 }
const bool fitNas4_
Definition: HelixFitOnGPU.h:65
static constexpr uint32_t maxNumberOfConcurrentFits_
Definition: HelixFitOnGPU.h:57
TupleMultiplicity const * tupleMultiplicity_
Definition: HelixFitOnGPU.h:61
assert(be >=bs)
Eigen::Matrix< float, 6, N > Matrix6xNf
Definition: HelixFitOnGPU.h:26
constexpr uint32_t maxNumberOfTuples
Definition: CAConstants.h:36
Eigen::Matrix< double, 3, N > Matrix3xNd
Definition: FitResult.h:24
OutputSoA * outputSoa_
Definition: HelixFitOnGPU.h:62
Tuples const * tuples_
Definition: HelixFitOnGPU.h:60
Eigen::Vector4d Vector4d
Definition: FitResult.h:15

◆ launchRiemannKernels()

void HelixFitOnGPU::launchRiemannKernels ( HitsView const *  hv,
uint32_t  nhits,
uint32_t  maxNumberOfTuples,
cudaStream_t  cudaStream 
)

◆ launchRiemannKernelsOnCPU()

void HelixFitOnGPU::launchRiemannKernelsOnCPU ( HitsView const *  hv,
uint32_t  nhits,
uint32_t  maxNumberOfTuples 
)

Definition at line 3 of file RiemannFitOnGPU.cc.

References cms::cuda::assert(), bField_, fitNas4_, maxNumberOfConcurrentFits_, caConstants::maxNumberOfTuples, hltrates_dqm_sourceclient-live_cfg::offset, outputSoa_, tupleMultiplicity_, and tuples_.

Referenced by CAHitNtupletGeneratorOnGPU::makeTuples().

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

◆ setBField()

void HelixFitOnGPU::setBField ( double  bField)
inline

Definition at line 46 of file HelixFitOnGPU.h.

References Calorimetry_cff::bField, and bField_.

Member Data Documentation

◆ bField_

float HelixFitOnGPU::bField_
private

◆ fitNas4_

const bool HelixFitOnGPU::fitNas4_
private

Definition at line 65 of file HelixFitOnGPU.h.

Referenced by launchBrokenLineKernelsOnCPU(), and launchRiemannKernelsOnCPU().

◆ maxNumberOfConcurrentFits_

constexpr uint32_t HelixFitOnGPU::maxNumberOfConcurrentFits_ = riemannFit::maxNumberOfConcurrentFits
staticprivate

Definition at line 57 of file HelixFitOnGPU.h.

Referenced by launchBrokenLineKernelsOnCPU(), and launchRiemannKernelsOnCPU().

◆ outputSoa_

OutputSoA* HelixFitOnGPU::outputSoa_
private

◆ tupleMultiplicity_

TupleMultiplicity const* HelixFitOnGPU::tupleMultiplicity_ = nullptr
private

◆ tuples_

Tuples const* HelixFitOnGPU::tuples_ = nullptr
private