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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

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_
 
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 >
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 21 of file HcalRawToDigiGPU.cc.

Member Typedef Documentation

◆ ProductTypef01

Definition at line 33 of file HcalRawToDigiGPU.cc.

◆ ProductTypef3

Definition at line 37 of file HcalRawToDigiGPU.cc.

◆ ProductTypef5

Definition at line 35 of file HcalRawToDigiGPU.cc.

Constructor & Destructor Documentation

◆ HcalRawToDigiGPU()

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

Definition at line 72 of file HcalRawToDigiGPU.cc.

73  : rawDataToken_{consumes<FEDRawDataCollection>(ps.getParameter<edm::InputTag>("InputLabel"))},
74  digisF01HEToken_{produces<ProductTypef01>(ps.getParameter<std::string>("digisLabelF01HE"))},
75  digisF5HBToken_{produces<ProductTypef5>(ps.getParameter<std::string>("digisLabelF5HB"))},
76  digisF3HBToken_{produces<ProductTypef3>(ps.getParameter<std::string>("digisLabelF3HB"))},
77  fedsToUnpack_{ps.getParameter<std::vector<int>>("FEDs")} {
78  config_.maxChannelsF01HE = ps.getParameter<uint32_t>("maxChannelsF01HE");
79  config_.maxChannelsF5HB = ps.getParameter<uint32_t>("maxChannelsF5HB");
80  config_.maxChannelsF3HB = ps.getParameter<uint32_t>("maxChannelsF3HB");
81  config_.nsamplesF01HE = ps.getParameter<uint32_t>("nsamplesF01HE");
82  config_.nsamplesF5HB = ps.getParameter<uint32_t>("nsamplesF5HB");
83  config_.nsamplesF3HB = ps.getParameter<uint32_t>("nsamplesF3HB");
84 }

References edm::ParameterSet::getParameter().

◆ ~HcalRawToDigiGPU()

HcalRawToDigiGPU::~HcalRawToDigiGPU ( )
override

Definition at line 86 of file HcalRawToDigiGPU.cc.

86 {}

Member Function Documentation

◆ acquire()

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

Definition at line 88 of file HcalRawToDigiGPU.cc.

90  {
91  // raii
92  cms::cuda::ScopedContextAcquire ctx{event.streamID(), std::move(holder), cudaState_};
93 
94  // conditions
96  setup.get<HcalElectronicsMapRcd>().get(eMappingHandle);
97  auto const& eMappingProduct = eMappingHandle->getProduct(ctx.stream());
98 
99  // bundle up conditions
100  hcal::raw::ConditionsProducts conditions{eMappingProduct};
101 
102  // event data
103  edm::Handle<FEDRawDataCollection> rawDataHandle;
104  event.getByToken(rawDataToken_, rawDataHandle);
105 
106  // scratch
107  hcal::raw::ScratchDataGPU scratchGPU = {
108  cms::cuda::make_device_unique<uint32_t[]>(hcal::raw::numOutputCollections, ctx.stream())};
109 
110  // input cpu data
111  hcal::raw::InputDataCPU inputCPU = {cms::cuda::make_host_unique<unsigned char[]>(
113  cms::cuda::make_host_unique<uint32_t[]>(hcal::raw::utca_nfeds_max, ctx.stream()),
115 
116  // input data gpu
117  hcal::raw::InputDataGPU inputGPU = {
118  cms::cuda::make_device_unique<unsigned char[]>(hcal::raw::utca_nfeds_max * hcal::raw::nbytes_per_fed_max,
119  ctx.stream()),
120  cms::cuda::make_device_unique<uint32_t[]>(hcal::raw::utca_nfeds_max, ctx.stream()),
122 
123  // output cpu
124  outputCPU_ = {cms::cuda::make_host_unique<uint32_t[]>(hcal::raw::numOutputCollections, ctx.stream())};
125 
126  // output gpu
127  outputGPU_.allocate(config_, ctx.stream());
128 
129  // iterate over feds
130  // TODO: another idea
131  // - loop over all feds to unpack and enqueue cuda memcpy
132  // - accumulate the sizes
133  // - after the loop launch cuda memcpy for sizes
134  // - enqueue the kernel
135  uint32_t currentCummOffset = 0;
136  uint32_t counter = 0;
137  for (auto const& fed : fedsToUnpack_) {
138  auto const& data = rawDataHandle->FEDData(fed);
139  auto const nbytes = data.size();
140 
141  // skip empty feds
142  if (nbytes < hcal::raw::empty_event_size)
143  continue;
144 
145 #ifdef HCAL_RAWDECODE_CPUDEBUG
146  printf("fed = %d nbytes = %lu\n", fed, nbytes);
147 #endif
148 
149  // copy raw data into plain buffer
150  std::memcpy(inputCPU.data.get() + currentCummOffset, data.data(), nbytes);
151  // set the offset in bytes from the start
152  inputCPU.offsets[counter] = currentCummOffset;
153  inputCPU.feds[counter] = fed;
154 
155  // this is the current offset into the vector
156  currentCummOffset += nbytes;
157  ++counter;
158  }
159 
160  hcal::raw::entryPoint(inputCPU,
161  inputGPU,
162  outputGPU_,
163  scratchGPU,
164  outputCPU_,
165  conditions,
166  config_,
167  ctx.stream(),
168  counter,
169  currentCummOffset);
170 }

References hcal::raw::OutputDataGPU::allocate(), submitPVValidationJobs::conditions, config_, counter, cudaState_, hcal::raw::InputDataCPU::data, data, hcal::raw::empty_event_size, hcal::raw::entryPoint(), FEDRawDataCollection::FEDData(), hcal::raw::InputDataCPU::feds, fedsToUnpack_, get, hcal::raw::ElectronicsMappingGPU::getProduct(), 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.

◆ fillDescriptions()

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

Definition at line 49 of file HcalRawToDigiGPU.cc.

49  {
51 
52  desc.add<edm::InputTag>("InputLabel", edm::InputTag("rawDataCollector"));
54  std::vector<int> feds(nFeds);
55  for (int i = 0; i < nFeds; ++i)
57  desc.add<std::vector<int>>("FEDs", feds);
58  desc.add<uint32_t>("maxChannelsF01HE", 10000u);
59  desc.add<uint32_t>("maxChannelsF5HB", 10000u);
60  desc.add<uint32_t>("maxChannelsF3HB", 10000u);
61  desc.add<uint32_t>("nsamplesF01HE", 8);
62  desc.add<uint32_t>("nsamplesF5HB", 8);
63  desc.add<uint32_t>("nsamplesF3HB", 8);
64  desc.add<std::string>("digisLabelF5HB", "f5HBDigisGPU");
65  desc.add<std::string>("digisLabelF01HE", "f01HEDigisGPU");
66  desc.add<std::string>("digisLabelF3HB", "f3HBDigisGPU");
67 
68  std::string label = "hcalRawToDigiGPU";
69  confDesc.add(label, desc);
70 }

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

◆ produce()

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

Definition at line 172 of file HcalRawToDigiGPU.cc.

172  {
174 
175 #ifdef HCAL_RAWDECODE_CPUDEBUG
176  printf("f01he channels = %u f5hb channesl = %u\n",
179 #endif
180 
181  // FIXME: use sizes of views directly for cuda mem cpy?
182  auto const nchannelsF01HE = outputCPU_.nchannels[hcal::raw::OutputF01HE];
183  auto const nchannelsF5HB = outputCPU_.nchannels[hcal::raw::OutputF5HB];
184  auto const nchannelsF3HB = outputCPU_.nchannels[hcal::raw::OutputF3HB];
185  outputGPU_.digisF01HE.size = nchannelsF01HE;
186  outputGPU_.digisF5HB.size = nchannelsF5HB;
187  outputGPU_.digisF3HB.size = nchannelsF3HB;
188  outputGPU_.digisF01HE.stride = hcal::compute_stride<hcal::Flavor1>(config_.nsamplesF01HE);
189  outputGPU_.digisF5HB.stride = hcal::compute_stride<hcal::Flavor5>(config_.nsamplesF5HB);
190  outputGPU_.digisF3HB.stride = hcal::compute_stride<hcal::Flavor3>(config_.nsamplesF3HB);
191 
195 
196  // reset ptrs that are carried as members
197  outputCPU_.nchannels.reset();
198 }

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_.

Member Data Documentation

◆ config_

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

Definition at line 44 of file HcalRawToDigiGPU.cc.

Referenced by acquire(), and produce().

◆ cudaState_

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

Definition at line 40 of file HcalRawToDigiGPU.cc.

Referenced by acquire(), and produce().

◆ digisF01HEToken_

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

Definition at line 34 of file HcalRawToDigiGPU.cc.

Referenced by produce().

◆ digisF3HBToken_

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

Definition at line 38 of file HcalRawToDigiGPU.cc.

Referenced by produce().

◆ digisF5HBToken_

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

Definition at line 36 of file HcalRawToDigiGPU.cc.

Referenced by produce().

◆ fedsToUnpack_

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

Definition at line 42 of file HcalRawToDigiGPU.cc.

Referenced by acquire().

◆ outputCPU_

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

Definition at line 46 of file HcalRawToDigiGPU.cc.

Referenced by acquire(), and produce().

◆ outputGPU_

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

Definition at line 45 of file HcalRawToDigiGPU.cc.

Referenced by acquire(), and produce().

◆ rawDataToken_

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

Definition at line 32 of file HcalRawToDigiGPU.cc.

Referenced by acquire().

l1tstage2emulator_dqm_sourceclient-live_cfg.feds
feds
Definition: l1tstage2emulator_dqm_sourceclient-live_cfg.py:152
counter
Definition: counter.py:1
mps_fire.i
i
Definition: mps_fire.py:428
HcalElectronicsMapRcd
Definition: HcalElectronicsMapRcd.h:8
HcalRawToDigiGPU::digisF3HBToken_
edm::EDPutTokenT< ProductTypef3 > digisF3HBToken_
Definition: HcalRawToDigiGPU.cc:38
cms::cuda::ScopedContextProduce
Definition: ScopedContext.h:149
cms::cuda::make_device_unique
device::impl::make_device_unique_selector< T >::non_array make_device_unique(cudaStream_t stream)
Definition: device_unique_ptr.h:52
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89281
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
hcal::raw::InputDataCPU::offsets
cms::cuda::host::unique_ptr< uint32_t[]> offsets
Definition: DeclsForKernels.h:38
HcalRawToDigiGPU::config_
hcal::raw::ConfigurationParameters config_
Definition: HcalRawToDigiGPU.cc:44
hcal::raw::OutputF01HE
constexpr uint8_t OutputF01HE
Definition: DeclsForKernels.h:23
edm::Handle< FEDRawDataCollection >
HcalRawToDigiGPU::outputCPU_
hcal::raw::OutputDataCPU outputCPU_
Definition: HcalRawToDigiGPU.cc:46
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
hcal::raw::OutputDataGPU::digisF5HB
DigiCollection< Flavor5, ::calo::common::DevStoragePolicy > digisF5HB
Definition: DeclsForKernels.h:54
HcalRawToDigiGPU::digisF01HEToken_
edm::EDPutTokenT< ProductTypef01 > digisF01HEToken_
Definition: HcalRawToDigiGPU.cc:34
hcal::raw::OutputF5HB
constexpr uint8_t OutputF5HB
Definition: DeclsForKernels.h:24
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
HcalRawToDigiGPU::digisF5HBToken_
edm::EDPutTokenT< ProductTypef5 > digisF5HBToken_
Definition: HcalRawToDigiGPU.cc:36
edm::ESHandle
Definition: DTSurvey.h:22
hcal::raw::ConfigurationParameters::nsamplesF01HE
uint32_t nsamplesF01HE
Definition: DeclsForKernels.h:31
hcal::raw::ConfigurationParameters::maxChannelsF01HE
uint32_t maxChannelsF01HE
Definition: DeclsForKernels.h:28
hcal::raw::ConfigurationParameters::maxChannelsF3HB
uint32_t maxChannelsF3HB
Definition: DeclsForKernels.h:30
hcal::raw::empty_event_size
constexpr int32_t empty_event_size
Definition: DeclsForKernels.h:16
FEDRawDataCollection::FEDData
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
Definition: FEDRawDataCollection.cc:19
hcal::raw::ConfigurationParameters::nsamplesF5HB
uint32_t nsamplesF5HB
Definition: DeclsForKernels.h:32
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
hcal::raw::numOutputCollections
constexpr uint32_t numOutputCollections
Definition: DeclsForKernels.h:22
hcal::raw::nbytes_per_fed_max
constexpr uint32_t nbytes_per_fed_max
Definition: DeclsForKernels.h:18
HcalRawToDigiGPU::fedsToUnpack_
std::vector< int > fedsToUnpack_
Definition: HcalRawToDigiGPU.cc:42
hcal::raw::ElectronicsMappingGPU::getProduct
const Product & getProduct(cudaStream_t) const
Definition: ElectronicsMappingGPU.cc:37
hcal::raw::entryPoint
void entryPoint(InputDataCPU const &, InputDataGPU &, OutputDataGPU &, ScratchDataGPU &, OutputDataCPU &, ConditionsProducts const &, ConfigurationParameters const &, cudaStream_t cudaStream, uint32_t const, uint32_t const)
FEDNumbering::MAXHCALuTCAFEDID
Definition: FEDNumbering.h:104
hcal::raw::InputDataCPU::feds
cms::cuda::host::unique_ptr< int[]> feds
Definition: DeclsForKernels.h:39
counter
static std::atomic< unsigned int > counter
Definition: SharedResourceNames.cc:18
hcal::raw::ConfigurationParameters::nsamplesF3HB
uint32_t nsamplesF3HB
Definition: DeclsForKernels.h:33
get
#define get
hcal::raw::InputDataCPU::data
cms::cuda::host::unique_ptr< unsigned char[]> data
Definition: DeclsForKernels.h:37
FEDNumbering::MINHCALuTCAFEDID
Definition: FEDNumbering.h:103
hcal::raw::OutputDataGPU::digisF01HE
DigiCollection< Flavor1, ::calo::common::DevStoragePolicy > digisF01HE
Definition: DeclsForKernels.h:53
cms::cuda::ScopedContextAcquire
Definition: ScopedContext.h:101
hcal::raw::InputDataGPU
Definition: DeclsForKernels.h:73
hcal::raw::InputDataCPU
Definition: DeclsForKernels.h:36
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
submitPVValidationJobs.conditions
list conditions
Definition: submitPVValidationJobs.py:674
eostools.move
def move(src, dest)
Definition: eostools.py:511
HcalRawToDigiGPU::outputGPU_
hcal::raw::OutputDataGPU outputGPU_
Definition: HcalRawToDigiGPU.cc:45
hcal::raw::OutputDataCPU::nchannels
cms::cuda::host::unique_ptr< uint32_t[]> nchannels
Definition: DeclsForKernels.h:43
hcal::raw::OutputDataGPU::digisF3HB
DigiCollection< Flavor3, ::calo::common::DevStoragePolicy > digisF3HB
Definition: DeclsForKernels.h:55
hcal::raw::OutputF3HB
constexpr uint8_t OutputF3HB
Definition: DeclsForKernels.h:25
hcal::raw::ConfigurationParameters::maxChannelsF5HB
uint32_t maxChannelsF5HB
Definition: DeclsForKernels.h:29
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
hcal::raw::ScratchDataGPU
Definition: DeclsForKernels.h:46
hcal::raw::ConditionsProducts
Definition: DeclsForKernels.h:79
hcal::raw::OutputDataGPU::allocate
void allocate(ConfigurationParameters const &config, cudaStream_t cudaStream)
Definition: DeclsForKernels.h:57
HcalRawToDigiGPU::rawDataToken_
edm::EDGetTokenT< FEDRawDataCollection > rawDataToken_
Definition: HcalRawToDigiGPU.cc:32
cms::cuda::make_host_unique
host::impl::make_host_unique_selector< T >::non_array make_host_unique(cudaStream_t stream)
Definition: host_unique_ptr.h:41
event
Definition: event.py:1
edm::InputTag
Definition: InputTag.h:15
label
const char * label
Definition: PFTauDecayModeTools.cc:11
HcalRawToDigiGPU::cudaState_
cms::cuda::ContextState cudaState_
Definition: HcalRawToDigiGPU.cc:40
hcal::raw::utca_nfeds_max
constexpr uint32_t utca_nfeds_max
Definition: DeclsForKernels.h:17