CMS 3D CMS Logo

CAHitNtupletGeneratorKernelsAlloc.cc
Go to the documentation of this file.
2 
4 
5 //#define GPU_DEBUG
6 
7 template <typename TrackerTraits>
8 #ifdef __CUDACC__
10  using Traits = cms::cudacompat::GPUTraits;
11 #else
14 #endif
15 
17 
19  // ALLOCATIONS FOR THE INTERMEDIATE RESULTS (STAYS ON WORKER)
21 
22  this->device_theCellNeighbors_ = Traits::template make_unique<CellNeighborsVector>(stream);
23  this->device_theCellTracks_ = Traits::template make_unique<CellTracksVector>(stream);
24 
25 #ifdef GPU_DEBUG
26  std::cout << "Allocation for tuple building. N hits " << nHits << std::endl;
27 #endif
28 
29  nHits++; // storage requires one more counter;
30  assert(nHits > 0);
31  this->device_hitToTuple_ = Traits::template make_unique<HitToTuple>(stream);
32  this->device_hitToTupleStorage_ = Traits::template make_unique<typename HitToTuple::Counter[]>(nHits, stream);
33  this->hitToTupleView_.assoc = this->device_hitToTuple_.get();
34  this->hitToTupleView_.offStorage = this->device_hitToTupleStorage_.get();
35  this->hitToTupleView_.offSize = nHits;
36 
37  this->device_tupleMultiplicity_ = Traits::template make_unique<TupleMultiplicity>(stream);
38 
39  this->device_storage_ = Traits::template make_unique<cms::cuda::AtomicPairCounter::c_type[]>(3, stream);
40 
41  this->device_hitTuple_apc_ = (cms::cuda::AtomicPairCounter*)this->device_storage_.get();
42  this->device_hitToTuple_apc_ = (cms::cuda::AtomicPairCounter*)this->device_storage_.get() + 1;
43  this->device_nCells_ = (uint32_t*)(this->device_storage_.get() + 2);
44 
45  this->device_cellCuts_ = Traits::template make_unique<CellCuts>(stream);
46  // FIXME: consider collapsing these 3 in one adhoc kernel
48  cudaCheck(cudaMemsetAsync(this->device_nCells_, 0, sizeof(uint32_t), stream));
49  cudaCheck(cudaMemcpyAsync(
50  this->device_cellCuts_.get(), &(this->params_.cellCuts_), sizeof(CellCuts), cudaMemcpyDefault, stream));
51  } else {
52  *(this->device_nCells_) = 0;
53  *(this->device_cellCuts_.get()) = this->params_.cellCuts_;
54  }
55  cms::cuda::launchZero(this->device_tupleMultiplicity_.get(), stream);
56  cms::cuda::launchZero(this->hitToTupleView_, stream); // we may wish to keep it in the edm
57 #ifdef GPU_DEBUG
58  cudaDeviceSynchronize();
59  cudaCheck(cudaGetLastError());
60 #endif
61 }
62 
66 
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
assert(be >=bs)
void allocateOnGPU(int32_t nHits, cudaStream_t stream)
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
void allocateOnGPU(int32_t nHits, cudaStream_t stream)
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:69
TupleMultiplicity< TrackerTraits > const *__restrict__ uint32_t nHits