Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-03-30 08:50:57

0001 #ifndef RecoLocalCalo_HGCalRecProducers_KernelManagerHGCalRecHit_h
0002 #define RecoLocalCalo_HGCalRecProducers_KernelManagerHGCalRecHit_h
0003 
0004 #include "HeterogeneousCore/CUDAUtilities/interface/cudaCheck.h"
0005 #include "RecoLocalCalo/HGCalRecProducers/plugins/HGCalRecHitKernelImpl.cuh"
0006 #include "CUDADataFormats/HGCal/interface/HGCConditions.h"
0007 #include "CUDADataFormats/HGCal/interface/HGCRecHitSoA.h"
0008 #include "CUDADataFormats/HGCal/interface/ConstHGCRecHitSoA.h"
0009 
0010 #include <vector>
0011 #include <algorithm>  //std::swap
0012 #include <variant>
0013 #include <cuda.h>
0014 #include <cuda_runtime.h>
0015 
0016 #ifdef __CUDA_ARCH__
0017 extern __constant__ uint32_t calo_rechit_masks[];
0018 #endif
0019 
0020 template <typename T>
0021 class KernelConstantData {
0022 public:
0023   KernelConstantData(T& data, HGCConstantVectorData& vdata) : data_(data), vdata_(vdata) {
0024     static_assert(std::is_same<T, HGCeeUncalibRecHitConstantData>::value or
0025                       std::is_same<T, HGChefUncalibRecHitConstantData>::value or
0026                       std::is_same<T, HGChebUncalibRecHitConstantData>::value,
0027                   "The KernelConstantData class does not support this type.");
0028   }
0029   T data_;
0030   HGCConstantVectorData vdata_;
0031 };
0032 
0033 class KernelManagerHGCalRecHit {
0034 public:
0035   KernelManagerHGCalRecHit();
0036   KernelManagerHGCalRecHit(const HGCUncalibRecHitSoA&, const HGCUncalibRecHitSoA&, const HGCRecHitSoA&);
0037   KernelManagerHGCalRecHit(const HGCRecHitSoA&, const ConstHGCRecHitSoA&);
0038   ~KernelManagerHGCalRecHit();
0039   void run_kernels(const KernelConstantData<HGCeeUncalibRecHitConstantData>*, const cudaStream_t&);
0040   void run_kernels(const KernelConstantData<HGChefUncalibRecHitConstantData>*, const cudaStream_t&);
0041   void run_kernels(const KernelConstantData<HGChebUncalibRecHitConstantData>*, const cudaStream_t&);
0042   void transfer_soa_to_host(const cudaStream_t&);
0043 
0044 private:
0045   void transfer_soa_to_device_(const cudaStream_t&);
0046 
0047   uint32_t nhits_;
0048   uint32_t pad_;
0049   uint32_t nbytes_host_;
0050   uint32_t nbytes_device_;
0051   HGCUncalibRecHitSoA h_uncalibSoA_, d_uncalibSoA_;
0052   HGCRecHitSoA h_calibSoA_, d_calibSoA_;
0053   ConstHGCRecHitSoA d_calibConstSoA_;
0054 };
0055 
0056 #endif  //RecoLocalCalo_HGCalRecProducers_KernelManagerHGCalRecHit_h