Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-05-04 02:52:44

0001 #include "CUDADataFormats/TrackingRecHit/interface/TrackingRecHit2DHeterogeneous.h"
0002 #include "HeterogeneousCore/CUDAUtilities/interface/copyAsync.h"
0003 #include "HeterogeneousCore/CUDAUtilities/interface/cudaCheck.h"
0004 #include "HeterogeneousCore/CUDAUtilities/interface/device_unique_ptr.h"
0005 #include "HeterogeneousCore/CUDAUtilities/interface/host_unique_ptr.h"
0006 
0007 template <>
0008 cms::cuda::host::unique_ptr<float[]> TrackingRecHit2DGPU::localCoordToHostAsync(cudaStream_t stream) const {
0009   auto ret = cms::cuda::make_host_unique<float[]>(5 * nHits(), stream);
0010   cms::cuda::copyAsync(ret, m_store32, 5 * nHits(), stream);
0011   return ret;
0012 }
0013 
0014 template <>
0015 cms::cuda::host::unique_ptr<float[]> TrackingRecHit2DGPU::store32ToHostAsync(cudaStream_t stream) const {
0016   auto ret = cms::cuda::make_host_unique<float[]>(static_cast<int>(n32) * nHits(), stream);
0017   cms::cuda::copyAsync(ret, m_store32, static_cast<int>(n32) * nHits(), stream);
0018   return ret;
0019 }
0020 
0021 template <>
0022 cms::cuda::host::unique_ptr<uint16_t[]> TrackingRecHit2DGPU::store16ToHostAsync(cudaStream_t stream) const {
0023   auto ret = cms::cuda::make_host_unique<uint16_t[]>(static_cast<int>(n16) * nHits(), stream);
0024   cms::cuda::copyAsync(ret, m_store16, static_cast<int>(n16) * nHits(), stream);
0025   return ret;
0026 }
0027 
0028 template <>
0029 cms::cuda::host::unique_ptr<uint32_t[]> TrackingRecHit2DGPU::hitsModuleStartToHostAsync(cudaStream_t stream) const {
0030   auto ret = cms::cuda::make_host_unique<uint32_t[]>(nMaxModules() + 1, stream);
0031   cudaCheck(
0032       cudaMemcpyAsync(ret.get(), m_hitsModuleStart, sizeof(uint32_t) * (nMaxModules() + 1), cudaMemcpyDefault, stream));
0033   return ret;
0034 }
0035 
0036 // the only specialization needed
0037 template <>
0038 void TrackingRecHit2DHost::copyFromGPU(TrackingRecHit2DGPU const* input, cudaStream_t stream) {
0039   assert(input);
0040   m_store32 = input->localCoordToHostAsync(stream);
0041 }