CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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:
79  WordFedAppender(uint32_t maxFedWords);
80  ~WordFedAppender() = default;
81 
82  void initializeWordFed(int fedId, unsigned int wordCounterGPU, const cms_uint32_t* src, unsigned int length);
83 
84  const unsigned int* word() const { return word_.get(); }
85  const unsigned char* fedId() const { return fedId_.get(); }
86 
87  private:
90  };
91 
92  SiPixelRawToClusterGPUKernel() = default;
94 
99 
100  void makeClustersAsync(bool isRun2,
101  const SiPixelClusterThresholds clusterThresholds,
102  const SiPixelROCsStatusAndMapping* cablingMap,
103  const unsigned char* modToUnp,
104  const SiPixelGainForHLTonGPU* gains,
105  const WordFedAppender& wordFed,
106  SiPixelFormatterErrors&& errors,
107  const uint32_t wordCounter,
108  const uint32_t fedCounter,
109  const uint32_t maxFedWords,
110  bool useQualityInfo,
111  bool includeErrors,
112  bool debug,
113  cudaStream_t stream);
114 
115  std::pair<SiPixelDigisCUDA, SiPixelClustersCUDA> getResults() {
119  // need to explicitly deallocate while the associated CUDA
120  // stream is still alive
121  //
122  // technically the statement above is not true anymore now that
123  // the CUDA streams are cached within the cms::cuda::StreamCache, but it is
124  // still better to release as early as possible
125  nModules_Clusters_h.reset();
126  return std::make_pair(std::move(digis_d), std::move(clusters_d));
127  }
128 
130 
131  private:
132  uint32_t nDigis = 0;
133 
134  // Data to be put in the event
139  };
140 
141 } // namespace pixelgpudetails
142 
143 #endif // RecoLocalTracker_SiPixelClusterizer_plugins_SiPixelRawToClusterGPUKernel_h
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, const uint32_t maxFedWords, bool useQualityInfo, bool includeErrors, bool debug, cudaStream_t stream)
cms::cuda::host::noncached::unique_ptr< unsigned char[]> fedId_
std::pair< SiPixelDigisCUDA, SiPixelClustersCUDA > getResults()
std::unique_ptr< T, impl::HostDeleter > unique_ptr
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
assert(be >=bs)
cms::cuda::host::noncached::unique_ptr< unsigned int[]> word_
void initializeWordFed(int fedId, unsigned int wordCounterGPU, const cms_uint32_t *src, unsigned int length)
static constexpr Packing thePacking
std::map< cms_uint32_t, std::vector< SiPixelRawDataError >> SiPixelFormatterErrors
def move
Definition: eostools.py:511
T min(T a, T b)
Definition: MathUtil.h:58
unsigned int cms_uint32_t
Definition: typedefs.h:15
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)
void setNModulesDigis(uint32_t nModules, uint32_t nDigis)
std::unique_ptr< T, impl::HostDeleter > unique_ptr
constexpr uint32_t pixelToChannel(int row, int col)
int col
Definition: cuy.py:1009
uint16_t *__restrict__ uint16_t const *__restrict__ adc