CMS 3D CMS Logo

TrackingRecHit2DHeterogeneous.h
Go to the documentation of this file.
1 #ifndef CUDADataFormats_TrackingRecHit_interface_TrackingRecHit2DHeterogeneous_h
2 #define CUDADataFormats_TrackingRecHit_interface_TrackingRecHit2DHeterogeneous_h
3 
6 
7 template <typename Traits>
9 public:
10  template <typename T>
12 
14 
16 
17  explicit TrackingRecHit2DHeterogeneous(uint32_t nHits,
18  pixelCPEforGPU::ParamsOnGPU const* cpeParams,
19  uint32_t const* hitsModuleStart,
20  cudaStream_t stream);
21 
23 
28 
29  TrackingRecHit2DSOAView* view() { return m_view.get(); }
30  TrackingRecHit2DSOAView const* view() const { return m_view.get(); }
31 
32  auto nHits() const { return m_nHits; }
33 
34  auto hitsModuleStart() const { return m_hitsModuleStart; }
35  auto hitsLayerStart() { return m_hitsLayerStart; }
36  auto phiBinner() { return m_phiBinner; }
37  auto iphi() { return m_iphi; }
38 
39  // only the local coord and detector index
42 
43 private:
44  static constexpr uint32_t n16 = 4; // number of elements in m_store16
45  static constexpr uint32_t n32 = 9; // number of elements in m_store32
46  static_assert(sizeof(uint32_t) == sizeof(float)); // just stating the obvious
47 
50 
53 
55 
56  uint32_t m_nHits;
57 
58  uint32_t const* m_hitsModuleStart; // needed for legacy, this is on GPU!
59 
60  // needed as kernel params...
62  uint32_t* m_hitsLayerStart;
63  int16_t* m_iphi;
64 };
65 
68 
69 template <typename Traits>
71  pixelCPEforGPU::ParamsOnGPU const* cpeParams,
72  uint32_t const* hitsModuleStart,
73  cudaStream_t stream)
74  : m_nHits(nHits), m_hitsModuleStart(hitsModuleStart) {
75  auto view = Traits::template make_host_unique<TrackingRecHit2DSOAView>(stream);
76 
77  view->m_nHits = nHits;
78  m_view = Traits::template make_device_unique<TrackingRecHit2DSOAView>(stream);
79  m_AverageGeometryStore = Traits::template make_device_unique<TrackingRecHit2DSOAView::AverageGeometry>(stream);
81  view->m_cpeParams = cpeParams;
83 
84  // if empy do not bother
85  if (0 == nHits) {
88  } else {
89  m_view.reset(view.release()); // NOLINT: std::move() breaks CUDA version
90  }
91  return;
92  }
93 
94  // the single arrays are not 128 bit alligned...
95  // the hits are actually accessed in order only in building
96  // if ordering is relevant they may have to be stored phi-ordered by layer or so
97  // this will break 1to1 correspondence with cluster and module locality
98  // so unless proven VERY inefficient we keep it ordered as generated
99  m_store16 = Traits::template make_device_unique<uint16_t[]>(nHits * n16, stream);
100  m_store32 = Traits::template make_device_unique<float[]>(nHits * n32 + 11, stream);
101  m_PhiBinnerStore = Traits::template make_device_unique<TrackingRecHit2DSOAView::PhiBinner>(stream);
102 
103  auto get16 = [&](int i) { return m_store16.get() + i * nHits; };
104  auto get32 = [&](int i) { return m_store32.get() + i * nHits; };
105 
106  // copy all the pointers
108 
109  view->m_xl = get32(0);
110  view->m_yl = get32(1);
111  view->m_xerr = get32(2);
112  view->m_yerr = get32(3);
113 
114  view->m_xg = get32(4);
115  view->m_yg = get32(5);
116  view->m_zg = get32(6);
117  view->m_rg = get32(7);
118 
119  m_iphi = view->m_iphi = reinterpret_cast<int16_t*>(get16(0));
120 
121  view->m_charge = reinterpret_cast<int32_t*>(get32(8));
122  view->m_xsize = reinterpret_cast<int16_t*>(get16(2));
123  view->m_ysize = reinterpret_cast<int16_t*>(get16(3));
124  view->m_detInd = get16(1);
125 
126  m_hitsLayerStart = view->m_hitsLayerStart = reinterpret_cast<uint32_t*>(get32(n32));
127 
128  // transfer view
131  } else {
132  m_view.reset(view.release()); // NOLINT: std::move() breaks CUDA version
133  }
134 }
135 
140 
141 #endif // CUDADataFormats_TrackingRecHit_interface_TrackingRecHit2DHeterogeneous_h
TrackingRecHit2DSOAView::m_iphi
int16_t * m_iphi
Definition: TrackingRecHit2DSOAView.h:81
TrackingRecHit2DHeterogeneous::view
TrackingRecHit2DSOAView * view()
Definition: TrackingRecHit2DHeterogeneous.h:29
TrackingRecHit2DHeterogeneous::m_iphi
int16_t * m_iphi
Definition: TrackingRecHit2DHeterogeneous.h:63
TrackingRecHit2DSOAView::m_yg
float * m_yg
Definition: TrackingRecHit2DSOAView.h:80
TrackingRecHit2DSOAView::m_hitsLayerStart
uint32_t * m_hitsLayerStart
Definition: TrackingRecHit2DSOAView.h:95
TrackingRecHit2DSOAView::m_xerr
float * m_xerr
Definition: TrackingRecHit2DSOAView.h:77
mps_fire.i
i
Definition: mps_fire.py:428
TrackingRecHit2DHeterogeneous::m_view
unique_ptr< TrackingRecHit2DSOAView > m_view
Definition: TrackingRecHit2DHeterogeneous.h:54
TrackingRecHit2DHeterogeneous::~TrackingRecHit2DHeterogeneous
~TrackingRecHit2DHeterogeneous()=default
cms::cuda::stream
cudaStream_t stream
Definition: HistoContainer.h:57
TrackingRecHit2DHeterogeneous
Definition: TrackingRecHit2DHeterogeneous.h:8
TrackingRecHit2DSOAView::m_xl
float * m_xl
Definition: TrackingRecHit2DSOAView.h:76
TrackingRecHit2DSOAView::m_nHits
uint32_t m_nHits
Definition: TrackingRecHit2DSOAView.h:99
TrackingRecHit2DSOAView
Definition: TrackingRecHit2DSOAView.h:15
TrackingRecHit2DHeterogeneous::n16
static constexpr uint32_t n16
Definition: TrackingRecHit2DHeterogeneous.h:44
TrackingRecHit2DHeterogeneous::hitsLayerStart
auto hitsLayerStart()
Definition: TrackingRecHit2DHeterogeneous.h:35
TrackingRecHit2DSOAView::m_charge
int32_t * m_charge
Definition: TrackingRecHit2DSOAView.h:84
nHits
const caConstants::TupleMultiplicity *__restrict__ const HitsOnGPU *__restrict__ double *__restrict__ float *__restrict__ double *__restrict__ uint32_t nHits
Definition: BrokenLineFitOnGPU.h:27
TrackingRecHit2DSOAView::m_ysize
int16_t * m_ysize
Definition: TrackingRecHit2DSOAView.h:86
HeterogeneousSoA.h
TrackingRecHit2DHeterogeneous::m_hitsModuleStart
uint32_t const * m_hitsModuleStart
Definition: TrackingRecHit2DHeterogeneous.h:58
TrackingRecHit2DHeterogeneous::m_phiBinner
PhiBinner * m_phiBinner
Definition: TrackingRecHit2DHeterogeneous.h:61
TrackingRecHit2DHeterogeneous::iphi
auto iphi()
Definition: TrackingRecHit2DHeterogeneous.h:37
TrackingRecHit2DHeterogeneous::unique_ptr
typename Traits::template unique_ptr< T > unique_ptr
Definition: TrackingRecHit2DHeterogeneous.h:11
TrackingRecHit2DHeterogeneous::phiBinner
auto phiBinner()
Definition: TrackingRecHit2DHeterogeneous.h:36
TrackingRecHit2DHeterogeneous::m_store16
unique_ptr< uint16_t[]> m_store16
Definition: TrackingRecHit2DHeterogeneous.h:46
TrackingRecHit2DHeterogeneous::n32
static constexpr uint32_t n32
Definition: TrackingRecHit2DHeterogeneous.h:45
TrackingRecHit2DSOAView::m_averageGeometry
AverageGeometry * m_averageGeometry
Definition: TrackingRecHit2DSOAView.h:91
TrackingRecHit2DHeterogeneous::hitsModuleStart
auto hitsModuleStart() const
Definition: TrackingRecHit2DHeterogeneous.h:34
TrackingRecHit2DSOAView::m_cpeParams
pixelCPEforGPU::ParamsOnGPU const * m_cpeParams
Definition: TrackingRecHit2DSOAView.h:92
cudaCheck.h
TrackingRecHit2DSOAView::m_yerr
float * m_yerr
Definition: TrackingRecHit2DSOAView.h:77
copyAsync.h
TrackingRecHit2DHeterogeneous::nHits
auto nHits() const
Definition: TrackingRecHit2DHeterogeneous.h:32
svgfig.template
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
TrackingRecHit2DHeterogeneous::m_AverageGeometryStore
unique_ptr< TrackingRecHit2DSOAView::AverageGeometry > m_AverageGeometryStore
Definition: TrackingRecHit2DHeterogeneous.h:52
TrackingRecHit2DSOAView::m_phiBinner
PhiBinner * m_phiBinner
Definition: TrackingRecHit2DSOAView.h:97
pixelCPEforGPU::ParamsOnGPU
Definition: pixelCPEforGPU.h:54
TrackingRecHit2DHeterogeneous::operator=
TrackingRecHit2DHeterogeneous & operator=(const TrackingRecHit2DHeterogeneous &)=delete
TrackingRecHit2DHeterogeneous::hitsModuleStartToHostAsync
cms::cuda::host::unique_ptr< uint32_t[]> hitsModuleStartToHostAsync(cudaStream_t stream) const
Definition: TrackingRecHit2DHeterogeneous.cc:15
TrackingRecHit2DHeterogeneous::m_store32
unique_ptr< float[]> m_store32
Definition: TrackingRecHit2DHeterogeneous.h:49
TrackingRecHit2DSOAView.h
cms::cuda::host::unique_ptr
std::unique_ptr< T, impl::HostDeleter > unique_ptr
Definition: host_unique_ptr.h:21
relativeConstraints.value
value
Definition: relativeConstraints.py:53
TrackingRecHit2DSOAView::m_yl
float * m_yl
Definition: TrackingRecHit2DSOAView.h:76
TrackingRecHit2DHeterogeneous::localCoordToHostAsync
cms::cuda::host::unique_ptr< float[]> localCoordToHostAsync(cudaStream_t stream) const
Definition: TrackingRecHit2DHeterogeneous.cc:8
TrackingRecHit2DHeterogeneous::m_PhiBinnerStore
unique_ptr< TrackingRecHit2DSOAView::PhiBinner > m_PhiBinnerStore
Definition: TrackingRecHit2DHeterogeneous.h:51
TrackingRecHit2DHeterogeneous::view
TrackingRecHit2DSOAView const * view() const
Definition: TrackingRecHit2DHeterogeneous.h:30
TrackingRecHit2DSOAView::m_xg
float * m_xg
Definition: TrackingRecHit2DSOAView.h:80
TrackingRecHit2DSOAView::m_xsize
int16_t * m_xsize
Definition: TrackingRecHit2DSOAView.h:85
cms::cuda::HistoContainer
Definition: HistoContainer.h:152
TrackingRecHit2DSOAView::m_detInd
uint16_t * m_detInd
Definition: TrackingRecHit2DSOAView.h:87
TrackingRecHit2DHeterogeneous::TrackingRecHit2DHeterogeneous
TrackingRecHit2DHeterogeneous()=default
TrackingRecHit2DHeterogeneous::m_hitsLayerStart
uint32_t * m_hitsLayerStart
Definition: TrackingRecHit2DHeterogeneous.h:62
TrackingRecHit2DHeterogeneous::m_nHits
uint32_t m_nHits
Definition: TrackingRecHit2DHeterogeneous.h:56
TrackingRecHit2DSOAView::PhiBinner
cms::cuda::HistoContainer< int16_t, 128, gpuClustering::maxNumClusters, 8 *sizeof(int16_t), hindex_type, 10 > PhiBinner
Definition: TrackingRecHit2DSOAView.h:21
TrackingRecHit2DSOAView::m_hitsModuleStart
uint32_t const * m_hitsModuleStart
Definition: TrackingRecHit2DSOAView.h:93
TrackingRecHit2DSOAView::m_rg
float * m_rg
Definition: TrackingRecHit2DSOAView.h:80
TrackingRecHit2DSOAView::m_zg
float * m_zg
Definition: TrackingRecHit2DSOAView.h:80
cms::cuda::copyAsync
void copyAsync(device::unique_ptr< T > &dst, const host::unique_ptr< T > &src, cudaStream_t stream)
Definition: copyAsync.h:20