File indexing completed on 2023-03-17 10:47:03
0001 #include "CondFormats/HcalObjects/interface/HcalPedestalWidths.h"
0002 #include "CondFormats/HcalObjects/interface/HcalPedestalWidthsGPU.h"
0003 #include "FWCore/Utilities/interface/typelookup.h"
0004 #include "HeterogeneousCore/CUDAUtilities/interface/copyAsync.h"
0005
0006
0007 HcalPedestalWidthsGPU::HcalPedestalWidthsGPU(HcalPedestalWidths const& pedestals)
0008 : unitIsADC_{pedestals.isADC()},
0009 totalChannels_{pedestals.getAllContainers()[0].second.size() + pedestals.getAllContainers()[1].second.size()},
0010 sigma00_(totalChannels_),
0011 sigma01_(totalChannels_),
0012 sigma02_(totalChannels_),
0013 sigma03_(totalChannels_),
0014 sigma10_(totalChannels_),
0015 sigma11_(totalChannels_),
0016 sigma12_(totalChannels_),
0017 sigma13_(totalChannels_),
0018 sigma20_(totalChannels_),
0019 sigma21_(totalChannels_),
0020 sigma22_(totalChannels_),
0021 sigma23_(totalChannels_),
0022 sigma30_(totalChannels_),
0023 sigma31_(totalChannels_),
0024 sigma32_(totalChannels_),
0025 sigma33_(totalChannels_) {
0026 auto const containers = pedestals.getAllContainers();
0027
0028
0029 auto const& barrelValues = containers[0].second;
0030 for (uint64_t i = 0; i < barrelValues.size(); ++i) {
0031 sigma00_[i] = *(barrelValues[i].getValues() );
0032 sigma01_[i] = *(barrelValues[i].getValues() + 1);
0033 sigma02_[i] = *(barrelValues[i].getValues() + 2);
0034 sigma03_[i] = *(barrelValues[i].getValues() + 3);
0035 sigma10_[i] = *(barrelValues[i].getValues() + 3);
0036 sigma11_[i] = *(barrelValues[i].getValues() + 5);
0037 sigma12_[i] = *(barrelValues[i].getValues() + 6);
0038 sigma13_[i] = *(barrelValues[i].getValues() + 7);
0039 sigma20_[i] = *(barrelValues[i].getValues() + 8);
0040 sigma21_[i] = *(barrelValues[i].getValues() + 9);
0041 sigma22_[i] = *(barrelValues[i].getValues() + 10);
0042 sigma23_[i] = *(barrelValues[i].getValues() + 11);
0043 sigma30_[i] = *(barrelValues[i].getValues() + 12);
0044 sigma31_[i] = *(barrelValues[i].getValues() + 13);
0045 sigma32_[i] = *(barrelValues[i].getValues() + 14);
0046 sigma33_[i] = *(barrelValues[i].getValues() + 15);
0047 }
0048
0049
0050 auto const& endcapValues = containers[1].second;
0051 auto const offset = barrelValues.size();
0052 for (uint64_t i = 0; i < endcapValues.size(); ++i) {
0053 sigma00_[i + offset] = *(endcapValues[i].getValues() );
0054 sigma01_[i + offset] = *(endcapValues[i].getValues() + 1);
0055 sigma02_[i + offset] = *(endcapValues[i].getValues() + 2);
0056 sigma03_[i + offset] = *(endcapValues[i].getValues() + 3);
0057 sigma10_[i + offset] = *(endcapValues[i].getValues() + 3);
0058 sigma11_[i + offset] = *(endcapValues[i].getValues() + 5);
0059 sigma12_[i + offset] = *(endcapValues[i].getValues() + 6);
0060 sigma13_[i + offset] = *(endcapValues[i].getValues() + 7);
0061 sigma20_[i + offset] = *(endcapValues[i].getValues() + 8);
0062 sigma21_[i + offset] = *(endcapValues[i].getValues() + 9);
0063 sigma22_[i + offset] = *(endcapValues[i].getValues() + 10);
0064 sigma23_[i + offset] = *(endcapValues[i].getValues() + 11);
0065 sigma30_[i + offset] = *(endcapValues[i].getValues() + 12);
0066 sigma31_[i + offset] = *(endcapValues[i].getValues() + 13);
0067 sigma32_[i + offset] = *(endcapValues[i].getValues() + 14);
0068 sigma33_[i + offset] = *(endcapValues[i].getValues() + 15);
0069 }
0070 }
0071
0072 HcalPedestalWidthsGPU::Product const& HcalPedestalWidthsGPU::getProduct(cudaStream_t stream) const {
0073 auto const& product =
0074 product_.dataForCurrentDeviceAsync(stream, [this](HcalPedestalWidthsGPU::Product& product, cudaStream_t stream) {
0075
0076 product.sigma00 = cms::cuda::make_device_unique<float[]>(sigma00_.size(), stream);
0077 product.sigma01 = cms::cuda::make_device_unique<float[]>(sigma01_.size(), stream);
0078 product.sigma02 = cms::cuda::make_device_unique<float[]>(sigma02_.size(), stream);
0079 product.sigma03 = cms::cuda::make_device_unique<float[]>(sigma03_.size(), stream);
0080
0081 product.sigma10 = cms::cuda::make_device_unique<float[]>(sigma10_.size(), stream);
0082 product.sigma11 = cms::cuda::make_device_unique<float[]>(sigma11_.size(), stream);
0083 product.sigma12 = cms::cuda::make_device_unique<float[]>(sigma12_.size(), stream);
0084 product.sigma13 = cms::cuda::make_device_unique<float[]>(sigma13_.size(), stream);
0085
0086 product.sigma20 = cms::cuda::make_device_unique<float[]>(sigma20_.size(), stream);
0087 product.sigma21 = cms::cuda::make_device_unique<float[]>(sigma21_.size(), stream);
0088 product.sigma22 = cms::cuda::make_device_unique<float[]>(sigma22_.size(), stream);
0089 product.sigma23 = cms::cuda::make_device_unique<float[]>(sigma23_.size(), stream);
0090
0091 product.sigma30 = cms::cuda::make_device_unique<float[]>(sigma30_.size(), stream);
0092 product.sigma31 = cms::cuda::make_device_unique<float[]>(sigma31_.size(), stream);
0093 product.sigma32 = cms::cuda::make_device_unique<float[]>(sigma32_.size(), stream);
0094 product.sigma33 = cms::cuda::make_device_unique<float[]>(sigma33_.size(), stream);
0095
0096
0097 cms::cuda::copyAsync(product.sigma00, sigma00_, stream);
0098 cms::cuda::copyAsync(product.sigma01, sigma01_, stream);
0099 cms::cuda::copyAsync(product.sigma02, sigma02_, stream);
0100 cms::cuda::copyAsync(product.sigma03, sigma03_, stream);
0101
0102 cms::cuda::copyAsync(product.sigma10, sigma10_, stream);
0103 cms::cuda::copyAsync(product.sigma11, sigma11_, stream);
0104 cms::cuda::copyAsync(product.sigma12, sigma12_, stream);
0105 cms::cuda::copyAsync(product.sigma13, sigma13_, stream);
0106
0107 cms::cuda::copyAsync(product.sigma20, sigma20_, stream);
0108 cms::cuda::copyAsync(product.sigma21, sigma21_, stream);
0109 cms::cuda::copyAsync(product.sigma22, sigma22_, stream);
0110 cms::cuda::copyAsync(product.sigma23, sigma23_, stream);
0111
0112 cms::cuda::copyAsync(product.sigma30, sigma30_, stream);
0113 cms::cuda::copyAsync(product.sigma31, sigma31_, stream);
0114 cms::cuda::copyAsync(product.sigma32, sigma32_, stream);
0115 cms::cuda::copyAsync(product.sigma33, sigma33_, stream);
0116 });
0117
0118 return product;
0119 }
0120
0121 TYPELOOKUP_DATA_REG(HcalPedestalWidthsGPU);