Skip to content

Commit 53993f8

Browse files
authored
Merge pull request cms-sw#33371 from VinInn/NewBinner113x
Make the the size of the binner (HistoContainer) settable at run time. The total number of Pixel Clusters is not a limit anymore on GPU
2 parents df1b846 + 9420952 commit 53993f8

29 files changed

+853
-346
lines changed

CUDADataFormats/SiPixelCluster/interface/gpuClusteringConstants.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,6 @@
44
#include <cstdint>
55
#include <limits>
66

7-
namespace pixelGPUConstants {
8-
#ifdef GPU_SMALL_EVENTS
9-
// kept for testing and debugging
10-
constexpr uint32_t maxNumberOfHits = 24 * 1024;
11-
#else
12-
// data at pileup 50 has 18300 +/- 3500 hits; 40000 is around 6 sigma away
13-
// tested on MC events with 55-75 pileup events
14-
constexpr uint32_t maxNumberOfHits = 48 * 1024;
15-
#endif
16-
} // namespace pixelGPUConstants
17-
187
namespace gpuClustering {
198
#ifdef GPU_SMALL_EVENTS
209
// kept for testing and debugging
@@ -28,7 +17,6 @@ namespace gpuClustering {
2817

2918
constexpr uint16_t maxNumModules = 2000;
3019
constexpr int32_t maxNumClustersPerModules = maxHitsInModule();
31-
constexpr uint32_t maxNumClusters = pixelGPUConstants::maxNumberOfHits;
3220
constexpr uint16_t invalidModuleId = std::numeric_limits<uint16_t>::max() - 1;
3321
static_assert(invalidModuleId > maxNumModules); // invalidModuleId must be > maxNumModules
3422

CUDADataFormats/Track/interface/TrackSoAHeterogeneousT.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class TrackSoAHeterogeneousT {
1717

1818
using Quality = pixelTrack::Quality;
1919
using hindex_type = uint32_t;
20-
using HitContainer = cms::cuda::OneToManyAssoc<hindex_type, S, 5 * S>;
20+
using HitContainer = cms::cuda::OneToManyAssoc<hindex_type, S + 1, 5 * S>;
2121

2222
// Always check quality is at least loose!
2323
// CUDA does not support enums in __lgc ...

CUDADataFormats/TrackingRecHit/interface/TrackingRecHit2DHeterogeneous.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class TrackingRecHit2DHeterogeneous {
3434
auto hitsModuleStart() const { return m_hitsModuleStart; }
3535
auto hitsLayerStart() { return m_hitsLayerStart; }
3636
auto phiBinner() { return m_phiBinner; }
37+
auto phiBinnerStorage() { return m_phiBinnerStorage; }
3738
auto iphi() { return m_iphi; }
3839

3940
// only the local coord and detector index
@@ -42,7 +43,7 @@ class TrackingRecHit2DHeterogeneous {
4243

4344
private:
4445
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 constexpr uint32_t n32 = 10; // number of elements in m_store32
4647
static_assert(sizeof(uint32_t) == sizeof(float)); // just stating the obvious
4748

4849
unique_ptr<uint16_t[]> m_store16; //!
@@ -59,6 +60,7 @@ class TrackingRecHit2DHeterogeneous {
5960

6061
// needed as kernel params...
6162
PhiBinner* m_phiBinner;
63+
PhiBinner::index_type* m_phiBinnerStorage;
6264
uint32_t* m_hitsLayerStart;
6365
int16_t* m_iphi;
6466
};
@@ -97,14 +99,20 @@ TrackingRecHit2DHeterogeneous<Traits>::TrackingRecHit2DHeterogeneous(uint32_t nH
9799
// this will break 1to1 correspondence with cluster and module locality
98100
// so unless proven VERY inefficient we keep it ordered as generated
99101
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);
102+
m_store32 =
103+
Traits::template make_device_unique<float[]>(nHits * n32 + phase1PixelTopology::numberOfLayers + 1, stream);
101104
m_PhiBinnerStore = Traits::template make_device_unique<TrackingRecHit2DSOAView::PhiBinner>(stream);
102105

106+
static_assert(sizeof(TrackingRecHit2DSOAView::hindex_type) == sizeof(float));
107+
static_assert(sizeof(TrackingRecHit2DSOAView::hindex_type) == sizeof(TrackingRecHit2DSOAView::PhiBinner::index_type));
108+
103109
auto get16 = [&](int i) { return m_store16.get() + i * nHits; };
104110
auto get32 = [&](int i) { return m_store32.get() + i * nHits; };
105111

106112
// copy all the pointers
107113
m_phiBinner = view->m_phiBinner = m_PhiBinnerStore.get();
114+
m_phiBinnerStorage = view->m_phiBinnerStorage =
115+
reinterpret_cast<TrackingRecHit2DSOAView::PhiBinner::index_type*>(get32(9));
108116

109117
view->m_xl = get32(0);
110118
view->m_yl = get32(1);

CUDADataFormats/TrackingRecHit/interface/TrackingRecHit2DSOAView.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ namespace pixelCPEforGPU {
1414

1515
class TrackingRecHit2DSOAView {
1616
public:
17-
static constexpr uint32_t maxHits() { return gpuClustering::maxNumClusters; }
1817
using hindex_type = uint32_t; // if above is <=2^32
1918

20-
using PhiBinner =
21-
cms::cuda::HistoContainer<int16_t, 128, gpuClustering::maxNumClusters, 8 * sizeof(int16_t), hindex_type, 10>;
19+
using PhiBinner = cms::cuda::HistoContainer<int16_t, 128, -1, 8 * sizeof(int16_t), hindex_type, 10>;
2220

2321
using AverageGeometry = phase1PixelTopology::AverageGeometry;
2422

@@ -95,6 +93,7 @@ class TrackingRecHit2DSOAView {
9593
uint32_t* m_hitsLayerStart;
9694

9795
PhiBinner* m_phiBinner;
96+
PhiBinner::index_type* m_phiBinnerStorage;
9897

9998
uint32_t m_nHits;
10099
};
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#ifndef HeterogeneousCore_CUDAUtilities_interface_FlexiStorage_h
2+
#define HeterogeneousCore_CUDAUtilities_interface_FlexiStorage_h
3+
4+
#include <cstdint>
5+
6+
namespace cms {
7+
namespace cuda {
8+
9+
template <typename I, int S>
10+
class FlexiStorage {
11+
public:
12+
constexpr int capacity() const { return S; }
13+
14+
constexpr I& operator[](int i) { return m_v[i]; }
15+
constexpr const I& operator[](int i) const { return m_v[i]; }
16+
17+
constexpr I* data() { return m_v; }
18+
constexpr I const* data() const { return m_v; }
19+
20+
private:
21+
I m_v[S];
22+
};
23+
24+
template <typename I>
25+
class FlexiStorage<I, -1> {
26+
public:
27+
constexpr void init(I* v, int s) {
28+
m_v = v;
29+
m_capacity = s;
30+
}
31+
32+
constexpr int capacity() const { return m_capacity; }
33+
34+
constexpr I& operator[](int i) { return m_v[i]; }
35+
constexpr const I& operator[](int i) const { return m_v[i]; }
36+
37+
constexpr I* data() { return m_v; }
38+
constexpr I const* data() const { return m_v; }
39+
40+
private:
41+
I* m_v;
42+
int m_capacity;
43+
};
44+
45+
} // namespace cuda
46+
47+
} // namespace cms
48+
49+
#endif

0 commit comments

Comments
 (0)