Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "CondFormats/EcalObjects/interface/EcalRecHitParametersGPU.h"
0002 
0003 #include "FWCore/Utilities/interface/typelookup.h"
0004 #include "HeterogeneousCore/CUDAUtilities/interface/copyAsync.h"
0005 #include "CondFormats/EcalObjects/interface/EcalRechitChannelStatusGPU.h"
0006 #include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
0007 
0008 EcalRecHitParametersGPU::EcalRecHitParametersGPU(std::vector<int> const& channelStatusToBeExcluded,
0009                                                  std::vector<DBStatus> const& flagsMapDBReco) {
0010   channelStatusToBeExcluded_.resize(channelStatusToBeExcluded.size());
0011   std::copy(channelStatusToBeExcluded.begin(), channelStatusToBeExcluded.end(), channelStatusToBeExcluded_.begin());
0012 
0013   for (auto const& flagInfo : flagsMapDBReco) {
0014     EcalRecHit::Flags recoflagbit = static_cast<EcalRecHit::Flags>(flagInfo.recoflagbit);
0015     for (auto v : flagInfo.dbstatus) {
0016       EcalChannelStatusCode::Code dbstatus = static_cast<EcalChannelStatusCode::Code>(v);
0017       expanded_v_DB_reco_flags_.push_back(dbstatus);
0018     }
0019 
0020     expanded_Sizes_v_DB_reco_flags_.push_back(flagInfo.dbstatus.size());
0021     expanded_flagbit_v_DB_reco_flags_.push_back(recoflagbit);
0022   }
0023 }
0024 
0025 EcalRecHitParametersGPU::Product const& EcalRecHitParametersGPU::getProduct(cudaStream_t cudaStream) const {
0026   auto const& product = product_.dataForCurrentDeviceAsync(
0027       cudaStream, [this](EcalRecHitParametersGPU::Product& product, cudaStream_t cudaStream) {
0028         // allocate
0029         product.channelStatusToBeExcluded =
0030             cms::cuda::make_device_unique<int[]>(channelStatusToBeExcluded_.size(), cudaStream);
0031         product.expanded_v_DB_reco_flags =
0032             cms::cuda::make_device_unique<int[]>(expanded_v_DB_reco_flags_.size(), cudaStream);
0033         product.expanded_Sizes_v_DB_reco_flags =
0034             cms::cuda::make_device_unique<uint32_t[]>(expanded_Sizes_v_DB_reco_flags_.size(), cudaStream);
0035         product.expanded_flagbit_v_DB_reco_flags =
0036             cms::cuda::make_device_unique<uint32_t[]>(expanded_flagbit_v_DB_reco_flags_.size(), cudaStream);
0037         // transfer
0038         cms::cuda::copyAsync(product.channelStatusToBeExcluded, channelStatusToBeExcluded_, cudaStream);
0039         cms::cuda::copyAsync(product.expanded_v_DB_reco_flags, expanded_v_DB_reco_flags_, cudaStream);
0040         cms::cuda::copyAsync(product.expanded_Sizes_v_DB_reco_flags, expanded_Sizes_v_DB_reco_flags_, cudaStream);
0041         cms::cuda::copyAsync(product.expanded_flagbit_v_DB_reco_flags, expanded_flagbit_v_DB_reco_flags_, cudaStream);
0042       });
0043   return product;
0044 }
0045 
0046 TYPELOOKUP_DATA_REG(EcalRecHitParametersGPU);