CMS 3D CMS Logo

TestAlpakaStreamProducer.cc
Go to the documentation of this file.
2 #include "DataFormats/TestObjects/interface/ToyProducts.h"
13 
14 #include "TestAlgo.h"
15 
25  public:
27  : size_{config.getParameter<edm::ParameterSet>("size").getParameter<int32_t>(
29  getToken_ = consumes(config.getParameter<edm::InputTag>("source"));
30  esToken_ = esConsumes(config.getParameter<edm::ESInputTag>("eventSetupSource"));
31  devicePutToken_ = produces(config.getParameter<std::string>("productInstanceName"));
32  }
33 
34  void produce(device::Event& iEvent, device::EventSetup const& iSetup) override {
35  [[maybe_unused]] auto inpData = iEvent.getHandle(getToken_);
36  [[maybe_unused]] auto const& esData = iSetup.getData(esToken_);
37 
38  auto deviceProduct = std::make_unique<portabletest::TestDeviceCollection>(size_, iEvent.queue());
39 
40  // run the algorithm, potentially asynchronously
41  algo_.fill(iEvent.queue(), *deviceProduct);
42 
43  iEvent.put(devicePutToken_, std::move(deviceProduct));
44  }
45 
46  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
48  desc.add<edm::InputTag>("source");
49  desc.add("eventSetupSource", edm::ESInputTag{});
50  desc.add<std::string>("productInstanceName", "");
51 
53  psetSize.add<int32_t>("alpaka_serial_sync");
54  psetSize.add<int32_t>("alpaka_cuda_async");
55  psetSize.add<int32_t>("alpaka_rocm_async");
56  desc.add("size", psetSize);
57 
58  descriptions.addWithDefaultLabel(desc);
59  }
60 
61  private:
65  const int32_t size_;
66 
67  // implementation of the algorithm
69  };
70 
71 } // namespace ALPAKA_ACCELERATOR_NAMESPACE
72 
74 DEFINE_FWK_ALPAKA_MODULE(TestAlpakaStreamProducer);
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: config.py:1
int iEvent
Definition: GenABIO.cc:224
device::EDPutToken< portabletest::TestDeviceCollection > devicePutToken_
device::ESGetToken< cms::alpakatest::AlpakaESTestDataB< Device >, AlpakaESTestRecordB > esToken_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void produce(device::Event &iEvent, device::EventSetup const &iSetup) override
T const & getData(edm::ESGetToken< T, R > const &iToken) const
Definition: EventSetup.h:32
void fill(Queue &queue, portabletest::TestDeviceCollection &collection, double xvalue=0.) const
Definition: TestAlgo.dev.cc:41
#define EDM_STRINGIZE(token)
Definition: stringize.h:6
auto produces(std::string instanceName) noexcept
declare what type of product will make and with which optional label
#define DEFINE_FWK_ALPAKA_MODULE(name)
Definition: MakerMacros.h:16
def move(src, dest)
Definition: eostools.py:511