Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "CondFormats/EcalObjects/interface/EcalMultifitParametersGPU.h"
0002 
0003 #include "FWCore/Utilities/interface/typelookup.h"
0004 #include "HeterogeneousCore/CUDAUtilities/interface/copyAsync.h"
0005 
0006 EcalMultifitParametersGPU::EcalMultifitParametersGPU(std::vector<double> const& amplitudeFitParametersEB,
0007                                                      std::vector<double> const& amplitudeFitParametersEE,
0008                                                      std::vector<double> const& timeFitParametersEB,
0009                                                      std::vector<double> const& timeFitParametersEE) {
0010   amplitudeFitParametersEB_.resize(amplitudeFitParametersEB.size());
0011   amplitudeFitParametersEE_.resize(amplitudeFitParametersEE.size());
0012   timeFitParametersEB_.resize(timeFitParametersEB.size());
0013   timeFitParametersEE_.resize(timeFitParametersEE.size());
0014 
0015   std::copy(amplitudeFitParametersEB.begin(), amplitudeFitParametersEB.end(), amplitudeFitParametersEB_.begin());
0016   std::copy(amplitudeFitParametersEE.begin(), amplitudeFitParametersEE.end(), amplitudeFitParametersEE_.begin());
0017   std::copy(timeFitParametersEB.begin(), timeFitParametersEB.end(), timeFitParametersEB_.begin());
0018   std::copy(timeFitParametersEE.begin(), timeFitParametersEE.end(), timeFitParametersEE_.begin());
0019 }
0020 
0021 EcalMultifitParametersGPU::Product const& EcalMultifitParametersGPU::getProduct(cudaStream_t cudaStream) const {
0022   auto const& product = product_.dataForCurrentDeviceAsync(
0023       cudaStream, [this](EcalMultifitParametersGPU::Product& product, cudaStream_t cudaStream) {
0024         // allocate
0025         product.amplitudeFitParametersEB =
0026             cms::cuda::make_device_unique<double[]>(amplitudeFitParametersEB_.size(), cudaStream);
0027         product.amplitudeFitParametersEE =
0028             cms::cuda::make_device_unique<double[]>(amplitudeFitParametersEE_.size(), cudaStream);
0029         product.timeFitParametersEB = cms::cuda::make_device_unique<double[]>(timeFitParametersEB_.size(), cudaStream);
0030         product.timeFitParametersEE = cms::cuda::make_device_unique<double[]>(timeFitParametersEE_.size(), cudaStream);
0031         // transfer
0032         cms::cuda::copyAsync(product.amplitudeFitParametersEB, amplitudeFitParametersEB_, cudaStream);
0033         cms::cuda::copyAsync(product.amplitudeFitParametersEE, amplitudeFitParametersEE_, cudaStream);
0034         cms::cuda::copyAsync(product.timeFitParametersEB, timeFitParametersEB_, cudaStream);
0035         cms::cuda::copyAsync(product.timeFitParametersEE, timeFitParametersEE_, cudaStream);
0036       });
0037   return product;
0038 }
0039 
0040 TYPELOOKUP_DATA_REG(EcalMultifitParametersGPU);