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  // ALLOCATIONS FOR THE INTERMEDIATE RESULTS (STAYS ON WORKER)
17 
18  this->device_theCellNeighbors_ = Traits::template make_unique<CellNeighborsVector>(stream);
19  this->device_theCellTracks_ = Traits::template make_unique<CellTracksVector>(stream);
20 
21 #ifdef GPU_DEBUG
22  std::cout << "Allocation for tuple building. N hits " << nHits << std::endl;
23 #endif
24 
25  nHits++; // storage requires one more counter;
26  assert(nHits > 0);
27  this->device_hitToTuple_ = Traits::template make_unique<HitToTuple>(stream);
28  this->device_hitToTupleStorage_ = Traits::template make_unique<typename HitToTuple::Counter[]>(nHits, stream);
29  this->hitToTupleView_.assoc = this->device_hitToTuple_.get();
30  this->hitToTupleView_.offStorage = this->device_hitToTupleStorage_.get();
31  this->hitToTupleView_.offSize = nHits;
32 
33  this->device_tupleMultiplicity_ = Traits::template make_unique<TupleMultiplicity>(stream);
34 
35  this->device_storage_ = Traits::template make_unique<cms::cuda::AtomicPairCounter::c_type[]>(3, stream);
36 
37  this->device_hitTuple_apc_ = (cms::cuda::AtomicPairCounter*)this->device_storage_.get();
38  this->device_hitToTuple_apc_ = (cms::cuda::AtomicPairCounter*)this->device_storage_.get() + 1;
39  this->device_nCells_ = (uint32_t*)(this->device_storage_.get() + 2);
40 
41  // FIXME: consider collapsing these 3 in one adhoc kernel
43  cudaCheck(cudaMemsetAsync(this->device_nCells_, 0, sizeof(uint32_t), stream));
44  } else {
45  *(this->device_nCells_) = 0;
46  }
47  cms::cuda::launchZero(this->device_tupleMultiplicity_.get(), stream);
48  cms::cuda::launchZero(this->hitToTupleView_, stream); // we may wish to keep it in the edm
49 #ifdef GPU_DEBUG
50  cudaDeviceSynchronize();
51  cudaCheck(cudaGetLastError());
52 #endif
53 }
54 
57 
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