CMS 3D CMS Logo

SiStripClusterizerConditionsGPU.h
Go to the documentation of this file.
1 #ifndef CalibFormats_SiStripObjects_SiStripClusterizerConditionsGPU_h
2 #define CalibFormats_SiStripObjects_SiStripClusterizerConditionsGPU_h
3 
6 
12 
13 class SiStripQuality;
14 class SiStripGain;
15 class SiStripNoises;
16 
17 namespace stripgpu {
19  __host__ __device__ inline std::uint32_t stripIndex(fedId_t fed, fedCh_t channel, stripId_t strip) {
22  }
23  __host__ __device__ inline std::uint32_t apvIndex(fedId_t fed, fedCh_t channel, stripId_t strip) {
26  }
27  __host__ __device__ inline std::uint32_t channelIndex(fedId_t fed, fedCh_t channel) {
28  return fedIndex(fed) * sistrip::FEDCH_PER_FED + channel;
29  }
30 
32  public:
33  class DetToFed {
34  public:
36  : detid_(detid), ipair_(ipair), fedid_(fedid), fedch_(fedch) {}
37  detId_t detID() const { return detid_; }
38  apvPair_t pair() const { return ipair_; }
39  fedId_t fedID() const { return fedid_; }
40  fedCh_t fedCh() const { return fedch_; }
41 
42  private:
47  };
48  using DetToFeds = std::vector<DetToFed>;
49 
50  static constexpr std::uint16_t badBit = 1 << 15;
51 
52  class Data {
53  public:
54  struct DeviceView {
55  __device__ inline detId_t detID(fedId_t fed, fedCh_t channel) const {
56  return detID_[channelIndex(fed, channel)];
57  }
58 
59  __device__ inline apvPair_t iPair(fedId_t fed, fedCh_t channel) const {
60  return iPair_[channelIndex(fed, channel)];
61  }
62 
63  __device__ inline float invthick(fedId_t fed, fedCh_t channel) const {
64  return invthick_[channelIndex(fed, channel)];
65  }
66 
67  __device__ inline float noise(fedId_t fed, fedCh_t channel, stripId_t strip) const {
68  // noise is stored as 9 bits with a fixed point scale factor of 0.1
69  return 0.1f * (noise_[stripIndex(fed, channel, strip)] & ~badBit);
70  }
71 
72  __device__ inline float gain(fedId_t fed, fedCh_t channel, stripId_t strip) const {
73  return gain_[apvIndex(fed, channel, strip)];
74  }
75 
76  __device__ inline bool bad(fedId_t fed, fedCh_t channel, stripId_t strip) const {
77  return badBit == (noise_[stripIndex(fed, channel, strip)] & badBit);
78  }
79  const std::uint16_t* noise_; //[sistrip::NUMBER_OF_FEDS*sistrip::FEDCH_PER_FED * sistrip::STRIPS_PER_FEDCH];
80  const float* invthick_; //[sistrip::NUMBER_OF_FEDS*sistrip::FEDCH_PER_FED];
81  const detId_t* detID_; //[sistrip::NUMBER_OF_FEDS*sistrip::FEDCH_PER_FED];
82  const apvPair_t* iPair_; //[sistrip::NUMBER_OF_FEDS*sistrip::FEDCH_PER_FED];
83  const float* gain_; //[sistrip::NUMBER_OF_FEDS*sistrip::APVS_PER_FEDCH * sistrip::FEDCH_PER_FED];
84  };
85 
86  const DeviceView* deviceView() const { return deviceView_.get(); }
87 
90 
92  noise_; //[sistrip::NUMBER_OF_FEDS*sistrip::FEDCH_PER_FED * sistrip::STRIPS_PER_FEDCH];
93  cms::cuda::device::unique_ptr<float[]> invthick_; //[sistrip::NUMBER_OF_FEDS*sistrip::FEDCH_PER_FED];
94  cms::cuda::device::unique_ptr<detId_t[]> detID_; //[sistrip::NUMBER_OF_FEDS*sistrip::FEDCH_PER_FED];
95  cms::cuda::device::unique_ptr<apvPair_t[]> iPair_; //[sistrip::NUMBER_OF_FEDS*sistrip::FEDCH_PER_FED];
97  gain_; //[sistrip::NUMBER_OF_FEDS*sistrip::APVS_PER_FEDCH * sistrip::FEDCH_PER_FED];
98  };
99 
101  const SiStripGain* gains,
102  const SiStripNoises& noises);
104 
105  // Function to return the actual payload on the memory of the current device
106  Data const& getGPUProductAsync(cudaStream_t stream) const;
107 
108  const DetToFeds& detToFeds() const { return detToFeds_; }
109 
110  private:
111  void setStrip(fedId_t fed, fedCh_t channel, stripId_t strip, std::uint16_t noise, float gain, bool bad) {
112  gain_[apvIndex(fed, channel, strip)] = gain;
113  noise_[stripIndex(fed, channel, strip)] = noise;
114  if (bad) {
115  noise_[stripIndex(fed, channel, strip)] |= badBit;
116  }
117  }
118 
119  void setInvThickness(fedId_t fed, fedCh_t channel, float invthick) {
120  invthick_[channelIndex(fed, channel)] = invthick;
121  }
122 
123  // Holds the data in pinned CPU memory
124  std::vector<std::uint16_t, cms::cuda::HostAllocator<std::uint16_t>> noise_;
125  std::vector<float, cms::cuda::HostAllocator<float>> invthick_;
126  std::vector<detId_t, cms::cuda::HostAllocator<detId_t>> detID_;
127  std::vector<apvPair_t, cms::cuda::HostAllocator<apvPair_t>> iPair_;
128  std::vector<float, cms::cuda::HostAllocator<float>> gain_;
129 
130  // Helper that takes care of complexity of transferring the data to
131  // multiple devices
134  };
135 } // namespace stripgpu
136 
137 #endif
std::uint16_t apvPair_t
Definition: SiStripTypes.h:11
std::uint32_t detId_t
Definition: SiStripTypes.h:8
static const uint16_t FED_ID_MIN
cms::cuda::device::unique_ptr< std::uint16_t[]> noise_
cms::cuda::host::unique_ptr< DeviceView > hostView_
std::vector< std::uint16_t, cms::cuda::HostAllocator< std::uint16_t > > noise_
#define __host__
Data const & getGPUProductAsync(cudaStream_t stream) const
__host__ __device__ std::uint32_t channelIndex(fedId_t fed, fedCh_t channel)
std::vector< detId_t, cms::cuda::HostAllocator< detId_t > > detID_
__device__ detId_t detID(fedId_t fed, fedCh_t channel) const
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
string quality
__host__ __device__ std::uint32_t stripIndex(fedId_t fed, fedCh_t channel, stripId_t strip)
__device__ float noise(fedId_t fed, fedCh_t channel, stripId_t strip) const
__device__ bool bad(fedId_t fed, fedCh_t channel, stripId_t strip) const
cms::cuda::device::unique_ptr< apvPair_t[]> iPair_
void setInvThickness(fedId_t fed, fedCh_t channel, float invthick)
void setStrip(fedId_t fed, fedCh_t channel, stripId_t strip, std::uint16_t noise, float gain, bool bad)
constexpr float gains[NGAINS]
Definition: EcalConstants.h:11
static const uint16_t STRIPS_PER_FEDCH
__device__ apvPair_t iPair(fedId_t fed, fedCh_t channel) const
__device__ float invthick(fedId_t fed, fedCh_t channel) const
Constants and enumerated types for FED/FEC systems.
cms::cuda::device::unique_ptr< DeviceView > deviceView_
DetToFed(detId_t detid, apvPair_t ipair, fedId_t fedid, fedCh_t fedch)
std::vector< apvPair_t, cms::cuda::HostAllocator< apvPair_t > > iPair_
static const uint16_t APVS_PER_CHAN
static const uint16_t FEDCH_PER_FED
static const uint16_t STRIPS_PER_APV
__host__ __device__ std::uint32_t apvIndex(fedId_t fed, fedCh_t channel, stripId_t strip)
SiStripClusterizerConditionsGPU(const SiStripQuality &quality, const SiStripGain *gains, const SiStripNoises &noises)
std::unique_ptr< T, impl::HostDeleter > unique_ptr
std::vector< float, cms::cuda::HostAllocator< float > > gain_
std::uint8_t fedCh_t
Definition: SiStripTypes.h:10
std::uint16_t fedId_t
Definition: SiStripTypes.h:9
static const uint16_t APVS_PER_FEDCH
#define __device__
std::vector< float, cms::cuda::HostAllocator< float > > invthick_
__host__ __device__ fedId_t fedIndex(fedId_t fed)
__device__ float gain(fedId_t fed, fedCh_t channel, stripId_t strip) const
std::uint16_t stripId_t
Definition: SiStripTypes.h:12