Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-03-25 10:54:40

0001 #include "CondFormats/EcalObjects/interface/EcalPulseShapesGPU.h"
0002 
0003 #include "FWCore/Utilities/interface/typelookup.h"
0004 #include "HeterogeneousCore/CUDAUtilities/interface/cudaCheck.h"
0005 
0006 EcalPulseShapesGPU::EcalPulseShapesGPU(EcalPulseShapes const& values)
0007     : valuesEB_{values.barrelItems()}, valuesEE_{values.endcapItems()} {}
0008 
0009 EcalPulseShapesGPU::Product::~Product() {
0010   // deallocation
0011   cudaCheck(cudaFree(values));
0012 }
0013 
0014 EcalPulseShapesGPU::Product const& EcalPulseShapesGPU::getProduct(cudaStream_t cudaStream) const {
0015   auto const& product = product_.dataForCurrentDeviceAsync(
0016       cudaStream, [this](EcalPulseShapesGPU::Product& product, cudaStream_t cudaStream) {
0017         // malloc
0018         cudaCheck(cudaMalloc((void**)&product.values,
0019                              (this->valuesEE_.size() + this->valuesEB_.size()) * sizeof(EcalPulseShape)));
0020 
0021         // offset in terms of sizeof(EcalPulseShape) - plain c array
0022         uint32_t offset = this->valuesEB_.size();
0023 
0024         // transfer eb
0025         cudaCheck(cudaMemcpyAsync(product.values,
0026                                   this->valuesEB_.data(),
0027                                   this->valuesEB_.size() * sizeof(EcalPulseShape),
0028                                   cudaMemcpyHostToDevice,
0029                                   cudaStream));
0030 
0031         // transfer ee starting at values + offset
0032         cudaCheck(cudaMemcpyAsync(product.values + offset,
0033                                   this->valuesEE_.data(),
0034                                   this->valuesEE_.size() * sizeof(EcalPulseShape),
0035                                   cudaMemcpyHostToDevice,
0036                                   cudaStream));
0037       });
0038 
0039   return product;
0040 }
0041 
0042 TYPELOOKUP_DATA_REG(EcalPulseShapesGPU);