CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HeterogeneousHGCalHEFCellPositionsConditions.h
Go to the documentation of this file.
1 #ifndef CondFormats_HGCalObjects_HeterogeneousHGCalHEFConditions_h
2 #define CondFormats_HGCalObjects_HeterogeneousHGCalHEFConditions_h
3 
4 #include <numeric> //accumulate
5 #include <typeinfo>
6 
13 
14 namespace cpar = hgcal_conditions::parameters;
15 namespace cpos = hgcal_conditions::positions;
16 
17 // Declare the wrapper ESProduct. The corresponding ESProducer should
18 // produce objects of this type.
20 public:
21  // Constructor takes the standard CPU ESProduct, and transforms the
22  // necessary data to array(s) in pinned host memory
24 
25  // Deallocates all pinned host memory
27 
28  // Function to return the actual payload on the memory of the current device
30  cudaStream_t stream) const;
31 
32 private:
33  // Holds the data in pinned CPU memory
34  // Contrary to its non-heterogeneous counterpart (constructor argument) it is *not* a pointer (so to avoid an extra allocation)
37 
38  std::vector<size_t> sizes_;
39  size_t chunk_;
40  const size_t number_position_arrays =
41  2; //x and y; required due to the assymetry between cpos::HeterogeneousHGCalPositionsMapping and cpos::HGCalPositionsMapping
42 
44  size_t allocate_memory_(const std::vector<size_t>&);
47 
48  /*methods for managing SoA's pointers*/
49  //float
50  float*& select_pointer_f_(cpos::HeterogeneousHGCalPositionsMapping*, const unsigned int&) const;
51  std::vector<float>& select_pointer_f_(cpos::HGCalPositionsMapping*, const unsigned int&);
52  //int32_t
53  int32_t*& select_pointer_i_(cpos::HeterogeneousHGCalPositionsMapping*, const unsigned int&) const;
54  std::vector<int32_t>& select_pointer_i_(cpos::HGCalPositionsMapping*, const unsigned int&);
55  //uint32_t
56  uint32_t*& select_pointer_u_(cpos::HeterogeneousHGCalPositionsMapping*, const unsigned int&) const;
57  std::vector<uint32_t>& select_pointer_u_(cpos::HGCalPositionsMapping*, const unsigned int&);
58 
59  // Helper struct to hold all information that has to be allocated and
60  // deallocated per device
61  struct GPUData {
62  // Destructor should free all member pointers
63  ~GPUData();
64  // internal pointers are on device, struct itself is on CPU
66  // internal pounters and struct are on device
68  };
69 
70  // Helper that takes care of complexity of transferring the data to
71  // multiple devices
73 };
74 
75 #endif //CondFormats_HGCalObjects_HeterogeneousHGCalHEFConditions_h
hgcal_conditions::HeterogeneousHEFCellPositionsConditionsESProduct * device
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
void transfer_data_to_heterogeneous_pointers_(const std::vector< size_t > &, cpos::HGCalPositionsMapping *)
float *& select_pointer_f_(cpos::HeterogeneousHGCalPositionsMapping *, const unsigned int &) const
int32_t *& select_pointer_i_(cpos::HeterogeneousHGCalPositionsMapping *, const unsigned int &) const
hgcal_conditions::HeterogeneousHEFCellPositionsConditionsESProduct const * getHeterogeneousConditionsESProductAsync(cudaStream_t stream) const
void transfer_data_to_heterogeneous_vars_(const cpos::HGCalPositionsMapping *)
std::vector< size_t > calculate_memory_bytes_(cpos::HGCalPositionsMapping *)
uint32_t *& select_pointer_u_(cpos::HeterogeneousHGCalPositionsMapping *, const unsigned int &) const
hgcal_conditions::HeterogeneousHEFCellPositionsConditionsESProduct * host