CMS 3D CMS Logo

TrackingRecHitsDevice.h
Go to the documentation of this file.
1 #ifndef DataFormats_TrackingRecHitSoA_interface_TrackingRecHitSoADevice_h
2 #define DataFormats_TrackingRecHitSoA_interface_TrackingRecHitSoADevice_h
3 
4 #include <cstdint>
5 
6 #include <alpaka/alpaka.hpp>
7 
11 
12 template <typename TrackerTraits, typename TDev>
13 class TrackingRecHitDevice : public PortableDeviceCollection<TrackingRecHitLayout<TrackerTraits>, TDev> {
14 public:
16 
17  // Need to decorate the class with the inherited portable accessors being now a template
21 
22  TrackingRecHitDevice() = default;
23 
24  // Constructor which specifies the SoA size, number of BPIX1 hits, and the modules entry points
25  template <typename TQueue>
26  explicit TrackingRecHitDevice(TQueue queue, uint32_t nHits, int32_t offsetBPIX2, uint32_t const* hitsModuleStart)
28  const auto device = alpaka::getDev(queue);
29 
31  auto start_d =
33  alpaka::memcpy(queue, start_d, start_h);
34 
36  auto off_d = cms::alpakatools::make_device_view(device, view().offsetBPIX2());
37  alpaka::memcpy(queue, off_d, off_h);
39  }
40 
41  uint32_t nHits() const { return view().metadata().size(); }
42 
43  int32_t offsetBPIX2() const { return offsetBPIX2_; }
44 
45  uint32_t const* hitsModuleStart() const { return view().hitsModuleStart().data(); }
46 
47  // asynchronously update the information cached within the class itself from the information on the device
48  template <typename TQueue>
49  void updateFromDevice(TQueue queue) {
51  auto off_d = cms::alpakatools::make_device_view(alpaka::getDev(queue), view().offsetBPIX2());
52  alpaka::memcpy(queue, off_h, off_d);
53  }
54 
55 private:
56  // offsetBPIX2 is used on host functions so is useful to have it also stored in the class and not only in the layout
57  int32_t offsetBPIX2_ = 0;
58 };
59 
60 #endif // DataFormats_RecHits_interface_TrackingRecHitSoADevice_h
typename TrackingRecHitSoA< TrackerTraits >::template TrackingRecHitSoALayout<> TrackingRecHitLayout
std::enable_if_t< not std::is_array_v< T >, device_view< TDev, T > > make_device_view(TDev const &device, T &data)
Definition: memory.h:260
constexpr uint16_t numberOfModules
TrackingRecHitDevice()=default
void updateFromDevice(TQueue queue)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
TrackingRecHitDevice(TQueue queue, uint32_t nHits, int32_t offsetBPIX2, uint32_t const *hitsModuleStart)
std::enable_if_t< not std::is_array_v< T >, host_view< T > > make_host_view(T &data)
Definition: memory.h:153
uint32_t const * hitsModuleStart() const