CMS 3D CMS Logo

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

Public Member Functions

 HcalRawToDigiGPU (edm::ParameterSet const &ps)
 
 ~HcalRawToDigiGPU () override
 
- 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 ProductTypef01 = cms::cuda::Product< hcal::DigiCollection< hcal::Flavor1, calo::common::DevStoragePolicy > >
 
using ProductTypef3 = cms::cuda::Product< hcal::DigiCollection< hcal::Flavor3, calo::common::DevStoragePolicy > >
 
using ProductTypef5 = cms::cuda::Product< hcal::DigiCollection< hcal::Flavor5, calo::common::DevStoragePolicy > >
 

Private Member Functions

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

Private Attributes

hcal::raw::ConfigurationParameters config_
 
cms::cuda::ContextState cudaState_
 
edm::EDPutTokenT< ProductTypef01digisF01HEToken_
 
edm::EDPutTokenT< ProductTypef3digisF3HBToken_
 
edm::EDPutTokenT< ProductTypef5digisF5HBToken_
 
edm::ESGetToken< hcal::raw::ElectronicsMappingGPU, HcalElectronicsMapRcdeMappingToken_
 
std::vector< int > fedsToUnpack_
 
hcal::raw::OutputDataCPU outputCPU_
 
hcal::raw::OutputDataGPU outputGPU_
 
edm::EDGetTokenT< FEDRawDataCollectionrawDataToken_
 

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 16 of file HcalRawToDigiGPU.cc.

Member Typedef Documentation

◆ ProductTypef01

Definition at line 29 of file HcalRawToDigiGPU.cc.

◆ ProductTypef3

Definition at line 33 of file HcalRawToDigiGPU.cc.

◆ ProductTypef5

Definition at line 31 of file HcalRawToDigiGPU.cc.

Constructor & Destructor Documentation

◆ HcalRawToDigiGPU()

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

Definition at line 68 of file HcalRawToDigiGPU.cc.

References deDxTools::esConsumes().

70  rawDataToken_{consumes<FEDRawDataCollection>(ps.getParameter<edm::InputTag>("InputLabel"))},
71  digisF01HEToken_{produces<ProductTypef01>(ps.getParameter<std::string>("digisLabelF01HE"))},
72  digisF5HBToken_{produces<ProductTypef5>(ps.getParameter<std::string>("digisLabelF5HB"))},
73  digisF3HBToken_{produces<ProductTypef3>(ps.getParameter<std::string>("digisLabelF3HB"))},
74  fedsToUnpack_{ps.getParameter<std::vector<int>>("FEDs")} {
75  config_.maxChannelsF01HE = ps.getParameter<uint32_t>("maxChannelsF01HE");
76  config_.maxChannelsF5HB = ps.getParameter<uint32_t>("maxChannelsF5HB");
77  config_.maxChannelsF3HB = ps.getParameter<uint32_t>("maxChannelsF3HB");
78  config_.nsamplesF01HE = ps.getParameter<uint32_t>("nsamplesF01HE");
79  config_.nsamplesF5HB = ps.getParameter<uint32_t>("nsamplesF5HB");
80  config_.nsamplesF3HB = ps.getParameter<uint32_t>("nsamplesF3HB");
81 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::ESGetToken< hcal::raw::ElectronicsMappingGPU, HcalElectronicsMapRcd > eMappingToken_
edm::EDPutTokenT< ProductTypef5 > digisF5HBToken_
edm::EDGetTokenT< FEDRawDataCollection > rawDataToken_
edm::EDPutTokenT< ProductTypef01 > digisF01HEToken_
hcal::raw::ConfigurationParameters config_
edm::EDPutTokenT< ProductTypef3 > digisF3HBToken_
std::vector< int > fedsToUnpack_

◆ ~HcalRawToDigiGPU()

HcalRawToDigiGPU::~HcalRawToDigiGPU ( )
override

Definition at line 83 of file HcalRawToDigiGPU.cc.

83 {}

Member Function Documentation

◆ acquire()

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

Definition at line 85 of file HcalRawToDigiGPU.cc.

References hcal::raw::OutputDataGPU::allocate(), PixelBaryCentreAnalyzer_cfg::conditions, config_, counter, cudaState_, hcal::raw::InputDataCPU::data, data, eMappingToken_, hcal::raw::empty_event_size, hcal::raw::entryPoint(), FEDRawDataCollection::FEDData(), hcal::raw::InputDataCPU::feds, fedsToUnpack_, cms::cuda::make_device_unique(), cms::cuda::make_host_unique(), eostools::move(), hcal::raw::nbytes_per_fed_max, hcal::raw::numOutputCollections, hcal::raw::InputDataCPU::offsets, outputCPU_, outputGPU_, rawDataToken_, singleTopDQM_cfi::setup, and hcal::raw::utca_nfeds_max.

87  {
88  // raii
89  cms::cuda::ScopedContextAcquire ctx{event.streamID(), std::move(holder), cudaState_};
90 
91  // conditions
92  auto const& eMappingProduct = setup.getData(eMappingToken_).getProduct(ctx.stream());
93 
94  // bundle up conditions
96 
97  // event data
99  event.getByToken(rawDataToken_, rawDataHandle);
100 
101  // scratch
102  hcal::raw::ScratchDataGPU scratchGPU = {
103  cms::cuda::make_device_unique<uint32_t[]>(hcal::raw::numOutputCollections, ctx.stream())};
104 
105  // input cpu data
106  hcal::raw::InputDataCPU inputCPU = {cms::cuda::make_host_unique<unsigned char[]>(
108  cms::cuda::make_host_unique<uint32_t[]>(hcal::raw::utca_nfeds_max, ctx.stream()),
110 
111  // input data gpu
112  hcal::raw::InputDataGPU inputGPU = {
113  cms::cuda::make_device_unique<unsigned char[]>(hcal::raw::utca_nfeds_max * hcal::raw::nbytes_per_fed_max,
114  ctx.stream()),
115  cms::cuda::make_device_unique<uint32_t[]>(hcal::raw::utca_nfeds_max, ctx.stream()),
117 
118  // output cpu
119  outputCPU_ = {cms::cuda::make_host_unique<uint32_t[]>(hcal::raw::numOutputCollections, ctx.stream())};
120 
121  // output gpu
122  outputGPU_.allocate(config_, ctx.stream());
123 
124  // iterate over feds
125  // TODO: another idea
126  // - loop over all feds to unpack and enqueue cuda memcpy
127  // - accumulate the sizes
128  // - after the loop launch cuda memcpy for sizes
129  // - enqueue the kernel
130  uint32_t currentCummOffset = 0;
131  uint32_t counter = 0;
132  for (auto const& fed : fedsToUnpack_) {
133  auto const& data = rawDataHandle->FEDData(fed);
134  auto const nbytes = data.size();
135 
136  // skip empty feds
137  if (nbytes < hcal::raw::empty_event_size)
138  continue;
139 
140 #ifdef HCAL_RAWDECODE_CPUDEBUG
141  printf("fed = %d nbytes = %lu\n", fed, nbytes);
142 #endif
143 
144  // copy raw data into plain buffer
145  std::memcpy(inputCPU.data.get() + currentCummOffset, data.data(), nbytes);
146  // set the offset in bytes from the start
147  inputCPU.offsets[counter] = currentCummOffset;
148  inputCPU.feds[counter] = fed;
149 
150  // this is the current offset into the vector
151  currentCummOffset += nbytes;
152  ++counter;
153  }
154 
155  hcal::raw::entryPoint(inputCPU,
156  inputGPU,
157  outputGPU_,
158  scratchGPU,
159  outputCPU_,
160  conditions,
161  config_,
162  ctx.stream(),
163  counter,
164  currentCummOffset);
165 }
hcal::raw::OutputDataGPU outputGPU_
host::impl::make_host_unique_selector< T >::non_array make_host_unique()
constexpr uint32_t nbytes_per_fed_max
cms::cuda::ContextState cudaState_
constexpr int32_t empty_event_size
cms::cuda::host::unique_ptr< unsigned char[]> data
edm::ESGetToken< hcal::raw::ElectronicsMappingGPU, HcalElectronicsMapRcd > eMappingToken_
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
edm::EDGetTokenT< FEDRawDataCollection > rawDataToken_
void entryPoint(InputDataCPU const &, InputDataGPU &, OutputDataGPU &, ScratchDataGPU &, OutputDataCPU &, ConditionsProducts const &, ConfigurationParameters const &, cudaStream_t cudaStream, uint32_t const, uint32_t const)
hcal::raw::OutputDataCPU outputCPU_
constexpr uint32_t numOutputCollections
hcal::raw::ConfigurationParameters config_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
std::vector< int > fedsToUnpack_
static std::atomic< unsigned int > counter
device::impl::make_device_unique_selector< T >::non_array make_device_unique(cudaStream_t stream)
cms::cuda::host::unique_ptr< int[]> feds
cms::cuda::host::unique_ptr< uint32_t[]> offsets
void allocate(ConfigurationParameters const &config, cudaStream_t cudaStream)
def move(src, dest)
Definition: eostools.py:511
constexpr uint32_t utca_nfeds_max

◆ fillDescriptions()

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

Definition at line 45 of file HcalRawToDigiGPU.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, l1tstage2emulator_dqm_sourceclient-live_cfg::feds, mps_fire::i, ProducerED_cfi::InputTag, label, FEDNumbering::MAXHCALuTCAFEDID, FEDNumbering::MINHCALuTCAFEDID, and AlCaHLTBitMon_QueryRunRegistry::string.

45  {
47 
48  desc.add<edm::InputTag>("InputLabel", edm::InputTag("rawDataCollector"));
50  std::vector<int> feds(nFeds);
51  for (int i = 0; i < nFeds; ++i)
53  desc.add<std::vector<int>>("FEDs", feds);
54  desc.add<uint32_t>("maxChannelsF01HE", 10000u);
55  desc.add<uint32_t>("maxChannelsF5HB", 10000u);
56  desc.add<uint32_t>("maxChannelsF3HB", 10000u);
57  desc.add<uint32_t>("nsamplesF01HE", 8);
58  desc.add<uint32_t>("nsamplesF5HB", 8);
59  desc.add<uint32_t>("nsamplesF3HB", 8);
60  desc.add<std::string>("digisLabelF5HB", "f5HBDigisGPU");
61  desc.add<std::string>("digisLabelF01HE", "f01HEDigisGPU");
62  desc.add<std::string>("digisLabelF3HB", "f3HBDigisGPU");
63 
64  std::string label = "hcalRawToDigiGPU";
65  confDesc.add(label, desc);
66 }
char const * label
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

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

Definition at line 167 of file HcalRawToDigiGPU.cc.

References config_, cudaState_, hcal::raw::OutputDataGPU::digisF01HE, digisF01HEToken_, hcal::raw::OutputDataGPU::digisF3HB, digisF3HBToken_, hcal::raw::OutputDataGPU::digisF5HB, digisF5HBToken_, eostools::move(), hcal::raw::OutputDataCPU::nchannels, hcal::raw::ConfigurationParameters::nsamplesF01HE, hcal::raw::ConfigurationParameters::nsamplesF3HB, hcal::raw::ConfigurationParameters::nsamplesF5HB, outputCPU_, hcal::raw::OutputF01HE, hcal::raw::OutputF3HB, hcal::raw::OutputF5HB, and outputGPU_.

167  {
169 
170 #ifdef HCAL_RAWDECODE_CPUDEBUG
171  printf("f01he channels = %u f5hb channesl = %u\n",
174 #endif
175 
176  // FIXME: use sizes of views directly for cuda mem cpy?
177  auto const nchannelsF01HE = outputCPU_.nchannels[hcal::raw::OutputF01HE];
178  auto const nchannelsF5HB = outputCPU_.nchannels[hcal::raw::OutputF5HB];
179  auto const nchannelsF3HB = outputCPU_.nchannels[hcal::raw::OutputF3HB];
180  outputGPU_.digisF01HE.size = nchannelsF01HE;
181  outputGPU_.digisF5HB.size = nchannelsF5HB;
182  outputGPU_.digisF3HB.size = nchannelsF3HB;
183  outputGPU_.digisF01HE.stride = hcal::compute_stride<hcal::Flavor1>(config_.nsamplesF01HE);
184  outputGPU_.digisF5HB.stride = hcal::compute_stride<hcal::Flavor5>(config_.nsamplesF5HB);
185  outputGPU_.digisF3HB.stride = hcal::compute_stride<hcal::Flavor3>(config_.nsamplesF3HB);
186 
190 
191  // reset ptrs that are carried as members
192  outputCPU_.nchannels.reset();
193 }
hcal::raw::OutputDataGPU outputGPU_
DigiCollection< Flavor5, ::calo::common::DevStoragePolicy > digisF5HB
constexpr uint8_t OutputF5HB
cms::cuda::ContextState cudaState_
edm::EDPutTokenT< ProductTypef5 > digisF5HBToken_
constexpr uint8_t OutputF3HB
DigiCollection< Flavor1, ::calo::common::DevStoragePolicy > digisF01HE
edm::EDPutTokenT< ProductTypef01 > digisF01HEToken_
hcal::raw::OutputDataCPU outputCPU_
cms::cuda::host::unique_ptr< uint32_t[]> nchannels
hcal::raw::ConfigurationParameters config_
edm::EDPutTokenT< ProductTypef3 > digisF3HBToken_
DigiCollection< Flavor3, ::calo::common::DevStoragePolicy > digisF3HB
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1
constexpr uint8_t OutputF01HE

Member Data Documentation

◆ config_

hcal::raw::ConfigurationParameters HcalRawToDigiGPU::config_
private

Definition at line 40 of file HcalRawToDigiGPU.cc.

Referenced by acquire(), and produce().

◆ cudaState_

cms::cuda::ContextState HcalRawToDigiGPU::cudaState_
private

Definition at line 36 of file HcalRawToDigiGPU.cc.

Referenced by acquire(), and produce().

◆ digisF01HEToken_

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

Definition at line 30 of file HcalRawToDigiGPU.cc.

Referenced by produce().

◆ digisF3HBToken_

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

Definition at line 34 of file HcalRawToDigiGPU.cc.

Referenced by produce().

◆ digisF5HBToken_

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

Definition at line 32 of file HcalRawToDigiGPU.cc.

Referenced by produce().

◆ eMappingToken_

edm::ESGetToken<hcal::raw::ElectronicsMappingGPU, HcalElectronicsMapRcd> HcalRawToDigiGPU::eMappingToken_
private

Definition at line 27 of file HcalRawToDigiGPU.cc.

Referenced by acquire().

◆ fedsToUnpack_

std::vector<int> HcalRawToDigiGPU::fedsToUnpack_
private

Definition at line 38 of file HcalRawToDigiGPU.cc.

Referenced by acquire().

◆ outputCPU_

hcal::raw::OutputDataCPU HcalRawToDigiGPU::outputCPU_
private

Definition at line 42 of file HcalRawToDigiGPU.cc.

Referenced by acquire(), and produce().

◆ outputGPU_

hcal::raw::OutputDataGPU HcalRawToDigiGPU::outputGPU_
private

Definition at line 41 of file HcalRawToDigiGPU.cc.

Referenced by acquire(), and produce().

◆ rawDataToken_

edm::EDGetTokenT<FEDRawDataCollection> HcalRawToDigiGPU::rawDataToken_
private

Definition at line 28 of file HcalRawToDigiGPU.cc.

Referenced by acquire().