Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-03-25 10:54:41

0001 #include "CondFormats/EcalObjects/interface/EcalTimeBiasCorrectionsGPU.h"
0002 
0003 #include "FWCore/Utilities/interface/typelookup.h"
0004 #include "HeterogeneousCore/CUDAUtilities/interface/copyAsync.h"
0005 
0006 EcalTimeBiasCorrectionsGPU::EcalTimeBiasCorrectionsGPU(EcalTimeBiasCorrections const& values) {
0007   ebTimeCorrAmplitudeBins_.reserve(values.EBTimeCorrAmplitudeBins.size());
0008   for (const auto& ebTimeCorrAmplitudeBin : values.EBTimeCorrAmplitudeBins) {
0009     ebTimeCorrAmplitudeBins_.emplace_back(ebTimeCorrAmplitudeBin);
0010   }
0011 
0012   ebTimeCorrShiftBins_.reserve(values.EBTimeCorrAmplitudeBins.size());
0013   for (const auto& ebTimeCorrShiftBin : values.EBTimeCorrShiftBins) {
0014     ebTimeCorrShiftBins_.emplace_back(ebTimeCorrShiftBin);
0015   }
0016 
0017   eeTimeCorrAmplitudeBins_.reserve(values.EETimeCorrAmplitudeBins.size());
0018   for (const auto& eeTimeCorrAmplitudeBin : values.EETimeCorrAmplitudeBins) {
0019     eeTimeCorrAmplitudeBins_.emplace_back(eeTimeCorrAmplitudeBin);
0020   }
0021 
0022   eeTimeCorrShiftBins_.reserve(values.EETimeCorrAmplitudeBins.size());
0023   for (const auto& eeTimeCorrShiftBin : values.EETimeCorrShiftBins) {
0024     eeTimeCorrShiftBins_.emplace_back(eeTimeCorrShiftBin);
0025   }
0026 }
0027 
0028 EcalTimeBiasCorrectionsGPU::Product const& EcalTimeBiasCorrectionsGPU::getProduct(cudaStream_t cudaStream) const {
0029   auto const& product = product_.dataForCurrentDeviceAsync(
0030       cudaStream, [this](EcalTimeBiasCorrectionsGPU::Product& product, cudaStream_t cudaStream) {
0031         // to get the size of vectors later on
0032         // should be removed and host conditions' objects used directly
0033         product.ebTimeCorrAmplitudeBinsSize = this->ebTimeCorrAmplitudeBins_.size();
0034         product.eeTimeCorrAmplitudeBinsSize = this->eeTimeCorrAmplitudeBins_.size();
0035 
0036         // allocate
0037         product.ebTimeCorrAmplitudeBins =
0038             cms::cuda::make_device_unique<float[]>(ebTimeCorrAmplitudeBins_.size(), cudaStream);
0039         product.ebTimeCorrShiftBins = cms::cuda::make_device_unique<float[]>(ebTimeCorrShiftBins_.size(), cudaStream);
0040         product.eeTimeCorrAmplitudeBins =
0041             cms::cuda::make_device_unique<float[]>(eeTimeCorrAmplitudeBins_.size(), cudaStream);
0042         product.eeTimeCorrShiftBins = cms::cuda::make_device_unique<float[]>(eeTimeCorrShiftBins_.size(), cudaStream);
0043         // transfer
0044         cms::cuda::copyAsync(product.ebTimeCorrAmplitudeBins, ebTimeCorrAmplitudeBins_, cudaStream);
0045         cms::cuda::copyAsync(product.ebTimeCorrShiftBins, ebTimeCorrShiftBins_, cudaStream);
0046         cms::cuda::copyAsync(product.eeTimeCorrAmplitudeBins, eeTimeCorrAmplitudeBins_, cudaStream);
0047         cms::cuda::copyAsync(product.eeTimeCorrShiftBins, eeTimeCorrShiftBins_, cudaStream);
0048       });
0049 
0050   return product;
0051 }
0052 
0053 TYPELOOKUP_DATA_REG(EcalTimeBiasCorrectionsGPU);