EcalLinearCorrectionsGPU

Product

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
#ifndef CondFormats_EcalObjects_interface_EcalLinearCorrectionsGPU_h
#define CondFormats_EcalObjects_interface_EcalLinearCorrectionsGPU_h

#include "CondFormats/EcalObjects/interface/EcalLinearCorrections.h"
#include "FWCore/Utilities/interface/propagate_const_array.h"
#include "HeterogeneousCore/CUDAUtilities/interface/device_unique_ptr.h"

#ifndef __CUDACC__
#include "HeterogeneousCore/CUDAUtilities/interface/HostAllocator.h"
#include "HeterogeneousCore/CUDACore/interface/ESProduct.h"
#endif  // __CUDACC__

class EcalLinearCorrectionsGPU {
public:
  struct Product {
    edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> p1;
    edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> p2;
    edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> p3;
    edm::propagate_const_array<cms::cuda::device::unique_ptr<edm::TimeValue_t[]>> t1;
    edm::propagate_const_array<cms::cuda::device::unique_ptr<edm::TimeValue_t[]>> t2;
    edm::propagate_const_array<cms::cuda::device::unique_ptr<edm::TimeValue_t[]>> t3;
  };

#ifndef __CUDACC__

  //
  EcalLinearCorrectionsGPU(EcalLinearCorrections const &);

  // will call dealloation for Product thru ~Product
  ~EcalLinearCorrectionsGPU() = default;

  // get device pointers
  Product const &getProduct(cudaStream_t) const;

  //
  static std::string name() { return std::string{"ecalLinearCorrectionsGPU"}; }

private:
  // in the future, we need to arrange so to avoid this copy on the host
  // store eb first then ee
  std::vector<float, cms::cuda::HostAllocator<float>> p1_;
  std::vector<float, cms::cuda::HostAllocator<float>> p2_;
  std::vector<float, cms::cuda::HostAllocator<float>> p3_;

  std::vector<edm::TimeValue_t, cms::cuda::HostAllocator<edm::TimeValue_t>> t1_;
  std::vector<edm::TimeValue_t, cms::cuda::HostAllocator<edm::TimeValue_t>> t2_;
  std::vector<edm::TimeValue_t, cms::cuda::HostAllocator<edm::TimeValue_t>> t3_;

  cms::cuda::ESProduct<Product> product_;

#endif  // __CUDACC__
};

#endif  // CondFormats_EcalObjects_interface_EcalLinearCorrectionsGPU_h