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
HGCUncalibRecHitHost
Definition: HGCUncalibRecHitHost.h:12
HGCUncalibRecHitHost::nhits_
uint32_t nhits_
Definition: HGCUncalibRecHitHost.h:75
HGCUncalibRecHitHost::operator=
HGCUncalibRecHitHost & operator=(const HGCUncalibRecHitHost &)=delete
mps_fire.i
i
Definition: mps_fire.py:428
HGCUncalibRecHitSoA::jitter_
float * jitter_
Definition: HGCUncalibRecHitSoA.h:10
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
HGCUncalibRecHitSoA::pad_
std::uint32_t pad_
Definition: HGCUncalibRecHitSoA.h:21
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
HGCUncalibRecHitSoA::amplitude_
float * amplitude_
Definition: HGCUncalibRecHitSoA.h:8
HGCUncalibRecHitHost::ptr_
cms::cuda::host::unique_ptr< std::byte[]> ptr_
Definition: HGCUncalibRecHitHost.h:68
memory::npointers::uint32_hgcuncalibrechits_soa
constexpr unsigned uint32_hgcuncalibrechits_soa
Definition: HGCUncalibRecHitSoA.h:27
HGCUncalibRecHitSoA::nhits_
std::uint32_t nhits_
Definition: HGCUncalibRecHitSoA.h:20
HGCUncalibRecHitHost::HGCUncalibRecHitHost
HGCUncalibRecHitHost()=default
HGCUncalibRecHitSoA::pedestal_
float * pedestal_
Definition: HGCUncalibRecHitSoA.h:9
memory::npointers::float_hgcuncalibrechits_soa
constexpr unsigned float_hgcuncalibrechits_soa
Definition: HGCUncalibRecHitSoA.h:26
cms::cuda::stream
uint32_t const T *__restrict__ const uint32_t *__restrict__ int32_t int Histo::index_type cudaStream_t stream
Definition: HistoContainer.h:51
HGCUncalibRecHitHost::size_tot_
uint32_t size_tot_
Definition: HGCUncalibRecHitHost.h:73
HGCUncalibRecHitSoA::aux_
std::uint32_t * aux_
Definition: HGCUncalibRecHitSoA.h:16
HGCUncalibRecHitHost::pad
uint32_t pad() const
Definition: HGCUncalibRecHitHost.h:64
HGCUncalibRecHitSoA::chi2_
float * chi2_
Definition: HGCUncalibRecHitSoA.h:11
HGCUncalibRecHitSoA::id_
std::uint32_t * id_
Definition: HGCUncalibRecHitSoA.h:17
host_unique_ptr.h
HGCUncalibRecHitSoA
Definition: HGCUncalibRecHitSoA.h:6
HGCUncalibRecHitHost::nHits
uint32_t nHits() const
Definition: HGCUncalibRecHitHost.h:63
nhits
Definition: HIMultiTrackSelector.h:42
HGCUncalibRecHitHost::pad_
uint32_t pad_
Definition: HGCUncalibRecHitHost.h:74
HGCUncalibRecHitHost::nBytes
uint32_t nBytes() const
Definition: HGCUncalibRecHitHost.h:65
HGCRecHitSoA.h
HGCUncalibRecHitSoA.h
HGCUncalibRecHitSoA::nbytes_
std::uint32_t nbytes_
Definition: HGCUncalibRecHitSoA.h:19
HGCUncalibRecHitHost::~HGCUncalibRecHitHost
~HGCUncalibRecHitHost()=default
HGCUncalibRecHitSoA::OOTchi2_
float * OOTchi2_
Definition: HGCUncalibRecHitSoA.h:13
HGCUncalibRecHitHost::get
HGCUncalibRecHitSoA get() const
Definition: HGCUncalibRecHitHost.h:62
HGCUncalibRecHitSoA::flags_
std::uint32_t * flags_
Definition: HGCUncalibRecHitSoA.h:15
HGCUncalibRecHitHost::HGCUncalibRecHitHost
HGCUncalibRecHitHost(uint32_t nhits, const T &hits, const cudaStream_t &stream)
Definition: HGCUncalibRecHitHost.h:15
HGCUncalibRecHitSoA::OOTamplitude_
float * OOTamplitude_
Definition: HGCUncalibRecHitSoA.h:12
T
long double T
Definition: Basic3DVectorLD.h:48
cms::cuda::host::unique_ptr
std::unique_ptr< T, impl::HostDeleter > unique_ptr
Definition: host_unique_ptr.h:21
HGCUncalibRecHitHost::sizes_
static constexpr std::array< int, memory::npointers::ntypes_hgcuncalibrechits_soa > sizes_
Definition: HGCUncalibRecHitHost.h:70
HGCUncalibRecHitHost::fillSoA_
void fillSoA_(const T &c)
Definition: HGCUncalibRecHitHost.h:48
HGCUncalibRecHitHost::soa_
HGCUncalibRecHitSoA soa_
Definition: HGCUncalibRecHitHost.h:69
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
HGCUncalibRecHitHost::defineSoAMemoryLayout_
void defineSoAMemoryLayout_()
Definition: HGCUncalibRecHitHost.h:30