Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-13 13:13:51

0001 #include <cassert>
0002 
0003 #include "CUDADataFormats/SiPixelDigi/interface/SiPixelDigisCUDA.h"
0004 #include "HeterogeneousCore/CUDAUtilities/interface/copyAsync.h"
0005 #include "HeterogeneousCore/CUDAUtilities/interface/device_unique_ptr.h"
0006 #include "HeterogeneousCore/CUDAUtilities/interface/host_unique_ptr.h"
0007 
0008 SiPixelDigisCUDA::SiPixelDigisCUDA(size_t maxFedWords, cudaStream_t stream)
0009     : m_store(cms::cuda::make_device_unique<SiPixelDigisCUDA::StoreType[]>(
0010           SiPixelDigisCUDASOAView::roundFor128ByteAlignment(maxFedWords) *
0011               static_cast<int>(SiPixelDigisCUDASOAView::StorageLocation::kMAX),
0012           stream)),
0013       m_view(m_store, maxFedWords, SiPixelDigisCUDASOAView::StorageLocation::kMAX) {
0014   assert(maxFedWords != 0);
0015 }
0016 
0017 cms::cuda::host::unique_ptr<SiPixelDigisCUDA::StoreType[]> SiPixelDigisCUDA::copyAllToHostAsync(
0018     cudaStream_t stream) const {
0019   auto ret = cms::cuda::make_host_unique<StoreType[]>(
0020       m_view.roundFor128ByteAlignment(nDigis()) * static_cast<int>(SiPixelDigisCUDASOAView::StorageLocationHost::kMAX),
0021       stream);
0022   cudaCheck(cudaMemcpyAsync(ret.get(),
0023                             m_view.clus(),
0024                             m_view.roundFor128ByteAlignment(nDigis()) * sizeof(SiPixelDigisCUDA::StoreType) *
0025                                 static_cast<int>(SiPixelDigisCUDASOAView::StorageLocationHost::kMAX),
0026                             cudaMemcpyDeviceToHost,
0027                             stream));
0028   return ret;
0029 }