Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "CondFormats/EcalObjects/interface/EcalGainRatiosGPU.h"
0002 
0003 #include "FWCore/Utilities/interface/typelookup.h"
0004 #include "HeterogeneousCore/CUDAUtilities/interface/copyAsync.h"
0005 
0006 EcalGainRatiosGPU::EcalGainRatiosGPU(EcalGainRatios const& values)
0007     : gain12Over6_(values.size()), gain6Over1_(values.size()) {
0008   // fill in eb
0009   auto const& barrelValues = values.barrelItems();
0010   for (unsigned int i = 0; i < barrelValues.size(); i++) {
0011     gain12Over6_[i] = barrelValues[i].gain12Over6();
0012     gain6Over1_[i] = barrelValues[i].gain6Over1();
0013   }
0014 
0015   // fill in ee
0016   auto const& endcapValues = values.endcapItems();
0017   auto const offset = barrelValues.size();
0018   for (unsigned int i = 0; i < endcapValues.size(); i++) {
0019     gain12Over6_[offset + i] = endcapValues[i].gain12Over6();
0020     gain6Over1_[offset + i] = endcapValues[i].gain6Over1();
0021   }
0022 }
0023 
0024 EcalGainRatiosGPU::Product const& EcalGainRatiosGPU::getProduct(cudaStream_t cudaStream) const {
0025   auto const& product = product_.dataForCurrentDeviceAsync(
0026       cudaStream, [this](EcalGainRatiosGPU::Product& product, cudaStream_t cudaStream) {
0027         // allocate
0028         product.gain12Over6 = cms::cuda::make_device_unique<float[]>(gain12Over6_.size(), cudaStream);
0029         product.gain6Over1 = cms::cuda::make_device_unique<float[]>(gain6Over1_.size(), cudaStream);
0030         // transfer
0031         cms::cuda::copyAsync(product.gain12Over6, gain12Over6_, cudaStream);
0032         cms::cuda::copyAsync(product.gain6Over1, gain6Over1_, cudaStream);
0033       });
0034 
0035   return product;
0036 }
0037 
0038 TYPELOOKUP_DATA_REG(EcalGainRatiosGPU);