CMS 3D CMS Logo

AlpakaESTestData.h
Go to the documentation of this file.
1 #ifndef HeterogeneousCore_AlpakaTest_interface_AlpakaESTestData_h
2 #define HeterogeneousCore_AlpakaTest_interface_AlpakaESTestData_h
3 
9 
10 namespace cms::alpakatest {
11  // PortableCollection-based model
15 
16  // Template-over-device model
17  template <typename TDev>
19  public:
22 
24 
25  Buffer buffer() { return buffer_; }
26  ConstBuffer buffer() const { return buffer_; }
27  ConstBuffer const_buffer() const { return buffer_; }
28 
29  int const* data() const { return buffer_.data(); }
30  auto size() const { return alpaka::getExtentProduct(buffer_); }
31 
32  private:
34  };
35 } // namespace cms::alpakatest
36 
37 namespace cms::alpakatools {
38  // Explicit specialization is needed for the template-over-device model
39  //
40  // PortableCollection-based model gets this for free from PortableCollection itself
41  template <>
42  struct CopyToDevice<cms::alpakatest::AlpakaESTestDataB<alpaka_common::DevHost>> {
43  template <typename TQueue>
45  // TODO: In principle associating the allocation to a queue is
46  // incorrect. Framework will keep the memory alive until the IOV
47  // ends. By that point all asynchronous activity using that
48  // memory has finished, and the memory could be marked as "free"
49  // in the allocator already by the host-side release of the
50  // memory. There could also be other, independent asynchronous
51  // activity going on that uses the same queue (since we don't
52  // retain the queue here), and at the time of host-side release
53  // the device-side release gets associated to the complemention
54  // of that activity (which has nothing to do with the memory here).
55  auto dstBuffer = cms::alpakatools::make_device_buffer<int[]>(queue, srcData.size());
56  alpaka::memcpy(queue, dstBuffer, srcData.buffer());
58  }
59  };
60 } // namespace cms::alpakatools
61 
62 #endif
cms::alpakatools::const_device_buffer< TDev, int[]> ConstBuffer
Namespace of DDCMS conversion namespace.
cms::alpakatools::device_buffer< TDev, int[]> Buffer
static auto copyAsync(TQueue &queue, cms::alpakatest::AlpakaESTestDataB< alpaka_common::DevHost > const &srcData)
typename detail::buffer_type< TDev, T >::type device_buffer
Definition: memory.h:169
def move(src, dest)
Definition: eostools.py:511
alpaka::ViewConst< device_buffer< TDev, T > > const_device_buffer
Definition: memory.h:172