File indexing completed on 2024-04-06 12:02:16
0001 #include "CondFormats/HcalObjects/interface/HcalTimeCorrs.h"
0002 #include "CondFormats/HcalObjects/interface/HcalTimeCorrsGPU.h"
0003 #include "FWCore/Utilities/interface/typelookup.h"
0004 #include "HeterogeneousCore/CUDAUtilities/interface/copyAsync.h"
0005
0006
0007 HcalTimeCorrsGPU::HcalTimeCorrsGPU(HcalTimeCorrs const& timecorrs)
0008 : value_(timecorrs.getAllContainers()[0].second.size() + timecorrs.getAllContainers()[1].second.size()) {
0009 auto const containers = timecorrs.getAllContainers();
0010
0011
0012 auto const& barrelValues = containers[0].second;
0013 for (uint64_t i = 0; i < barrelValues.size(); ++i) {
0014 value_[i] = barrelValues[i].getValue();
0015 }
0016
0017
0018 auto const& endcapValues = containers[1].second;
0019 auto const offset = barrelValues.size();
0020 for (uint64_t i = 0; i < endcapValues.size(); ++i) {
0021 value_[i + offset] = endcapValues[i].getValue();
0022 }
0023 }
0024
0025 HcalTimeCorrsGPU::Product const& HcalTimeCorrsGPU::getProduct(cudaStream_t stream) const {
0026 auto const& product =
0027 product_.dataForCurrentDeviceAsync(stream, [this](HcalTimeCorrsGPU::Product& product, cudaStream_t stream) {
0028
0029 product.value = cms::cuda::make_device_unique<float[]>(value_.size(), stream);
0030
0031
0032 cms::cuda::copyAsync(product.value, value_, stream);
0033 });
0034
0035 return product;
0036 }
0037
0038 TYPELOOKUP_DATA_REG(HcalTimeCorrsGPU);