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  size2_{config.getParameter<edm::ParameterSet>("size").getParameter<int32_t>(
31  size3_{config.getParameter<edm::ParameterSet>("size").getParameter<int32_t>(
33  getToken_ = consumes(config.getParameter<edm::InputTag>("source"));
34  esToken_ = esConsumes(config.getParameter<edm::ESInputTag>("eventSetupSource"));
35  devicePutToken_ = produces(config.getParameter<std::string>("productInstanceName"));
36  devicePutTokenMulti2_ = produces(config.getParameter<std::string>("productInstanceName"));
37  devicePutTokenMulti3_ = produces(config.getParameter<std::string>("productInstanceName"));
38  }
39 
40  void produce(device::Event& iEvent, device::EventSetup const& iSetup) override {
41  [[maybe_unused]] auto inpData = iEvent.getHandle(getToken_);
42  [[maybe_unused]] auto const& esData = iSetup.getData(esToken_);
43 
44  auto deviceProduct = std::make_unique<portabletest::TestDeviceCollection>(size_, iEvent.queue());
45  auto deviceProductMulti2 = std::make_unique<portabletest::TestDeviceMultiCollection2>(
47  auto deviceProductMulti3 = std::make_unique<portabletest::TestDeviceMultiCollection3>(
49 
50  // run the algorithm, potentially asynchronously
51  algo_.fill(iEvent.queue(), *deviceProduct);
52  algo_.fillMulti2(iEvent.queue(), *deviceProductMulti2);
53  algo_.fillMulti3(iEvent.queue(), *deviceProductMulti3);
54 
55  iEvent.put(devicePutToken_, std::move(deviceProduct));
56  iEvent.put(devicePutTokenMulti2_, std::move(deviceProductMulti2));
57  iEvent.put(devicePutTokenMulti3_, std::move(deviceProductMulti3));
58  }
59 
60  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
62  desc.add<edm::InputTag>("source");
63  desc.add("eventSetupSource", edm::ESInputTag{});
64  desc.add<std::string>("productInstanceName", "");
65 
67  psetSize.add<int32_t>("alpaka_serial_sync");
68  psetSize.add<int32_t>("alpaka_cuda_async");
69  psetSize.add<int32_t>("alpaka_rocm_async");
70  desc.add("size", psetSize);
71 
72  descriptions.addWithDefaultLabel(desc);
73  }
74 
75  private:
81  const int32_t size_;
82  const int32_t size2_;
83  const int32_t size3_;
84 
85  // implementation of the algorithm
87  };
88 
89 } // namespace ALPAKA_ACCELERATOR_NAMESPACE
90 
92 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
void fillMulti2(Queue &queue, portabletest::TestDeviceMultiCollection2 &collection, double xvalue=0.) const
Definition: TestAlgo.dev.cc:98
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:83
#define EDM_STRINGIZE(token)
Definition: stringize.h:6
device::EDPutToken< portabletest::TestDeviceMultiCollection3 > devicePutTokenMulti3_
std::array< int32_t, members_ > SizesArray
device::EDPutToken< portabletest::TestDeviceMultiCollection2 > devicePutTokenMulti2_
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
void fillMulti3(Queue &queue, portabletest::TestDeviceMultiCollection3 &collection, double xvalue=0.) const
def move(src, dest)
Definition: eostools.py:511