CMS 3D CMS Logo

CAHitNtupletGeneratorKernelsAlloc.cc
Go to the documentation of this file.
2 
4 
5 // #define GPU_DEBUG
6 template <typename TrackerTraits>
7 #ifdef __CUDACC__
9  using Traits = cms::cudacompat::GPUTraits;
10 #else
13 #endif
14 
16 
18  // ALLOCATIONS FOR THE INTERMEDIATE RESULTS (STAYS ON WORKER)
20 
21  this->device_theCellNeighbors_ = Traits::template make_unique<CellNeighborsVector>(stream);
22  this->device_theCellTracks_ = Traits::template make_unique<CellTracksVector>(stream);
23 
24 #ifdef GPU_DEBUG
25  std::cout << "Allocation for tuple building. N hits " << nHits << std::endl;
26 #endif
27 
28  nHits++; // storage requires one more counter;
29  assert(nHits > 0);
30  this->device_hitToTuple_ = Traits::template make_unique<HitToTuple>(stream);
31  this->device_hitToTupleStorage_ = Traits::template make_unique<typename HitToTuple::Counter[]>(nHits, stream);
32  this->hitToTupleView_.assoc = this->device_hitToTuple_.get();
33  this->hitToTupleView_.offStorage = this->device_hitToTupleStorage_.get();
34  this->hitToTupleView_.offSize = nHits;
35 
36  this->device_tupleMultiplicity_ = Traits::template make_unique<TupleMultiplicity>(stream);
37 
38  this->device_storage_ = Traits::template make_unique<cms::cuda::AtomicPairCounter::c_type[]>(3, stream);
39 
40  this->device_hitTuple_apc_ = (cms::cuda::AtomicPairCounter*)this->device_storage_.get();
41  this->device_hitToTuple_apc_ = (cms::cuda::AtomicPairCounter*)this->device_storage_.get() + 1;
42  this->device_nCells_ = (uint32_t*)(this->device_storage_.get() + 2);
43 
44  this->device_cellCuts_ = Traits::template make_unique<CellCuts>(stream);
45  // FIXME: consider collapsing these 3 in one adhoc kernel
47  cudaCheck(cudaMemsetAsync(this->device_nCells_, 0, sizeof(uint32_t), stream));
48  cudaCheck(cudaMemcpyAsync(
49  this->device_cellCuts_.get(), &(this->params_.cellCuts_), sizeof(CellCuts), cudaMemcpyDefault, stream));
50  } else {
51  *(this->device_nCells_) = 0;
52  *(this->device_cellCuts_.get()) = this->params_.cellCuts_;
53  }
54  cms::cuda::launchZero(this->device_tupleMultiplicity_.get(), stream);
55  cms::cuda::launchZero(this->hitToTupleView_, stream); // we may wish to keep it in the edm
56 #ifdef GPU_DEBUG
57  cudaDeviceSynchronize();
58  cudaCheck(cudaGetLastError());
59 #endif
60 }
61 
65 
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