Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-06-05 02:29:02

0001 #ifndef CondFormats_EcalObjects_interface_EcalRecHitParametersGPU_h
0002 #define CondFormats_EcalObjects_interface_EcalRecHitParametersGPU_h
0003 
0004 #include <array>
0005 
0006 #include "FWCore/Utilities/interface/propagate_const_array.h"
0007 #include "HeterogeneousCore/CUDAUtilities/interface/device_unique_ptr.h"
0008 
0009 #ifndef __CUDACC__
0010 #include "HeterogeneousCore/CUDAUtilities/interface/HostAllocator.h"
0011 #include "HeterogeneousCore/CUDACore/interface/ESProduct.h"
0012 #endif  // __CUDACC__
0013 
0014 class EcalRecHitParametersGPU {
0015 public:
0016   struct Product {
0017     edm::propagate_const_array<cms::cuda::device::unique_ptr<int[]>> channelStatusToBeExcluded;
0018     edm::propagate_const_array<cms::cuda::device::unique_ptr<int[]>> expanded_v_DB_reco_flags;
0019     edm::propagate_const_array<cms::cuda::device::unique_ptr<uint32_t[]>> expanded_Sizes_v_DB_reco_flags;
0020     edm::propagate_const_array<cms::cuda::device::unique_ptr<uint32_t[]>> expanded_flagbit_v_DB_reco_flags;
0021   };
0022 
0023 #ifndef __CUDACC__
0024   struct DBStatus {
0025     DBStatus(int flag, std::vector<uint32_t> status) : recoflagbit{flag}, dbstatus(std::move(status)) {}
0026     int recoflagbit;                 //must be a EcalRecHit::Flags
0027     std::vector<uint32_t> dbstatus;  //must contain EcalChannelStatusCode::Code
0028   };
0029 
0030   /// channelStatusToBeExcluded must contain EcalChannelStatusCode::Code
0031   EcalRecHitParametersGPU(std::vector<int> const& channelStatusToBeExcluded,
0032                           std::vector<DBStatus> const& flagsMapDBReco);
0033 
0034   ~EcalRecHitParametersGPU() = default;
0035 
0036   Product const& getProduct(cudaStream_t) const;
0037 
0038   using intvec = std::reference_wrapper<std::vector<int, cms::cuda::HostAllocator<int>> const>;
0039   using uint32vec = std::reference_wrapper<std::vector<uint32_t, cms::cuda::HostAllocator<uint32_t>> const>;
0040   std::tuple<intvec, intvec, uint32vec, uint32vec> getValues() const {
0041     return {channelStatusToBeExcluded_,
0042             expanded_v_DB_reco_flags_,
0043             expanded_Sizes_v_DB_reco_flags_,
0044             expanded_flagbit_v_DB_reco_flags_};
0045   }
0046 
0047 private:
0048   std::vector<int, cms::cuda::HostAllocator<int>> channelStatusToBeExcluded_;
0049   std::vector<int, cms::cuda::HostAllocator<int>> expanded_v_DB_reco_flags_;
0050   std::vector<uint32_t, cms::cuda::HostAllocator<uint32_t>> expanded_Sizes_v_DB_reco_flags_,
0051       expanded_flagbit_v_DB_reco_flags_;
0052 
0053   cms::cuda::ESProduct<Product> product_;
0054 #endif  // __CUDACC__
0055 };
0056 
0057 #endif  // CondFormats_EcalObjects_interface_EcalRecHitParametersGPU_h