File indexing completed on 2024-04-06 12:25:48
0001 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalMahiPulseOffsetsGPU.h"
0002
0003 #include "FWCore/Utilities/interface/typelookup.h"
0004 #include "HeterogeneousCore/CUDAUtilities/interface/cudaCheck.h"
0005
0006
0007 HcalMahiPulseOffsetsGPU::HcalMahiPulseOffsetsGPU(std::vector<int> const& values) {
0008 values_.resize(values.size());
0009 std::copy(values.begin(), values.end(), values_.begin());
0010 }
0011
0012 HcalMahiPulseOffsetsGPU::Product::~Product() {
0013
0014 cudaCheck(cudaFree(values));
0015 }
0016
0017 HcalMahiPulseOffsetsGPU::Product const& HcalMahiPulseOffsetsGPU::getProduct(cudaStream_t cudaStream) const {
0018 auto const& product = product_.dataForCurrentDeviceAsync(
0019 cudaStream, [this](HcalMahiPulseOffsetsGPU::Product& product, cudaStream_t cudaStream) {
0020
0021 cudaCheck(cudaMalloc((void**)&product.values, this->values_.size() * sizeof(int)));
0022
0023
0024 cudaCheck(cudaMemcpyAsync(product.values,
0025 this->values_.data(),
0026 this->values_.size() * sizeof(int),
0027 cudaMemcpyHostToDevice,
0028 cudaStream));
0029 });
0030
0031 return product;
0032 }
0033
0034 TYPELOOKUP_DATA_REG(HcalMahiPulseOffsetsGPU);