CMS 3D CMS Logo

LSTESData.h
Go to the documentation of this file.
1 #ifndef RecoTracker_LSTCore_interface_LSTESData_h
2 #define RecoTracker_LSTCore_interface_LSTESData_h
3 
8 
10 
11 #include <memory>
12 
13 namespace lst {
14 
15  template <typename TDev>
16  struct LSTESData {
17  uint16_t nModules;
18  uint16_t nLowerModules;
19  unsigned int nPixels;
20  unsigned int nEndCapMap;
21  // Using shared_ptr so that for the serial backend all streams can use the same data
22  std::shared_ptr<const PortableMultiCollection<TDev, ModulesSoA, ModulesPixelSoA>> modules;
23  std::shared_ptr<const PortableCollection<EndcapGeometryDevSoA, TDev>> endcapGeometry;
24  // Host-side object that is shared between the LSTESData<TDev> objects for different devices
25  std::shared_ptr<const PixelMap> pixelMapping;
26 
27  LSTESData(uint16_t const& nModulesIn,
28  uint16_t const& nLowerModulesIn,
29  unsigned int const& nPixelsIn,
30  unsigned int const& nEndCapMapIn,
31  std::shared_ptr<const PortableMultiCollection<TDev, ModulesSoA, ModulesPixelSoA>> modulesIn,
32  std::shared_ptr<const PortableCollection<EndcapGeometryDevSoA, TDev>> endcapGeometryIn,
33  std::shared_ptr<const PixelMap> const& pixelMappingIn)
34  : nModules(nModulesIn),
35  nLowerModules(nLowerModulesIn),
36  nPixels(nPixelsIn),
37  nEndCapMap(nEndCapMapIn),
38  modules(std::move(modulesIn)),
39  endcapGeometry(std::move(endcapGeometryIn)),
40  pixelMapping(pixelMappingIn) {}
41  };
42 
43  std::unique_ptr<LSTESData<alpaka_common::DevHost>> loadAndFillESHost();
44 
45 } // namespace lst
46 
47 namespace cms::alpakatools {
48 
49  template <>
50  struct CopyToDevice<lst::LSTESData<alpaka_common::DevHost>> {
51  template <typename TQueue>
54  using TDev = alpaka::Dev<TQueue>;
55  std::shared_ptr<const PortableMultiCollection<TDev, lst::ModulesSoA, lst::ModulesPixelSoA>> deviceModules;
56  std::shared_ptr<const PortableCollection<lst::EndcapGeometryDevSoA, TDev>> deviceEndcapGeometry;
57 
58  if constexpr (std::is_same_v<TDev, alpaka_common::DevHost>) {
59  deviceModules = srcData.modules;
60  deviceEndcapGeometry = srcData.endcapGeometry;
61  } else {
62  deviceModules = std::make_shared<PortableMultiCollection<TDev, lst::ModulesSoA, lst::ModulesPixelSoA>>(
64  queue, *srcData.modules));
65  deviceEndcapGeometry = std::make_shared<PortableCollection<lst::EndcapGeometryDevSoA, TDev>>(
67  }
68 
70  srcData.nLowerModules,
71  srcData.nPixels,
72  srcData.nEndCapMap,
73  std::move(deviceModules),
74  std::move(deviceEndcapGeometry),
75  srcData.pixelMapping);
76  }
77  };
78 } // namespace cms::alpakatools
79 
80 #endif
std::shared_ptr< const PixelMap > pixelMapping
Definition: LSTESData.h:25
static lst::LSTESData< alpaka::Dev< TQueue > > copyAsync(TQueue &queue, lst::LSTESData< alpaka_common::DevHost > const &srcData)
Definition: LSTESData.h:52
Definition: Common.h:15
typename traits::PortableMultiCollectionTrait< TDev, T0, Args... >::CollectionType PortableMultiCollection
std::shared_ptr< const PortableMultiCollection< TDev, ModulesSoA, ModulesPixelSoA > > modules
Definition: LSTESData.h:22
std::unique_ptr< LSTESData< alpaka_common::DevHost > > loadAndFillESHost()
Definition: LSTESData.cc:81
unsigned int nPixels
Definition: LSTESData.h:19
void copyAsync(device::unique_ptr< T > &dst, const host::unique_ptr< T > &src, cudaStream_t stream)
Definition: copyAsync.h:20
uint16_t nModules
Definition: LSTESData.h:17
unsigned int nEndCapMap
Definition: LSTESData.h:20
std::shared_ptr< const PortableCollection< EndcapGeometryDevSoA, TDev > > endcapGeometry
Definition: LSTESData.h:23
LSTESData(uint16_t const &nModulesIn, uint16_t const &nLowerModulesIn, unsigned int const &nPixelsIn, unsigned int const &nEndCapMapIn, std::shared_ptr< const PortableMultiCollection< TDev, ModulesSoA, ModulesPixelSoA >> modulesIn, std::shared_ptr< const PortableCollection< EndcapGeometryDevSoA, TDev >> endcapGeometryIn, std::shared_ptr< const PixelMap > const &pixelMappingIn)
Definition: LSTESData.h:27
typename traits::PortableCollectionTrait< T, TDev >::CollectionType PortableCollection
uint16_t nLowerModules
Definition: LSTESData.h:18
def move(src, dest)
Definition: eostools.py:511