CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SiPixelDigiErrorsSoAFromCUDA.cc
Go to the documentation of this file.
13 
14 class SiPixelDigiErrorsSoAFromCUDA : public edm::stream::EDProducer<edm::ExternalWork> {
15 public:
17  ~SiPixelDigiErrorsSoAFromCUDA() override = default;
18 
19  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
20 
21 private:
22  void acquire(const edm::Event& iEvent,
23  const edm::EventSetup& iSetup,
24  edm::WaitingTaskWithArenaHolder waitingTaskHolder) override;
25  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
26 
29 
33 };
34 
36  : digiErrorGetToken_(
37  consumes<cms::cuda::Product<SiPixelDigiErrorsCUDA>>(iConfig.getParameter<edm::InputTag>("src"))),
38  digiErrorPutToken_(produces<SiPixelErrorsSoA>()) {}
39 
42  desc.add<edm::InputTag>("src", edm::InputTag("siPixelClustersCUDA"));
43  descriptions.addWithDefaultLabel(desc);
44 }
45 
47  const edm::EventSetup& iSetup,
48  edm::WaitingTaskWithArenaHolder waitingTaskHolder) {
49  // Do the transfer in a CUDA stream parallel to the computation CUDA stream
50  cms::cuda::ScopedContextAcquire ctx{iEvent.streamID(), std::move(waitingTaskHolder)};
51 
52  const auto& gpuDigiErrors = ctx.get(iEvent, digiErrorGetToken_);
53 
54  auto tmp = gpuDigiErrors.dataErrorToHostAsync(ctx.stream());
55  error_ = tmp.first;
56  data_ = std::move(tmp.second);
57  formatterErrors_ = &(gpuDigiErrors.formatterErrors());
58 }
59 
61  // The following line copies the data from the pinned host memory to
62  // regular host memory. In principle that feels unnecessary (why not
63  // just use the pinned host memory?). There are a few arguments for
64  // doing it though
65  // - Now can release the pinned host memory back to the (caching) allocator
66  // * if we'd like to keep the pinned memory, we'd need to also
67  // keep the CUDA stream around as long as that, or allow pinned
68  // host memory to be allocated without a CUDA stream
69  // - What if a CPU algorithm would produce the same SoA? We can't
70  // use cudaMallocHost without a GPU...
72 
73  error_ = cms::cuda::make_SimpleVector<SiPixelErrorCompact>(0, nullptr);
74  data_.reset();
75  formatterErrors_ = nullptr;
76 }
77 
78 // define as framework plugin
edm::EDGetTokenT< cms::cuda::Product< SiPixelDigiErrorsCUDA > > digiErrorGetToken_
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
edm::EDPutTokenT< SiPixelErrorsSoA > digiErrorPutToken_
constexpr int size() const
Definition: SimpleVector.h:109
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
SiPixelDigiErrorsSoAFromCUDA(const edm::ParameterSet &iConfig)
int iEvent
Definition: GenABIO.cc:224
void acquire(const edm::Event &iEvent, const edm::EventSetup &iSetup, edm::WaitingTaskWithArenaHolder waitingTaskHolder) override
std::map< cms_uint32_t, std::vector< SiPixelRawDataError >> SiPixelFormatterErrors
def move
Definition: eostools.py:511
cms::cuda::SimpleVector< SiPixelErrorCompact > error_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&...args)
puts a new product
Definition: Event.h:433
constexpr T const * data() const
Definition: SimpleVector.h:111
StreamID streamID() const
Definition: Event.h:98
std::unique_ptr< T, impl::HostDeleter > unique_ptr
const SiPixelFormatterErrors * formatterErrors_
tmp
align.sh
Definition: createJobs.py:716
cms::cuda::host::unique_ptr< SiPixelErrorCompact[]> data_
~SiPixelDigiErrorsSoAFromCUDA() override=default