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)
29  auto start_d =
31  alpaka::memcpy(queue, start_d, start_h);
32 
35  alpaka::memcpy(queue, off_d, off_h);
36  }
37 
38  uint32_t nHits() const { return view().metadata().size(); }
39 
40  int32_t offsetBPIX2() const { return offsetBPIX2_; }
41 
42  uint32_t const* hitsModuleStart() const { return view().hitsModuleStart().data(); }
43 
44  // asynchronously update the information cached within the class itself from the information on the device
45  template <typename TQueue>
46  void updateFromDevice(TQueue queue) {
49  alpaka::memcpy(queue, off_h, off_d);
50  }
51 
52 private:
53  // offsetBPIX2 is used on host functions so is useful to have it also stored in the class and not only in the layout
54  int32_t offsetBPIX2_ = 0;
55 };
56 
57 #endif // DataFormats_RecHits_interface_TrackingRecHitSoADevice_h
typename TrackingRecHitSoA< TrackerTraits >::template TrackingRecHitSoALayout<> TrackingRecHitLayout
std::enable_if_t< alpaka::isDevice< TDev > and 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