From 00013ddd202dcd2f50761b903430f137d2b7fa19 Mon Sep 17 00:00:00 2001 From: Slava Krutelyov Date: Thu, 24 Oct 2024 12:02:14 -0700 Subject: [PATCH] migrate pT3 and pT5 to SoATemplate --- RecoTracker/LSTCore/interface/Constants.h | 3 + .../PixelQuintupletsHostCollection.h | 10 + .../LSTCore/interface/PixelQuintupletsSoA.h | 35 +++ .../interface/PixelTripletsHostCollection.h | 10 + .../LSTCore/interface/PixelTripletsSoA.h | 39 +++ .../alpaka/PixelQuintupletsDeviceCollection.h | 10 + .../alpaka/PixelTripletsDeviceCollection.h | 10 + RecoTracker/LSTCore/src/alpaka/Event.dev.cc | 197 ++++++--------- RecoTracker/LSTCore/src/alpaka/Event.h | 22 +- RecoTracker/LSTCore/src/alpaka/Kernels.h | 71 +++--- .../LSTCore/src/alpaka/PixelQuintuplet.h | 223 ++++------------- RecoTracker/LSTCore/src/alpaka/PixelTriplet.h | 226 ++++-------------- RecoTracker/LSTCore/src/alpaka/Quintuplet.h | 1 + .../LSTCore/src/alpaka/TrackCandidate.h | 118 ++++----- .../standalone/code/core/AccessHelper.cc | 16 +- .../standalone/code/core/write_lst_ntuple.cc | 9 +- 16 files changed, 415 insertions(+), 585 deletions(-) create mode 100644 RecoTracker/LSTCore/interface/PixelQuintupletsHostCollection.h create mode 100644 RecoTracker/LSTCore/interface/PixelQuintupletsSoA.h create mode 100644 RecoTracker/LSTCore/interface/PixelTripletsHostCollection.h create mode 100644 RecoTracker/LSTCore/interface/PixelTripletsSoA.h create mode 100644 RecoTracker/LSTCore/interface/alpaka/PixelQuintupletsDeviceCollection.h create mode 100644 RecoTracker/LSTCore/interface/alpaka/PixelTripletsDeviceCollection.h diff --git a/RecoTracker/LSTCore/interface/Constants.h b/RecoTracker/LSTCore/interface/Constants.h index 2f93e9e10c204..82e889be9a780 100644 --- a/RecoTracker/LSTCore/interface/Constants.h +++ b/RecoTracker/LSTCore/interface/Constants.h @@ -103,6 +103,9 @@ namespace lst { }; struct Params_pT3 { static constexpr int kLayers = 5, kHits = 10; + using ArrayU8xLayers = edm::StdArray; + using ArrayU16xLayers = edm::StdArray; + using ArrayUxHits = edm::StdArray; }; struct Params_T5 { static constexpr int kLayers = 5, kHits = 10; diff --git a/RecoTracker/LSTCore/interface/PixelQuintupletsHostCollection.h b/RecoTracker/LSTCore/interface/PixelQuintupletsHostCollection.h new file mode 100644 index 0000000000000..afb2560680621 --- /dev/null +++ b/RecoTracker/LSTCore/interface/PixelQuintupletsHostCollection.h @@ -0,0 +1,10 @@ +#ifndef RecoTracker_LSTCore_interface_PixelQuintupletsHostCollection_h +#define RecoTracker_LSTCore_interface_PixelQuintupletsHostCollection_h + +#include "RecoTracker/LSTCore/interface/PixelQuintupletsSoA.h" +#include "DataFormats/Portable/interface/PortableHostCollection.h" + +namespace lst { + using PixelQuintupletsHostCollection = PortableHostCollection; +} // namespace lst +#endif diff --git a/RecoTracker/LSTCore/interface/PixelQuintupletsSoA.h b/RecoTracker/LSTCore/interface/PixelQuintupletsSoA.h new file mode 100644 index 0000000000000..504594dae6d94 --- /dev/null +++ b/RecoTracker/LSTCore/interface/PixelQuintupletsSoA.h @@ -0,0 +1,35 @@ +#ifndef RecoTracker_LSTCore_interface_PixelQuintupletsSoA_h +#define RecoTracker_LSTCore_interface_PixelQuintupletsSoA_h + +#include +#include "DataFormats/Common/interface/StdArray.h" +#include "DataFormats/SoATemplate/interface/SoALayout.h" + +#include "RecoTracker/LSTCore/interface/Constants.h" + +namespace lst { + GENERATE_SOA_LAYOUT(PixelQuintupletsSoALayout, + SOA_COLUMN(unsigned int, pixelSegmentIndices), + SOA_COLUMN(unsigned int, quintupletIndices), + SOA_COLUMN(Params_pT5::ArrayU16xLayers, lowerModuleIndices), // lower module index (OT part) + SOA_COLUMN(Params_pT5::ArrayU8xLayers, logicalLayers), // layer ID + SOA_COLUMN(Params_pT5::ArrayUxHits, hitIndices), // hit indices + SOA_COLUMN(float, rPhiChiSquared), // chi2 from pLS to T5 + SOA_COLUMN(float, rPhiChiSquaredInwards), // chi2 from T5 to pLS + SOA_COLUMN(float, rzChiSquared), + SOA_COLUMN(FPX, pixelRadius), // pLS pt converted + SOA_COLUMN(FPX, quintupletRadius), // T5 circle + SOA_COLUMN(FPX, eta), + SOA_COLUMN(FPX, phi), + SOA_COLUMN(FPX, score), // used for ranking (in e.g. duplicate cleaning) + SOA_COLUMN(FPX, centerX), // T3-based circle center x + SOA_COLUMN(FPX, centerY), // T3-based circle center y + SOA_COLUMN(bool, isDup), + SOA_SCALAR(unsigned int, nPixelQuintuplets), + SOA_SCALAR(unsigned int, totOccupancyPixelQuintuplets)); + + using PixelQuintupletsSoA = PixelQuintupletsSoALayout<>; + using PixelQuintuplets = PixelQuintupletsSoA::View; + using PixelQuintupletsConst = PixelQuintupletsSoA::ConstView; +} // namespace lst +#endif diff --git a/RecoTracker/LSTCore/interface/PixelTripletsHostCollection.h b/RecoTracker/LSTCore/interface/PixelTripletsHostCollection.h new file mode 100644 index 0000000000000..67678e64bfc03 --- /dev/null +++ b/RecoTracker/LSTCore/interface/PixelTripletsHostCollection.h @@ -0,0 +1,10 @@ +#ifndef RecoTracker_LSTCore_interface_PixelTripletsHostCollection_h +#define RecoTracker_LSTCore_interface_PixelTripletsHostCollection_h + +#include "RecoTracker/LSTCore/interface/PixelTripletsSoA.h" +#include "DataFormats/Portable/interface/PortableHostCollection.h" + +namespace lst { + using PixelTripletsHostCollection = PortableHostCollection; +} // namespace lst +#endif diff --git a/RecoTracker/LSTCore/interface/PixelTripletsSoA.h b/RecoTracker/LSTCore/interface/PixelTripletsSoA.h new file mode 100644 index 0000000000000..bf940e2cd3bd0 --- /dev/null +++ b/RecoTracker/LSTCore/interface/PixelTripletsSoA.h @@ -0,0 +1,39 @@ +#ifndef RecoTracker_LSTCore_interface_PixelTripletsSoA_h +#define RecoTracker_LSTCore_interface_PixelTripletsSoA_h + +#include +#include "DataFormats/Common/interface/StdArray.h" +#include "DataFormats/SoATemplate/interface/SoALayout.h" + +#include "RecoTracker/LSTCore/interface/Constants.h" + +namespace lst { + GENERATE_SOA_LAYOUT(PixelTripletsSoALayout, + SOA_COLUMN(unsigned int, pixelSegmentIndices), + SOA_COLUMN(unsigned int, tripletIndices), + SOA_COLUMN(Params_pT3::ArrayU16xLayers, lowerModuleIndices), // lower module index (OT part) + SOA_COLUMN(Params_pT3::ArrayU8xLayers, logicalLayers), // layer ID + SOA_COLUMN(Params_pT3::ArrayUxHits, hitIndices), // hit indices + SOA_COLUMN(float, rPhiChiSquared), // chi2 from pLS to T3 + SOA_COLUMN(float, rPhiChiSquaredInwards), // chi2 from T3 to pLS + SOA_COLUMN(float, rzChiSquared), + SOA_COLUMN(FPX, pixelRadius), // pLS pt converted + SOA_COLUMN(FPX, tripletRadius), // T3 circle + SOA_COLUMN(FPX, pt), + SOA_COLUMN(FPX, eta), + SOA_COLUMN(FPX, phi), + SOA_COLUMN(FPX, eta_pix), // eta from pLS + SOA_COLUMN(FPX, phi_pix), // phi from pLS + SOA_COLUMN(FPX, score), // used for ranking (in e.g. duplicate cleaning) + SOA_COLUMN(FPX, centerX), // T3-based circle center x + SOA_COLUMN(FPX, centerY), // T3-based circle center y + SOA_COLUMN(bool, isDup), + SOA_SCALAR(unsigned int, nPixelTriplets), + SOA_SCALAR(unsigned int, totOccupancyPixelTriplets)); + + using PixelTripletsSoA = PixelTripletsSoALayout<>; + using PixelTriplets = PixelTripletsSoA::View; + using PixelTripletsConst = PixelTripletsSoA::ConstView; + +} // namespace lst +#endif diff --git a/RecoTracker/LSTCore/interface/alpaka/PixelQuintupletsDeviceCollection.h b/RecoTracker/LSTCore/interface/alpaka/PixelQuintupletsDeviceCollection.h new file mode 100644 index 0000000000000..e2553f7b42c50 --- /dev/null +++ b/RecoTracker/LSTCore/interface/alpaka/PixelQuintupletsDeviceCollection.h @@ -0,0 +1,10 @@ +#ifndef RecoTracker_LSTCore_interface_PixelQuintupletsDeviceCollection_h +#define RecoTracker_LSTCore_interface_PixelQuintupletsDeviceCollection_h + +#include "RecoTracker/LSTCore/interface/PixelQuintupletsSoA.h" +#include "DataFormats/Portable/interface/alpaka/PortableCollection.h" + +namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { + using PixelQuintupletsDeviceCollection = PortableCollection; +} // namespace ALPAKA_ACCELERATOR_NAMESPACE::lst +#endif diff --git a/RecoTracker/LSTCore/interface/alpaka/PixelTripletsDeviceCollection.h b/RecoTracker/LSTCore/interface/alpaka/PixelTripletsDeviceCollection.h new file mode 100644 index 0000000000000..ac010b9028ac4 --- /dev/null +++ b/RecoTracker/LSTCore/interface/alpaka/PixelTripletsDeviceCollection.h @@ -0,0 +1,10 @@ +#ifndef RecoTracker_LSTCore_interface_PixelTripletsDeviceCollection_h +#define RecoTracker_LSTCore_interface_PixelTripletsDeviceCollection_h + +#include "RecoTracker/LSTCore/interface/PixelTripletsSoA.h" +#include "DataFormats/Portable/interface/alpaka/PortableCollection.h" + +namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { + using PixelTripletsDeviceCollection = PortableCollection; +} // namespace ALPAKA_ACCELERATOR_NAMESPACE::lst +#endif diff --git a/RecoTracker/LSTCore/src/alpaka/Event.dev.cc b/RecoTracker/LSTCore/src/alpaka/Event.dev.cc index 5c75a079425c5..e64a9cda41609 100644 --- a/RecoTracker/LSTCore/src/alpaka/Event.dev.cc +++ b/RecoTracker/LSTCore/src/alpaka/Event.dev.cc @@ -3,6 +3,8 @@ #include "Event.h" #include "MiniDoublet.h" +#include "PixelQuintuplet.h" +#include "PixelTriplet.h" #include "Quintuplet.h" #include "Segment.h" #include "TrackCandidate.h" @@ -66,10 +68,8 @@ void Event::resetEventSync() { tripletsDC_.reset(); quintupletsDC_.reset(); trackCandidatesDC_.reset(); - pixelTripletsInGPU_.reset(); - pixelTripletsBuffers_.reset(); - pixelQuintupletsInGPU_.reset(); - pixelQuintupletsBuffers_.reset(); + pixelTripletsDC_.reset(); + pixelQuintupletsDC_.reset(); hitsInCPU_.reset(); rangesInCPU_.reset(); @@ -77,8 +77,8 @@ void Event::resetEventSync() { segmentsHC_.reset(); tripletsHC_.reset(); quintupletsHC_.reset(); - pixelTripletsInCPU_.reset(); - pixelQuintupletsInCPU_.reset(); + pixelTripletsHC_.reset(); + pixelQuintupletsHC_.reset(); trackCandidatesHC_.reset(); modulesInCPU_.reset(); } @@ -545,17 +545,17 @@ void Event::createTrackCandidates(bool no_pls_dupclean, bool tc_pls_triplets) { CrossCleanpT3{}, *modulesBuffers_.data(), *rangesInGPU_, - *pixelTripletsInGPU_, + pixelTripletsDC_->view(), segmentsDC_->const_view(), - *pixelQuintupletsInGPU_); + pixelQuintupletsDC_->const_view()); - WorkDiv1D const addpT3asTrackCandidatesInGPU_workDiv = createWorkDiv({1}, {512}, {1}); + WorkDiv1D const addpT3asTrackCandidates_workDiv = createWorkDiv({1}, {512}, {1}); alpaka::exec(queue_, - addpT3asTrackCandidatesInGPU_workDiv, - AddpT3asTrackCandidatesInGPU{}, + addpT3asTrackCandidates_workDiv, + AddpT3asTrackCandidates{}, nLowerModules_, - *pixelTripletsInGPU_, + pixelTripletsDC_->const_view(), trackCandidatesDC_->view(), segmentsDC_->const_view(), *rangesInGPU_); @@ -589,8 +589,8 @@ void Event::createTrackCandidates(bool no_pls_dupclean, bool tc_pls_triplets) { *modulesBuffers_.data(), quintupletsDC_->view(), quintupletsDC_->const_view(), - *pixelQuintupletsInGPU_, - *pixelTripletsInGPU_, + pixelQuintupletsDC_->const_view(), + pixelTripletsDC_->const_view(), *rangesInGPU_); Vec3D const threadsPerBlock_addT5asTrackCandidate{1, 8, 128}; @@ -632,7 +632,7 @@ void Event::createTrackCandidates(bool no_pls_dupclean, bool tc_pls_triplets) { CrossCleanpLS{}, *modulesBuffers_.data(), *rangesInGPU_, - *pixelTripletsInGPU_, + pixelTripletsDC_->const_view(), trackCandidatesDC_->view(), segmentsDC_->const_view(), segmentsDC_->const_view(), @@ -686,10 +686,13 @@ void Event::createTrackCandidates(bool no_pls_dupclean, bool tc_pls_triplets) { } void Event::createPixelTriplets() { - if (!pixelTripletsInGPU_) { - pixelTripletsInGPU_.emplace(); - pixelTripletsBuffers_.emplace(n_max_pixel_triplets, devAcc_, queue_); - pixelTripletsInGPU_->setData(*pixelTripletsBuffers_); + if (!pixelTripletsDC_) { + pixelTripletsDC_.emplace(n_max_pixel_triplets, queue_); + auto nPixelTriplets_view = alpaka::createView(devAcc_, &(*pixelTripletsDC_)->nPixelTriplets(), 1u); + alpaka::memset(queue_, nPixelTriplets_view, 0u); + auto totOccupancyPixelTriplets_view = + alpaka::createView(devAcc_, &(*pixelTripletsDC_)->totOccupancyPixelTriplets(), 1u); + alpaka::memset(queue_, totOccupancyPixelTriplets_view, 0u); } SegmentsOccupancy segmentsOccupancy = segmentsDC_->view(); SegmentsPixelConst segmentsPixel = segmentsDC_->view(); @@ -771,12 +774,11 @@ void Event::createPixelTriplets() { Vec3D const threadsPerBlock{1, 4, 32}; Vec3D const blocksPerGrid{16 /* above median of connected modules*/, 4096, 1}; - WorkDiv3D const createPixelTripletsInGPUFromMapv2_workDiv = - createWorkDiv(blocksPerGrid, threadsPerBlock, elementsPerThread); + WorkDiv3D const createPixelTripletsFromMap_workDiv = createWorkDiv(blocksPerGrid, threadsPerBlock, elementsPerThread); alpaka::exec(queue_, - createPixelTripletsInGPUFromMapv2_workDiv, - CreatePixelTripletsInGPUFromMapv2{}, + createPixelTripletsFromMap_workDiv, + CreatePixelTripletsFromMap{}, *modulesBuffers_.data(), *rangesInGPU_, miniDoubletsDC_->const_view(), @@ -784,7 +786,7 @@ void Event::createPixelTriplets() { segmentsDC_->const_view(), tripletsDC_->view(), tripletsDC_->const_view(), - *pixelTripletsInGPU_, + pixelTripletsDC_->view(), connectedPixelSize_dev_buf.data(), connectedPixelIndex_dev_buf.data(), nInnerSegments); @@ -792,7 +794,7 @@ void Event::createPixelTriplets() { #ifdef WARNINGS auto nPixelTriplets_buf = allocBufWrapper(cms::alpakatools::host(), 1, queue_); - alpaka::memcpy(queue_, nPixelTriplets_buf, pixelTripletsBuffers_->nPixelTriplets_buf); + alpaka::memcpy(queue_, nPixelTriplets_buf, alpaka::createView(devAcc_, &(*pixelTripletsDC_)->nPixelTriplets(), 1u)); alpaka::wait(queue_); // wait to get the value before using it std::cout << "number of pixel triplets = " << *nPixelTriplets_buf.data() << std::endl; @@ -802,11 +804,11 @@ void Event::createPixelTriplets() { Vec3D const threadsPerBlockDupPixTrip{1, 16, 16}; //seems like more blocks lead to conflicting writes Vec3D const blocksPerGridDupPixTrip{1, 40, 1}; - WorkDiv3D const removeDupPixelTripletsInGPUFromMap_workDiv = + WorkDiv3D const removeDupPixelTripletsFromMap_workDiv = createWorkDiv(blocksPerGridDupPixTrip, threadsPerBlockDupPixTrip, elementsPerThread); alpaka::exec( - queue_, removeDupPixelTripletsInGPUFromMap_workDiv, RemoveDupPixelTripletsInGPUFromMap{}, *pixelTripletsInGPU_); + queue_, removeDupPixelTripletsFromMap_workDiv, RemoveDupPixelTripletsFromMap{}, pixelTripletsDC_->view()); } void Event::createQuintuplets() { @@ -911,10 +913,13 @@ void Event::pixelLineSegmentCleaning(bool no_pls_dupclean) { } void Event::createPixelQuintuplets() { - if (!pixelQuintupletsInGPU_) { - pixelQuintupletsInGPU_.emplace(); - pixelQuintupletsBuffers_.emplace(n_max_pixel_quintuplets, devAcc_, queue_); - pixelQuintupletsInGPU_->setData(*pixelQuintupletsBuffers_); + if (!pixelQuintupletsDC_) { + pixelQuintupletsDC_.emplace(n_max_pixel_quintuplets, queue_); + auto nPixelQuintuplets_view = alpaka::createView(devAcc_, &(*pixelQuintupletsDC_)->nPixelQuintuplets(), 1u); + alpaka::memset(queue_, nPixelQuintuplets_view, 0u); + auto totOccupancyPixelQuintuplets_view = + alpaka::createView(devAcc_, &(*pixelQuintupletsDC_)->totOccupancyPixelQuintuplets(), 1u); + alpaka::memset(queue_, totOccupancyPixelQuintuplets_view, 0u); } if (!trackCandidatesDC_) { trackCandidatesDC_.emplace(n_max_nonpixel_track_candidates + n_max_pixel_track_candidates, queue_); @@ -1013,7 +1018,7 @@ void Event::createPixelQuintuplets() { tripletsDC_->view(), quintupletsDC_->view(), quintupletsDC_->const_view(), - *pixelQuintupletsInGPU_, + pixelQuintupletsDC_->view(), connectedPixelSize_dev_buf.data(), connectedPixelIndex_dev_buf.data(), nInnerSegments, @@ -1021,21 +1026,21 @@ void Event::createPixelQuintuplets() { Vec3D const threadsPerBlockDupPix{1, 16, 16}; Vec3D const blocksPerGridDupPix{1, max_blocks, 1}; - WorkDiv3D const removeDupPixelQuintupletsInGPUFromMap_workDiv = + WorkDiv3D const removeDupPixelQuintupletsFromMap_workDiv = createWorkDiv(blocksPerGridDupPix, threadsPerBlockDupPix, elementsPerThread); alpaka::exec(queue_, - removeDupPixelQuintupletsInGPUFromMap_workDiv, - RemoveDupPixelQuintupletsInGPUFromMap{}, - *pixelQuintupletsInGPU_); + removeDupPixelQuintupletsFromMap_workDiv, + RemoveDupPixelQuintupletsFromMap{}, + pixelQuintupletsDC_->view()); - WorkDiv1D const addpT5asTrackCandidateInGPU_workDiv = createWorkDiv({1}, {256}, {1}); + WorkDiv1D const addpT5asTrackCandidate_workDiv = createWorkDiv({1}, {256}, {1}); alpaka::exec(queue_, - addpT5asTrackCandidateInGPU_workDiv, - AddpT5asTrackCandidateInGPU{}, + addpT5asTrackCandidate_workDiv, + AddpT5asTrackCandidate{}, nLowerModules_, - *pixelQuintupletsInGPU_, + pixelQuintupletsDC_->const_view(), trackCandidatesDC_->view(), segmentsDC_->const_view(), *rangesInGPU_); @@ -1043,7 +1048,8 @@ void Event::createPixelQuintuplets() { #ifdef WARNINGS auto nPixelQuintuplets_buf = allocBufWrapper(cms::alpakatools::host(), 1, queue_); - alpaka::memcpy(queue_, nPixelQuintuplets_buf, pixelQuintupletsBuffers_->nPixelQuintuplets_buf); + alpaka::memcpy( + queue_, nPixelQuintuplets_buf, alpaka::createView(devAcc_, &(*pixelQuintupletsDC_)->nPixelQuintuplets(), 1u)); alpaka::wait(queue_); // wait to get the value before using it std::cout << "number of pixel quintuplets = " << *nPixelQuintuplets_buf.data() << std::endl; @@ -1277,7 +1283,7 @@ unsigned int Event::getNumberOfTripletsByLayerEndcap(unsigned int layer) { retur int Event::getNumberOfPixelTriplets() { auto nPixelTriplets_buf_h = cms::alpakatools::make_host_buffer(queue_, 1u); - alpaka::memcpy(queue_, nPixelTriplets_buf_h, pixelTripletsBuffers_->nPixelTriplets_buf); + alpaka::memcpy(queue_, nPixelTriplets_buf_h, alpaka::createView(devAcc_, &(*pixelTripletsDC_)->nPixelTriplets(), 1u)); alpaka::wait(queue_); return *nPixelTriplets_buf_h.data(); @@ -1286,7 +1292,8 @@ int Event::getNumberOfPixelTriplets() { int Event::getNumberOfPixelQuintuplets() { auto nPixelQuintuplets_buf_h = cms::alpakatools::make_host_buffer(queue_, 1u); - alpaka::memcpy(queue_, nPixelQuintuplets_buf_h, pixelQuintupletsBuffers_->nPixelQuintuplets_buf); + alpaka::memcpy( + queue_, nPixelQuintuplets_buf_h, alpaka::createView(devAcc_, &(*pixelQuintupletsDC_)->nPixelQuintuplets(), 1u)); alpaka::wait(queue_); return *nPixelQuintuplets_buf_h.data(); @@ -1520,90 +1527,40 @@ typename TSoA::ConstView Event::getQuintuplets(bool sync) { template QuintupletsConst Event::getQuintuplets(bool); template QuintupletsOccupancyConst Event::getQuintuplets(bool); -PixelTripletsBuffer& Event::getPixelTriplets(bool sync) { - if (!pixelTripletsInCPU_) { - // Get nPixelTriplets parameter to initialize host based pixelTripletsInCPU_ - auto nPixelTriplets_buf_h = cms::alpakatools::make_host_buffer(queue_, 1u); - alpaka::memcpy(queue_, nPixelTriplets_buf_h, pixelTripletsBuffers_->nPixelTriplets_buf); - alpaka::wait(queue_); // wait for the value before using - - auto const nPixelTriplets = *nPixelTriplets_buf_h.data(); - pixelTripletsInCPU_.emplace(nPixelTriplets, cms::alpakatools::host(), queue_); - pixelTripletsInCPU_->setData(*pixelTripletsInCPU_); +template +PixelTripletsConst Event::getPixelTriplets(bool sync) { + if constexpr (std::is_same_v) { + return pixelTripletsDC_->const_view(); + } else { + if (!pixelTripletsHC_) { + pixelTripletsHC_.emplace(cms::alpakatools::CopyToHost<::PortableCollection>::copyAsync( + queue_, *pixelTripletsDC_)); - alpaka::memcpy(queue_, pixelTripletsInCPU_->nPixelTriplets_buf, pixelTripletsBuffers_->nPixelTriplets_buf); - alpaka::memcpy(queue_, - pixelTripletsInCPU_->totOccupancyPixelTriplets_buf, - pixelTripletsBuffers_->totOccupancyPixelTriplets_buf); - alpaka::memcpy( - queue_, pixelTripletsInCPU_->rzChiSquared_buf, pixelTripletsBuffers_->rzChiSquared_buf, nPixelTriplets); - alpaka::memcpy( - queue_, pixelTripletsInCPU_->rPhiChiSquared_buf, pixelTripletsBuffers_->rPhiChiSquared_buf, nPixelTriplets); - alpaka::memcpy(queue_, - pixelTripletsInCPU_->rPhiChiSquaredInwards_buf, - pixelTripletsBuffers_->rPhiChiSquaredInwards_buf, - nPixelTriplets); - alpaka::memcpy( - queue_, pixelTripletsInCPU_->tripletIndices_buf, pixelTripletsBuffers_->tripletIndices_buf, nPixelTriplets); - alpaka::memcpy(queue_, - pixelTripletsInCPU_->pixelSegmentIndices_buf, - pixelTripletsBuffers_->pixelSegmentIndices_buf, - nPixelTriplets); - alpaka::memcpy( - queue_, pixelTripletsInCPU_->pixelRadius_buf, pixelTripletsBuffers_->pixelRadius_buf, nPixelTriplets); - alpaka::memcpy( - queue_, pixelTripletsInCPU_->tripletRadius_buf, pixelTripletsBuffers_->tripletRadius_buf, nPixelTriplets); - alpaka::memcpy(queue_, pixelTripletsInCPU_->isDup_buf, pixelTripletsBuffers_->isDup_buf, nPixelTriplets); - alpaka::memcpy(queue_, pixelTripletsInCPU_->eta_buf, pixelTripletsBuffers_->eta_buf, nPixelTriplets); - alpaka::memcpy(queue_, pixelTripletsInCPU_->phi_buf, pixelTripletsBuffers_->phi_buf, nPixelTriplets); - alpaka::memcpy(queue_, pixelTripletsInCPU_->score_buf, pixelTripletsBuffers_->score_buf, nPixelTriplets); - if (sync) - alpaka::wait(queue_); // host consumers expect filled data + if (sync) + alpaka::wait(queue_); // host consumers expect filled data + } } - return pixelTripletsInCPU_.value(); + return pixelTripletsHC_->const_view(); } +template PixelTripletsConst Event::getPixelTriplets<>(bool); -PixelQuintupletsBuffer& Event::getPixelQuintuplets(bool sync) { - if (!pixelQuintupletsInCPU_) { - // Get nPixelQuintuplets parameter to initialize host based quintupletsInCPU_ - auto nPixelQuintuplets_buf_h = cms::alpakatools::make_host_buffer(queue_, 1u); - alpaka::memcpy(queue_, nPixelQuintuplets_buf_h, pixelQuintupletsBuffers_->nPixelQuintuplets_buf); - alpaka::wait(queue_); // wait for the value before using - - auto const nPixelQuintuplets = *nPixelQuintuplets_buf_h.data(); - pixelQuintupletsInCPU_.emplace(nPixelQuintuplets, cms::alpakatools::host(), queue_); - pixelQuintupletsInCPU_->setData(*pixelQuintupletsInCPU_); +template +PixelQuintupletsConst Event::getPixelQuintuplets(bool sync) { + if constexpr (std::is_same_v) { + return pixelQuintupletsDC_->const_view(); + } else { + if (!pixelQuintupletsHC_) { + pixelQuintupletsHC_.emplace( + cms::alpakatools::CopyToHost<::PortableCollection>::copyAsync( + queue_, *pixelQuintupletsDC_)); - alpaka::memcpy( - queue_, pixelQuintupletsInCPU_->nPixelQuintuplets_buf, pixelQuintupletsBuffers_->nPixelQuintuplets_buf); - alpaka::memcpy(queue_, - pixelQuintupletsInCPU_->totOccupancyPixelQuintuplets_buf, - pixelQuintupletsBuffers_->totOccupancyPixelQuintuplets_buf); - alpaka::memcpy(queue_, - pixelQuintupletsInCPU_->rzChiSquared_buf, - pixelQuintupletsBuffers_->rzChiSquared_buf, - nPixelQuintuplets); - alpaka::memcpy(queue_, - pixelQuintupletsInCPU_->rPhiChiSquared_buf, - pixelQuintupletsBuffers_->rPhiChiSquared_buf, - nPixelQuintuplets); - alpaka::memcpy(queue_, - pixelQuintupletsInCPU_->rPhiChiSquaredInwards_buf, - pixelQuintupletsBuffers_->rPhiChiSquaredInwards_buf, - nPixelQuintuplets); - alpaka::memcpy(queue_, - pixelQuintupletsInCPU_->pixelIndices_buf, - pixelQuintupletsBuffers_->pixelIndices_buf, - nPixelQuintuplets); - alpaka::memcpy( - queue_, pixelQuintupletsInCPU_->T5Indices_buf, pixelQuintupletsBuffers_->T5Indices_buf, nPixelQuintuplets); - alpaka::memcpy(queue_, pixelQuintupletsInCPU_->isDup_buf, pixelQuintupletsBuffers_->isDup_buf, nPixelQuintuplets); - alpaka::memcpy(queue_, pixelQuintupletsInCPU_->score_buf, pixelQuintupletsBuffers_->score_buf, nPixelQuintuplets); - if (sync) - alpaka::wait(queue_); // host consumers expect filled data + if (sync) + alpaka::wait(queue_); // host consumers expect filled data + } } - return pixelQuintupletsInCPU_.value(); + return pixelQuintupletsHC_->const_view(); } +template PixelQuintupletsConst Event::getPixelQuintuplets<>(bool); const TrackCandidatesConst& Event::getTrackCandidatesWithSelection(bool inCMSSW, bool sync) { if (!trackCandidatesHC_) { diff --git a/RecoTracker/LSTCore/src/alpaka/Event.h b/RecoTracker/LSTCore/src/alpaka/Event.h index 3ec220074e164..97cab0bc608a7 100644 --- a/RecoTracker/LSTCore/src/alpaka/Event.h +++ b/RecoTracker/LSTCore/src/alpaka/Event.h @@ -4,6 +4,8 @@ #include #include "RecoTracker/LSTCore/interface/MiniDoubletsSoA.h" +#include "RecoTracker/LSTCore/interface/PixelQuintupletsHostCollection.h" +#include "RecoTracker/LSTCore/interface/PixelTripletsHostCollection.h" #include "RecoTracker/LSTCore/interface/QuintupletsHostCollection.h" #include "RecoTracker/LSTCore/interface/SegmentsSoA.h" #include "RecoTracker/LSTCore/interface/TrackCandidatesHostCollection.h" @@ -11,6 +13,8 @@ #include "RecoTracker/LSTCore/interface/alpaka/Constants.h" #include "RecoTracker/LSTCore/interface/alpaka/LST.h" #include "RecoTracker/LSTCore/interface/alpaka/MiniDoubletsDeviceCollection.h" +#include "RecoTracker/LSTCore/interface/alpaka/PixelQuintupletsDeviceCollection.h" +#include "RecoTracker/LSTCore/interface/alpaka/PixelTripletsDeviceCollection.h" #include "RecoTracker/LSTCore/interface/alpaka/QuintupletsDeviceCollection.h" #include "RecoTracker/LSTCore/interface/alpaka/SegmentsDeviceCollection.h" #include "RecoTracker/LSTCore/interface/alpaka/TrackCandidatesDeviceCollection.h" @@ -19,8 +23,6 @@ #include "Hit.h" #include "Kernels.h" -#include "PixelQuintuplet.h" -#include "PixelTriplet.h" #include "HeterogeneousCore/AlpakaInterface/interface/host.h" @@ -56,10 +58,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { std::optional tripletsDC_; std::optional quintupletsDC_; std::optional trackCandidatesDC_; - std::optional pixelTripletsInGPU_; - std::optional> pixelTripletsBuffers_; - std::optional pixelQuintupletsInGPU_; - std::optional> pixelQuintupletsBuffers_; + std::optional pixelTripletsDC_; + std::optional pixelQuintupletsDC_; //CPU interface stuff std::optional> rangesInCPU_; @@ -70,8 +70,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { std::optional trackCandidatesHC_; std::optional> modulesInCPU_; std::optional quintupletsHC_; - std::optional> pixelTripletsInCPU_; - std::optional> pixelQuintupletsInCPU_; + std::optional pixelTripletsHC_; + std::optional pixelQuintupletsHC_; void initSync(bool verbose); @@ -191,8 +191,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { typename TSoA::ConstView getTriplets(bool sync = true); template typename TSoA::ConstView getQuintuplets(bool sync = true); - PixelTripletsBuffer& getPixelTriplets(bool sync = true); - PixelQuintupletsBuffer& getPixelQuintuplets(bool sync = true); + template + PixelTripletsConst getPixelTriplets(bool sync = true); + template + PixelQuintupletsConst getPixelQuintuplets(bool sync = true); const TrackCandidatesConst& getTrackCandidatesWithSelection(bool inCMSSW, bool sync); const TrackCandidatesConst& getTrackCandidates(bool sync = true) { return getTrackCandidatesWithSelection(false, sync); diff --git a/RecoTracker/LSTCore/src/alpaka/Kernels.h b/RecoTracker/LSTCore/src/alpaka/Kernels.h index d676a16a15b77..ae4391cc0558c 100644 --- a/RecoTracker/LSTCore/src/alpaka/Kernels.h +++ b/RecoTracker/LSTCore/src/alpaka/Kernels.h @@ -4,14 +4,14 @@ #include "RecoTracker/LSTCore/interface/alpaka/Constants.h" #include "RecoTracker/LSTCore/interface/MiniDoubletsSoA.h" #include "RecoTracker/LSTCore/interface/Module.h" +#include "RecoTracker/LSTCore/interface/PixelQuintupletsSoA.h" +#include "RecoTracker/LSTCore/interface/PixelTripletsSoA.h" #include "RecoTracker/LSTCore/interface/QuintupletsSoA.h" #include "RecoTracker/LSTCore/interface/SegmentsSoA.h" #include "RecoTracker/LSTCore/interface/TripletsSoA.h" #include "Hit.h" #include "ObjectRanges.h" -#include "PixelQuintuplet.h" -#include "PixelTriplet.h" namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { ALPAKA_FN_ACC ALPAKA_FN_INLINE void rmQuintupletFromMemory(Quintuplets quintuplets, @@ -20,14 +20,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { quintuplets.isDup()[quintupletIndex] |= 1 + secondpass; } - ALPAKA_FN_ACC ALPAKA_FN_INLINE void rmPixelTripletFromMemory(PixelTriplets& pixelTripletsInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE void rmPixelTripletFromMemory(PixelTriplets pixelTriplets, unsigned int pixelTripletIndex) { - pixelTripletsInGPU.isDup[pixelTripletIndex] = true; + pixelTriplets.isDup()[pixelTripletIndex] = true; } - ALPAKA_FN_ACC ALPAKA_FN_INLINE void rmPixelQuintupletFromMemory(PixelQuintuplets& pixelQuintupletsInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE void rmPixelQuintupletFromMemory(PixelQuintuplets pixelQuintuplets, unsigned int pixelQuintupletIndex) { - pixelQuintupletsInGPU.isDup[pixelQuintupletIndex] = true; + pixelQuintuplets.isDup()[pixelQuintupletIndex] = true; } ALPAKA_FN_ACC ALPAKA_FN_INLINE void rmPixelSegmentFromMemory(SegmentsPixel segmentsPixel, @@ -63,13 +63,13 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { ALPAKA_FN_ACC ALPAKA_FN_INLINE int checkHitspT5(unsigned int ix, unsigned int jx, - PixelQuintuplets const& pixelQuintupletsInGPU) { + PixelQuintupletsConst pixelQuintuplets) { unsigned int hits1[Params_pT5::kHits]; unsigned int hits2[Params_pT5::kHits]; for (int i = 0; i < Params_pT5::kHits; i++) { - hits1[i] = pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * ix + i]; - hits2[i] = pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * jx + i]; + hits1[i] = pixelQuintuplets.hitIndices()[ix][i]; + hits2[i] = pixelQuintuplets.hitIndices()[jx][i]; } int nMatched = 0; @@ -90,14 +90,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { ALPAKA_FN_ACC ALPAKA_FN_INLINE void checkHitspT3(unsigned int ix, unsigned int jx, - PixelTriplets const& pixelTripletsInGPU, + PixelTripletsConst pixelTriplets, int* matched) { int phits1[Params_pLS::kHits]; int phits2[Params_pLS::kHits]; for (int i = 0; i < Params_pLS::kHits; i++) { - phits1[i] = pixelTripletsInGPU.hitIndices[Params_pT3::kHits * ix + i]; - phits2[i] = pixelTripletsInGPU.hitIndices[Params_pT3::kHits * jx + i]; + phits1[i] = pixelTriplets.hitIndices()[ix][i]; + phits2[i] = pixelTriplets.hitIndices()[jx][i]; } int npMatched = 0; @@ -118,8 +118,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { int hits2[Params_T3::kHits]; for (int i = 0; i < Params_T3::kHits; i++) { - hits1[i] = pixelTripletsInGPU.hitIndices[Params_pT3::kHits * ix + i + 4]; // Omitting the pLS hits - hits2[i] = pixelTripletsInGPU.hitIndices[Params_pT3::kHits * jx + i + 4]; // Omitting the pLS hits + hits1[i] = pixelTriplets.hitIndices()[ix][i + 4]; // Omitting the pLS hits + hits2[i] = pixelTriplets.hitIndices()[jx][i + 4]; // Omitting the pLS hits } int nMatched = 0; @@ -267,35 +267,32 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } }; - struct RemoveDupPixelTripletsInGPUFromMap { + struct RemoveDupPixelTripletsFromMap { template - ALPAKA_FN_ACC void operator()(TAcc const& acc, PixelTriplets pixelTripletsInGPU) const { + ALPAKA_FN_ACC void operator()(TAcc const& acc, PixelTriplets pixelTriplets) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); - for (unsigned int ix = globalThreadIdx[1]; ix < *pixelTripletsInGPU.nPixelTriplets; ix += gridThreadExtent[1]) { - for (unsigned int jx = globalThreadIdx[2]; jx < *pixelTripletsInGPU.nPixelTriplets; jx += gridThreadExtent[2]) { + for (unsigned int ix = globalThreadIdx[1]; ix < pixelTriplets.nPixelTriplets(); ix += gridThreadExtent[1]) { + for (unsigned int jx = globalThreadIdx[2]; jx < pixelTriplets.nPixelTriplets(); jx += gridThreadExtent[2]) { if (ix == jx) continue; int nMatched[2]; - checkHitspT3(ix, jx, pixelTripletsInGPU, nMatched); + checkHitspT3(ix, jx, pixelTriplets, nMatched); const int minNHitsForDup_pT3 = 5; if ((nMatched[0] + nMatched[1]) >= minNHitsForDup_pT3) { // Check the layers - if (pixelTripletsInGPU.logicalLayers[Params_pT3::kLayers * jx + 2] < - pixelTripletsInGPU.logicalLayers[Params_pT3::kLayers * ix + 2]) { - rmPixelTripletFromMemory(pixelTripletsInGPU, ix); + if (pixelTriplets.logicalLayers()[jx][2] < pixelTriplets.logicalLayers()[ix][2]) { + rmPixelTripletFromMemory(pixelTriplets, ix); break; - } else if (pixelTripletsInGPU.logicalLayers[Params_pT3::kLayers * ix + 2] == - pixelTripletsInGPU.logicalLayers[Params_pT3::kLayers * jx + 2] && - __H2F(pixelTripletsInGPU.score[ix]) > __H2F(pixelTripletsInGPU.score[jx])) { - rmPixelTripletFromMemory(pixelTripletsInGPU, ix); + } else if (pixelTriplets.logicalLayers()[ix][2] == pixelTriplets.logicalLayers()[jx][2] && + __H2F(pixelTriplets.score()[ix]) > __H2F(pixelTriplets.score()[jx])) { + rmPixelTripletFromMemory(pixelTriplets, ix); break; - } else if (pixelTripletsInGPU.logicalLayers[Params_pT3::kLayers * ix + 2] == - pixelTripletsInGPU.logicalLayers[Params_pT3::kLayers * jx + 2] && - (__H2F(pixelTripletsInGPU.score[ix]) == __H2F(pixelTripletsInGPU.score[jx])) && (ix < jx)) { - rmPixelTripletFromMemory(pixelTripletsInGPU, ix); + } else if (pixelTriplets.logicalLayers()[ix][2] == pixelTriplets.logicalLayers()[jx][2] && + (__H2F(pixelTriplets.score()[ix]) == __H2F(pixelTriplets.score()[jx])) && (ix < jx)) { + rmPixelTripletFromMemory(pixelTriplets, ix); break; } } @@ -304,25 +301,25 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } }; - struct RemoveDupPixelQuintupletsInGPUFromMap { + struct RemoveDupPixelQuintupletsFromMap { template - ALPAKA_FN_ACC void operator()(TAcc const& acc, PixelQuintuplets pixelQuintupletsInGPU) const { + ALPAKA_FN_ACC void operator()(TAcc const& acc, PixelQuintuplets pixelQuintuplets) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); - unsigned int nPixelQuintuplets = *pixelQuintupletsInGPU.nPixelQuintuplets; + unsigned int nPixelQuintuplets = pixelQuintuplets.nPixelQuintuplets(); for (unsigned int ix = globalThreadIdx[1]; ix < nPixelQuintuplets; ix += gridThreadExtent[1]) { - float score1 = __H2F(pixelQuintupletsInGPU.score[ix]); + float score1 = __H2F(pixelQuintuplets.score()[ix]); for (unsigned int jx = globalThreadIdx[2]; jx < nPixelQuintuplets; jx += gridThreadExtent[2]) { if (ix == jx) continue; - int nMatched = checkHitspT5(ix, jx, pixelQuintupletsInGPU); - float score2 = __H2F(pixelQuintupletsInGPU.score[jx]); + int nMatched = checkHitspT5(ix, jx, pixelQuintuplets); + float score2 = __H2F(pixelQuintuplets.score()[jx]); const int minNHitsForDup_pT5 = 7; if (nMatched >= minNHitsForDup_pT5) { if (score1 > score2 or ((score1 == score2) and (ix > jx))) { - rmPixelQuintupletFromMemory(pixelQuintupletsInGPU, ix); + rmPixelQuintupletFromMemory(pixelQuintuplets, ix); break; } } diff --git a/RecoTracker/LSTCore/src/alpaka/PixelQuintuplet.h b/RecoTracker/LSTCore/src/alpaka/PixelQuintuplet.h index 4dec857eccae3..475c27e750825 100644 --- a/RecoTracker/LSTCore/src/alpaka/PixelQuintuplet.h +++ b/RecoTracker/LSTCore/src/alpaka/PixelQuintuplet.h @@ -4,113 +4,19 @@ #include "RecoTracker/LSTCore/interface/alpaka/Constants.h" #include "RecoTracker/LSTCore/interface/MiniDoubletsSoA.h" #include "RecoTracker/LSTCore/interface/Module.h" +#include "RecoTracker/LSTCore/interface/PixelTripletsSoA.h" #include "RecoTracker/LSTCore/interface/QuintupletsSoA.h" #include "RecoTracker/LSTCore/interface/SegmentsSoA.h" #include "RecoTracker/LSTCore/interface/TripletsSoA.h" #include "Hit.h" -#include "PixelTriplet.h" namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { - struct PixelQuintuplets { - unsigned int* pixelIndices; - unsigned int* T5Indices; - unsigned int* nPixelQuintuplets; - unsigned int* totOccupancyPixelQuintuplets; - bool* isDup; - FPX* score; - FPX* eta; - FPX* phi; - uint8_t* logicalLayers; - unsigned int* hitIndices; - uint16_t* lowerModuleIndices; - FPX* pixelRadius; - FPX* quintupletRadius; - FPX* centerX; - FPX* centerY; - float* rzChiSquared; - float* rPhiChiSquared; - float* rPhiChiSquaredInwards; - - template - void setData(TBuff& buf) { - pixelIndices = buf.pixelIndices_buf.data(); - T5Indices = buf.T5Indices_buf.data(); - nPixelQuintuplets = buf.nPixelQuintuplets_buf.data(); - totOccupancyPixelQuintuplets = buf.totOccupancyPixelQuintuplets_buf.data(); - isDup = buf.isDup_buf.data(); - score = buf.score_buf.data(); - eta = buf.eta_buf.data(); - phi = buf.phi_buf.data(); - logicalLayers = buf.logicalLayers_buf.data(); - hitIndices = buf.hitIndices_buf.data(); - lowerModuleIndices = buf.lowerModuleIndices_buf.data(); - pixelRadius = buf.pixelRadius_buf.data(); - quintupletRadius = buf.quintupletRadius_buf.data(); - centerX = buf.centerX_buf.data(); - centerY = buf.centerY_buf.data(); - rzChiSquared = buf.rzChiSquared_buf.data(); - rPhiChiSquared = buf.rPhiChiSquared_buf.data(); - rPhiChiSquaredInwards = buf.rPhiChiSquaredInwards_buf.data(); - } - }; - - template - struct PixelQuintupletsBuffer { - Buf pixelIndices_buf; - Buf T5Indices_buf; - Buf nPixelQuintuplets_buf; - Buf totOccupancyPixelQuintuplets_buf; - Buf isDup_buf; - Buf score_buf; - Buf eta_buf; - Buf phi_buf; - Buf logicalLayers_buf; - Buf hitIndices_buf; - Buf lowerModuleIndices_buf; - Buf pixelRadius_buf; - Buf quintupletRadius_buf; - Buf centerX_buf; - Buf centerY_buf; - Buf rzChiSquared_buf; - Buf rPhiChiSquared_buf; - Buf rPhiChiSquaredInwards_buf; - - PixelQuintuplets data_; - - template - PixelQuintupletsBuffer(unsigned int maxPixelQuintuplets, TDevAcc const& devAccIn, TQueue& queue) - : pixelIndices_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), - T5Indices_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), - nPixelQuintuplets_buf(allocBufWrapper(devAccIn, 1, queue)), - totOccupancyPixelQuintuplets_buf(allocBufWrapper(devAccIn, 1, queue)), - isDup_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), - score_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), - eta_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), - phi_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), - logicalLayers_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets * Params_pT5::kLayers, queue)), - hitIndices_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets * Params_pT5::kHits, queue)), - lowerModuleIndices_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets * Params_pT5::kLayers, queue)), - pixelRadius_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), - quintupletRadius_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), - centerX_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), - centerY_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), - rzChiSquared_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), - rPhiChiSquared_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), - rPhiChiSquaredInwards_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)) { - alpaka::memset(queue, nPixelQuintuplets_buf, 0u); - alpaka::memset(queue, totOccupancyPixelQuintuplets_buf, 0u); - } - - inline PixelQuintuplets const* data() const { return &data_; } - inline void setData(PixelQuintupletsBuffer& buf) { data_.setData(buf); } - }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE void addPixelQuintupletToMemory(Modules const& modulesInGPU, MiniDoubletsConst mds, SegmentsConst segments, QuintupletsConst quintuplets, - PixelQuintuplets& pixelQuintupletsInGPU, + PixelQuintuplets pixelQuintuplets, unsigned int pixelIndex, unsigned int t5Index, unsigned int pixelQuintupletIndex, @@ -124,81 +30,56 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float quintupletRadius, float centerX, float centerY) { - pixelQuintupletsInGPU.pixelIndices[pixelQuintupletIndex] = pixelIndex; - pixelQuintupletsInGPU.T5Indices[pixelQuintupletIndex] = t5Index; - pixelQuintupletsInGPU.isDup[pixelQuintupletIndex] = false; - pixelQuintupletsInGPU.score[pixelQuintupletIndex] = __F2H(score); - pixelQuintupletsInGPU.eta[pixelQuintupletIndex] = __F2H(eta); - pixelQuintupletsInGPU.phi[pixelQuintupletIndex] = __F2H(phi); - - pixelQuintupletsInGPU.pixelRadius[pixelQuintupletIndex] = __F2H(pixelRadius); - pixelQuintupletsInGPU.quintupletRadius[pixelQuintupletIndex] = __F2H(quintupletRadius); - pixelQuintupletsInGPU.centerX[pixelQuintupletIndex] = __F2H(centerX); - pixelQuintupletsInGPU.centerY[pixelQuintupletIndex] = __F2H(centerY); - - pixelQuintupletsInGPU.logicalLayers[Params_pT5::kLayers * pixelQuintupletIndex] = 0; - pixelQuintupletsInGPU.logicalLayers[Params_pT5::kLayers * pixelQuintupletIndex + 1] = 0; - pixelQuintupletsInGPU.logicalLayers[Params_pT5::kLayers * pixelQuintupletIndex + 2] = - quintuplets.logicalLayers()[t5Index][0]; - pixelQuintupletsInGPU.logicalLayers[Params_pT5::kLayers * pixelQuintupletIndex + 3] = - quintuplets.logicalLayers()[t5Index][1]; - pixelQuintupletsInGPU.logicalLayers[Params_pT5::kLayers * pixelQuintupletIndex + 4] = - quintuplets.logicalLayers()[t5Index][2]; - pixelQuintupletsInGPU.logicalLayers[Params_pT5::kLayers * pixelQuintupletIndex + 5] = - quintuplets.logicalLayers()[t5Index][3]; - pixelQuintupletsInGPU.logicalLayers[Params_pT5::kLayers * pixelQuintupletIndex + 6] = - quintuplets.logicalLayers()[t5Index][4]; - - pixelQuintupletsInGPU.lowerModuleIndices[Params_pT5::kLayers * pixelQuintupletIndex] = - segments.innerLowerModuleIndices()[pixelIndex]; - pixelQuintupletsInGPU.lowerModuleIndices[Params_pT5::kLayers * pixelQuintupletIndex + 1] = - segments.outerLowerModuleIndices()[pixelIndex]; - pixelQuintupletsInGPU.lowerModuleIndices[Params_pT5::kLayers * pixelQuintupletIndex + 2] = - quintuplets.lowerModuleIndices()[t5Index][0]; - pixelQuintupletsInGPU.lowerModuleIndices[Params_pT5::kLayers * pixelQuintupletIndex + 3] = - quintuplets.lowerModuleIndices()[t5Index][1]; - pixelQuintupletsInGPU.lowerModuleIndices[Params_pT5::kLayers * pixelQuintupletIndex + 4] = - quintuplets.lowerModuleIndices()[t5Index][2]; - pixelQuintupletsInGPU.lowerModuleIndices[Params_pT5::kLayers * pixelQuintupletIndex + 5] = - quintuplets.lowerModuleIndices()[t5Index][3]; - pixelQuintupletsInGPU.lowerModuleIndices[Params_pT5::kLayers * pixelQuintupletIndex + 6] = - quintuplets.lowerModuleIndices()[t5Index][4]; + pixelQuintuplets.pixelSegmentIndices()[pixelQuintupletIndex] = pixelIndex; + pixelQuintuplets.quintupletIndices()[pixelQuintupletIndex] = t5Index; + pixelQuintuplets.isDup()[pixelQuintupletIndex] = false; + pixelQuintuplets.score()[pixelQuintupletIndex] = __F2H(score); + pixelQuintuplets.eta()[pixelQuintupletIndex] = __F2H(eta); + pixelQuintuplets.phi()[pixelQuintupletIndex] = __F2H(phi); + + pixelQuintuplets.pixelRadius()[pixelQuintupletIndex] = __F2H(pixelRadius); + pixelQuintuplets.quintupletRadius()[pixelQuintupletIndex] = __F2H(quintupletRadius); + pixelQuintuplets.centerX()[pixelQuintupletIndex] = __F2H(centerX); + pixelQuintuplets.centerY()[pixelQuintupletIndex] = __F2H(centerY); + + pixelQuintuplets.logicalLayers()[pixelQuintupletIndex][0] = 0; + pixelQuintuplets.logicalLayers()[pixelQuintupletIndex][1] = 0; + pixelQuintuplets.logicalLayers()[pixelQuintupletIndex][2] = quintuplets.logicalLayers()[t5Index][0]; + pixelQuintuplets.logicalLayers()[pixelQuintupletIndex][3] = quintuplets.logicalLayers()[t5Index][1]; + pixelQuintuplets.logicalLayers()[pixelQuintupletIndex][4] = quintuplets.logicalLayers()[t5Index][2]; + pixelQuintuplets.logicalLayers()[pixelQuintupletIndex][5] = quintuplets.logicalLayers()[t5Index][3]; + pixelQuintuplets.logicalLayers()[pixelQuintupletIndex][6] = quintuplets.logicalLayers()[t5Index][4]; + + pixelQuintuplets.lowerModuleIndices()[pixelQuintupletIndex][0] = segments.innerLowerModuleIndices()[pixelIndex]; + pixelQuintuplets.lowerModuleIndices()[pixelQuintupletIndex][1] = segments.outerLowerModuleIndices()[pixelIndex]; + pixelQuintuplets.lowerModuleIndices()[pixelQuintupletIndex][2] = quintuplets.lowerModuleIndices()[t5Index][0]; + pixelQuintuplets.lowerModuleIndices()[pixelQuintupletIndex][3] = quintuplets.lowerModuleIndices()[t5Index][1]; + pixelQuintuplets.lowerModuleIndices()[pixelQuintupletIndex][4] = quintuplets.lowerModuleIndices()[t5Index][2]; + pixelQuintuplets.lowerModuleIndices()[pixelQuintupletIndex][5] = quintuplets.lowerModuleIndices()[t5Index][3]; + pixelQuintuplets.lowerModuleIndices()[pixelQuintupletIndex][6] = quintuplets.lowerModuleIndices()[t5Index][4]; unsigned int pixelInnerMD = segments.mdIndices()[pixelIndex][0]; unsigned int pixelOuterMD = segments.mdIndices()[pixelIndex][1]; - pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex] = mds.anchorHitIndices()[pixelInnerMD]; - pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 1] = - mds.outerHitIndices()[pixelInnerMD]; - pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 2] = - mds.anchorHitIndices()[pixelOuterMD]; - pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 3] = - mds.outerHitIndices()[pixelOuterMD]; - - pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 4] = - quintuplets.hitIndices()[t5Index][0]; - pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 5] = - quintuplets.hitIndices()[t5Index][1]; - pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 6] = - quintuplets.hitIndices()[t5Index][2]; - pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 7] = - quintuplets.hitIndices()[t5Index][3]; - pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 8] = - quintuplets.hitIndices()[t5Index][4]; - pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 9] = - quintuplets.hitIndices()[t5Index][5]; - pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 10] = - quintuplets.hitIndices()[t5Index][6]; - pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 11] = - quintuplets.hitIndices()[t5Index][7]; - pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 12] = - quintuplets.hitIndices()[t5Index][8]; - pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 13] = - quintuplets.hitIndices()[t5Index][9]; - - pixelQuintupletsInGPU.rzChiSquared[pixelQuintupletIndex] = rzChiSquared; - pixelQuintupletsInGPU.rPhiChiSquared[pixelQuintupletIndex] = rPhiChiSquared; - pixelQuintupletsInGPU.rPhiChiSquaredInwards[pixelQuintupletIndex] = rPhiChiSquaredInwards; + pixelQuintuplets.hitIndices()[pixelQuintupletIndex][0] = mds.anchorHitIndices()[pixelInnerMD]; + pixelQuintuplets.hitIndices()[pixelQuintupletIndex][1] = mds.outerHitIndices()[pixelInnerMD]; + pixelQuintuplets.hitIndices()[pixelQuintupletIndex][2] = mds.anchorHitIndices()[pixelOuterMD]; + pixelQuintuplets.hitIndices()[pixelQuintupletIndex][3] = mds.outerHitIndices()[pixelOuterMD]; + + pixelQuintuplets.hitIndices()[pixelQuintupletIndex][4] = quintuplets.hitIndices()[t5Index][0]; + pixelQuintuplets.hitIndices()[pixelQuintupletIndex][5] = quintuplets.hitIndices()[t5Index][1]; + pixelQuintuplets.hitIndices()[pixelQuintupletIndex][6] = quintuplets.hitIndices()[t5Index][2]; + pixelQuintuplets.hitIndices()[pixelQuintupletIndex][7] = quintuplets.hitIndices()[t5Index][3]; + pixelQuintuplets.hitIndices()[pixelQuintupletIndex][8] = quintuplets.hitIndices()[t5Index][4]; + pixelQuintuplets.hitIndices()[pixelQuintupletIndex][9] = quintuplets.hitIndices()[t5Index][5]; + pixelQuintuplets.hitIndices()[pixelQuintupletIndex][10] = quintuplets.hitIndices()[t5Index][6]; + pixelQuintuplets.hitIndices()[pixelQuintupletIndex][11] = quintuplets.hitIndices()[t5Index][7]; + pixelQuintuplets.hitIndices()[pixelQuintupletIndex][12] = quintuplets.hitIndices()[t5Index][8]; + pixelQuintuplets.hitIndices()[pixelQuintupletIndex][13] = quintuplets.hitIndices()[t5Index][9]; + + pixelQuintuplets.rzChiSquared()[pixelQuintupletIndex] = rzChiSquared; + pixelQuintuplets.rPhiChiSquared()[pixelQuintupletIndex] = rPhiChiSquared; + pixelQuintuplets.rPhiChiSquaredInwards()[pixelQuintupletIndex] = rPhiChiSquaredInwards; } ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT5RZChiSquaredCuts(Modules const& modulesInGPU, @@ -828,7 +709,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { Triplets triplets, Quintuplets quintuplets, QuintupletsOccupancyConst quintupletsOccupancy, - PixelQuintuplets pixelQuintupletsInGPU, + PixelQuintuplets pixelQuintuplets, unsigned int* connectedPixelSize, unsigned int* connectedPixelIndex, unsigned int nPixelSegments, @@ -890,14 +771,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { static_cast(i_pLS)); if (success) { unsigned int totOccupancyPixelQuintuplets = alpaka::atomicAdd( - acc, pixelQuintupletsInGPU.totOccupancyPixelQuintuplets, 1u, alpaka::hierarchy::Threads{}); + acc, &pixelQuintuplets.totOccupancyPixelQuintuplets(), 1u, alpaka::hierarchy::Threads{}); if (totOccupancyPixelQuintuplets >= n_max_pixel_quintuplets) { #ifdef WARNINGS printf("Pixel Quintuplet excess alert!\n"); #endif } else { unsigned int pixelQuintupletIndex = - alpaka::atomicAdd(acc, pixelQuintupletsInGPU.nPixelQuintuplets, 1u, alpaka::hierarchy::Threads{}); + alpaka::atomicAdd(acc, &pixelQuintuplets.nPixelQuintuplets(), 1u, alpaka::hierarchy::Threads{}); float eta = __H2F(quintuplets.eta()[quintupletIndex]); float phi = __H2F(quintuplets.phi()[quintupletIndex]); @@ -905,7 +786,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { mds, segments, quintuplets, - pixelQuintupletsInGPU, + pixelQuintuplets, pixelSegmentIndex, quintupletIndex, pixelQuintupletIndex, diff --git a/RecoTracker/LSTCore/src/alpaka/PixelTriplet.h b/RecoTracker/LSTCore/src/alpaka/PixelTriplet.h index d83e4ff352ec8..8c096f5981865 100644 --- a/RecoTracker/LSTCore/src/alpaka/PixelTriplet.h +++ b/RecoTracker/LSTCore/src/alpaka/PixelTriplet.h @@ -3,136 +3,20 @@ #include "RecoTracker/LSTCore/interface/alpaka/Constants.h" #include "RecoTracker/LSTCore/interface/Module.h" +#include "RecoTracker/LSTCore/interface/MiniDoubletsSoA.h" +#include "RecoTracker/LSTCore/interface/PixelTripletsSoA.h" +#include "RecoTracker/LSTCore/interface/QuintupletsSoA.h" +#include "RecoTracker/LSTCore/interface/SegmentsSoA.h" +#include "RecoTracker/LSTCore/interface/TripletsSoA.h" -#include "Triplet.h" -#include "Segment.h" -#include "MiniDoublet.h" #include "Hit.h" #include "ObjectRanges.h" -#include "Quintuplet.h" namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { - // One pixel segment, one outer tracker triplet! - struct PixelTriplets { - unsigned int* pixelSegmentIndices; - unsigned int* tripletIndices; - unsigned int* nPixelTriplets; - unsigned int* totOccupancyPixelTriplets; - - float* rPhiChiSquared; - float* rPhiChiSquaredInwards; - float* rzChiSquared; - - FPX* pixelRadius; - FPX* tripletRadius; - FPX* pt; - FPX* eta; - FPX* phi; - FPX* eta_pix; - FPX* phi_pix; - FPX* score; - bool* isDup; - bool* partOfPT5; - - uint8_t* logicalLayers; - unsigned int* hitIndices; - uint16_t* lowerModuleIndices; - FPX* centerX; - FPX* centerY; - - template - void setData(TBuff& buf) { - pixelSegmentIndices = buf.pixelSegmentIndices_buf.data(); - tripletIndices = buf.tripletIndices_buf.data(); - nPixelTriplets = buf.nPixelTriplets_buf.data(); - totOccupancyPixelTriplets = buf.totOccupancyPixelTriplets_buf.data(); - pixelRadius = buf.pixelRadius_buf.data(); - tripletRadius = buf.tripletRadius_buf.data(); - pt = buf.pt_buf.data(); - eta = buf.eta_buf.data(); - phi = buf.phi_buf.data(); - eta_pix = buf.eta_pix_buf.data(); - phi_pix = buf.phi_pix_buf.data(); - score = buf.score_buf.data(); - isDup = buf.isDup_buf.data(); - partOfPT5 = buf.partOfPT5_buf.data(); - logicalLayers = buf.logicalLayers_buf.data(); - hitIndices = buf.hitIndices_buf.data(); - lowerModuleIndices = buf.lowerModuleIndices_buf.data(); - centerX = buf.centerX_buf.data(); - centerY = buf.centerY_buf.data(); - rPhiChiSquared = buf.rPhiChiSquared_buf.data(); - rPhiChiSquaredInwards = buf.rPhiChiSquaredInwards_buf.data(); - rzChiSquared = buf.rzChiSquared_buf.data(); - } - }; - - template - struct PixelTripletsBuffer { - Buf pixelSegmentIndices_buf; - Buf tripletIndices_buf; - Buf nPixelTriplets_buf; - Buf totOccupancyPixelTriplets_buf; - Buf pixelRadius_buf; - Buf tripletRadius_buf; - Buf pt_buf; - Buf eta_buf; - Buf phi_buf; - Buf eta_pix_buf; - Buf phi_pix_buf; - Buf score_buf; - Buf isDup_buf; - Buf partOfPT5_buf; - Buf logicalLayers_buf; - Buf hitIndices_buf; - Buf lowerModuleIndices_buf; - Buf centerX_buf; - Buf centerY_buf; - Buf pixelRadiusError_buf; - Buf rPhiChiSquared_buf; - Buf rPhiChiSquaredInwards_buf; - Buf rzChiSquared_buf; - - PixelTriplets data_; - - template - PixelTripletsBuffer(unsigned int maxPixelTriplets, TDevAcc const& devAccIn, TQueue& queue) - : pixelSegmentIndices_buf(allocBufWrapper(devAccIn, maxPixelTriplets, queue)), - tripletIndices_buf(allocBufWrapper(devAccIn, maxPixelTriplets, queue)), - nPixelTriplets_buf(allocBufWrapper(devAccIn, 1, queue)), - totOccupancyPixelTriplets_buf(allocBufWrapper(devAccIn, 1, queue)), - pixelRadius_buf(allocBufWrapper(devAccIn, maxPixelTriplets, queue)), - tripletRadius_buf(allocBufWrapper(devAccIn, maxPixelTriplets, queue)), - pt_buf(allocBufWrapper(devAccIn, maxPixelTriplets, queue)), - eta_buf(allocBufWrapper(devAccIn, maxPixelTriplets, queue)), - phi_buf(allocBufWrapper(devAccIn, maxPixelTriplets, queue)), - eta_pix_buf(allocBufWrapper(devAccIn, maxPixelTriplets, queue)), - phi_pix_buf(allocBufWrapper(devAccIn, maxPixelTriplets, queue)), - score_buf(allocBufWrapper(devAccIn, maxPixelTriplets, queue)), - isDup_buf(allocBufWrapper(devAccIn, maxPixelTriplets, queue)), - partOfPT5_buf(allocBufWrapper(devAccIn, maxPixelTriplets, queue)), - logicalLayers_buf(allocBufWrapper(devAccIn, maxPixelTriplets * Params_pT3::kLayers, queue)), - hitIndices_buf(allocBufWrapper(devAccIn, maxPixelTriplets * Params_pT3::kHits, queue)), - lowerModuleIndices_buf(allocBufWrapper(devAccIn, maxPixelTriplets * Params_pT3::kLayers, queue)), - centerX_buf(allocBufWrapper(devAccIn, maxPixelTriplets, queue)), - centerY_buf(allocBufWrapper(devAccIn, maxPixelTriplets, queue)), - pixelRadiusError_buf(allocBufWrapper(devAccIn, maxPixelTriplets, queue)), - rPhiChiSquared_buf(allocBufWrapper(devAccIn, maxPixelTriplets, queue)), - rPhiChiSquaredInwards_buf(allocBufWrapper(devAccIn, maxPixelTriplets, queue)), - rzChiSquared_buf(allocBufWrapper(devAccIn, maxPixelTriplets, queue)) { - alpaka::memset(queue, nPixelTriplets_buf, 0u); - alpaka::memset(queue, totOccupancyPixelTriplets_buf, 0u); - alpaka::memset(queue, partOfPT5_buf, false); - } - - inline PixelTriplets const* data() const { return &data_; } - inline void setData(PixelTripletsBuffer& buf) { data_.setData(buf); } - }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE void addPixelTripletToMemory(MiniDoubletsConst mds, SegmentsConst segments, TripletsConst triplets, - PixelTriplets& pixelTripletsInGPU, + PixelTriplets pixelTriplets, unsigned int pixelSegmentIndex, unsigned int tripletIndex, float pixelRadius, @@ -149,57 +33,49 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float eta_pix, float phi_pix, float score) { - pixelTripletsInGPU.pixelSegmentIndices[pixelTripletIndex] = pixelSegmentIndex; - pixelTripletsInGPU.tripletIndices[pixelTripletIndex] = tripletIndex; - pixelTripletsInGPU.pixelRadius[pixelTripletIndex] = __F2H(pixelRadius); - pixelTripletsInGPU.tripletRadius[pixelTripletIndex] = __F2H(tripletRadius); - pixelTripletsInGPU.pt[pixelTripletIndex] = __F2H(pt); - pixelTripletsInGPU.eta[pixelTripletIndex] = __F2H(eta); - pixelTripletsInGPU.phi[pixelTripletIndex] = __F2H(phi); - pixelTripletsInGPU.eta_pix[pixelTripletIndex] = __F2H(eta_pix); - pixelTripletsInGPU.phi_pix[pixelTripletIndex] = __F2H(phi_pix); - pixelTripletsInGPU.isDup[pixelTripletIndex] = false; - pixelTripletsInGPU.score[pixelTripletIndex] = __F2H(score); - - pixelTripletsInGPU.centerX[pixelTripletIndex] = __F2H(centerX); - pixelTripletsInGPU.centerY[pixelTripletIndex] = __F2H(centerY); - pixelTripletsInGPU.logicalLayers[Params_pT3::kLayers * pixelTripletIndex] = 0; - pixelTripletsInGPU.logicalLayers[Params_pT3::kLayers * pixelTripletIndex + 1] = 0; - pixelTripletsInGPU.logicalLayers[Params_pT3::kLayers * pixelTripletIndex + 2] = - triplets.logicalLayers()[tripletIndex][0]; - pixelTripletsInGPU.logicalLayers[Params_pT3::kLayers * pixelTripletIndex + 3] = - triplets.logicalLayers()[tripletIndex][1]; - pixelTripletsInGPU.logicalLayers[Params_pT3::kLayers * pixelTripletIndex + 4] = - triplets.logicalLayers()[tripletIndex][2]; - - pixelTripletsInGPU.lowerModuleIndices[Params_pT3::kLayers * pixelTripletIndex] = - segments.innerLowerModuleIndices()[pixelSegmentIndex]; - pixelTripletsInGPU.lowerModuleIndices[Params_pT3::kLayers * pixelTripletIndex + 1] = - segments.outerLowerModuleIndices()[pixelSegmentIndex]; - pixelTripletsInGPU.lowerModuleIndices[Params_pT3::kLayers * pixelTripletIndex + 2] = - triplets.lowerModuleIndices()[tripletIndex][0]; - pixelTripletsInGPU.lowerModuleIndices[Params_pT3::kLayers * pixelTripletIndex + 3] = - triplets.lowerModuleIndices()[tripletIndex][1]; - pixelTripletsInGPU.lowerModuleIndices[Params_pT3::kLayers * pixelTripletIndex + 4] = - triplets.lowerModuleIndices()[tripletIndex][2]; + pixelTriplets.pixelSegmentIndices()[pixelTripletIndex] = pixelSegmentIndex; + pixelTriplets.tripletIndices()[pixelTripletIndex] = tripletIndex; + pixelTriplets.pixelRadius()[pixelTripletIndex] = __F2H(pixelRadius); + pixelTriplets.tripletRadius()[pixelTripletIndex] = __F2H(tripletRadius); + pixelTriplets.pt()[pixelTripletIndex] = __F2H(pt); + pixelTriplets.eta()[pixelTripletIndex] = __F2H(eta); + pixelTriplets.phi()[pixelTripletIndex] = __F2H(phi); + pixelTriplets.eta_pix()[pixelTripletIndex] = __F2H(eta_pix); + pixelTriplets.phi_pix()[pixelTripletIndex] = __F2H(phi_pix); + pixelTriplets.isDup()[pixelTripletIndex] = false; + pixelTriplets.score()[pixelTripletIndex] = __F2H(score); + + pixelTriplets.centerX()[pixelTripletIndex] = __F2H(centerX); + pixelTriplets.centerY()[pixelTripletIndex] = __F2H(centerY); + pixelTriplets.logicalLayers()[pixelTripletIndex][0] = 0; + pixelTriplets.logicalLayers()[pixelTripletIndex][1] = 0; + pixelTriplets.logicalLayers()[pixelTripletIndex][2] = triplets.logicalLayers()[tripletIndex][0]; + pixelTriplets.logicalLayers()[pixelTripletIndex][3] = triplets.logicalLayers()[tripletIndex][1]; + pixelTriplets.logicalLayers()[pixelTripletIndex][4] = triplets.logicalLayers()[tripletIndex][2]; + + pixelTriplets.lowerModuleIndices()[pixelTripletIndex][0] = segments.innerLowerModuleIndices()[pixelSegmentIndex]; + pixelTriplets.lowerModuleIndices()[pixelTripletIndex][1] = segments.outerLowerModuleIndices()[pixelSegmentIndex]; + pixelTriplets.lowerModuleIndices()[pixelTripletIndex][2] = triplets.lowerModuleIndices()[tripletIndex][0]; + pixelTriplets.lowerModuleIndices()[pixelTripletIndex][3] = triplets.lowerModuleIndices()[tripletIndex][1]; + pixelTriplets.lowerModuleIndices()[pixelTripletIndex][4] = triplets.lowerModuleIndices()[tripletIndex][2]; unsigned int pixelInnerMD = segments.mdIndices()[pixelSegmentIndex][0]; unsigned int pixelOuterMD = segments.mdIndices()[pixelSegmentIndex][1]; - pixelTripletsInGPU.hitIndices[Params_pT3::kHits * pixelTripletIndex] = mds.anchorHitIndices()[pixelInnerMD]; - pixelTripletsInGPU.hitIndices[Params_pT3::kHits * pixelTripletIndex + 1] = mds.outerHitIndices()[pixelInnerMD]; - pixelTripletsInGPU.hitIndices[Params_pT3::kHits * pixelTripletIndex + 2] = mds.anchorHitIndices()[pixelOuterMD]; - pixelTripletsInGPU.hitIndices[Params_pT3::kHits * pixelTripletIndex + 3] = mds.outerHitIndices()[pixelOuterMD]; - - pixelTripletsInGPU.hitIndices[Params_pT3::kHits * pixelTripletIndex + 4] = triplets.hitIndices()[tripletIndex][0]; - pixelTripletsInGPU.hitIndices[Params_pT3::kHits * pixelTripletIndex + 5] = triplets.hitIndices()[tripletIndex][1]; - pixelTripletsInGPU.hitIndices[Params_pT3::kHits * pixelTripletIndex + 6] = triplets.hitIndices()[tripletIndex][2]; - pixelTripletsInGPU.hitIndices[Params_pT3::kHits * pixelTripletIndex + 7] = triplets.hitIndices()[tripletIndex][3]; - pixelTripletsInGPU.hitIndices[Params_pT3::kHits * pixelTripletIndex + 8] = triplets.hitIndices()[tripletIndex][4]; - pixelTripletsInGPU.hitIndices[Params_pT3::kHits * pixelTripletIndex + 9] = triplets.hitIndices()[tripletIndex][5]; - pixelTripletsInGPU.rPhiChiSquared[pixelTripletIndex] = rPhiChiSquared; - pixelTripletsInGPU.rPhiChiSquaredInwards[pixelTripletIndex] = rPhiChiSquaredInwards; - pixelTripletsInGPU.rzChiSquared[pixelTripletIndex] = rzChiSquared; + pixelTriplets.hitIndices()[pixelTripletIndex][0] = mds.anchorHitIndices()[pixelInnerMD]; + pixelTriplets.hitIndices()[pixelTripletIndex][1] = mds.outerHitIndices()[pixelInnerMD]; + pixelTriplets.hitIndices()[pixelTripletIndex][2] = mds.anchorHitIndices()[pixelOuterMD]; + pixelTriplets.hitIndices()[pixelTripletIndex][3] = mds.outerHitIndices()[pixelOuterMD]; + + pixelTriplets.hitIndices()[pixelTripletIndex][4] = triplets.hitIndices()[tripletIndex][0]; + pixelTriplets.hitIndices()[pixelTripletIndex][5] = triplets.hitIndices()[tripletIndex][1]; + pixelTriplets.hitIndices()[pixelTripletIndex][6] = triplets.hitIndices()[tripletIndex][2]; + pixelTriplets.hitIndices()[pixelTripletIndex][7] = triplets.hitIndices()[tripletIndex][3]; + pixelTriplets.hitIndices()[pixelTripletIndex][8] = triplets.hitIndices()[tripletIndex][4]; + pixelTriplets.hitIndices()[pixelTripletIndex][9] = triplets.hitIndices()[tripletIndex][5]; + pixelTriplets.rPhiChiSquared()[pixelTripletIndex] = rPhiChiSquared; + pixelTriplets.rPhiChiSquaredInwards()[pixelTripletIndex] = rPhiChiSquaredInwards; + pixelTriplets.rzChiSquared()[pixelTripletIndex] = rzChiSquared; }; template @@ -916,7 +792,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { return true; }; - struct CreatePixelTripletsInGPUFromMapv2 { + struct CreatePixelTripletsFromMap { template ALPAKA_FN_ACC void operator()(TAcc const& acc, Modules modulesInGPU, @@ -926,7 +802,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { SegmentsPixelConst segmentsPixel, Triplets triplets, TripletsOccupancyConst tripletsOccupancy, - PixelTriplets pixelTripletsInGPU, + PixelTriplets pixelTriplets, unsigned int* connectedPixelSize, unsigned int* connectedPixelIndex, unsigned int nPixelSegments) const { @@ -1018,19 +894,19 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float phi_pix = segmentsPixel.phi()[i_pLS]; float pt = segmentsPixel.ptIn()[i_pLS]; float score = rPhiChiSquared + rPhiChiSquaredInwards; - unsigned int totOccupancyPixelTriplets = alpaka::atomicAdd( - acc, pixelTripletsInGPU.totOccupancyPixelTriplets, 1u, alpaka::hierarchy::Threads{}); + unsigned int totOccupancyPixelTriplets = + alpaka::atomicAdd(acc, &pixelTriplets.totOccupancyPixelTriplets(), 1u, alpaka::hierarchy::Threads{}); if (totOccupancyPixelTriplets >= n_max_pixel_triplets) { #ifdef WARNINGS printf("Pixel Triplet excess alert!\n"); #endif } else { unsigned int pixelTripletIndex = - alpaka::atomicAdd(acc, pixelTripletsInGPU.nPixelTriplets, 1u, alpaka::hierarchy::Threads{}); + alpaka::atomicAdd(acc, &pixelTriplets.nPixelTriplets(), 1u, alpaka::hierarchy::Threads{}); addPixelTripletToMemory(mds, segments, triplets, - pixelTripletsInGPU, + pixelTriplets, pixelSegmentIndex, outerTripletIndex, pixelRadius, diff --git a/RecoTracker/LSTCore/src/alpaka/Quintuplet.h b/RecoTracker/LSTCore/src/alpaka/Quintuplet.h index 2e5dae70d4307..2fbcd2a0c989f 100644 --- a/RecoTracker/LSTCore/src/alpaka/Quintuplet.h +++ b/RecoTracker/LSTCore/src/alpaka/Quintuplet.h @@ -14,6 +14,7 @@ #include "NeuralNetwork.h" #include "Hit.h" #include "ObjectRanges.h" +#include "Triplet.h" // FIXME: need to refactor common functions to a common place namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { ALPAKA_FN_ACC ALPAKA_FN_INLINE bool checkIntervalOverlap(float firstMin, diff --git a/RecoTracker/LSTCore/src/alpaka/TrackCandidate.h b/RecoTracker/LSTCore/src/alpaka/TrackCandidate.h index 84f33ddd05956..9631382573e06 100644 --- a/RecoTracker/LSTCore/src/alpaka/TrackCandidate.h +++ b/RecoTracker/LSTCore/src/alpaka/TrackCandidate.h @@ -3,13 +3,14 @@ #include "RecoTracker/LSTCore/interface/alpaka/Constants.h" #include "RecoTracker/LSTCore/interface/Module.h" +#include "RecoTracker/LSTCore/interface/MiniDoubletsSoA.h" +#include "RecoTracker/LSTCore/interface/PixelQuintupletsSoA.h" +#include "RecoTracker/LSTCore/interface/PixelTripletsSoA.h" +#include "RecoTracker/LSTCore/interface/QuintupletsSoA.h" +#include "RecoTracker/LSTCore/interface/SegmentsSoA.h" #include "RecoTracker/LSTCore/interface/TrackCandidatesSoA.h" +#include "RecoTracker/LSTCore/interface/TripletsSoA.h" -#include "Triplet.h" -#include "Segment.h" -#include "MiniDoublet.h" -#include "PixelTriplet.h" -#include "Quintuplet.h" #include "Hit.h" #include "ObjectRanges.h" @@ -112,29 +113,29 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { ALPAKA_FN_ACC void operator()(TAcc const& acc, Modules modulesInGPU, ObjectRanges rangesInGPU, - PixelTriplets pixelTripletsInGPU, + PixelTriplets pixelTriplets, SegmentsPixelConst segmentsPixel, - PixelQuintuplets pixelQuintupletsInGPU) const { + PixelQuintupletsConst pixelQuintuplets) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); - unsigned int nPixelTriplets = *pixelTripletsInGPU.nPixelTriplets; + unsigned int nPixelTriplets = pixelTriplets.nPixelTriplets(); for (unsigned int pixelTripletIndex = globalThreadIdx[2]; pixelTripletIndex < nPixelTriplets; pixelTripletIndex += gridThreadExtent[2]) { - if (pixelTripletsInGPU.isDup[pixelTripletIndex]) + if (pixelTriplets.isDup()[pixelTripletIndex]) continue; // Cross cleaning step - float eta1 = __H2F(pixelTripletsInGPU.eta_pix[pixelTripletIndex]); - float phi1 = __H2F(pixelTripletsInGPU.phi_pix[pixelTripletIndex]); + float eta1 = __H2F(pixelTriplets.eta_pix()[pixelTripletIndex]); + float phi1 = __H2F(pixelTriplets.phi_pix()[pixelTripletIndex]); int pixelModuleIndex = *modulesInGPU.nLowerModules; unsigned int prefix = rangesInGPU.segmentModuleIndices[pixelModuleIndex]; - unsigned int nPixelQuintuplets = *pixelQuintupletsInGPU.nPixelQuintuplets; + unsigned int nPixelQuintuplets = pixelQuintuplets.nPixelQuintuplets(); for (unsigned int pixelQuintupletIndex = globalThreadIdx[1]; pixelQuintupletIndex < nPixelQuintuplets; pixelQuintupletIndex += gridThreadExtent[1]) { - unsigned int pLS_jx = pixelQuintupletsInGPU.pixelIndices[pixelQuintupletIndex]; + unsigned int pLS_jx = pixelQuintuplets.pixelSegmentIndices()[pixelQuintupletIndex]; float eta2 = segmentsPixel.eta()[pLS_jx - prefix]; float phi2 = segmentsPixel.phi()[pLS_jx - prefix]; float dEta = alpaka::math::abs(acc, (eta1 - eta2)); @@ -142,7 +143,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float dR2 = dEta * dEta + dPhi * dPhi; if (dR2 < 1e-5f) - pixelTripletsInGPU.isDup[pixelTripletIndex] = true; + pixelTriplets.isDup()[pixelTripletIndex] = true; } } } @@ -154,8 +155,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { Modules modulesInGPU, Quintuplets quintuplets, QuintupletsOccupancyConst quintupletsOccupancy, - PixelQuintuplets pixelQuintupletsInGPU, - PixelTriplets pixelTripletsInGPU, + PixelQuintupletsConst pixelQuintuplets, + PixelTripletsConst pixelTriplets, ObjectRanges rangesInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -176,19 +177,19 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { if (quintuplets.isDup()[quintupletIndex] or quintuplets.partOfPT5()[quintupletIndex]) continue; #ifdef Crossclean_T5 - unsigned int loop_bound = *pixelQuintupletsInGPU.nPixelQuintuplets + *pixelTripletsInGPU.nPixelTriplets; + unsigned int loop_bound = pixelQuintuplets.nPixelQuintuplets() + pixelTriplets.nPixelTriplets(); // Cross cleaning step float eta1 = __H2F(quintuplets.eta()[quintupletIndex]); float phi1 = __H2F(quintuplets.phi()[quintupletIndex]); for (unsigned int jx = globalThreadIdx[2]; jx < loop_bound; jx += gridThreadExtent[2]) { float eta2, phi2; - if (jx < *pixelQuintupletsInGPU.nPixelQuintuplets) { - eta2 = __H2F(pixelQuintupletsInGPU.eta[jx]); - phi2 = __H2F(pixelQuintupletsInGPU.phi[jx]); + if (jx < pixelQuintuplets.nPixelQuintuplets()) { + eta2 = __H2F(pixelQuintuplets.eta()[jx]); + phi2 = __H2F(pixelQuintuplets.phi()[jx]); } else { - eta2 = __H2F(pixelTripletsInGPU.eta[jx - *pixelQuintupletsInGPU.nPixelQuintuplets]); - phi2 = __H2F(pixelTripletsInGPU.phi[jx - *pixelQuintupletsInGPU.nPixelQuintuplets]); + eta2 = __H2F(pixelTriplets.eta()[jx - pixelQuintuplets.nPixelQuintuplets()]); + phi2 = __H2F(pixelTriplets.phi()[jx - pixelQuintuplets.nPixelQuintuplets()]); } float dEta = alpaka::math::abs(acc, eta1 - eta2); @@ -209,7 +210,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { ALPAKA_FN_ACC void operator()(TAcc const& acc, Modules modulesInGPU, ObjectRanges rangesInGPU, - PixelTriplets pixelTripletsInGPU, + PixelTripletsConst pixelTriplets, TrackCandidates cands, SegmentsConst segments, SegmentsOccupancyConst segmentsOccupancy, @@ -250,14 +251,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } if (type == 5) // pT3 { - int pLSIndex = pixelTripletsInGPU.pixelSegmentIndices[innerTrackletIdx]; + int pLSIndex = pixelTriplets.pixelSegmentIndices()[innerTrackletIdx]; int npMatched = checkPixelHits(prefix + pixelArrayIndex, pLSIndex, mds, segments, hitsInGPU); if (npMatched > 0) segmentsPixel.isDup()[pixelArrayIndex] = true; int pT3Index = innerTrackletIdx; - float eta2 = __H2F(pixelTripletsInGPU.eta_pix[pT3Index]); - float phi2 = __H2F(pixelTripletsInGPU.phi_pix[pT3Index]); + float eta2 = __H2F(pixelTriplets.eta_pix()[pT3Index]); + float phi2 = __H2F(pixelTriplets.phi_pix()[pT3Index]); float dEta = alpaka::math::abs(acc, eta1 - eta2); float dPhi = calculate_dPhi(phi1, phi2); @@ -287,11 +288,11 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } }; - struct AddpT3asTrackCandidatesInGPU { + struct AddpT3asTrackCandidates { template ALPAKA_FN_ACC void operator()(TAcc const& acc, uint16_t nLowerModules, - PixelTriplets pixelTripletsInGPU, + PixelTripletsConst pixelTriplets, TrackCandidates cands, SegmentsPixelConst segmentsPixel, ObjectRanges rangesInGPU) const { @@ -302,11 +303,11 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); - unsigned int nPixelTriplets = *pixelTripletsInGPU.nPixelTriplets; + unsigned int nPixelTriplets = pixelTriplets.nPixelTriplets(); unsigned int pLS_offset = rangesInGPU.segmentModuleIndices[nLowerModules]; for (unsigned int pixelTripletIndex = globalThreadIdx[0]; pixelTripletIndex < nPixelTriplets; pixelTripletIndex += gridThreadExtent[0]) { - if ((pixelTripletsInGPU.isDup[pixelTripletIndex])) + if ((pixelTriplets.isDup()[pixelTripletIndex])) continue; unsigned int trackCandidateIdx = @@ -322,19 +323,19 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } else { alpaka::atomicAdd(acc, &cands.nTrackCandidatespT3(), 1u, alpaka::hierarchy::Threads{}); - float radius = 0.5f * (__H2F(pixelTripletsInGPU.pixelRadius[pixelTripletIndex]) + - __H2F(pixelTripletsInGPU.tripletRadius[pixelTripletIndex])); - unsigned int pT3PixelIndex = pixelTripletsInGPU.pixelSegmentIndices[pixelTripletIndex]; + float radius = 0.5f * (__H2F(pixelTriplets.pixelRadius()[pixelTripletIndex]) + + __H2F(pixelTriplets.tripletRadius()[pixelTripletIndex])); + unsigned int pT3PixelIndex = pixelTriplets.pixelSegmentIndices()[pixelTripletIndex]; addTrackCandidateToMemory(cands, 5 /*track candidate type pT3=5*/, pixelTripletIndex, pixelTripletIndex, - &pixelTripletsInGPU.logicalLayers[Params_pT3::kLayers * pixelTripletIndex], - &pixelTripletsInGPU.lowerModuleIndices[Params_pT3::kLayers * pixelTripletIndex], - &pixelTripletsInGPU.hitIndices[Params_pT3::kHits * pixelTripletIndex], + pixelTriplets.logicalLayers()[pixelTripletIndex].data(), + pixelTriplets.lowerModuleIndices()[pixelTripletIndex].data(), + pixelTriplets.hitIndices()[pixelTripletIndex].data(), segmentsPixel.seedIdx()[pT3PixelIndex - pLS_offset], - __H2F(pixelTripletsInGPU.centerX[pixelTripletIndex]), - __H2F(pixelTripletsInGPU.centerY[pixelTripletIndex]), + __H2F(pixelTriplets.centerX()[pixelTripletIndex]), + __H2F(pixelTriplets.centerY()[pixelTripletIndex]), radius, trackCandidateIdx, pixelTripletIndex); @@ -438,11 +439,11 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } }; - struct AddpT5asTrackCandidateInGPU { + struct AddpT5asTrackCandidate { template ALPAKA_FN_ACC void operator()(TAcc const& acc, uint16_t nLowerModules, - PixelQuintuplets pixelQuintupletsInGPU, + PixelQuintupletsConst pixelQuintuplets, TrackCandidates cands, SegmentsPixelConst segmentsPixel, ObjectRanges rangesInGPU) const { @@ -453,11 +454,11 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); - int nPixelQuintuplets = *pixelQuintupletsInGPU.nPixelQuintuplets; + int nPixelQuintuplets = pixelQuintuplets.nPixelQuintuplets(); unsigned int pLS_offset = rangesInGPU.segmentModuleIndices[nLowerModules]; for (int pixelQuintupletIndex = globalThreadIdx[0]; pixelQuintupletIndex < nPixelQuintuplets; pixelQuintupletIndex += gridThreadExtent[0]) { - if (pixelQuintupletsInGPU.isDup[pixelQuintupletIndex]) + if (pixelQuintuplets.isDup()[pixelQuintupletIndex]) continue; unsigned int trackCandidateIdx = @@ -473,23 +474,22 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } else { alpaka::atomicAdd(acc, &cands.nTrackCandidatespT5(), 1u, alpaka::hierarchy::Threads{}); - float radius = 0.5f * (__H2F(pixelQuintupletsInGPU.pixelRadius[pixelQuintupletIndex]) + - __H2F(pixelQuintupletsInGPU.quintupletRadius[pixelQuintupletIndex])); - unsigned int pT5PixelIndex = pixelQuintupletsInGPU.pixelIndices[pixelQuintupletIndex]; - addTrackCandidateToMemory( - cands, - 7 /*track candidate type pT5=7*/, - pT5PixelIndex, - pixelQuintupletsInGPU.T5Indices[pixelQuintupletIndex], - &pixelQuintupletsInGPU.logicalLayers[Params_pT5::kLayers * pixelQuintupletIndex], - &pixelQuintupletsInGPU.lowerModuleIndices[Params_pT5::kLayers * pixelQuintupletIndex], - &pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex], - segmentsPixel.seedIdx()[pT5PixelIndex - pLS_offset], - __H2F(pixelQuintupletsInGPU.centerX[pixelQuintupletIndex]), - __H2F(pixelQuintupletsInGPU.centerY[pixelQuintupletIndex]), - radius, - trackCandidateIdx, - pixelQuintupletIndex); + float radius = 0.5f * (__H2F(pixelQuintuplets.pixelRadius()[pixelQuintupletIndex]) + + __H2F(pixelQuintuplets.quintupletRadius()[pixelQuintupletIndex])); + unsigned int pT5PixelIndex = pixelQuintuplets.pixelSegmentIndices()[pixelQuintupletIndex]; + addTrackCandidateToMemory(cands, + 7 /*track candidate type pT5=7*/, + pT5PixelIndex, + pixelQuintuplets.quintupletIndices()[pixelQuintupletIndex], + pixelQuintuplets.logicalLayers()[pixelQuintupletIndex].data(), + pixelQuintuplets.lowerModuleIndices()[pixelQuintupletIndex].data(), + pixelQuintuplets.hitIndices()[pixelQuintupletIndex].data(), + segmentsPixel.seedIdx()[pT5PixelIndex - pLS_offset], + __H2F(pixelQuintuplets.centerX()[pixelQuintupletIndex]), + __H2F(pixelQuintuplets.centerY()[pixelQuintupletIndex]), + radius, + trackCandidateIdx, + pixelQuintupletIndex); } } } diff --git a/RecoTracker/LSTCore/standalone/code/core/AccessHelper.cc b/RecoTracker/LSTCore/standalone/code/core/AccessHelper.cc index 7798d7e7afbf1..0fd216621b2e2 100644 --- a/RecoTracker/LSTCore/standalone/code/core/AccessHelper.cc +++ b/RecoTracker/LSTCore/standalone/code/core/AccessHelper.cc @@ -225,17 +225,17 @@ std::tuple, std::vector> getHitIdxsAndHi //____________________________________________________________________________________________ unsigned int getPixelLSFrompT3(Event* event, unsigned int pT3) { - PixelTriplets const* pixelTriplets = event->getPixelTriplets().data(); + auto const pixelTriplets = event->getPixelTriplets(); ObjectRanges const* rangesEvt = event->getRanges().data(); Modules const* modulesEvt = event->getModules().data(); const unsigned int pLS_offset = rangesEvt->segmentModuleIndices[*(modulesEvt->nLowerModules)]; - return pixelTriplets->pixelSegmentIndices[pT3] - pLS_offset; + return pixelTriplets.pixelSegmentIndices()[pT3] - pLS_offset; } //____________________________________________________________________________________________ unsigned int getT3FrompT3(Event* event, unsigned int pT3) { - PixelTriplets const* pixelTriplets = event->getPixelTriplets().data(); - return pixelTriplets->tripletIndices[pT3]; + auto const pixelTriplets = event->getPixelTriplets(); + return pixelTriplets.tripletIndices()[pT3]; } //____________________________________________________________________________________________ @@ -314,17 +314,17 @@ std::tuple, std::vector> getHitIdxsAndHi //____________________________________________________________________________________________ unsigned int getPixelLSFrompT5(Event* event, unsigned int pT5) { - PixelQuintuplets const* pixelQuintuplets = event->getPixelQuintuplets().data(); + auto const pixelQuintuplets = event->getPixelQuintuplets(); ObjectRanges const* rangesEvt = event->getRanges().data(); Modules const* modulesEvt = event->getModules().data(); const unsigned int pLS_offset = rangesEvt->segmentModuleIndices[*(modulesEvt->nLowerModules)]; - return pixelQuintuplets->pixelIndices[pT5] - pLS_offset; + return pixelQuintuplets.pixelSegmentIndices()[pT5] - pLS_offset; } //____________________________________________________________________________________________ unsigned int getT5FrompT5(Event* event, unsigned int pT5) { - PixelQuintuplets const* pixelQuintuplets = event->getPixelQuintuplets().data(); - return pixelQuintuplets->T5Indices[pT5]; + auto const pixelQuintuplets = event->getPixelQuintuplets(); + return pixelQuintuplets.quintupletIndices()[pT5]; } //____________________________________________________________________________________________ diff --git a/RecoTracker/LSTCore/standalone/code/core/write_lst_ntuple.cc b/RecoTracker/LSTCore/standalone/code/core/write_lst_ntuple.cc index b8ce2e93a1163..4b6ad8d838bfc 100644 --- a/RecoTracker/LSTCore/standalone/code/core/write_lst_ntuple.cc +++ b/RecoTracker/LSTCore/standalone/code/core/write_lst_ntuple.cc @@ -291,14 +291,13 @@ void setOptionalOutputBranches(Event* event) { //________________________________________________________________________________________________________________________________ void setPixelQuintupletOutputBranches(Event* event) { // ============ pT5 ============= - PixelQuintuplets const* pixelQuintuplets = event->getPixelQuintuplets().data(); + auto const pixelQuintuplets = event->getPixelQuintuplets(); auto const quintuplets = event->getQuintuplets(); auto const segmentsPixel = event->getSegments(); Modules const* modules = event->getModules().data(); int n_accepted_simtrk = ana.tx->getBranch>("sim_TC_matched").size(); - unsigned int nPixelQuintuplets = - *pixelQuintuplets->nPixelQuintuplets; // size of this nPixelTriplets array is 1 (NOTE: parallelism lost here.) + unsigned int nPixelQuintuplets = pixelQuintuplets.nPixelQuintuplets(); std::vector sim_pT5_matched(n_accepted_simtrk); std::vector> pT5_matched_simIdx; @@ -438,12 +437,12 @@ void setQuintupletOutputBranches(Event* event) { //________________________________________________________________________________________________________________________________ void setPixelTripletOutputBranches(Event* event) { - PixelTriplets const* pixelTriplets = event->getPixelTriplets().data(); + auto const pixelTriplets = event->getPixelTriplets(); Modules const* modules = event->getModules().data(); SegmentsPixelConst segmentsPixel = event->getSegments(); int n_accepted_simtrk = ana.tx->getBranch>("sim_TC_matched").size(); - unsigned int nPixelTriplets = *pixelTriplets->nPixelTriplets; + unsigned int nPixelTriplets = pixelTriplets.nPixelTriplets(); std::vector sim_pT3_matched(n_accepted_simtrk); std::vector> pT3_matched_simIdx;