CMS 3D CMS Logo

TestAlpakaESProducerC.cc
Go to the documentation of this file.
14 
22  public:
24  {
26  token_ = cc.consumes();
27  }
28  {
30  hostToken_ = cc.consumes();
31  }
32  }
33 
34  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
36  descriptions.addWithDefaultLabel(desc);
37  }
38 
39  std::optional<AlpakaESTestDataCHost> produceHost(AlpakaESTestRecordC const& iRecord) {
40  auto const& input = iRecord.get(token_);
41 
42  int const size = 5;
43  // TODO: pinned allocation?
44  // TODO: cached allocation?
46  for (int i = 0; i < size; ++i) {
47  product.view()[i].x() = input.value() - i;
48  }
49  return product;
50  }
51 
52  // TODO: in principle in this model the transfer to device could be automated
53  std::optional<AlpakaESTestDataCDevice> produceDevice(device::Record<AlpakaESTestRecordC> const& iRecord) {
54  auto hostHandle = iRecord.getTransientHandle(hostToken_);
55  auto const& hostProduct = *hostHandle;
56  AlpakaESTestDataCDevice deviceProduct(hostProduct->metadata().size(), iRecord.queue());
57  alpaka::memcpy(iRecord.queue(), deviceProduct.buffer(), hostProduct.buffer());
58 
59  return deviceProduct;
60  }
61 
62  private:
65  };
66 } // namespace ALPAKA_ACCELERATOR_NAMESPACE
67 
68 DEFINE_FWK_EVENTSETUP_ALPAKA_MODULE(TestAlpakaESProducerC);
size
Write out results.
std::optional< AlpakaESTestDataCDevice > produceDevice(device::Record< AlpakaESTestRecordC > const &iRecord)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
std::optional< AlpakaESTestDataCHost > produceHost(AlpakaESTestRecordC const &iRecord)
edm::ESGetToken< AlpakaESTestDataCHost, AlpakaESTestRecordC > hostToken_
static std::string const input
Definition: EdmProvDump.cc:50
edm::ESGetToken< cms::alpakatest::ESTestDataC, AlpakaESTestRecordC > token_
PRODUCT const & get(ESGetToken< PRODUCT, T > const &iToken) const
alpaka::DevCpu const & host()
Definition: host.h:24
auto setWhatProduced(T *iThis, edm::es::Label const &label={})
Definition: ESProducer.h:28
#define DEFINE_FWK_EVENTSETUP_ALPAKA_MODULE(type)
Definition: ModuleFactory.h:9
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::ESTransientHandle< TProduct > getTransientHandle(edm::ESGetToken< TProduct, TDepRecord > const &iToken) const
Definition: Record.h:58