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  // Model 1
15 
16  // Model 2
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  template <>
39  struct CopyToDevice<cms::alpakatest::AlpakaESTestDataB<alpaka_common::DevHost>> {
40  template <typename TQueue>
42  // TODO: In principle associating the allocation to a queue is
43  // incorrect. Framework will keep the memory alive until the IOV
44  // ends. By that point all asynchronous activity using that
45  // memory has finished, and the memory could be marked as "free"
46  // in the allocator already by the host-side release of the
47  // memory. There could also be other, independent asynchronous
48  // activity going on that uses the same queue (since we don't
49  // retain the queue here), and at the time of host-side release
50  // the device-side release gets associated to the complemention
51  // of that activity (which has nothing to do with the memory here).
52  auto dstBuffer = cms::alpakatools::make_device_buffer<int[]>(queue, srcData.size());
53  alpaka::memcpy(queue, dstBuffer, srcData.buffer());
55  }
56  };
57 } // namespace cms::alpakatools
58 
59 #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