CMS 3D CMS Logo

HGCUncalibRecHitHost.h
Go to the documentation of this file.
1 #ifndef CUDADAtaFormats_HGCal_HGCUncalibRecHitHost_H
2 #define CUDADAtaFormats_HGCal_HGCUncalibRecHitHost_H
3 
4 #include <cassert>
5 #include <numeric>
6 
10 
11 template <class T>
13 public:
14  HGCUncalibRecHitHost() = default;
15  explicit HGCUncalibRecHitHost(uint32_t nhits, const T &hits, 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  ptr_ = cms::cuda::make_host_unique<std::byte[]>(pad_ * size_tot_, stream);
19 
21  fillSoA_(hits);
22  }
23  ~HGCUncalibRecHitHost() = default;
24 
29 
31  soa_.amplitude_ = reinterpret_cast<float *>(ptr_.get());
37  soa_.flags_ = reinterpret_cast<uint32_t *>(soa_.OOTchi2_ + pad_);
38  soa_.aux_ = soa_.flags_ + pad_;
39  soa_.id_ = soa_.aux_ + pad_;
40  soa_.aux_ = soa_.flags_ + pad_;
41  soa_.id_ = soa_.aux_ + pad_;
42 
44  soa_.nhits_ = nhits_;
45  soa_.pad_ = pad_;
46  }
47 
48  void fillSoA_(const T &c) {
49  for (unsigned i(0); i < nhits_; ++i) {
50  soa_.amplitude_[i] = c[i].amplitude();
51  soa_.pedestal_[i] = c[i].pedestal();
52  soa_.jitter_[i] = c[i].jitter();
53  soa_.chi2_[i] = c[i].chi2();
54  soa_.OOTamplitude_[i] = c[i].outOfTimeEnergy();
55  soa_.OOTchi2_[i] = c[i].outOfTimeChi2();
56  soa_.flags_[i] = c[i].flags();
57  soa_.aux_[i] = 0;
58  soa_.id_[i] = c[i].id().rawId();
59  }
60  }
61 
62  HGCUncalibRecHitSoA get() const { return soa_; }
63  uint32_t nHits() const { return nhits_; }
64  uint32_t pad() const { return pad_; }
65  uint32_t nBytes() const { return size_tot_; }
66 
67 private:
70  static constexpr std::array<int, memory::npointers::ntypes_hgcuncalibrechits_soa> sizes_ = {
73  uint32_t size_tot_;
74  uint32_t pad_;
75  uint32_t nhits_;
76 };
77 
78 #endif //CUDADAtaFormats_HGCal_HGCUncalibRecHitHost_H
HGCUncalibRecHitSoA soa_
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
constexpr unsigned uint32_hgcuncalibrechits_soa
~HGCUncalibRecHitHost()=default
void fillSoA_(const T &c)
std::uint32_t * flags_
HGCUncalibRecHitHost & operator=(const HGCUncalibRecHitHost &)=delete
static constexpr std::array< int, memory::npointers::ntypes_hgcuncalibrechits_soa > sizes_
cms::cuda::host::unique_ptr< std::byte[]> ptr_
std::unique_ptr< T, impl::HostDeleter > unique_ptr
HGCUncalibRecHitHost(uint32_t nhits, const T &hits, const cudaStream_t &stream)
HGCUncalibRecHitHost()=default
constexpr unsigned float_hgcuncalibrechits_soa
long double T