CMS 3D CMS Logo

EcalRawToDigiGPU.cc
Go to the documentation of this file.
14 
15 #include "DeclsForKernels.h"
16 #include "UnpackGPU.h"
17 
18 class EcalRawToDigiGPU : public edm::stream::EDProducer<edm::ExternalWork> {
19 public:
20  explicit EcalRawToDigiGPU(edm::ParameterSet const& ps);
21  ~EcalRawToDigiGPU() override;
23 
24 private:
26  void produce(edm::Event&, edm::EventSetup const&) override;
27 
28 private:
33 
35 
36  std::vector<int> fedsToUnpack_;
37 
41 };
42 
45 
46  desc.add<edm::InputTag>("InputLabel", edm::InputTag("rawDataCollector"));
47  std::vector<int> feds(54);
48  for (uint32_t i = 0; i < 54; ++i)
49  feds[i] = i + 601;
50  desc.add<std::vector<int>>("FEDs", feds);
51  desc.add<uint32_t>("maxChannelsEB", 61200);
52  desc.add<uint32_t>("maxChannelsEE", 14648);
53  desc.add<std::string>("digisLabelEB", "ebDigis");
54  desc.add<std::string>("digisLabelEE", "eeDigis");
55 
56  std::string label = "ecalRawToDigiGPU";
57  confDesc.add(label, desc);
58 }
59 
61  : rawDataToken_{consumes<FEDRawDataCollection>(ps.getParameter<edm::InputTag>("InputLabel"))},
62  digisEBToken_{produces<OutputProduct>(ps.getParameter<std::string>("digisLabelEB"))},
63  digisEEToken_{produces<OutputProduct>(ps.getParameter<std::string>("digisLabelEE"))},
64  eMappingToken_{esConsumes<ecal::raw::ElectronicsMappingGPU, EcalMappingElectronicsRcd>()},
65  fedsToUnpack_{ps.getParameter<std::vector<int>>("FEDs")} {
66  config_.maxChannelsEB = ps.getParameter<uint32_t>("maxChannelsEB");
67  config_.maxChannelsEE = ps.getParameter<uint32_t>("maxChannelsEE");
68 }
69 
71 
73  edm::EventSetup const& setup,
75  // raii
76  cms::cuda::ScopedContextAcquire ctx{event.streamID(), std::move(holder), cudaState_};
77 
78  // conditions
80  auto const& eMappingProduct = eMappingHandle->getProduct(ctx.stream());
81 
82  // bundle up conditions
84 
85  // event data
87  event.getByToken(rawDataToken_, rawDataHandle);
88 
89  // scratch
90  ecal::raw::ScratchDataGPU scratchGPU = {cms::cuda::make_device_unique<uint32_t[]>(2, ctx.stream())};
91 
92  // input cpu data
93  ecal::raw::InputDataCPU inputCPU = {
94  cms::cuda::make_host_unique<unsigned char[]>(ecal::raw::nfeds_max * ecal::raw::nbytes_per_fed_max, ctx.stream()),
95  cms::cuda::make_host_unique<uint32_t[]>(ecal::raw::nfeds_max, ctx.stream()),
97 
98  // input data gpu
99  ecal::raw::InputDataGPU inputGPU = {cms::cuda::make_device_unique<unsigned char[]>(
101  cms::cuda::make_device_unique<uint32_t[]>(ecal::raw::nfeds_max, ctx.stream()),
103 
104  // output cpu
105  outputCPU_ = {cms::cuda::make_host_unique<uint32_t[]>(2, ctx.stream())};
106 
107  // output gpu
108  outputGPU_.allocate(config_, ctx.stream());
109 
110  // iterate over feds
111  // TODO: another idea
112  // - loop over all feds to unpack and enqueue cuda memcpy
113  // - accumulate the sizes
114  // - after the loop launch cuda memcpy for sizes
115  // - enqueue the kernel
116  uint32_t currentCummOffset = 0;
117  uint32_t counter = 0;
118  for (auto const& fed : fedsToUnpack_) {
119  auto const& data = rawDataHandle->FEDData(fed);
120  auto const nbytes = data.size();
121 
122  // skip empty feds
123  if (nbytes < ecal::raw::empty_event_size)
124  continue;
125 
126  // copy raw data into plain buffer
127  std::memcpy(inputCPU.data.get() + currentCummOffset, data.data(), nbytes);
128  // set the offset in bytes from the start
129  inputCPU.offsets[counter] = currentCummOffset;
130  inputCPU.feds[counter] = fed;
131 
132  // this is the current offset into the vector
133  currentCummOffset += nbytes;
134  ++counter;
135  }
136 
138  inputCPU, inputGPU, outputGPU_, scratchGPU, outputCPU_, conditions, ctx.stream(), counter, currentCummOffset);
139 }
140 
143 
144  // get the number of channels
147 
150 
151  // reset ptrs that are carried as members
152  outputCPU_.nchannels.reset();
153 }
154 
EcalRawToDigiGPU::produce
void produce(edm::Event &, edm::EventSetup const &) override
Definition: EcalRawToDigiGPU.cc:141
l1tstage2emulator_dqm_sourceclient-live_cfg.feds
feds
Definition: l1tstage2emulator_dqm_sourceclient-live_cfg.py:152
counter
Definition: counter.py:1
EcalRawToDigiGPU::digisEBToken_
edm::EDPutTokenT< OutputProduct > digisEBToken_
Definition: EcalRawToDigiGPU.cc:31
mps_fire.i
i
Definition: mps_fire.py:428
EcalRawToDigiGPU::rawDataToken_
edm::EDGetTokenT< FEDRawDataCollection > rawDataToken_
Definition: EcalRawToDigiGPU.cc:29
DeclsForKernels.h
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
edm::EDGetTokenT< FEDRawDataCollection >
ecal::raw::nbytes_per_fed_max
constexpr uint32_t nbytes_per_fed_max
Definition: DeclsForKernels.h:20
edm::EDPutTokenT
Definition: EDPutToken.h:33
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
EDProducer.h
EcalRawToDigiGPU::acquire
void acquire(edm::Event const &, edm::EventSetup const &, edm::WaitingTaskWithArenaHolder) override
Definition: EcalRawToDigiGPU.cc:72
EcalRawToDigiGPU::digisEEToken_
edm::EDPutTokenT< OutputProduct > digisEEToken_
Definition: EcalRawToDigiGPU.cc:31
EcalRawToDigiGPU::fedsToUnpack_
std::vector< int > fedsToUnpack_
Definition: EcalRawToDigiGPU.cc:36
ecal::raw::ElectronicsMappingGPU::getProduct
Product const & getProduct(cudaStream_t) const
Definition: ElectronicsMappingGPU.cc:32
ElectronicsMappingGPU.h
edm::Handle< FEDRawDataCollection >
ESGetToken.h
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
EcalRawToDigiGPU::EcalRawToDigiGPU
EcalRawToDigiGPU(edm::ParameterSet const &ps)
Definition: EcalRawToDigiGPU.cc:60
edm::WaitingTaskWithArenaHolder
Definition: WaitingTaskWithArenaHolder.h:34
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
ecal::raw::entryPoint
void entryPoint(InputDataCPU const &, InputDataGPU &, OutputDataGPU &, ScratchDataGPU &, OutputDataCPU &, ConditionsProducts const &, cudaStream_t, uint32_t const, uint32_t const)
EcalDigiCollections.h
edm::ESHandle
Definition: DTSurvey.h:22
EcalRawToDigiGPU::eMappingToken_
edm::ESGetToken< ecal::raw::ElectronicsMappingGPU, EcalMappingElectronicsRcd > eMappingToken_
Definition: EcalRawToDigiGPU.cc:32
EcalRawToDigiGPU::config_
ecal::raw::ConfigurationParameters config_
Definition: EcalRawToDigiGPU.cc:38
ecal::raw::ScratchDataGPU
Definition: DeclsForKernels.h:51
ecal::raw::nfeds_max
constexpr uint32_t nfeds_max
Definition: DeclsForKernels.h:19
FEDRawDataCollection::FEDData
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
Definition: FEDRawDataCollection.cc:19
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cms::cuda::ContextState
Definition: ContextState.h:15
ecal::raw::OutputDataGPU::digisEE
DigisCollection<::calo::common::DevStoragePolicy > digisEE
Definition: DeclsForKernels.h:39
edm::ParameterSet
Definition: ParameterSet.h:47
ecal::raw::ConfigurationParameters
Definition: DeclsForKernels.h:28
Event.h
ecal::raw::OutputDataGPU
Definition: DeclsForKernels.h:38
ecal::raw::OutputDataCPU
Definition: DeclsForKernels.h:33
UnpackGPU.h
ecal::raw::InputDataCPU::feds
cms::cuda::host::unique_ptr< int[]> feds
Definition: DeclsForKernels.h:25
ecal::raw::InputDataCPU::offsets
cms::cuda::host::unique_ptr< uint32_t[]> offsets
Definition: DeclsForKernels.h:24
EcalRawToDigiGPU::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &)
Definition: EcalRawToDigiGPU.cc:43
FEDRawDataCollection.h
EcalRawToDigiGPU::outputGPU_
ecal::raw::OutputDataGPU outputGPU_
Definition: EcalRawToDigiGPU.cc:39
cudaCheck.h
EcalMappingElectronicsRcd.h
edm::stream::EDProducer
Definition: EDProducer.h:38
counter
static std::atomic< unsigned int > counter
Definition: SharedResourceNames.cc:18
edm::EventSetup
Definition: EventSetup.h:58
DigisCollection.h
edm::ESGetToken< ecal::raw::ElectronicsMappingGPU, EcalMappingElectronicsRcd >
cms::cuda::ScopedContextAcquire
Definition: ScopedContext.h:101
ecal::raw::InputDataCPU
Definition: DeclsForKernels.h:22
ecal::raw::InputDataGPU
Definition: DeclsForKernels.h:57
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
ecal::raw::OutputDataGPU::digisEB
DigisCollection<::calo::common::DevStoragePolicy > digisEB
Definition: DeclsForKernels.h:39
cms::cuda::Product
Definition: Product.h:34
ecal::raw::OutputDataCPU::nchannels
cms::cuda::host::unique_ptr< uint32_t[]> nchannels
Definition: DeclsForKernels.h:35
ScopedContext.h
EcalRawToDigiGPU::outputCPU_
ecal::raw::OutputDataCPU outputCPU_
Definition: EcalRawToDigiGPU.cc:40
ecal::raw::OutputDataGPU::allocate
void allocate(ConfigurationParameters const &config, cudaStream_t cudaStream)
Definition: DeclsForKernels.h:41
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
EcalRawToDigiGPU::~EcalRawToDigiGPU
~EcalRawToDigiGPU() override
Definition: EcalRawToDigiGPU.cc:70
ecal::raw::ConditionsProducts
Definition: DeclsForKernels.h:63
ecal::raw::empty_event_size
constexpr auto empty_event_size
Definition: DeclsForKernels.h:18
ParameterSet.h
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
ecal::raw::InputDataCPU::data
cms::cuda::host::unique_ptr< unsigned char[]> data
Definition: DeclsForKernels.h:23
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
EcalRawToDigiGPU
Definition: EcalRawToDigiGPU.cc:18
label
const char * label
Definition: PFTauDecayModeTools.cc:11
EcalRawToDigiGPU::cudaState_
cms::cuda::ContextState cudaState_
Definition: EcalRawToDigiGPU.cc:34