CMS 3D CMS Logo

PixelVertexSoAFromCUDA.cc
Go to the documentation of this file.
1 #include <cuda_runtime.h>
2 
20 
21 class PixelVertexSoAFromCUDA : public edm::stream::EDProducer<edm::ExternalWork> {
22 public:
23  explicit PixelVertexSoAFromCUDA(const edm::ParameterSet& iConfig);
24  ~PixelVertexSoAFromCUDA() override = default;
25 
26  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
27 
28 private:
29  void acquire(edm::Event const& iEvent,
30  edm::EventSetup const& iSetup,
31  edm::WaitingTaskWithArenaHolder waitingTaskHolder) override;
32  void produce(edm::Event& iEvent, edm::EventSetup const& iSetup) override;
33 
36 
38 };
39 
41  : tokenCUDA_(consumes<cms::cuda::Product<ZVertexSoADevice>>(iConfig.getParameter<edm::InputTag>("src"))),
42  tokenSOA_(produces<ZVertexSoAHost>()) {}
43 
46 
47  desc.add<edm::InputTag>("src", edm::InputTag("pixelVerticesCUDA"));
48  descriptions.add("pixelVerticesSoA", desc);
49 }
50 
52  edm::EventSetup const& iSetup,
53  edm::WaitingTaskWithArenaHolder waitingTaskHolder) {
54  cms::cuda::Product<ZVertexSoADevice> const& inputDataWrapped = iEvent.get(tokenCUDA_);
55  cms::cuda::ScopedContextAcquire ctx{inputDataWrapped, std::move(waitingTaskHolder)};
56  auto const& zvertex_d = ctx.get(inputDataWrapped); // Tracks on device
57  zvertex_h = ZVertexSoAHost(ctx.stream()); // Create an instance of Tracks on Host, using the stream
58  cudaCheck(cudaMemcpyAsync(zvertex_h.buffer().get(),
59  zvertex_d.const_buffer().get(),
60  zvertex_d.bufferSize(),
61  cudaMemcpyDeviceToHost,
62  ctx.stream())); // Copy data from Device to Host
63 }
64 
66  // No copies....
68 }
69 
edm::EDGetTokenT< cms::cuda::Product< ZVertexSoADevice > > tokenCUDA_
int iEvent
Definition: GenABIO.cc:224
void acquire(edm::Event const &iEvent, edm::EventSetup const &iSetup, edm::WaitingTaskWithArenaHolder waitingTaskHolder) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
~PixelVertexSoAFromCUDA() override=default
edm::EDPutTokenT< ZVertexSoAHost > tokenSOA_
PixelVertexSoAFromCUDA(const edm::ParameterSet &iConfig)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Namespace of DDCMS conversion namespace.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void produce(edm::Event &iEvent, edm::EventSetup const &iSetup) override
HLT enums.
ZVertexSoAHeterogeneousHost< zVertex::utilities::MAXTRACKS > ZVertexSoAHost
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:69
def move(src, dest)
Definition: eostools.py:511