Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "CondFormats/EcalObjects/interface/EcalSamplesCorrelationGPU.h"
0002 
0003 #include "FWCore/Utilities/interface/typelookup.h"
0004 #include "HeterogeneousCore/CUDAUtilities/interface/copyAsync.h"
0005 
0006 EcalSamplesCorrelationGPU::EcalSamplesCorrelationGPU(EcalSamplesCorrelation const& values) {
0007   EBG12SamplesCorrelation_.reserve(values.EBG12SamplesCorrelation.size());
0008   for (const auto& EBG12SamplesCorrelation : values.EBG12SamplesCorrelation) {
0009     EBG12SamplesCorrelation_.emplace_back(EBG12SamplesCorrelation);
0010   }
0011 
0012   EBG6SamplesCorrelation_.reserve(values.EBG6SamplesCorrelation.size());
0013   for (const auto& EBG6SamplesCorrelation : values.EBG6SamplesCorrelation) {
0014     EBG6SamplesCorrelation_.emplace_back(EBG6SamplesCorrelation);
0015   }
0016 
0017   EBG1SamplesCorrelation_.reserve(values.EBG1SamplesCorrelation.size());
0018   for (const auto& EBG1SamplesCorrelation : values.EBG1SamplesCorrelation) {
0019     EBG1SamplesCorrelation_.emplace_back(EBG1SamplesCorrelation);
0020   }
0021 
0022   EEG12SamplesCorrelation_.reserve(values.EEG12SamplesCorrelation.size());
0023   for (const auto& EEG12SamplesCorrelation : values.EEG12SamplesCorrelation) {
0024     EEG12SamplesCorrelation_.emplace_back(EEG12SamplesCorrelation);
0025   }
0026 
0027   EEG6SamplesCorrelation_.reserve(values.EEG6SamplesCorrelation.size());
0028   for (const auto& EEG6SamplesCorrelation : values.EEG6SamplesCorrelation) {
0029     EEG6SamplesCorrelation_.emplace_back(EEG6SamplesCorrelation);
0030   }
0031 
0032   EEG1SamplesCorrelation_.reserve(values.EEG1SamplesCorrelation.size());
0033   for (const auto& EEG1SamplesCorrelation : values.EEG1SamplesCorrelation) {
0034     EEG1SamplesCorrelation_.emplace_back(EEG1SamplesCorrelation);
0035   }
0036 }
0037 
0038 EcalSamplesCorrelationGPU::Product const& EcalSamplesCorrelationGPU::getProduct(cudaStream_t cudaStream) const {
0039   auto const& product = product_.dataForCurrentDeviceAsync(
0040       cudaStream, [this](EcalSamplesCorrelationGPU::Product& product, cudaStream_t cudaStream) {
0041         // allocate
0042         product.EBG12SamplesCorrelation =
0043             cms::cuda::make_device_unique<double[]>(EBG12SamplesCorrelation_.size(), cudaStream);
0044         product.EBG6SamplesCorrelation =
0045             cms::cuda::make_device_unique<double[]>(EBG6SamplesCorrelation_.size(), cudaStream);
0046         product.EBG1SamplesCorrelation =
0047             cms::cuda::make_device_unique<double[]>(EBG1SamplesCorrelation_.size(), cudaStream);
0048         product.EEG12SamplesCorrelation =
0049             cms::cuda::make_device_unique<double[]>(EEG12SamplesCorrelation_.size(), cudaStream);
0050         product.EEG6SamplesCorrelation =
0051             cms::cuda::make_device_unique<double[]>(EEG6SamplesCorrelation_.size(), cudaStream);
0052         product.EEG1SamplesCorrelation =
0053             cms::cuda::make_device_unique<double[]>(EEG1SamplesCorrelation_.size(), cudaStream);
0054         // transfer
0055         cms::cuda::copyAsync(product.EBG12SamplesCorrelation, EBG12SamplesCorrelation_, cudaStream);
0056         cms::cuda::copyAsync(product.EBG6SamplesCorrelation, EBG6SamplesCorrelation_, cudaStream);
0057         cms::cuda::copyAsync(product.EBG1SamplesCorrelation, EBG1SamplesCorrelation_, cudaStream);
0058         cms::cuda::copyAsync(product.EEG12SamplesCorrelation, EEG12SamplesCorrelation_, cudaStream);
0059         cms::cuda::copyAsync(product.EEG6SamplesCorrelation, EEG6SamplesCorrelation_, cudaStream);
0060         cms::cuda::copyAsync(product.EEG1SamplesCorrelation, EEG1SamplesCorrelation_, cudaStream);
0061       });
0062 
0063   return product;
0064 }
0065 
0066 TYPELOOKUP_DATA_REG(EcalSamplesCorrelationGPU);