Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "CondFormats/HcalObjects/interface/HcalQIETypes.h"
0002 #include "CondFormats/HcalObjects/interface/HcalQIETypesGPU.h"
0003 #include "FWCore/Utilities/interface/typelookup.h"
0004 #include "HeterogeneousCore/CUDAUtilities/interface/copyAsync.h"
0005 
0006 // FIXME: add proper getters to conditions
0007 HcalQIETypesGPU::HcalQIETypesGPU(HcalQIETypes const& parameters)
0008     : values_(parameters.getAllContainers()[0].second.size() + parameters.getAllContainers()[1].second.size()) {
0009   auto const containers = parameters.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 HcalQIETypesGPU::Product const& HcalQIETypesGPU::getProduct(cudaStream_t stream) const {
0026   auto const& product =
0027       product_.dataForCurrentDeviceAsync(stream, [this](HcalQIETypesGPU::Product& product, cudaStream_t stream) {
0028         // allocate
0029         product.values = cms::cuda::make_device_unique<int[]>(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(HcalQIETypesGPU);