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 
18  uint32_t nHits,
19  pixelCPEforGPU::ParamsOnGPU const* cpeParams,
20  uint32_t const* hitsModuleStart,
21  cudaStream_t stream,
23 
25 
30 
31  TrackingRecHit2DSOAView* view() { return m_view.get(); }
32  TrackingRecHit2DSOAView const* view() const { return m_view.get(); }
33 
34  auto nHits() const { return m_nHits; }
35 
36  auto hitsModuleStart() const { return m_hitsModuleStart; }
37  auto hitsLayerStart() { return m_hitsLayerStart; }
38  auto phiBinner() { return m_phiBinner; }
40  auto iphi() { return m_iphi; }
41 
42  // only the local coord and detector index
45 
46  // needs specialization for Host
48 
49 private:
50  static constexpr uint32_t n16 = 4; // number of elements in m_store16
51  static constexpr uint32_t n32 = 10; // number of elements in m_store32
52  static_assert(sizeof(uint32_t) == sizeof(float)); // just stating the obvious
53 
56 
59 
61 
62  uint32_t m_nHits;
63 
64  uint32_t const* m_hitsModuleStart; // needed for legacy, this is on GPU!
65 
66  // needed as kernel params...
69  uint32_t* m_hitsLayerStart;
70  int16_t* m_iphi;
71 };
72 
76 
79 
80 template <typename Traits>
82  uint32_t nHits,
83  pixelCPEforGPU::ParamsOnGPU const* cpeParams,
84  uint32_t const* hitsModuleStart,
85  cudaStream_t stream,
87  : m_nHits(nHits), m_hitsModuleStart(hitsModuleStart) {
88  auto view = Traits::template make_host_unique<TrackingRecHit2DSOAView>(stream);
89 
90  view->m_nHits = nHits;
91  m_view = Traits::template make_unique<TrackingRecHit2DSOAView>(stream); // leave it on host and pass it by value?
92  m_AverageGeometryStore = Traits::template make_unique<TrackingRecHit2DSOAView::AverageGeometry>(stream);
94  view->m_cpeParams = cpeParams;
96 
97  // if empy do not bother
98  if (0 == nHits) {
101  } else {
102  m_view.reset(view.release()); // NOLINT: std::move() breaks CUDA version
103  }
104  return;
105  }
106 
107  // the single arrays are not 128 bit alligned...
108  // the hits are actually accessed in order only in building
109  // if ordering is relevant they may have to be stored phi-ordered by layer or so
110  // this will break 1to1 correspondence with cluster and module locality
111  // so unless proven VERY inefficient we keep it ordered as generated
112 
113  // host copy is "reduced" (to be reviewed at some point)
115  // it has to compile for ALL cases
117  } else {
118  assert(input == nullptr);
119  m_store16 = Traits::template make_unique<uint16_t[]>(nHits * n16, stream);
121  m_PhiBinnerStore = Traits::template make_unique<TrackingRecHit2DSOAView::PhiBinner>(stream);
122  }
123 
124  static_assert(sizeof(TrackingRecHit2DSOAView::hindex_type) == sizeof(float));
126 
127  auto get32 = [&](int i) { return m_store32.get() + i * nHits; };
128 
129  // copy all the pointers
132  reinterpret_cast<TrackingRecHit2DSOAView::PhiBinner::index_type*>(get32(9));
133 
134  view->m_xl = get32(0);
135  view->m_yl = get32(1);
136  view->m_xerr = get32(2);
137  view->m_yerr = get32(3);
138  view->m_chargeAndStatus = reinterpret_cast<uint32_t*>(get32(4));
139 
141  assert(input == nullptr);
142  view->m_xg = get32(5);
143  view->m_yg = get32(6);
144  view->m_zg = get32(7);
145  view->m_rg = get32(8);
146 
147  auto get16 = [&](int i) { return m_store16.get() + i * nHits; };
148  m_iphi = view->m_iphi = reinterpret_cast<int16_t*>(get16(1));
149 
150  view->m_xsize = reinterpret_cast<int16_t*>(get16(2));
151  view->m_ysize = reinterpret_cast<int16_t*>(get16(3));
152  view->m_detInd = get16(0);
153 
155  m_hitsLayerStart = view->m_hitsLayerStart = reinterpret_cast<uint32_t*>(get32(n32));
156  }
157 
158  // transfer view
161  } else {
162  m_view.reset(view.release()); // NOLINT: std::move() breaks CUDA version
163  }
164 }
165 
166 #endif // CUDADataFormats_TrackingRecHit_interface_TrackingRecHit2DHeterogeneous_h
TrackingRecHit2DSOAView::m_iphi
int16_t * m_iphi
Definition: TrackingRecHit2DSOAView.h:96
TrackingRecHit2DHeterogeneous::view
TrackingRecHit2DSOAView * view()
Definition: TrackingRecHit2DHeterogeneous.h:31
TrackingRecHit2DHeterogeneous::m_iphi
int16_t * m_iphi
Definition: TrackingRecHit2DHeterogeneous.h:70
TrackingRecHit2DSOAView::m_yg
float * m_yg
Definition: TrackingRecHit2DSOAView.h:95
TrackingRecHit2DSOAView::m_hitsLayerStart
uint32_t * m_hitsLayerStart
Definition: TrackingRecHit2DSOAView.h:111
TrackingRecHit2DSOAView::m_xerr
float * m_xerr
Definition: TrackingRecHit2DSOAView.h:92
mps_fire.i
i
Definition: mps_fire.py:428
input
static const std::string input
Definition: EdmProvDump.cc:48
TrackingRecHit2DHeterogeneous::m_view
unique_ptr< TrackingRecHit2DSOAView > m_view
Definition: TrackingRecHit2DHeterogeneous.h:60
TrackingRecHit2DHeterogeneous::~TrackingRecHit2DHeterogeneous
~TrackingRecHit2DHeterogeneous()=default
phase1PixelTopology::numberOfLayers
constexpr uint32_t numberOfLayers
Definition: phase1PixelTopology.h:25
TrackingRecHit2DHeterogeneous
Definition: TrackingRecHit2DHeterogeneous.h:8
TrackingRecHit2DSOAView::m_xl
float * m_xl
Definition: TrackingRecHit2DSOAView.h:91
cms::cuda::stream
uint32_t const T *__restrict__ const uint32_t *__restrict__ int32_t int Histo::index_type cudaStream_t stream
Definition: HistoContainer.h:51
TrackingRecHit2DSOAView::hindex_type
uint32_t hindex_type
Definition: TrackingRecHit2DSOAView.h:21
cms::cuda::assert
assert(be >=bs)
TrackingRecHit2DSOAView::m_nHits
uint32_t m_nHits
Definition: TrackingRecHit2DSOAView.h:116
TrackingRecHit2DSOAView
Definition: TrackingRecHit2DSOAView.h:16
TrackingRecHit2DHeterogeneous::n16
static constexpr uint32_t n16
Definition: TrackingRecHit2DHeterogeneous.h:50
TrackingRecHit2DHeterogeneous::hitsLayerStart
auto hitsLayerStart()
Definition: TrackingRecHit2DHeterogeneous.h:37
TrackingRecHit2DHeterogeneous::m_phiBinnerStorage
PhiBinner::index_type * m_phiBinnerStorage
Definition: TrackingRecHit2DHeterogeneous.h:68
cms::cuda::HistoContainer::index_type
typename Base::index_type index_type
Definition: HistoContainer.h:106
nHits
const caConstants::TupleMultiplicity *__restrict__ const HitsOnGPU *__restrict__ double *__restrict__ float *__restrict__ double *__restrict__ uint32_t nHits
Definition: BrokenLineFitOnGPU.h:27
TrackingRecHit2DHeterogeneous::copyFromGPU
void copyFromGPU(TrackingRecHit2DHeterogeneous< cms::cudacompat::GPUTraits > const *input, cudaStream_t stream)
TrackingRecHit2DSOAView::m_ysize
int16_t * m_ysize
Definition: TrackingRecHit2DSOAView.h:102
HeterogeneousSoA.h
TrackingRecHit2DHeterogeneous::m_hitsModuleStart
uint32_t const * m_hitsModuleStart
Definition: TrackingRecHit2DHeterogeneous.h:64
TrackingRecHit2DHeterogeneous::m_phiBinner
PhiBinner * m_phiBinner
Definition: TrackingRecHit2DHeterogeneous.h:67
TrackingRecHit2DHeterogeneous::iphi
auto iphi()
Definition: TrackingRecHit2DHeterogeneous.h:40
TrackingRecHit2DHeterogeneous::unique_ptr
typename Traits::template unique_ptr< T > unique_ptr
Definition: TrackingRecHit2DHeterogeneous.h:11
TrackingRecHit2DHeterogeneous::phiBinner
auto phiBinner()
Definition: TrackingRecHit2DHeterogeneous.h:38
TrackingRecHit2DHeterogeneous::m_store16
unique_ptr< uint16_t[]> m_store16
Definition: TrackingRecHit2DHeterogeneous.h:52
TrackingRecHit2DHeterogeneous::n32
static constexpr uint32_t n32
Definition: TrackingRecHit2DHeterogeneous.h:51
TrackingRecHit2DSOAView::m_averageGeometry
AverageGeometry * m_averageGeometry
Definition: TrackingRecHit2DSOAView.h:107
TrackingRecHit2DHeterogeneous::hitsModuleStart
auto hitsModuleStart() const
Definition: TrackingRecHit2DHeterogeneous.h:36
TrackingRecHit2DSOAView::m_cpeParams
pixelCPEforGPU::ParamsOnGPU const * m_cpeParams
Definition: TrackingRecHit2DSOAView.h:108
cudaCheck.h
TrackingRecHit2DSOAView::m_yerr
float * m_yerr
Definition: TrackingRecHit2DSOAView.h:92
copyAsync.h
TrackingRecHit2DHeterogeneous::phiBinnerStorage
auto phiBinnerStorage()
Definition: TrackingRecHit2DHeterogeneous.h:39
TrackingRecHit2DHeterogeneous::nHits
auto nHits() const
Definition: TrackingRecHit2DHeterogeneous.h:34
svgfig.template
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
TrackingRecHit2DHeterogeneous::m_AverageGeometryStore
unique_ptr< TrackingRecHit2DSOAView::AverageGeometry > m_AverageGeometryStore
Definition: TrackingRecHit2DHeterogeneous.h:58
TrackingRecHit2DSOAView::m_phiBinner
PhiBinner * m_phiBinner
Definition: TrackingRecHit2DSOAView.h:113
TrackingRecHit2DSOAView::PhiBinner
cms::cuda::HistoContainer< int16_t, 128, -1, 8 *sizeof(int16_t), hindex_type, 10 > PhiBinner
Definition: TrackingRecHit2DSOAView.h:23
pixelCPEforGPU::ParamsOnGPU
Definition: pixelCPEforGPU.h:60
TrackingRecHit2DHeterogeneous::operator=
TrackingRecHit2DHeterogeneous & operator=(const TrackingRecHit2DHeterogeneous &)=delete
TrackingRecHit2DHeterogeneous::m_store32
unique_ptr< float[]> m_store32
Definition: TrackingRecHit2DHeterogeneous.h:55
TrackingRecHit2DSOAView.h
cms::cuda::host::unique_ptr
std::unique_ptr< T, impl::HostDeleter > unique_ptr
Definition: host_unique_ptr.h:21
TrackingRecHit2DSOAView::m_chargeAndStatus
m_chargeAndStatus[i]
Definition: TrackingRecHit2DSOAView.h:59
relativeConstraints.value
value
Definition: relativeConstraints.py:53
TrackingRecHit2DSOAView::m_yl
float * m_yl
Definition: TrackingRecHit2DSOAView.h:91
TrackingRecHit2DSOAView::m_phiBinnerStorage
PhiBinner::index_type * m_phiBinnerStorage
Definition: TrackingRecHit2DSOAView.h:114
TrackingRecHit2DHeterogeneous::m_PhiBinnerStore
unique_ptr< TrackingRecHit2DSOAView::PhiBinner > m_PhiBinnerStore
Definition: TrackingRecHit2DHeterogeneous.h:57
TrackingRecHit2DHeterogeneous::view
TrackingRecHit2DSOAView const * view() const
Definition: TrackingRecHit2DHeterogeneous.h:32
TrackingRecHit2DSOAView::m_xg
float * m_xg
Definition: TrackingRecHit2DSOAView.h:95
TrackingRecHit2DSOAView::m_xsize
int16_t * m_xsize
Definition: TrackingRecHit2DSOAView.h:101
cms::cuda::HistoContainer
Definition: HistoContainer.h:101
TrackingRecHit2DSOAView::m_detInd
uint16_t * m_detInd
Definition: TrackingRecHit2DSOAView.h:103
TrackingRecHit2DHeterogeneous::TrackingRecHit2DHeterogeneous
TrackingRecHit2DHeterogeneous()=default
TrackingRecHit2DHeterogeneous::hitsModuleStartToHostAsync
cms::cuda::host::unique_ptr< uint32_t[]> hitsModuleStartToHostAsync(cudaStream_t stream) const
Definition: TrackingRecHit2DHeterogeneous.cc:15
TrackingRecHit2DHeterogeneous::m_hitsLayerStart
uint32_t * m_hitsLayerStart
Definition: TrackingRecHit2DHeterogeneous.h:69
TrackingRecHit2DHeterogeneous::localCoordToHostAsync
cms::cuda::host::unique_ptr< float[]> localCoordToHostAsync(cudaStream_t stream) const
Definition: TrackingRecHit2DHeterogeneous.cc:8
TrackingRecHit2DHeterogeneous::m_nHits
uint32_t m_nHits
Definition: TrackingRecHit2DHeterogeneous.h:62
TrackingRecHit2DSOAView::m_hitsModuleStart
uint32_t const * m_hitsModuleStart
Definition: TrackingRecHit2DSOAView.h:109
TrackingRecHit2DSOAView::m_rg
float * m_rg
Definition: TrackingRecHit2DSOAView.h:95
TrackingRecHit2DSOAView::m_zg
float * m_zg
Definition: TrackingRecHit2DSOAView.h:95
cms::cuda::copyAsync
void copyAsync(device::unique_ptr< T > &dst, const host::unique_ptr< T > &src, cudaStream_t stream)
Definition: copyAsync.h:20