Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:10

0001 #include "CondFormats/EcalObjects/interface/EcalPedestalsGPU.h"
0002 
0003 #include "FWCore/Utilities/interface/typelookup.h"
0004 #include "HeterogeneousCore/CUDAUtilities/interface/copyAsync.h"
0005 
0006 EcalPedestalsGPU::EcalPedestalsGPU(EcalPedestals const& pedestals)
0007     : mean_x12_(pedestals.size()),
0008       rms_x12_(pedestals.size()),
0009       mean_x6_(pedestals.size()),
0010       rms_x6_(pedestals.size()),
0011       mean_x1_(pedestals.size()),
0012       rms_x1_(pedestals.size()) {
0013   // fill in eb
0014   auto const& barrelValues = pedestals.barrelItems();
0015   for (unsigned int i = 0; i < barrelValues.size(); i++) {
0016     mean_x12_[i] = barrelValues[i].mean_x12;
0017     rms_x12_[i] = barrelValues[i].rms_x12;
0018     mean_x6_[i] = barrelValues[i].mean_x6;
0019     rms_x6_[i] = barrelValues[i].rms_x6;
0020     mean_x1_[i] = barrelValues[i].mean_x1;
0021     rms_x1_[i] = barrelValues[i].rms_x1;
0022   }
0023 
0024   // fill in ee
0025   auto const& endcapValues = pedestals.endcapItems();
0026   auto const offset = barrelValues.size();
0027   for (unsigned int i = 0; i < endcapValues.size(); i++) {
0028     mean_x12_[offset + i] = endcapValues[i].mean_x12;
0029     rms_x12_[offset + i] = endcapValues[i].rms_x12;
0030     mean_x6_[offset + i] = endcapValues[i].mean_x6;
0031     rms_x6_[offset + i] = endcapValues[i].rms_x6;
0032     mean_x1_[offset + i] = endcapValues[i].mean_x1;
0033     rms_x1_[offset + i] = endcapValues[i].rms_x1;
0034   }
0035 }
0036 
0037 EcalPedestalsGPU::Product const& EcalPedestalsGPU::getProduct(cudaStream_t cudaStream) const {
0038   auto const& product = product_.dataForCurrentDeviceAsync(
0039       cudaStream, [this](EcalPedestalsGPU::Product& product, cudaStream_t cudaStream) {
0040         // allocate
0041         product.mean_x12 = cms::cuda::make_device_unique<float[]>(mean_x12_.size(), cudaStream);
0042         product.mean_x6 = cms::cuda::make_device_unique<float[]>(mean_x6_.size(), cudaStream);
0043         product.mean_x1 = cms::cuda::make_device_unique<float[]>(mean_x1_.size(), cudaStream);
0044         product.rms_x12 = cms::cuda::make_device_unique<float[]>(rms_x12_.size(), cudaStream);
0045         product.rms_x6 = cms::cuda::make_device_unique<float[]>(rms_x6_.size(), cudaStream);
0046         product.rms_x1 = cms::cuda::make_device_unique<float[]>(rms_x1_.size(), cudaStream);
0047         // transfer
0048         cms::cuda::copyAsync(product.mean_x12, mean_x12_, cudaStream);
0049         cms::cuda::copyAsync(product.mean_x6, mean_x6_, cudaStream);
0050         cms::cuda::copyAsync(product.mean_x1, mean_x1_, cudaStream);
0051         cms::cuda::copyAsync(product.rms_x12, rms_x12_, cudaStream);
0052         cms::cuda::copyAsync(product.rms_x6, rms_x6_, cudaStream);
0053         cms::cuda::copyAsync(product.rms_x1, rms_x1_, cudaStream);
0054       });
0055 
0056   return product;
0057 }
0058 
0059 TYPELOOKUP_DATA_REG(EcalPedestalsGPU);