Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:28:35

0001 #include "RiemannFitOnGPU.h"
0002 
0003 template <typename TrackerTraits>
0004 void HelixFitOnGPU<TrackerTraits>::launchRiemannKernelsOnCPU(const TrackingRecHitSoAConstView<TrackerTraits> &hv,
0005                                                              uint32_t nhits,
0006                                                              uint32_t maxNumberOfTuples) {
0007   assert(tuples_);
0008 
0009   //  Fit internals
0010   auto hitsGPU =
0011       std::make_unique<double[]>(maxNumberOfConcurrentFits_ * sizeof(riemannFit::Matrix3xNd<4>) / sizeof(double));
0012   auto hits_geGPU =
0013       std::make_unique<float[]>(maxNumberOfConcurrentFits_ * sizeof(riemannFit::Matrix6x4f) / sizeof(float));
0014   auto fast_fit_resultsGPU =
0015       std::make_unique<double[]>(maxNumberOfConcurrentFits_ * sizeof(riemannFit::Vector4d) / sizeof(double));
0016   auto circle_fit_resultsGPU_holder =
0017       std::make_unique<char[]>(maxNumberOfConcurrentFits_ * sizeof(riemannFit::CircleFit));
0018   riemannFit::CircleFit *circle_fit_resultsGPU = (riemannFit::CircleFit *)(circle_fit_resultsGPU_holder.get());
0019 
0020   for (uint32_t offset = 0; offset < maxNumberOfTuples; offset += maxNumberOfConcurrentFits_) {
0021     // triplets
0022     kernel_FastFit<3, TrackerTraits>(
0023         tuples_, tupleMultiplicity_, 3, hv, hitsGPU.get(), hits_geGPU.get(), fast_fit_resultsGPU.get(), offset);
0024 
0025     kernel_CircleFit<3, TrackerTraits>(tupleMultiplicity_,
0026                                        3,
0027                                        bField_,
0028                                        hitsGPU.get(),
0029                                        hits_geGPU.get(),
0030                                        fast_fit_resultsGPU.get(),
0031                                        circle_fit_resultsGPU,
0032                                        offset);
0033 
0034     kernel_LineFit<3, TrackerTraits>(tupleMultiplicity_,
0035                                      3,
0036                                      bField_,
0037                                      outputSoa_,
0038                                      hitsGPU.get(),
0039                                      hits_geGPU.get(),
0040                                      fast_fit_resultsGPU.get(),
0041                                      circle_fit_resultsGPU,
0042                                      offset);
0043 
0044     // quads
0045     kernel_FastFit<4, TrackerTraits>(
0046         tuples_, tupleMultiplicity_, 4, hv, hitsGPU.get(), hits_geGPU.get(), fast_fit_resultsGPU.get(), offset);
0047 
0048     kernel_CircleFit<4, TrackerTraits>(tupleMultiplicity_,
0049                                        4,
0050                                        bField_,
0051                                        hitsGPU.get(),
0052                                        hits_geGPU.get(),
0053                                        fast_fit_resultsGPU.get(),
0054                                        circle_fit_resultsGPU,
0055                                        offset);
0056 
0057     kernel_LineFit<4, TrackerTraits>(tupleMultiplicity_,
0058                                      4,
0059                                      bField_,
0060                                      outputSoa_,
0061                                      hitsGPU.get(),
0062                                      hits_geGPU.get(),
0063                                      fast_fit_resultsGPU.get(),
0064                                      circle_fit_resultsGPU,
0065                                      offset);
0066 
0067     if (fitNas4_) {
0068       // penta
0069       kernel_FastFit<4, TrackerTraits>(
0070           tuples_, tupleMultiplicity_, 5, hv, hitsGPU.get(), hits_geGPU.get(), fast_fit_resultsGPU.get(), offset);
0071 
0072       kernel_CircleFit<4, TrackerTraits>(tupleMultiplicity_,
0073                                          5,
0074                                          bField_,
0075                                          hitsGPU.get(),
0076                                          hits_geGPU.get(),
0077                                          fast_fit_resultsGPU.get(),
0078                                          circle_fit_resultsGPU,
0079                                          offset);
0080 
0081       kernel_LineFit<4, TrackerTraits>(tupleMultiplicity_,
0082                                        5,
0083                                        bField_,
0084                                        outputSoa_,
0085                                        hitsGPU.get(),
0086                                        hits_geGPU.get(),
0087                                        fast_fit_resultsGPU.get(),
0088                                        circle_fit_resultsGPU,
0089                                        offset);
0090 
0091     } else {
0092       // penta all 5
0093       kernel_FastFit<5, TrackerTraits>(
0094           tuples_, tupleMultiplicity_, 5, hv, hitsGPU.get(), hits_geGPU.get(), fast_fit_resultsGPU.get(), offset);
0095 
0096       kernel_CircleFit<5, TrackerTraits>(tupleMultiplicity_,
0097                                          5,
0098                                          bField_,
0099                                          hitsGPU.get(),
0100                                          hits_geGPU.get(),
0101                                          fast_fit_resultsGPU.get(),
0102                                          circle_fit_resultsGPU,
0103                                          offset);
0104 
0105       kernel_LineFit<5, TrackerTraits>(tupleMultiplicity_,
0106                                        5,
0107                                        bField_,
0108                                        outputSoa_,
0109                                        hitsGPU.get(),
0110                                        hits_geGPU.get(),
0111                                        fast_fit_resultsGPU.get(),
0112                                        circle_fit_resultsGPU,
0113                                        offset);
0114     }
0115   }
0116 }
0117 
0118 template class HelixFitOnGPU<pixelTopology::Phase1>;
0119 template class HelixFitOnGPU<pixelTopology::Phase2>;
0120 template class HelixFitOnGPU<pixelTopology::HIonPhase1>;