CMS 3D CMS Logo

ChannelLocsGPU.h
Go to the documentation of this file.
1 #ifndef RecoLocalTracker_SiStripClusterizer_plugins_ChannelLocsGPU_h
2 #define RecoLocalTracker_SiStripClusterizer_plugins_ChannelLocsGPU_h
3 
4 #include <memory>
5 #include <vector>
6 
7 #include <cuda_runtime.h>
8 
12 
13 class ChannelLocsGPU;
14 
15 template <template <typename> class T>
17 public:
19  virtual ~ChannelLocsBase() = default;
20 
22  : input_(std::move(arg.input_)),
29  size_(arg.size_) {}
30 
31  void setChannelLoc(uint32_t index,
32  const uint8_t* input,
33  size_t inoff,
34  size_t offset,
35  uint16_t length,
39  input_[index] = input;
40  inoff_[index] = inoff;
41  offset_[index] = offset;
42  length_[index] = length;
43  fedID_[index] = fedID;
44  fedCh_[index] = fedCh;
45  detID_[index] = detID;
46  }
47 
48  size_t size() const { return size_; }
49 
50  const uint8_t* input(uint32_t index) const { return input_[index]; }
51  size_t inoff(uint32_t index) const { return inoff_[index]; }
52  size_t offset(uint32_t index) const { return offset_[index]; }
53  uint16_t length(uint32_t index) const { return length_[index]; }
54  stripgpu::fedId_t fedID(uint32_t index) const { return fedID_[index]; }
55  stripgpu::fedCh_t fedCh(uint32_t index) const { return fedCh_[index]; }
56  stripgpu::detId_t detID(uint32_t index) const { return detID_[index]; }
57 
58  const uint8_t* const* input() const { return input_.get(); }
59  size_t* inoff() const { return inoff_.get(); }
60  size_t* offset() const { return offset_.get(); }
61  uint16_t* length() const { return length_.get(); }
62  stripgpu::fedId_t* fedID() const { return fedID_.get(); }
63  stripgpu::fedCh_t* fedCh() const { return fedCh_.get(); }
64  stripgpu::detId_t* detID() const { return detID_.get(); }
65 
66 protected:
67  T<const uint8_t*[]> input_; // input raw data for channel
68  T<size_t[]> inoff_; // offset in input raw data
69  T<size_t[]> offset_; // global offset in alldata
70  T<uint16_t[]> length_; // length of channel data
74  size_t size_ = 0;
75 };
76 
77 class ChannelLocs : public ChannelLocsBase<cms::cuda::host::unique_ptr> {
78  friend class ChannelLocsGPU;
79 
80 public:
81  ChannelLocs(size_t size, cudaStream_t stream);
83 
84  ChannelLocs(ChannelLocs&) = delete;
85  ChannelLocs(const ChannelLocs&) = delete;
86  ChannelLocs& operator=(const ChannelLocs&) = delete;
87  ChannelLocs& operator=(ChannelLocs&&) = delete;
88 
89  ~ChannelLocs() override = default;
90 };
91 
93 public:
94  void fill(const ChannelLocsGPU& c);
95 
96  __device__ size_t size() const { return size_; }
97 
98  __device__ const uint8_t* input(uint32_t index) const { return input_[index]; }
99  __device__ size_t inoff(uint32_t index) const { return inoff_[index]; }
100  __device__ size_t offset(uint32_t index) const { return offset_[index]; }
101  __device__ uint16_t length(uint32_t index) const { return length_[index]; }
102  __device__ stripgpu::fedId_t fedID(uint32_t index) const { return fedID_[index]; }
103  __device__ stripgpu::fedCh_t fedCh(uint32_t index) const { return fedCh_[index]; }
104  __device__ stripgpu::detId_t detID(uint32_t index) const { return detID_[index]; }
105 
106 private:
107  const uint8_t* const* input_; // input raw data for channel
108  size_t* inoff_; // offset in input raw data
109  size_t* offset_; // global offset in alldata
110  uint16_t* length_; // length of channel data
114  size_t size_;
115 };
116 
117 class ChannelLocsGPU : public ChannelLocsBase<cms::cuda::device::unique_ptr> {
118 public:
119  //using Base = ChannelLocsBase<cms::cuda::device::unique_ptr>;
120  ChannelLocsGPU(size_t size, cudaStream_t stream);
123 
124  ChannelLocsGPU(ChannelLocsGPU&) = delete;
125  ChannelLocsGPU(const ChannelLocsGPU&) = delete;
126  ChannelLocsGPU& operator=(const ChannelLocsGPU&) = delete;
128 
129  ~ChannelLocsGPU() override = default;
130 
131  void setVals(const ChannelLocs* c, cms::cuda::host::unique_ptr<const uint8_t*[]> inputGPU, cudaStream_t stream);
132  const ChannelLocsView* channelLocsView() const { return channelLocsViewGPU_.get(); }
133 
134 private:
136 };
137 
138 #endif
std::uint32_t detId_t
Definition: SiStripTypes.h:8
stripgpu::detId_t * detID_
stripgpu::fedCh_t * fedCh_
virtual ~ChannelLocsBase()=default
__device__ size_t offset(uint32_t index) const
stripgpu::fedId_t * fedID_
T< stripgpu::fedId_t[]> fedID_
const ChannelLocsView * channelLocsView() const
const uint8_t * input(uint32_t index) const
uint16_t * length() const
const uint8_t *const * input_
stripgpu::fedCh_t fedCh(uint32_t index) const
ChannelLocsBase(ChannelLocsBase &&arg)
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
void setVals(const ChannelLocs *c, cms::cuda::host::unique_ptr< const uint8_t *[]> inputGPU, cudaStream_t stream)
A arg
Definition: Factorize.h:31
__device__ size_t inoff(uint32_t index) const
size_t * offset() const
T< size_t[]> inoff_
T< stripgpu::fedCh_t[]> fedCh_
ChannelLocsGPU & operator=(const ChannelLocsGPU &)=delete
T< const uint8_t *[]> input_
const uint8_t *const * input() const
~ChannelLocsGPU() override=default
__device__ uint16_t length(uint32_t index) const
ChannelLocsGPU(ChannelLocsGPU &&arg)
__device__ size_t size() const
ChannelLocsGPU(size_t size, cudaStream_t stream)
ChannelLocs(ChannelLocs &&arg)
ChannelLocsBase(size_t size)
cms::cuda::device::unique_ptr< ChannelLocsView > channelLocsViewGPU_
void setChannelLoc(uint32_t index, const uint8_t *input, size_t inoff, size_t offset, uint16_t length, stripgpu::fedId_t fedID, stripgpu::fedCh_t fedCh, stripgpu::detId_t detID)
void fill(const ChannelLocsGPU &c)
size_t offset(uint32_t index) const
__device__ stripgpu::detId_t detID(uint32_t index) const
uint16_t length(uint32_t index) const
stripgpu::fedId_t fedID(uint32_t index) const
stripgpu::detId_t * detID() const
stripgpu::detId_t detID(uint32_t index) const
__device__ stripgpu::fedId_t fedID(uint32_t index) const
size_t inoff(uint32_t index) const
__device__ stripgpu::fedCh_t fedCh(uint32_t index) const
T< stripgpu::detId_t[]> detID_
size_t * inoff() const
std::unique_ptr< T, impl::HostDeleter > unique_ptr
T< uint16_t[]> length_
std::uint8_t fedCh_t
Definition: SiStripTypes.h:10
stripgpu::fedId_t * fedID() const
~ChannelLocs() override=default
ChannelLocs & operator=(const ChannelLocs &)=delete
stripgpu::fedCh_t * fedCh() const
uint16_t * length_
std::uint16_t fedId_t
Definition: SiStripTypes.h:9
__device__ const uint8_t * input(uint32_t index) const
long double T
T< size_t[]> offset_
#define __device__
def move(src, dest)
Definition: eostools.py:511
ChannelLocs(size_t size, cudaStream_t stream)
size_t size() const