CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes
HcalDigisProducerGPU Class Reference
Inheritance diagram for HcalDigisProducerGPU:
edm::stream::EDProducer< edm::ExternalWork >

Classes

struct  ConfigParameters
 

Public Member Functions

 HcalDigisProducerGPU (edm::ParameterSet const &ps)
 
 ~HcalDigisProducerGPU () override=default
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::ExternalWork >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &)
 

Private Types

using DeviceCollectionf01 = hcal::DigiCollection< hcal::Flavor1, calo::common::DevStoragePolicy >
 
using DeviceCollectionf3 = hcal::DigiCollection< hcal::Flavor3, calo::common::DevStoragePolicy >
 
using DeviceCollectionf5 = hcal::DigiCollection< hcal::Flavor5, calo::common::DevStoragePolicy >
 
using HostCollectionf01 = hcal::DigiCollection< hcal::Flavor1, calo::common::VecStoragePolicy< calo::common::CUDAHostAllocatorAlias > >
 
using HostCollectionf3 = hcal::DigiCollection< hcal::Flavor3, calo::common::VecStoragePolicy< calo::common::CUDAHostAllocatorAlias > >
 
using HostCollectionf5 = hcal::DigiCollection< hcal::Flavor5, calo::common::VecStoragePolicy< calo::common::CUDAHostAllocatorAlias > >
 
using ProductTypef01 = cms::cuda::Product< DeviceCollectionf01 >
 
using ProductTypef3 = cms::cuda::Product< DeviceCollectionf3 >
 
using ProductTypef5 = cms::cuda::Product< DeviceCollectionf5 >
 

Private Member Functions

void acquire (edm::Event const &, edm::EventSetup const &, edm::WaitingTaskWithArenaHolder) override
 
void produce (edm::Event &, edm::EventSetup const &) override
 

Private Attributes

ConfigParameters config_
 
cms::cuda::ContextState cudaState_
 
DeviceCollectionf01 df01_
 
DeviceCollectionf3 df3_
 
DeviceCollectionf5 df5_
 
edm::EDPutTokenT< ProductTypef01digisF01HEToken_
 
edm::EDPutTokenT< ProductTypef3digisF3HBToken_
 
edm::EDPutTokenT< ProductTypef5digisF5HBToken_
 
edm::EDGetTokenT< HBHEDigiCollectionhbheDigiToken_
 
HostCollectionf01 hf01_
 
HostCollectionf3 hf3_
 
HostCollectionf5 hf5_
 
edm::EDGetTokenT< QIE11DigiCollectionqie11DigiToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer< edm::ExternalWork >
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 15 of file HcalDigisProducerGPU.cc.

Member Typedef Documentation

◆ DeviceCollectionf01

Definition at line 33 of file HcalDigisProducerGPU.cc.

◆ DeviceCollectionf3

Definition at line 39 of file HcalDigisProducerGPU.cc.

◆ DeviceCollectionf5

Definition at line 36 of file HcalDigisProducerGPU.cc.

◆ HostCollectionf01

Definition at line 32 of file HcalDigisProducerGPU.cc.

◆ HostCollectionf3

Definition at line 38 of file HcalDigisProducerGPU.cc.

◆ HostCollectionf5

Definition at line 35 of file HcalDigisProducerGPU.cc.

◆ ProductTypef01

Definition at line 42 of file HcalDigisProducerGPU.cc.

◆ ProductTypef3

Definition at line 46 of file HcalDigisProducerGPU.cc.

◆ ProductTypef5

Definition at line 44 of file HcalDigisProducerGPU.cc.

Constructor & Destructor Documentation

◆ HcalDigisProducerGPU()

HcalDigisProducerGPU::HcalDigisProducerGPU ( edm::ParameterSet const &  ps)
explicit

Definition at line 83 of file HcalDigisProducerGPU.cc.

References edm::ParameterSet::getParameter().

84  : hbheDigiToken_{consumes<HBHEDigiCollection>(ps.getParameter<edm::InputTag>("hbheDigisLabel"))},
85  qie11DigiToken_{consumes<QIE11DigiCollection>(ps.getParameter<edm::InputTag>("qie11DigiLabel"))},
86  digisF01HEToken_{produces<ProductTypef01>(ps.getParameter<std::string>("digisLabelF01HE"))},
87  digisF5HBToken_{produces<ProductTypef5>(ps.getParameter<std::string>("digisLabelF5HB"))},
88  digisF3HBToken_{produces<ProductTypef3>(ps.getParameter<std::string>("digisLabelF3HB"))} {
89  config_.maxChannelsF01HE = ps.getParameter<uint32_t>("maxChannelsF01HE");
90  config_.maxChannelsF5HB = ps.getParameter<uint32_t>("maxChannelsF5HB");
91  config_.maxChannelsF3HB = ps.getParameter<uint32_t>("maxChannelsF3HB");
92 
93  // this is a preallocation for the max statically known number of time samples
94  // actual stride/nsamples will be inferred from data
95  hf01_.stride = hcal::compute_stride<hcal::Flavor1>(QIE11DigiCollection::MAXSAMPLES);
96  hf5_.stride = hcal::compute_stride<hcal::Flavor5>(HBHEDataFrame::MAXSAMPLES);
97  hf3_.stride = hcal::compute_stride<hcal::Flavor3>(QIE11DigiCollection::MAXSAMPLES);
98 
99  // preallocate pinned host memory only if CUDA is available
101  if (cs and cs->enabled()) {
105  }
106 }
static const int MAXSAMPLES
Definition: HBHEDataFrame.h:95
edm::EDPutTokenT< ProductTypef01 > digisF01HEToken_
edm::EDPutTokenT< ProductTypef3 > digisF3HBToken_
edm::EDPutTokenT< ProductTypef5 > digisF5HBToken_
static const size_type MAXSAMPLES
edm::EDGetTokenT< HBHEDigiCollection > hbheDigiToken_
std::enable_if< std::is_same< T, ::calo::common::tags::Vec >::value, void >::type reserve(std::size_t size)
edm::EDGetTokenT< QIE11DigiCollection > qie11DigiToken_

◆ ~HcalDigisProducerGPU()

HcalDigisProducerGPU::~HcalDigisProducerGPU ( )
overridedefault

Member Function Documentation

◆ acquire()

void HcalDigisProducerGPU::acquire ( edm::Event const &  event,
edm::EventSetup const &  setup,
edm::WaitingTaskWithArenaHolder  holder 
)
overrideprivate

Definition at line 108 of file HcalDigisProducerGPU.cc.

References cms::cuda::assert(), hcal::DigiCollectionBase< StoragePolicy >::clear(), config_, cudaCheck, cudaState_, hcal::DigiCollectionBase< StoragePolicy >::data, mps_fire::dest, df01_, df3_, df5_, edm::SortedCollection< T, SORT >::empty(), edm::DataFrameContainer::empty(), photonIsolationHIProducer_cfi::hbhe, hbheDigiToken_, HcalBarrel, HcalEndcap, hcal::Flavor1::HEADER_WORDS, hcal::Flavor3::HEADER_WORDS, hcal::Flavor5::HEADER_WORDS, hf01_, hf3_, hf5_, mps_fire::i, hcal::DigiCollectionBase< StoragePolicy >::ids, HcalDigisProducerGPU::ConfigParameters::maxChannelsF01HE, HcalDigisProducerGPU::ConfigParameters::maxChannelsF3HB, HcalDigisProducerGPU::ConfigParameters::maxChannelsF5HB, eostools::move(), or, hcalTTPDigis_cfi::presamples, qie11DigiToken_, ecalGpuTask_cfi::sample, HcalDataFrameContainer< Digi >::samples(), edm::DataFrameContainer::size(), TrackRefitter_38T_cff::src, gpuPixelDoublets::stride, hcal::DigiCollectionBase< StoragePolicy >::stride, and relativeConstraints::value.

110  {
111  // raii
112  cms::cuda::ScopedContextAcquire ctx{event.streamID(), std::move(holder), cudaState_};
113 
114  // clear host buffers
115  hf01_.clear();
116  hf5_.clear();
117  hf3_.clear();
118 
119  // event data
122  event.getByToken(hbheDigiToken_, hbheDigis);
123  event.getByToken(qie11DigiToken_, qie11Digis);
124 
125  // init f5 collection
126  if (not hbheDigis->empty()) {
127  auto const nsamples = (*hbheDigis)[0].size();
128  auto const stride = hcal::compute_stride<hcal::Flavor5>(nsamples);
129  hf5_.stride = stride;
130 
131  // flavor5 get device blobs
132  df5_.stride = stride;
133  df5_.data = cms::cuda::make_device_unique<uint16_t[]>(config_.maxChannelsF5HB * stride, ctx.stream());
134  df5_.ids = cms::cuda::make_device_unique<uint32_t[]>(config_.maxChannelsF5HB, ctx.stream());
135  df5_.npresamples = cms::cuda::make_device_unique<uint8_t[]>(config_.maxChannelsF5HB, ctx.stream());
136  }
137 
138  if (not qie11Digis->empty()) {
139  auto const nsamples = qie11Digis->samples();
140  auto const stride01 = hcal::compute_stride<hcal::Flavor1>(nsamples);
141  auto const stride3 = hcal::compute_stride<hcal::Flavor3>(nsamples);
142 
143  hf01_.stride = stride01;
144  hf3_.stride = stride3;
145 
146  // flavor 0/1 get devie blobs
147  df01_.stride = stride01;
148  df01_.data = cms::cuda::make_device_unique<uint16_t[]>(config_.maxChannelsF01HE * stride01, ctx.stream());
149  df01_.ids = cms::cuda::make_device_unique<uint32_t[]>(config_.maxChannelsF01HE, ctx.stream());
150 
151  // flavor3 get device blobs
152  df3_.stride = stride3;
153  df3_.data = cms::cuda::make_device_unique<uint16_t[]>(config_.maxChannelsF3HB * stride3, ctx.stream());
154  df3_.ids = cms::cuda::make_device_unique<uint32_t[]>(config_.maxChannelsF3HB, ctx.stream());
155  }
156 
157  for (auto const& hbhe : *hbheDigis) {
158  auto const id = hbhe.id().rawId();
159  auto const presamples = hbhe.presamples();
160  hf5_.ids.push_back(id);
161  hf5_.npresamples.push_back(presamples);
162  auto const stride = hcal::compute_stride<hcal::Flavor5>(hbhe.size());
163  assert(stride == hf5_.stride && "strides must be the same for every single digi of the collection");
164  // simple for now...
165  static_assert(hcal::Flavor5::HEADER_WORDS == 1);
166  uint16_t header_word = (1 << 15) | (0x5 << 12) | (0 << 10) | ((hbhe.sample(0).capid() & 0x3) << 8);
167  hf5_.data.push_back(header_word);
168  for (unsigned int i = 0; i < stride - hcal::Flavor5::HEADER_WORDS; i++) {
169  uint16_t s0 = (0 << 7) | (static_cast<uint8_t>(hbhe.sample(2 * i).adc()) & 0x7f);
170  uint16_t s1 = (0 << 7) | (static_cast<uint8_t>(hbhe.sample(2 * i + 1).adc()) & 0x7f);
171  uint16_t sample = (s1 << 8) | s0;
172  hf5_.data.push_back(sample);
173  }
174  }
175 
176  for (unsigned int i = 0; i < qie11Digis->size(); i++) {
177  auto const& digi = QIE11DataFrame{(*qie11Digis)[i]};
178  assert(digi.samples() == qie11Digis->samples() && "collection nsamples must equal per digi samples");
179  if (digi.flavor() == 0 or digi.flavor() == 1) {
180  if (digi.detid().subdetId() != HcalEndcap)
181  continue;
182  auto const id = digi.detid().rawId();
183  hf01_.ids.push_back(id);
184  for (int hw = 0; hw < hcal::Flavor1::HEADER_WORDS; hw++)
185  hf01_.data.push_back((*qie11Digis)[i][hw]);
186  for (int sample = 0; sample < digi.samples(); sample++) {
187  hf01_.data.push_back((*qie11Digis)[i][hcal::Flavor1::HEADER_WORDS + sample]);
188  }
189  } else if (digi.flavor() == 3) {
190  if (digi.detid().subdetId() != HcalBarrel)
191  continue;
192  auto const id = digi.detid().rawId();
193  hf3_.ids.push_back(id);
194  for (int hw = 0; hw < hcal::Flavor3::HEADER_WORDS; hw++)
195  hf3_.data.push_back((*qie11Digis)[i][hw]);
196  for (int sample = 0; sample < digi.samples(); sample++) {
197  hf3_.data.push_back((*qie11Digis)[i][hcal::Flavor3::HEADER_WORDS + sample]);
198  }
199  }
200  }
201 
202  auto lambdaToTransfer = [&ctx](auto* dest, auto const& src) {
203  if (src.empty())
204  return;
205  using vector_type = typename std::remove_reference<decltype(src)>::type;
206  using type = typename vector_type::value_type;
207  using dest_data_type = typename std::remove_pointer<decltype(dest)>::type;
208  static_assert(std::is_same<dest_data_type, type>::value && "Dest and Src data typesdo not match");
209  cudaCheck(cudaMemcpyAsync(dest, src.data(), src.size() * sizeof(type), cudaMemcpyHostToDevice, ctx.stream()));
210  };
211 
212  lambdaToTransfer(df01_.data.get(), hf01_.data);
213  lambdaToTransfer(df01_.ids.get(), hf01_.ids);
214 
215  lambdaToTransfer(df5_.data.get(), hf5_.data);
216  lambdaToTransfer(df5_.ids.get(), hf5_.ids);
217  lambdaToTransfer(df5_.npresamples.get(), hf5_.npresamples);
218 
219  lambdaToTransfer(df3_.data.get(), hf3_.data);
220  lambdaToTransfer(df3_.ids.get(), hf3_.ids);
221 
222  df01_.size = hf01_.ids.size();
223  df5_.size = hf5_.ids.size();
224  df3_.size = hf3_.ids.size();
225 }
static constexpr int HEADER_WORDS
StoragePolicy::template StorageSelector< uint16_t >::type data
static constexpr int HEADER_WORDS
assert(be >=bs)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
DeviceCollectionf3 df3_
StoragePolicy::template StorageSelector< uint32_t >::type ids
edm::EDGetTokenT< HBHEDigiCollection > hbheDigiToken_
DeviceCollectionf5 df5_
cms::cuda::ContextState cudaState_
static constexpr int HEADER_WORDS
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:69
std::enable_if< std::is_same< T, ::calo::common::tags::Vec >::value, void >::type clear()
edm::EDGetTokenT< QIE11DigiCollection > qie11DigiToken_
DeviceCollectionf01 df01_
def move(src, dest)
Definition: eostools.py:511

◆ fillDescriptions()

void HcalDigisProducerGPU::fillDescriptions ( edm::ConfigurationDescriptions confDesc)
static

Definition at line 67 of file HcalDigisProducerGPU.cc.

References edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, HLT_2022v15_cff::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

67  {
69 
70  // FIXME
71  desc.add<edm::InputTag>("hbheDigisLabel", edm::InputTag("hcalDigis"));
72  desc.add<edm::InputTag>("qie11DigiLabel", edm::InputTag("hcalDigis"));
73  desc.add<std::string>("digisLabelF01HE", std::string{"f01HEDigisGPU"});
74  desc.add<std::string>("digisLabelF5HB", std::string{"f5HBDigisGPU"});
75  desc.add<std::string>("digisLabelF3HB", std::string{"f3HBDigisGPU"});
76  desc.add<uint32_t>("maxChannelsF01HE", 10000u);
77  desc.add<uint32_t>("maxChannelsF5HB", 10000u);
78  desc.add<uint32_t>("maxChannelsF3HB", 10000u);
79 
80  confDesc.addWithDefaultLabel(desc);
81 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

◆ produce()

void HcalDigisProducerGPU::produce ( edm::Event event,
edm::EventSetup const &  setup 
)
overrideprivate

Definition at line 227 of file HcalDigisProducerGPU.cc.

References cudaState_, df01_, df3_, df5_, digisF01HEToken_, digisF3HBToken_, digisF5HBToken_, and eostools::move().

227  {
229 
230  ctx.emplace(event, digisF01HEToken_, std::move(df01_));
231  ctx.emplace(event, digisF5HBToken_, std::move(df5_));
232  ctx.emplace(event, digisF3HBToken_, std::move(df3_));
233 }
edm::EDPutTokenT< ProductTypef01 > digisF01HEToken_
edm::EDPutTokenT< ProductTypef3 > digisF3HBToken_
DeviceCollectionf3 df3_
edm::EDPutTokenT< ProductTypef5 > digisF5HBToken_
DeviceCollectionf5 df5_
cms::cuda::ContextState cudaState_
DeviceCollectionf01 df01_
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1

Member Data Documentation

◆ config_

ConfigParameters HcalDigisProducerGPU::config_
private

Definition at line 54 of file HcalDigisProducerGPU.cc.

Referenced by acquire().

◆ cudaState_

cms::cuda::ContextState HcalDigisProducerGPU::cudaState_
private

Definition at line 49 of file HcalDigisProducerGPU.cc.

Referenced by acquire(), and produce().

◆ df01_

DeviceCollectionf01 HcalDigisProducerGPU::df01_
private

Definition at line 62 of file HcalDigisProducerGPU.cc.

Referenced by acquire(), and produce().

◆ df3_

DeviceCollectionf3 HcalDigisProducerGPU::df3_
private

Definition at line 64 of file HcalDigisProducerGPU.cc.

Referenced by acquire(), and produce().

◆ df5_

DeviceCollectionf5 HcalDigisProducerGPU::df5_
private

Definition at line 63 of file HcalDigisProducerGPU.cc.

Referenced by acquire(), and produce().

◆ digisF01HEToken_

edm::EDPutTokenT<ProductTypef01> HcalDigisProducerGPU::digisF01HEToken_
private

Definition at line 43 of file HcalDigisProducerGPU.cc.

Referenced by produce().

◆ digisF3HBToken_

edm::EDPutTokenT<ProductTypef3> HcalDigisProducerGPU::digisF3HBToken_
private

Definition at line 47 of file HcalDigisProducerGPU.cc.

Referenced by produce().

◆ digisF5HBToken_

edm::EDPutTokenT<ProductTypef5> HcalDigisProducerGPU::digisF5HBToken_
private

Definition at line 45 of file HcalDigisProducerGPU.cc.

Referenced by produce().

◆ hbheDigiToken_

edm::EDGetTokenT<HBHEDigiCollection> HcalDigisProducerGPU::hbheDigiToken_
private

Definition at line 27 of file HcalDigisProducerGPU.cc.

Referenced by acquire().

◆ hf01_

HostCollectionf01 HcalDigisProducerGPU::hf01_
private

Definition at line 57 of file HcalDigisProducerGPU.cc.

Referenced by acquire().

◆ hf3_

HostCollectionf3 HcalDigisProducerGPU::hf3_
private

Definition at line 59 of file HcalDigisProducerGPU.cc.

Referenced by acquire().

◆ hf5_

HostCollectionf5 HcalDigisProducerGPU::hf5_
private

Definition at line 58 of file HcalDigisProducerGPU.cc.

Referenced by acquire().

◆ qie11DigiToken_

edm::EDGetTokenT<QIE11DigiCollection> HcalDigisProducerGPU::qie11DigiToken_
private

Definition at line 28 of file HcalDigisProducerGPU.cc.

Referenced by acquire().