Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 10:02:45

0001 #include "BrokenLineFitOnGPU.h"
0002 
0003 template <typename TrackerTraits>
0004 void HelixFitOnGPU<TrackerTraits>::launchBrokenLineKernelsOnCPU(const TrackingRecHitSoAConstView<TrackerTraits> &hv,
0005                                                                 uint32_t hitsInFit,
0006                                                                 uint32_t maxNumberOfTuples) {
0007   assert(tuples_);
0008 
0009 #ifdef BROKENLINE_DEBUG
0010   setlinebuf(stdout);
0011 #endif
0012 
0013   //  Fit internals
0014   auto tkidGPU = std::make_unique<typename TrackerTraits::tindex_type[]>(maxNumberOfConcurrentFits_);
0015   auto hitsGPU =
0016       std::make_unique<double[]>(maxNumberOfConcurrentFits_ * sizeof(riemannFit::Matrix3xNd<6>) / sizeof(double));
0017   auto hits_geGPU =
0018       std::make_unique<float[]>(maxNumberOfConcurrentFits_ * sizeof(riemannFit::Matrix6xNf<6>) / sizeof(float));
0019   auto fast_fit_resultsGPU =
0020       std::make_unique<double[]>(maxNumberOfConcurrentFits_ * sizeof(riemannFit::Vector4d) / sizeof(double));
0021 
0022   for (uint32_t offset = 0; offset < maxNumberOfTuples; offset += maxNumberOfConcurrentFits_) {
0023     // fit triplets
0024     kernel_BLFastFit<3, TrackerTraits>(tuples_,
0025                                        tupleMultiplicity_,
0026                                        hv,
0027                                        tkidGPU.get(),
0028                                        hitsGPU.get(),
0029                                        hits_geGPU.get(),
0030                                        fast_fit_resultsGPU.get(),
0031                                        3,
0032                                        3,
0033                                        offset);
0034 
0035     kernel_BLFit<3, TrackerTraits>(tupleMultiplicity_,
0036                                    bField_,
0037                                    outputSoa_,
0038                                    tkidGPU.get(),
0039                                    hitsGPU.get(),
0040                                    hits_geGPU.get(),
0041                                    fast_fit_resultsGPU.get());
0042     if (fitNas4_) {
0043       riemannFit::rolling_fits<4, TrackerTraits::maxHitsOnTrack, 1>(
0044           [this, &hv, &tkidGPU, &hitsGPU, &hits_geGPU, &fast_fit_resultsGPU, &offset](auto i) {
0045             kernel_BLFastFit<4, TrackerTraits>(tuples_,
0046                                                tupleMultiplicity_,
0047                                                hv,
0048                                                tkidGPU.get(),
0049                                                hitsGPU.get(),
0050                                                hits_geGPU.get(),
0051                                                fast_fit_resultsGPU.get(),
0052                                                4,
0053                                                i,
0054                                                offset);
0055 
0056             kernel_BLFit<4, TrackerTraits>(tupleMultiplicity_,
0057                                            bField_,
0058                                            outputSoa_,
0059                                            tkidGPU.get(),
0060                                            hitsGPU.get(),
0061                                            hits_geGPU.get(),
0062                                            fast_fit_resultsGPU.get());
0063           });
0064 
0065     } else {
0066       //Fit these using all the hits they have
0067       riemannFit::rolling_fits<4, TrackerTraits::maxHitsOnTrackForFullFit, 1>(
0068           [this, &hv, &tkidGPU, &hitsGPU, &hits_geGPU, &fast_fit_resultsGPU, &offset](auto i) {
0069             kernel_BLFastFit<i, TrackerTraits>(tuples_,
0070                                                tupleMultiplicity_,
0071                                                hv,
0072                                                tkidGPU.get(),
0073                                                hitsGPU.get(),
0074                                                hits_geGPU.get(),
0075                                                fast_fit_resultsGPU.get(),
0076                                                i,
0077                                                i,
0078                                                offset);
0079 
0080             kernel_BLFit<i, TrackerTraits>(tupleMultiplicity_,
0081                                            bField_,
0082                                            outputSoa_,
0083                                            tkidGPU.get(),
0084                                            hitsGPU.get(),
0085                                            hits_geGPU.get(),
0086                                            fast_fit_resultsGPU.get());
0087           });
0088 
0089       static_assert(TrackerTraits::maxHitsOnTrackForFullFit < TrackerTraits::maxHitsOnTrack);
0090 
0091       //Fit all the rest using the maximum from previous call
0092 
0093       kernel_BLFastFit<TrackerTraits::maxHitsOnTrackForFullFit, TrackerTraits>(tuples_,
0094                                                                                tupleMultiplicity_,
0095                                                                                hv,
0096                                                                                tkidGPU.get(),
0097                                                                                hitsGPU.get(),
0098                                                                                hits_geGPU.get(),
0099                                                                                fast_fit_resultsGPU.get(),
0100                                                                                TrackerTraits::maxHitsOnTrackForFullFit,
0101                                                                                TrackerTraits::maxHitsOnTrack - 1,
0102                                                                                offset);
0103 
0104       kernel_BLFit<TrackerTraits::maxHitsOnTrackForFullFit, TrackerTraits>(tupleMultiplicity_,
0105                                                                            bField_,
0106                                                                            outputSoa_,
0107                                                                            tkidGPU.get(),
0108                                                                            hitsGPU.get(),
0109                                                                            hits_geGPU.get(),
0110                                                                            fast_fit_resultsGPU.get());
0111     }
0112 
0113   }  // loop on concurrent fits
0114 }
0115 
0116 template class HelixFitOnGPU<pixelTopology::Phase1>;
0117 template class HelixFitOnGPU<pixelTopology::Phase2>;
0118 template class HelixFitOnGPU<pixelTopology::HIonPhase1>;