CMS 3D CMS Logo

TestAlpakaESProducerB.cc
Go to the documentation of this file.
11 
19  public:
21  {
23  token_ = cc.consumes();
24  }
25  {
27  hostToken_ = cc.consumes();
28  }
29  }
30 
31  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
33  descriptions.addWithDefaultLabel(desc);
34  }
35 
36  std::optional<cms::alpakatest::AlpakaESTestDataB<DevHost>> produceHost(AlpakaESTestRecordB const& iRecord) {
37  auto const& input = iRecord.get(token_);
38 
39  int const size = 5;
40  // TODO: cached allocation?
41  auto buffer = cms::alpakatools::make_host_buffer<int[], Platform>(size);
42  for (int i = 0; i < size; ++i) {
43  buffer[i] = i + input.value();
44  }
46  }
47 
48  // TODO: in principle in this model the transfer to device could be automated
49  std::optional<cms::alpakatest::AlpakaESTestDataB<Device>> produceDevice(
50  device::Record<AlpakaESTestRecordB> const& iRecord) {
51  auto hostHandle = iRecord.getTransientHandle(hostToken_);
52  auto buffer = cms::alpakatools::make_device_buffer<int[]>(iRecord.queue(), hostHandle->size());
53  alpaka::memcpy(iRecord.queue(), buffer, hostHandle->buffer());
55  }
56 
57  private:
60  };
61 } // namespace ALPAKA_ACCELERATOR_NAMESPACE
62 
63 DEFINE_FWK_EVENTSETUP_ALPAKA_MODULE(TestAlpakaESProducerB);
size
Write out results.
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
static std::string const input
Definition: EdmProvDump.cc:50
std::optional< cms::alpakatest::AlpakaESTestDataB< Device > > produceDevice(device::Record< AlpakaESTestRecordB > const &iRecord)
PRODUCT const & get(ESGetToken< PRODUCT, T > const &iToken) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::ESGetToken< cms::alpakatest::ESTestDataB, AlpakaESTestRecordB > token_
std::optional< cms::alpakatest::AlpakaESTestDataB< DevHost > > produceHost(AlpakaESTestRecordB const &iRecord)
auto setWhatProduced(T *iThis, edm::es::Label const &label={})
Definition: ESProducer.h:28
#define DEFINE_FWK_EVENTSETUP_ALPAKA_MODULE(type)
Definition: ModuleFactory.h:9
edm::ESGetToken< cms::alpakatest::AlpakaESTestDataB< DevHost >, AlpakaESTestRecordB > hostToken_
edm::ESTransientHandle< TProduct > getTransientHandle(edm::ESGetToken< TProduct, TDepRecord > const &iToken) const
Definition: Record.h:58
def move(src, dest)
Definition: eostools.py:511