CMS 3D CMS Logo

SiPixelRawToClusterGPUKernel.h
Go to the documentation of this file.
1 #ifndef RecoLocalTracker_SiPixelClusterizer_plugins_SiPixelRawToClusterGPUKernel_h
2 #define RecoLocalTracker_SiPixelClusterizer_plugins_SiPixelRawToClusterGPUKernel_h
3 
4 #include <algorithm>
5 #include <cuda_runtime.h>
6 
17 
18 // local include(s)
20 
23 
24 namespace pixelgpudetails {
25 
26  inline namespace phase1geometry {
27  const uint32_t layerStartBit = 20;
28  const uint32_t ladderStartBit = 12;
29  const uint32_t moduleStartBit = 2;
30 
31  const uint32_t panelStartBit = 10;
32  const uint32_t diskStartBit = 18;
33  const uint32_t bladeStartBit = 12;
34 
35  const uint32_t layerMask = 0xF;
36  const uint32_t ladderMask = 0xFF;
37  const uint32_t moduleMask = 0x3FF;
38  const uint32_t panelMask = 0x3;
39  const uint32_t diskMask = 0xF;
40  const uint32_t bladeMask = 0x3F;
41  } // namespace phase1geometry
42 
43  const uint32_t maxROCIndex = 8;
44  const uint32_t numRowsInRoc = 80;
45  const uint32_t numColsInRoc = 52;
46 
47  const uint32_t MAX_WORD = 2000;
48 
49  struct DetIdGPU {
50  uint32_t rawId;
51  uint32_t rocInDet;
52  uint32_t moduleId;
53  };
54 
55  struct Pixel {
56  uint32_t row;
57  uint32_t col;
58  };
59 
61 
62  inline constexpr uint32_t pack(uint32_t row, uint32_t col, uint32_t adc, uint32_t flag = 0) {
63  constexpr pixelchannelidentifierimpl::Packing thePacking = packing();
64  adc = std::min(adc, uint32_t(thePacking.max_adc));
65 
66  return (row << thePacking.row_shift) | (col << thePacking.column_shift) | (adc << thePacking.adc_shift);
67  }
68 
69  constexpr uint32_t pixelToChannel(int row, int col) {
70  constexpr pixelchannelidentifierimpl::Packing thePacking = packing();
71  return (row << thePacking.column_width) | col;
72  }
73 
75  public:
77  public:
78  WordFedAppender(uint32_t words, cudaStream_t stream)
79  : word_{cms::cuda::make_host_unique<unsigned int[]>(words, stream)},
80  fedId_{cms::cuda::make_host_unique<unsigned char[]>(words, stream)} {}
81 
82  void initializeWordFed(int fedId, unsigned int index, cms_uint32_t const* src, unsigned int length) {
83  std::memcpy(word_.get() + index, src, sizeof(cms_uint32_t) * length);
84  std::memset(fedId_.get() + index / 2, fedId - FEDNumbering::MINSiPixeluTCAFEDID, length / 2);
85  }
86 
87  const unsigned int* word() const { return word_.get(); }
88  const unsigned char* fedId() const { return fedId_.get(); }
89 
90  private:
93  };
94 
95  SiPixelRawToClusterGPUKernel() = default;
97 
102 
103  void makeClustersAsync(bool isRun2,
104  const SiPixelClusterThresholds clusterThresholds,
105  const SiPixelROCsStatusAndMapping* cablingMap,
106  const unsigned char* modToUnp,
108  const WordFedAppender& wordFed,
110  const uint32_t wordCounter,
111  const uint32_t fedCounter,
112  bool useQualityInfo,
113  bool includeErrors,
114  bool debug,
115  cudaStream_t stream);
116 
117  void makePhase2ClustersAsync(const SiPixelClusterThresholds clusterThresholds,
118  const uint16_t* moduleIds,
119  const uint16_t* xDigis,
120  const uint16_t* yDigis,
121  const uint16_t* adcDigis,
122  const uint32_t* packedData,
123  const uint32_t* rawIds,
124  const uint32_t numDigis,
125  cudaStream_t stream);
126 
127  std::pair<SiPixelDigisCUDA, SiPixelClustersCUDA> getResults() {
131  // need to explicitly deallocate while the associated CUDA
132  // stream is still alive
133  //
134  // technically the statement above is not true anymore now that
135  // the CUDA streams are cached within the cms::cuda::StreamCache, but it is
136  // still better to release as early as possible
137  nModules_Clusters_h.reset();
138  return std::make_pair(std::move(digis_d), std::move(clusters_d));
139  }
140 
142 
143  private:
144  uint32_t nDigis;
145 
146  // Data to be put in the event
151  };
152 
153 } // namespace pixelgpudetails
154 
155 #endif // RecoLocalTracker_SiPixelClusterizer_plugins_SiPixelRawToClusterGPUKernel_h
void initializeWordFed(int fedId, unsigned int index, cms_uint32_t const *src, unsigned int length)
std::pair< SiPixelDigisCUDA, SiPixelClustersCUDA > getResults()
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
assert(be >=bs)
static constexpr Packing thePacking
unsigned int cms_uint32_t
Definition: typedefs.h:15
constexpr float gains[NGAINS]
Definition: EcalConstants.h:11
void makePhase2ClustersAsync(const SiPixelClusterThresholds clusterThresholds, const uint16_t *moduleIds, const uint16_t *xDigis, const uint16_t *yDigis, const uint16_t *adcDigis, const uint32_t *packedData, const uint32_t *rawIds, const uint32_t numDigis, cudaStream_t stream)
void setNClusters(uint32_t nClusters, int32_t offsetBPIX2)
#define debug
Definition: HDRShower.cc:19
SiPixelRawToClusterGPUKernel & operator=(const SiPixelRawToClusterGPUKernel &)=delete
constexpr pixelchannelidentifierimpl::Packing packing()
cms::cuda::host::unique_ptr< uint32_t[]> nModules_Clusters_h
constexpr uint32_t pack(uint32_t row, uint32_t col, uint32_t adc, uint32_t flag=0)
col
Definition: cuy.py:1009
void setNModulesDigis(uint32_t nModules, uint32_t nDigis)
std::unique_ptr< T, impl::HostDeleter > unique_ptr
Definition: errors.py:1
void makeClustersAsync(bool isRun2, const SiPixelClusterThresholds clusterThresholds, const SiPixelROCsStatusAndMapping *cablingMap, const unsigned char *modToUnp, const SiPixelGainForHLTonGPU *gains, const WordFedAppender &wordFed, SiPixelFormatterErrors &&errors, const uint32_t wordCounter, const uint32_t fedCounter, bool useQualityInfo, bool includeErrors, bool debug, cudaStream_t stream)
constexpr uint32_t pixelToChannel(int row, int col)
std::map< cms_uint32_t, std::vector< SiPixelRawDataError > > SiPixelFormatterErrors
def move(src, dest)
Definition: eostools.py:511
uint16_t *__restrict__ uint16_t const *__restrict__ adc