CMS 3D CMS Logo

HGCRecHitGPUProduct.h
Go to the documentation of this file.
1 #ifndef CUDADAtaFormats_HGCal_HGCRecHitGPUProduct_H
2 #define CUDADAtaFormats_HGCal_HGCRecHitGPUProduct_H
3 
4 #include <cassert>
5 #include <numeric>
6 
11 
13 public:
14  HGCRecHitGPUProduct() = default;
15  explicit HGCRecHitGPUProduct(uint32_t nhits, const cudaStream_t &stream) : nhits_(nhits) {
16  size_tot_ = std::accumulate(sizes_.begin(), sizes_.end(), 0); //this might be done at compile time
17  pad_ = ((nhits - 1) / 32 + 1) * 32; //align to warp boundary (assumption: warpSize = 32)
18  mem_ = cms::cuda::make_device_unique<std::byte[]>(pad_ * size_tot_, stream);
19  }
20  ~HGCRecHitGPUProduct() = default;
21 
22  HGCRecHitGPUProduct(const HGCRecHitGPUProduct &) = delete;
26 
29  soa.energy_ = reinterpret_cast<float *>(mem_.get());
30  soa.time_ = soa.energy_ + pad_;
31  soa.timeError_ = soa.time_ + pad_;
32  soa.id_ = reinterpret_cast<uint32_t *>(soa.timeError_ + pad_);
33  soa.flagBits_ = soa.id_ + pad_;
34  soa.son_ = reinterpret_cast<uint8_t *>(soa.flagBits_ + pad_);
35  soa.nbytes_ = size_tot_;
36  soa.nhits_ = nhits_;
37  soa.pad_ = pad_;
38  return soa;
39  }
42  soa.energy_ = reinterpret_cast<float const *>(mem_.get());
43  soa.time_ = soa.energy_ + pad_;
44  soa.timeError_ = soa.time_ + pad_;
45  soa.id_ = reinterpret_cast<uint32_t const *>(soa.timeError_ + pad_);
46  soa.flagBits_ = soa.id_ + pad_;
47  soa.son_ = reinterpret_cast<uint8_t const *>(soa.flagBits_ + pad_);
48  return soa;
49  }
50 
51  //number of hits stored in the SoA
52  uint32_t nHits() const { return nhits_; }
53  //pad of memory block (used for warp alignment, slighlty larger than 'nhits_')
54  uint32_t pad() const { return pad_; }
55  //number of bytes of the SoA
56  uint32_t nBytes() const { return size_tot_; }
57 
58 private:
60  static constexpr std::array<int, memory::npointers::ntypes_hgcrechits_soa> sizes_ = {
63  memory::npointers::uint8_hgcrechits_soa * sizeof(uint8_t)}};
64  uint32_t pad_;
65  uint32_t nhits_;
66  uint32_t size_tot_;
67 };
68 
69 #endif //CUDADAtaFormats_HGCal_HGCRecHitGPUProduct_H
ConstHGCRecHitSoA.h
HGCRecHitGPUProduct::size_tot_
uint32_t size_tot_
Definition: HGCRecHitGPUProduct.h:66
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
cms::cuda::stream
cudaStream_t stream
Definition: HistoContainer.h:57
HGCRecHitGPUProduct::operator=
HGCRecHitGPUProduct & operator=(const HGCRecHitGPUProduct &)=delete
gpuVertexFinder::soa
ZVertexSoA * soa
Definition: gpuVertexFinderImpl.h:24
HGCRecHitGPUProduct
Definition: HGCRecHitGPUProduct.h:12
device_unique_ptr.h
HGCRecHitGPUProduct::pad_
uint32_t pad_
Definition: HGCRecHitGPUProduct.h:64
HGCRecHitGPUProduct::mem_
cms::cuda::device::unique_ptr< std::byte[]> mem_
Definition: HGCRecHitGPUProduct.h:59
HGCRecHitGPUProduct::nhits_
uint32_t nhits_
Definition: HGCRecHitGPUProduct.h:65
HGCRecHitGPUProduct::HGCRecHitGPUProduct
HGCRecHitGPUProduct(uint32_t nhits, const cudaStream_t &stream)
Definition: HGCRecHitGPUProduct.h:15
nhits
Definition: HIMultiTrackSelector.h:42
HGCRecHitSoA
Definition: HGCRecHitSoA.h:6
HGCRecHitSoA.h
HGCRecHitGPUProduct::pad
uint32_t pad() const
Definition: HGCRecHitGPUProduct.h:54
HGCUncalibRecHitSoA.h
HGCRecHitGPUProduct::~HGCRecHitGPUProduct
~HGCRecHitGPUProduct()=default
HGCRecHitGPUProduct::nHits
uint32_t nHits() const
Definition: HGCRecHitGPUProduct.h:52
memory::npointers::uint32_hgcrechits_soa
constexpr unsigned uint32_hgcrechits_soa
Definition: HGCRecHitSoA.h:23
HGCRecHitGPUProduct::get
HGCRecHitSoA get()
Definition: HGCRecHitGPUProduct.h:27
cms::cuda::device::unique_ptr
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
Definition: device_unique_ptr.h:33
HGCRecHitGPUProduct::get
ConstHGCRecHitSoA get() const
Definition: HGCRecHitGPUProduct.h:40
ConstHGCRecHitSoA
Definition: ConstHGCRecHitSoA.h:6
HGCRecHitGPUProduct::nBytes
uint32_t nBytes() const
Definition: HGCRecHitGPUProduct.h:56
HGCRecHitGPUProduct::HGCRecHitGPUProduct
HGCRecHitGPUProduct()=default
memory::npointers::uint8_hgcrechits_soa
constexpr unsigned uint8_hgcrechits_soa
Definition: HGCRecHitSoA.h:24
HGCRecHitGPUProduct::sizes_
static constexpr std::array< int, memory::npointers::ntypes_hgcrechits_soa > sizes_
Definition: HGCRecHitGPUProduct.h:60
memory::npointers::float_hgcrechits_soa
constexpr unsigned float_hgcrechits_soa
Definition: HGCRecHitSoA.h:22