Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "CondFormats/HcalObjects/interface/HcalRespCorrs.h"
0002 #include "CondFormats/HcalObjects/interface/HcalRespCorrsGPU.h"
0003 #include "FWCore/Utilities/interface/typelookup.h"
0004 #include "HeterogeneousCore/CUDAUtilities/interface/copyAsync.h"
0005 
0006 // FIXME: add proper getters to conditions
0007 HcalRespCorrsGPU::HcalRespCorrsGPU(HcalRespCorrs const& respcorrs)
0008     : values_(respcorrs.getAllContainers()[0].second.size() + respcorrs.getAllContainers()[1].second.size()) {
0009   auto const containers = respcorrs.getAllContainers();
0010 
0011   // fill in eb
0012   auto const& barrelValues = containers[0].second;
0013   for (uint64_t i = 0; i < barrelValues.size(); ++i) {
0014     values_[i] = barrelValues[i].getValue();
0015   }
0016 
0017   // fill in ee
0018   auto const& endcapValues = containers[1].second;
0019   auto const offset = barrelValues.size();
0020   for (uint64_t i = 0; i < endcapValues.size(); ++i) {
0021     values_[i + offset] = endcapValues[i].getValue();
0022   }
0023 }
0024 
0025 HcalRespCorrsGPU::Product const& HcalRespCorrsGPU::getProduct(cudaStream_t stream) const {
0026   auto const& product =
0027       product_.dataForCurrentDeviceAsync(stream, [this](HcalRespCorrsGPU::Product& product, cudaStream_t stream) {
0028         // allocate
0029         product.values = cms::cuda::make_device_unique<float[]>(values_.size(), stream);
0030 
0031         // transfer
0032         cms::cuda::copyAsync(product.values, values_, stream);
0033       });
0034 
0035   return product;
0036 }
0037 
0038 TYPELOOKUP_DATA_REG(HcalRespCorrsGPU);