CMS 3D CMS Logo

TestPortableTranscriber.cc
Go to the documentation of this file.
16 
17 class TestPortableTranscriber : public edm::stream::EDProducer<edm::ExternalWork> {
18 public:
20  : deviceToken_{consumes(config.getParameter<edm::InputTag>("source"))}, hostToken_{produces()} {}
21 
23  // create a context reusing the same device and queue as the producer of the input collection
24  auto const& input = event.get(deviceToken_);
26 
27  cudatest::TestDeviceCollection const& deviceProduct = ctx.get(input);
28 
29  // allocate a host product based on the metadata of the device product
30  hostProduct_ = cudatest::TestHostCollection{deviceProduct->metadata().size(), ctx.stream()};
31 
32  // copy the content of the device product to the host product
33  cms::cuda::copyAsync(hostProduct_.buffer(), deviceProduct.const_buffer(), deviceProduct.bufferSize(), ctx.stream());
34 
35  // do not wait for the asynchronous operation to complete
36  }
37 
38  void produce(edm::Event& event, edm::EventSetup const&) override {
39  // produce() is called once the asynchronous operation has completed, so there is no need for an explicit wait
40  event.emplace(hostToken_, std::move(hostProduct_));
41  }
42 
43  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
45  desc.add<edm::InputTag>("source");
46  descriptions.addWithDefaultLabel(desc);
47  }
48 
49 private:
52 
53  // hold the output product between acquire() and produce()
55 };
56 
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
Definition: config.py:1
const edm::EDGetTokenT< cms::cuda::Product< cudatest::TestDeviceCollection > > deviceToken_
static std::string const input
Definition: EdmProvDump.cc:50
void produce(edm::Event &event, edm::EventSetup const &) override
TestPortableTranscriber(edm::ParameterSet const &config)
void copyAsync(device::unique_ptr< T > &dst, const host::unique_ptr< T > &src, cudaStream_t stream)
Definition: copyAsync.h:20
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::EDPutTokenT< cudatest::TestHostCollection > hostToken_
void acquire(edm::Event const &event, edm::EventSetup const &setup, edm::WaitingTaskWithArenaHolder task) override
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1
cudatest::TestHostCollection hostProduct_