CMS 3D CMS Logo

SiPixelDigisCUDA.h
Go to the documentation of this file.
1 #ifndef CUDADataFormats_SiPixelDigi_interface_SiPixelDigisCUDA_h
2 #define CUDADataFormats_SiPixelDigi_interface_SiPixelDigisCUDA_h
3 
4 #include <cuda_runtime.h>
5 
9 
11 public:
12  SiPixelDigisCUDA() = default;
13  explicit SiPixelDigisCUDA(size_t maxFedWords, cudaStream_t stream);
14  ~SiPixelDigisCUDA() = default;
15 
16  SiPixelDigisCUDA(const SiPixelDigisCUDA &) = delete;
17  SiPixelDigisCUDA &operator=(const SiPixelDigisCUDA &) = delete;
18  SiPixelDigisCUDA(SiPixelDigisCUDA &&) = default;
20 
21  void setNModulesDigis(uint32_t nModules, uint32_t nDigis) {
23  nDigis_h = nDigis;
24  }
25 
26  uint32_t nModules() const { return nModules_h; }
27  uint32_t nDigis() const { return nDigis_h; }
28 
29  uint16_t *xx() { return xx_d.get(); }
30  uint16_t *yy() { return yy_d.get(); }
31  uint16_t *adc() { return adc_d.get(); }
32  uint16_t *moduleInd() { return moduleInd_d.get(); }
33  int32_t *clus() { return clus_d.get(); }
34  uint32_t *pdigi() { return pdigi_d.get(); }
35  uint32_t *rawIdArr() { return rawIdArr_d.get(); }
36 
37  uint16_t const *xx() const { return xx_d.get(); }
38  uint16_t const *yy() const { return yy_d.get(); }
39  uint16_t const *adc() const { return adc_d.get(); }
40  uint16_t const *moduleInd() const { return moduleInd_d.get(); }
41  int32_t const *clus() const { return clus_d.get(); }
42  uint32_t const *pdigi() const { return pdigi_d.get(); }
43  uint32_t const *rawIdArr() const { return rawIdArr_d.get(); }
44 
49 
51  public:
52  __device__ __forceinline__ uint16_t xx(int i) const { return __ldg(xx_ + i); }
53  __device__ __forceinline__ uint16_t yy(int i) const { return __ldg(yy_ + i); }
54  __device__ __forceinline__ uint16_t adc(int i) const { return __ldg(adc_ + i); }
55  __device__ __forceinline__ uint16_t moduleInd(int i) const { return __ldg(moduleInd_ + i); }
56  __device__ __forceinline__ int32_t clus(int i) const { return __ldg(clus_ + i); }
57 
58  uint16_t const *xx_;
59  uint16_t const *yy_;
60  uint16_t const *adc_;
61  uint16_t const *moduleInd_;
62  int32_t const *clus_;
63  };
64 
65  const DeviceConstView *view() const { return view_d.get(); }
66 
67 private:
68  // These are consumed by downstream device code
69  cms::cuda::device::unique_ptr<uint16_t[]> xx_d; // local coordinates of each pixel
73  cms::cuda::device::unique_ptr<int32_t[]> clus_d; // cluster id of each pixel
75 
76  // These are for CPU output; should we (eventually) place them to a
77  // separate product?
78  cms::cuda::device::unique_ptr<uint32_t[]> pdigi_d; // packed digi (row, col, adc) of each pixel
80 
81  uint32_t nModules_h = 0;
82  uint32_t nDigis_h = 0;
83 };
84 
85 #endif // CUDADataFormats_SiPixelDigi_interface_SiPixelDigisCUDA_h
SiPixelDigisCUDA::moduleInd
uint16_t * moduleInd()
Definition: SiPixelDigisCUDA.h:32
SiPixelDigisCUDA::xx
uint16_t * xx()
Definition: SiPixelDigisCUDA.h:29
mps_fire.i
i
Definition: mps_fire.py:428
SiPixelDigisCUDA::rawIdArr_d
cms::cuda::device::unique_ptr< uint32_t[]> rawIdArr_d
Definition: SiPixelDigisCUDA.h:79
SiPixelDigisCUDA::adc_d
cms::cuda::device::unique_ptr< uint16_t[]> adc_d
Definition: SiPixelDigisCUDA.h:71
SiPixelDigisCUDA::SiPixelDigisCUDA
SiPixelDigisCUDA()=default
SiPixelDigisCUDA::DeviceConstView
Definition: SiPixelDigisCUDA.h:50
cms::cuda::stream
cudaStream_t stream
Definition: HistoContainer.h:57
SiPixelDigisCUDA::xx
const uint16_t * xx() const
Definition: SiPixelDigisCUDA.h:37
SiPixelDigisCUDA::nModules_h
uint32_t nModules_h
Definition: SiPixelDigisCUDA.h:81
SiPixelDigisCUDA::setNModulesDigis
void setNModulesDigis(uint32_t nModules, uint32_t nDigis)
Definition: SiPixelDigisCUDA.h:21
SiPixelDigisCUDA::pdigiToHostAsync
cms::cuda::host::unique_ptr< uint32_t[]> pdigiToHostAsync(cudaStream_t stream) const
Definition: SiPixelDigisCUDA.cc:36
SiPixelDigisCUDA::operator=
SiPixelDigisCUDA & operator=(const SiPixelDigisCUDA &)=delete
device_unique_ptr.h
SiPixelDigisCUDA::yy
uint16_t * yy()
Definition: SiPixelDigisCUDA.h:30
SiPixelDigisCUDA::nDigis_h
uint32_t nDigis_h
Definition: SiPixelDigisCUDA.h:82
SiPixelDigisCUDA::pdigi_d
cms::cuda::device::unique_ptr< uint32_t[]> pdigi_d
Definition: SiPixelDigisCUDA.h:78
SiPixelDigisCUDA::view_d
cms::cuda::device::unique_ptr< DeviceConstView > view_d
Definition: SiPixelDigisCUDA.h:74
host_unique_ptr.h
SiPixelDigisCUDA::yy
const uint16_t * yy() const
Definition: SiPixelDigisCUDA.h:38
SiPixelDigisCUDA::DeviceConstView::xx_
const uint16_t * xx_
Definition: SiPixelDigisCUDA.h:58
SiPixelDigisCUDA::adcToHostAsync
cms::cuda::host::unique_ptr< uint16_t[]> adcToHostAsync(cudaStream_t stream) const
Definition: SiPixelDigisCUDA.cc:24
SiPixelDigisCUDA
Definition: SiPixelDigisCUDA.h:10
SiPixelDigisCUDA::nDigis
uint32_t nDigis() const
Definition: SiPixelDigisCUDA.h:27
SiPixelDigisCUDA::adc
const uint16_t * adc() const
Definition: SiPixelDigisCUDA.h:39
SiPixelDigisCUDA::moduleInd
const uint16_t * moduleInd() const
Definition: SiPixelDigisCUDA.h:40
SiPixelDigisCUDA::DeviceConstView::moduleInd_
const uint16_t * moduleInd_
Definition: SiPixelDigisCUDA.h:61
SiPixelDigisCUDA::pdigi
uint32_t * pdigi()
Definition: SiPixelDigisCUDA.h:34
SiPixelDigisCUDA::~SiPixelDigisCUDA
~SiPixelDigisCUDA()=default
SiPixelDigisCUDA::DeviceConstView::yy_
const uint16_t * yy_
Definition: SiPixelDigisCUDA.h:59
SiPixelDigisCUDA::moduleInd_d
cms::cuda::device::unique_ptr< uint16_t[]> moduleInd_d
Definition: SiPixelDigisCUDA.h:72
SiPixelDigisCUDA::rawIdArr
const uint32_t * rawIdArr() const
Definition: SiPixelDigisCUDA.h:43
SiPixelDigisCUDA::DeviceConstView::clus_
const int32_t * clus_
Definition: SiPixelDigisCUDA.h:62
SiPixelDigisCUDA::nModules
uint32_t nModules() const
Definition: SiPixelDigisCUDA.h:26
SiPixelDigisCUDA::clus
int32_t * clus()
Definition: SiPixelDigisCUDA.h:33
SiPixelDigisCUDA::yy_d
cms::cuda::device::unique_ptr< uint16_t[]> yy_d
Definition: SiPixelDigisCUDA.h:70
__device__
#define __device__
Definition: SiPixelGainForHLTonGPU.h:15
SiPixelDigisCUDA::xx_d
cms::cuda::device::unique_ptr< uint16_t[]> xx_d
Definition: SiPixelDigisCUDA.h:69
SiPixelDigisCUDA::adc
uint16_t * adc()
Definition: SiPixelDigisCUDA.h:31
SiPixelDigisCUDA::pdigi
const uint32_t * pdigi() const
Definition: SiPixelDigisCUDA.h:42
SiPixelDigisCUDA::clusToHostAsync
cms::cuda::host::unique_ptr< int32_t[]> clusToHostAsync(cudaStream_t stream) const
Definition: SiPixelDigisCUDA.cc:30
__forceinline__
#define __forceinline__
Definition: cudaCompat.h:22
cms::cuda::device::unique_ptr
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
Definition: device_unique_ptr.h:33
SiPixelDigisCUDA::clus_d
cms::cuda::device::unique_ptr< int32_t[]> clus_d
Definition: SiPixelDigisCUDA.h:73
SiPixelDigisCUDA::clus
const int32_t * clus() const
Definition: SiPixelDigisCUDA.h:41
SiPixelDigisCUDA::rawIdArr
uint32_t * rawIdArr()
Definition: SiPixelDigisCUDA.h:35
SiPixelDigisCUDA::view
const DeviceConstView * view() const
Definition: SiPixelDigisCUDA.h:65
SiPixelDigisCUDA::rawIdArrToHostAsync
cms::cuda::host::unique_ptr< uint32_t[]> rawIdArrToHostAsync(cudaStream_t stream) const
Definition: SiPixelDigisCUDA.cc:42
cms::cuda::host::unique_ptr
std::unique_ptr< T, impl::HostDeleter > unique_ptr
Definition: host_unique_ptr.h:21
cudaCompat.h
cms::cudacompat::__ldg
T __ldg(T const *x)
Definition: cudaCompat.h:82
SiPixelDigisCUDA::DeviceConstView::adc_
const uint16_t * adc_
Definition: SiPixelDigisCUDA.h:60