CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
gpuVertexFinder::Producer Class Reference

#include <gpuVertexFinder.h>

Public Types

using TkSoA = pixelTrack::TrackSoA
 
using WorkSpace = gpuVertexFinder::WorkSpace
 
using ZVertices = ZVertexSoA
 

Public Member Functions

ZVertexHeterogeneous make (TkSoA const *tksoa, float ptMin) const
 
ZVertexHeterogeneous makeAsync (cudaStream_t stream, TkSoA const *tksoa, float ptMin) const
 
 Producer (bool oneKernel, bool useDensity, bool useDBSCAN, bool useIterative, int iminT, float ieps, float ierrmax, float ichi2max)
 
 ~Producer ()=default
 

Private Attributes

float chi2max
 
float eps
 
float errmax
 
int minT
 
const bool oneKernel_
 
const bool useDBSCAN_
 
const bool useDensity_
 
const bool useIterative_
 

Detailed Description

Definition at line 40 of file gpuVertexFinder.h.

Member Typedef Documentation

◆ TkSoA

Definition at line 44 of file gpuVertexFinder.h.

◆ WorkSpace

Definition at line 43 of file gpuVertexFinder.h.

◆ ZVertices

Definition at line 42 of file gpuVertexFinder.h.

Constructor & Destructor Documentation

◆ Producer()

gpuVertexFinder::Producer::Producer ( bool  oneKernel,
bool  useDensity,
bool  useDBSCAN,
bool  useIterative,
int  iminT,
float  ieps,
float  ierrmax,
float  ichi2max 
)
inline

Definition at line 46 of file gpuVertexFinder.h.

55  : oneKernel_(oneKernel && !(useDBSCAN || useIterative)),
56  useDensity_(useDensity),
57  useDBSCAN_(useDBSCAN),
58  useIterative_(useIterative),
59  minT(iminT),
60  eps(ieps),
61  errmax(ierrmax),
62  chi2max(ichi2max) {}

◆ ~Producer()

gpuVertexFinder::Producer::~Producer ( )
default

Member Function Documentation

◆ make()

ZVertexHeterogeneous gpuVertexFinder::Producer::make ( TkSoA const *  tksoa,
float  ptMin 
) const

Definition at line 105 of file gpuVertexFinderImpl.h.

105  {
106 #ifdef PIXVERTEX_DEBUG_PRODUCE
107  std::cout << "producing Vertices on CPU" << std::endl;
108 #endif // PIXVERTEX_DEBUG_PRODUCE
109  ZVertexHeterogeneous vertices(std::make_unique<ZVertexSoA>());
110 #endif
111  assert(tksoa);
112  auto* soa = vertices.get();
113  assert(soa);
114 
115 #ifdef __CUDACC__
116  auto ws_d = cms::cuda::make_device_unique<WorkSpace>(stream);
117 #else
118  auto ws_d = std::make_unique<WorkSpace>();
119 #endif
120 
121 #ifdef __CUDACC__
122  init<<<1, 1, 0, stream>>>(soa, ws_d.get());
123  auto blockSize = 128;
124  auto numberOfBlocks = (TkSoA::stride() + blockSize - 1) / blockSize;
125  loadTracks<<<numberOfBlocks, blockSize, 0, stream>>>(tksoa, soa, ws_d.get(), ptMin);
126  cudaCheck(cudaGetLastError());
127 #else
128  init(soa, ws_d.get());
129  loadTracks(tksoa, soa, ws_d.get(), ptMin);
130 #endif
131 
132 #ifdef __CUDACC__
133  // Running too many thread lead to problems when printf is enabled.
134  constexpr int maxThreadsForPrint = 1024 - 256;
135  constexpr int numBlocks = 1024;
136  constexpr int threadsPerBlock = 128;
137 
138  if (oneKernel_) {
139  // implemented only for density clustesrs
140 #ifndef THREE_KERNELS
141  vertexFinderOneKernel<<<1, maxThreadsForPrint, 0, stream>>>(soa, ws_d.get(), minT, eps, errmax, chi2max);
142 #else
143  vertexFinderKernel1<<<1, maxThreadsForPrint, 0, stream>>>(soa, ws_d.get(), minT, eps, errmax, chi2max);
144  cudaCheck(cudaGetLastError());
145  // one block per vertex...
146  splitVerticesKernel<<<numBlocks, threadsPerBlock, 0, stream>>>(soa, ws_d.get(), maxChi2ForSplit);
147  cudaCheck(cudaGetLastError());
148  vertexFinderKernel2<<<1, maxThreadsForPrint, 0, stream>>>(soa, ws_d.get());
149 #endif
150  } else { // five kernels
151  if (useDensity_) {
152  clusterTracksByDensityKernel<<<1, maxThreadsForPrint, 0, stream>>>(soa, ws_d.get(), minT, eps, errmax, chi2max);
153  } else if (useDBSCAN_) {
154  clusterTracksDBSCAN<<<1, maxThreadsForPrint, 0, stream>>>(soa, ws_d.get(), minT, eps, errmax, chi2max);
155  } else if (useIterative_) {
156  clusterTracksIterative<<<1, maxThreadsForPrint, 0, stream>>>(soa, ws_d.get(), minT, eps, errmax, chi2max);
157  }
158  cudaCheck(cudaGetLastError());
159  fitVerticesKernel<<<1, maxThreadsForPrint, 0, stream>>>(soa, ws_d.get(), maxChi2ForFirstFit);
160  cudaCheck(cudaGetLastError());
161  // one block per vertex...
162  splitVerticesKernel<<<numBlocks, threadsPerBlock, 0, stream>>>(soa, ws_d.get(), maxChi2ForSplit);
163  cudaCheck(cudaGetLastError());
164  fitVerticesKernel<<<1, maxThreadsForPrint, 0, stream>>>(soa, ws_d.get(), maxChi2ForFinalFit);
165  cudaCheck(cudaGetLastError());
166  sortByPt2Kernel<<<1, maxThreadsForPrint, 0, stream>>>(soa, ws_d.get());
167  }
168  cudaCheck(cudaGetLastError());
169 #else // __CUDACC__
170  if (useDensity_) {
171  clusterTracksByDensity(soa, ws_d.get(), minT, eps, errmax, chi2max);
172  } else if (useDBSCAN_) {
173  clusterTracksDBSCAN(soa, ws_d.get(), minT, eps, errmax, chi2max);
174  } else if (useIterative_) {
175  clusterTracksIterative(soa, ws_d.get(), minT, eps, errmax, chi2max);
176  }
177 #ifdef PIXVERTEX_DEBUG_PRODUCE
178  std::cout << "found " << (*ws_d).nvIntermediate << " vertices " << std::endl;
179 #endif // PIXVERTEX_DEBUG_PRODUCE
180  fitVertices(soa, ws_d.get(), maxChi2ForFirstFit);
181  // one block per vertex!
182  splitVertices(soa, ws_d.get(), maxChi2ForSplit);
183  fitVertices(soa, ws_d.get(), maxChi2ForFinalFit);
184  sortByPt2(soa, ws_d.get());
185 #endif
186 
187  return vertices;
188  }

References gpuVertexFinder::assert(), chi2max, gather_cfg::cout, cudaCheck, eps, errmax, gpuVertexFinder::init(), gpuVertexFinder::maxChi2ForFinalFit, gpuVertexFinder::maxChi2ForFirstFit, gpuVertexFinder::maxChi2ForSplit, minT, oneKernel_, gpuVertexFinder::ptMin, gpuVertexFinder::soa, cms::cuda::stream, TrackSoAHeterogeneousT< S >::stride(), useDBSCAN_, useDensity_, useIterative_, and pwdgSkimBPark_cfi::vertices.

Referenced by PixelVertexProducerCUDA::produceOnCPU().

◆ makeAsync()

ZVertexHeterogeneous gpuVertexFinder::Producer::makeAsync ( cudaStream_t  stream,
TkSoA const *  tksoa,
float  ptMin 
) const

Member Data Documentation

◆ chi2max

float gpuVertexFinder::Producer::chi2max
private

Definition at line 78 of file gpuVertexFinder.h.

Referenced by make().

◆ eps

float gpuVertexFinder::Producer::eps
private

Definition at line 76 of file gpuVertexFinder.h.

Referenced by make().

◆ errmax

float gpuVertexFinder::Producer::errmax
private

Definition at line 77 of file gpuVertexFinder.h.

Referenced by make().

◆ minT

int gpuVertexFinder::Producer::minT
private

Definition at line 75 of file gpuVertexFinder.h.

Referenced by make().

◆ oneKernel_

const bool gpuVertexFinder::Producer::oneKernel_
private

Definition at line 70 of file gpuVertexFinder.h.

Referenced by make().

◆ useDBSCAN_

const bool gpuVertexFinder::Producer::useDBSCAN_
private

Definition at line 72 of file gpuVertexFinder.h.

Referenced by make().

◆ useDensity_

const bool gpuVertexFinder::Producer::useDensity_
private

Definition at line 71 of file gpuVertexFinder.h.

Referenced by make().

◆ useIterative_

const bool gpuVertexFinder::Producer::useIterative_
private

Definition at line 73 of file gpuVertexFinder.h.

Referenced by make().

gpuVertexFinder::maxChi2ForSplit
constexpr float maxChi2ForSplit
Definition: gpuVertexFinderImpl.h:22
gpuVertexFinder::Producer::useDBSCAN_
const bool useDBSCAN_
Definition: gpuVertexFinder.h:72
gpuVertexFinder::init
pws init()
gpuVertexFinder::Producer::oneKernel_
const bool oneKernel_
Definition: gpuVertexFinder.h:70
gpuVertexFinder::assert
assert(pdata)
gpuVertexFinder::Producer::useIterative_
const bool useIterative_
Definition: gpuVertexFinder.h:73
cms::cuda::stream
cudaStream_t stream
Definition: HistoContainer.h:57
gather_cfg.cout
cout
Definition: gather_cfg.py:144
gpuVertexFinder::soa
ZVertexSoA * soa
Definition: gpuVertexFinderImpl.h:24
HeterogeneousSoA
Definition: HeterogeneousSoA.h:13
TrackSoAHeterogeneousT::stride
static constexpr int32_t stride()
Definition: TrackSoAHeterogeneousT.h:16
gpuVertexFinder::Producer::minT
int minT
Definition: gpuVertexFinder.h:75
gpuVertexFinder::Producer::eps
float eps
Definition: gpuVertexFinder.h:76
gpuVertexFinder::maxChi2ForFirstFit
constexpr float maxChi2ForFirstFit
Definition: gpuVertexFinderImpl.h:18
gpuVertexFinder::Producer::errmax
float errmax
Definition: gpuVertexFinder.h:77
gpuVertexFinder::Producer::chi2max
float chi2max
Definition: gpuVertexFinder.h:78
gpuVertexFinder::maxChi2ForFinalFit
constexpr float maxChi2ForFinalFit
Definition: gpuVertexFinderImpl.h:19
cudaCheck
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:62
gpuVertexFinder::Producer::useDensity_
const bool useDensity_
Definition: gpuVertexFinder.h:71
gpuVertexFinder::ptMin
ZVertexSoA WorkSpace float ptMin
Definition: gpuVertexFinderImpl.h:24
pwdgSkimBPark_cfi.vertices
vertices
Definition: pwdgSkimBPark_cfi.py:7