From 476d3aa87bfcb43915df1cc5485a54c35a49420a Mon Sep 17 00:00:00 2001 From: Slava Krutelyov Date: Mon, 4 Nov 2024 06:02:24 -0800 Subject: [PATCH] batch8 of updates for LST integration in CMSSW (#113) * Removed allocBufWrapper and cache toggle * Removed references to temporaries * Fixed headers * Removed devAcc_ * Simplified view creation * File and class renaming * Update workflow, enums, compilation flags * Move LSTOutputConverter to edm::stream::EDProducer * Merge standalone and CMSSW functions to get hits and TCs * Updates to remove syncs when creating or destroying the LSTEvent in CMSSW * Rename lst_INF and finalize simplification of compilation flags * Create lstProducerTask, move to C++20 pi and use C++20 in standalone compilation * Include numbers * Limit number of make threads --------- Co-authored-by: Andres Rios Tascon Co-authored-by: Manos Vourliotis --- .../python/upgradeWorkflowComponents.py | 2 +- .../python/HighPtTripletStep_cff.py | 4 +- RecoTracker/LST/plugins/BuildFile.xml | 1 - RecoTracker/LST/plugins/LSTOutputConverter.cc | 8 +- ...Producer_cff.py => lstProducerTask_cff.py} | 2 +- RecoTracker/LSTCore/BuildFile.xml | 2 +- .../interface/{Constants.h => Common.h} | 34 +- RecoTracker/LSTCore/interface/HitsSoA.h | 2 +- RecoTracker/LSTCore/interface/LSTESData.h | 3 +- .../LSTCore/interface/MiniDoubletsSoA.h | 4 +- RecoTracker/LSTCore/interface/ModulesSoA.h | 2 +- .../LSTCore/interface/ObjectRangesSoA.h | 2 +- RecoTracker/LSTCore/interface/PixelMap.h | 2 +- .../LSTCore/interface/PixelQuintupletsSoA.h | 2 +- .../LSTCore/interface/PixelTripletsSoA.h | 2 +- .../LSTCore/interface/QuintupletsSoA.h | 2 +- RecoTracker/LSTCore/interface/SegmentsSoA.h | 6 +- .../LSTCore/interface/TrackCandidatesSoA.h | 2 +- RecoTracker/LSTCore/interface/TripletsSoA.h | 2 +- .../alpaka/{Constants.h => Common.h} | 13 +- .../EndcapGeometryDevDeviceCollection.h | 1 + .../interface/alpaka/HitsDeviceCollection.h | 1 + RecoTracker/LSTCore/interface/alpaka/LST.h | 6 +- .../alpaka/MiniDoubletsDeviceCollection.h | 1 + .../alpaka/ModulesDeviceCollection.h | 1 + .../alpaka/ObjectRangesDeviceCollection.h | 1 + .../alpaka/PixelQuintupletsDeviceCollection.h | 4 +- .../alpaka/PixelTripletsDeviceCollection.h | 4 +- .../alpaka/QuintupletsDeviceCollection.h | 4 +- .../alpaka/SegmentsDeviceCollection.h | 1 + .../alpaka/TrackCandidatesDeviceCollection.h | 4 +- .../alpaka/TripletsDeviceCollection.h | 4 +- RecoTracker/LSTCore/src/LSTESData.cc | 14 +- .../LSTCore/src/ModuleConnectionMap.cc | 6 +- RecoTracker/LSTCore/src/ModuleMethods.h | 6 +- RecoTracker/LSTCore/src/alpaka/Hit.h | 18 +- RecoTracker/LSTCore/src/alpaka/Kernels.h | 2 +- .../LSTCore/src/alpaka/{LST.dev.cc => LST.cc} | 248 +++---- .../alpaka/{Event.dev.cc => LSTEvent.dev.cc} | 680 +++++++++--------- .../src/alpaka/{Event.h => LSTEvent.h} | 60 +- RecoTracker/LSTCore/src/alpaka/MiniDoublet.h | 20 +- .../LSTCore/src/alpaka/NeuralNetwork.h | 2 +- .../LSTCore/src/alpaka/PixelQuintuplet.h | 48 +- RecoTracker/LSTCore/src/alpaka/PixelTriplet.h | 68 +- RecoTracker/LSTCore/src/alpaka/Quintuplet.h | 201 +++--- RecoTracker/LSTCore/src/alpaka/Segment.h | 15 +- .../LSTCore/src/alpaka/TrackCandidate.h | 25 +- RecoTracker/LSTCore/src/alpaka/Triplet.h | 16 +- RecoTracker/LSTCore/standalone/LST/Makefile | 51 +- RecoTracker/LSTCore/standalone/Makefile | 2 +- RecoTracker/LSTCore/standalone/bin/lst.cc | 3 +- RecoTracker/LSTCore/standalone/bin/lst.h | 2 +- .../standalone/bin/lst_make_tracklooper | 30 +- .../standalone/code/core/AccessHelper.cc | 110 +-- .../standalone/code/core/AccessHelper.h | 6 +- .../LSTCore/standalone/code/core/trkCore.h | 4 +- .../standalone/code/core/write_lst_ntuple.cc | 50 +- .../standalone/code/core/write_lst_ntuple.h | 4 +- .../standalone/efficiency/bin/lst_timing | 3 - RecoTracker/LSTCore/standalone/setup.sh | 2 +- 60 files changed, 880 insertions(+), 945 deletions(-) rename RecoTracker/LST/python/{lstProducer_cff.py => lstProducerTask_cff.py} (77%) rename RecoTracker/LSTCore/interface/{Constants.h => Common.h} (69%) rename RecoTracker/LSTCore/interface/alpaka/{Constants.h => Common.h} (90%) rename RecoTracker/LSTCore/src/alpaka/{LST.dev.cc => LST.cc} (75%) rename RecoTracker/LSTCore/src/alpaka/{Event.dev.cc => LSTEvent.dev.cc} (67%) rename RecoTracker/LSTCore/src/alpaka/{Event.h => LSTEvent.h} (84%) diff --git a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py index 75debc1d8b864..f7b8df82d85c3 100644 --- a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py +++ b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py @@ -529,7 +529,7 @@ def condition_(self, fragment, stepList, key, hasHarvest): ) upgradeWFs['lstOnGPUIters01TrackingOnly'].step3 = upgradeWFs['trackingOnly'].step3 | { '--procModifiers': 'trackingIters01,trackingLST', - '--accelerators' : 'gpu-nvidia' + '--accelerators' : 'gpu-*' } #DeepCore seeding for JetCore iteration workflow diff --git a/RecoTracker/IterativeTracking/python/HighPtTripletStep_cff.py b/RecoTracker/IterativeTracking/python/HighPtTripletStep_cff.py index 7de7a0b2ad925..7c1dab22afd58 100644 --- a/RecoTracker/IterativeTracking/python/HighPtTripletStep_cff.py +++ b/RecoTracker/IterativeTracking/python/HighPtTripletStep_cff.py @@ -428,10 +428,10 @@ from RecoTracker.LST.lstSeedTracks_cff import lstInitialStepSeedTracks,lstHighPtTripletStepSeedTracks from RecoTracker.LST.lstPixelSeedInputProducer_cfi import lstPixelSeedInputProducer from RecoTracker.LST.lstPhase2OTHitsInputProducer_cfi import lstPhase2OTHitsInputProducer -from RecoTracker.LST.lstProducer_cff import * +from RecoTracker.LST.lstProducerTask_cff import * _HighPtTripletStepTask_LST.add(siPhase2RecHits, lstInitialStepSeedTracks, lstHighPtTripletStepSeedTracks, lstPixelSeedInputProducer, lstPhase2OTHitsInputProducer, - lstProducer, lstModulesDevESProducer, highPtTripletStepLSTpTracks, highPtTripletStepLSTT5Tracks, highPtTripletStepSelectorLSTT5) + lstProducerTask, highPtTripletStepLSTpTracks, highPtTripletStepLSTT5Tracks, highPtTripletStepSelectorLSTT5) (trackingPhase2PU140 & trackingLST).toReplaceWith(HighPtTripletStepTask, _HighPtTripletStepTask_LST) # fast tracking mask producer diff --git a/RecoTracker/LST/plugins/BuildFile.xml b/RecoTracker/LST/plugins/BuildFile.xml index 1b6e79b68e8b4..49e9ee77f5a3b 100644 --- a/RecoTracker/LST/plugins/BuildFile.xml +++ b/RecoTracker/LST/plugins/BuildFile.xml @@ -35,7 +35,6 @@ - diff --git a/RecoTracker/LST/plugins/LSTOutputConverter.cc b/RecoTracker/LST/plugins/LSTOutputConverter.cc index c40603c9c1e5d..0bbdd68051b87 100644 --- a/RecoTracker/LST/plugins/LSTOutputConverter.cc +++ b/RecoTracker/LST/plugins/LSTOutputConverter.cc @@ -3,7 +3,7 @@ #include "DataFormats/TrackCandidate/interface/TrackCandidateCollection.h" #include "DataFormats/TrackReco/interface/SeedStopInfo.h" #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h" -#include "FWCore/Framework/interface/global/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" @@ -25,7 +25,7 @@ #include "TrackingTools/Records/interface/TrackingComponentsRecord.h" #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h" -class LSTOutputConverter : public edm::global::EDProducer<> { +class LSTOutputConverter : public edm::stream::EDProducer<> { public: explicit LSTOutputConverter(edm::ParameterSet const& iConfig); ~LSTOutputConverter() override = default; @@ -33,7 +33,7 @@ class LSTOutputConverter : public edm::global::EDProducer<> { static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: - void produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const override; + void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override; const edm::EDGetTokenT lstOutputToken_; const edm::EDGetTokenT lstPhase2OTHitsInputToken_; @@ -110,7 +110,7 @@ void LSTOutputConverter::fillDescriptions(edm::ConfigurationDescriptions& descri descriptions.addWithDefaultLabel(desc); } -void LSTOutputConverter::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const { +void LSTOutputConverter::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { // Setup auto const& lstOutput = iEvent.get(lstOutputToken_); auto const& phase2OTRecHits = iEvent.get(lstPhase2OTHitsInputToken_); diff --git a/RecoTracker/LST/python/lstProducer_cff.py b/RecoTracker/LST/python/lstProducerTask_cff.py similarity index 77% rename from RecoTracker/LST/python/lstProducer_cff.py rename to RecoTracker/LST/python/lstProducerTask_cff.py index 9cf355bb3a3fa..4497fba36cb9b 100644 --- a/RecoTracker/LST/python/lstProducer_cff.py +++ b/RecoTracker/LST/python/lstProducerTask_cff.py @@ -5,4 +5,4 @@ from RecoTracker.LST.lstModulesDevESProducer_cfi import lstModulesDevESProducer # not scheduled task to get the framework to hide the producer -dummyLSTModulesDevESProducerTask = cms.Task(lstModulesDevESProducer) +lstProducerTask = cms.Task(lstModulesDevESProducer, lstProducer) diff --git a/RecoTracker/LSTCore/BuildFile.xml b/RecoTracker/LSTCore/BuildFile.xml index 1208407185001..a58a1898046ae 100644 --- a/RecoTracker/LSTCore/BuildFile.xml +++ b/RecoTracker/LSTCore/BuildFile.xml @@ -2,7 +2,7 @@ - + diff --git a/RecoTracker/LSTCore/interface/Constants.h b/RecoTracker/LSTCore/interface/Common.h similarity index 69% rename from RecoTracker/LSTCore/interface/Constants.h rename to RecoTracker/LSTCore/interface/Common.h index b1bd4e124eacc..be4e5dd41e133 100644 --- a/RecoTracker/LSTCore/interface/Constants.h +++ b/RecoTracker/LSTCore/interface/Common.h @@ -1,5 +1,5 @@ -#ifndef RecoTracker_LSTCore_interface_Constants_h -#define RecoTracker_LSTCore_interface_Constants_h +#ifndef RecoTracker_LSTCore_interface_Common_h +#define RecoTracker_LSTCore_interface_Common_h #include "HeterogeneousCore/AlpakaInterface/interface/config.h" #include "DataFormats/Common/interface/StdArray.h" @@ -12,38 +12,14 @@ #endif #endif -#ifdef CACHE_ALLOC -#include "HeterogeneousCore/AlpakaInterface/interface/CachedBufAlloc.h" -#endif - namespace lst { - // Buffer type for allocations where auto type can't be used. - template - using Buf = alpaka::Buf; - - // Allocation wrapper function to make integration of the caching allocator easier and reduce code boilerplate. - template - ALPAKA_FN_HOST ALPAKA_FN_INLINE Buf allocBufWrapper(TDev const& dev, TSize nElements, TQueue queue) { -#ifdef CACHE_ALLOC - return cms::alpakatools::allocCachedBuf( - dev, queue, alpaka_common::Vec1D(static_cast(nElements))); -#else - return alpaka::allocBuf(dev, - alpaka_common::Vec1D(static_cast(nElements))); -#endif - } - - // Second allocation wrapper function when queue is not given. Reduces code boilerplate. - template - ALPAKA_FN_HOST ALPAKA_FN_INLINE Buf allocBufWrapper(TDev const& dev, TSize nElements) { - return alpaka::allocBuf(dev, - alpaka_common::Vec1D(static_cast(nElements))); - } - // Named constants for pixelTypes enum PixelType : int8_t { kInvalid = -1, kHighPt = 0, kLowPtPosCurv = 1, kLowPtNegCurv = 2 }; + // Named types for LST objects + enum LSTObjType { T5 = 4, pT3 = 5, pT5 = 7, pLS = 8 }; + // If a compile time flag does not define PT_CUT, default to 0.8 (GeV) #ifndef PT_CUT constexpr float PT_CUT = 0.8f; diff --git a/RecoTracker/LSTCore/interface/HitsSoA.h b/RecoTracker/LSTCore/interface/HitsSoA.h index 4aed06e1bc31f..b1f5de9eff46e 100644 --- a/RecoTracker/LSTCore/interface/HitsSoA.h +++ b/RecoTracker/LSTCore/interface/HitsSoA.h @@ -4,7 +4,7 @@ #include "DataFormats/SoATemplate/interface/SoALayout.h" #include "DataFormats/Portable/interface/PortableCollection.h" -#include "RecoTracker/LSTCore/interface/Constants.h" +#include "RecoTracker/LSTCore/interface/Common.h" namespace lst { diff --git a/RecoTracker/LSTCore/interface/LSTESData.h b/RecoTracker/LSTCore/interface/LSTESData.h index 83798e92dcb3f..b5d68cde5dd26 100644 --- a/RecoTracker/LSTCore/interface/LSTESData.h +++ b/RecoTracker/LSTCore/interface/LSTESData.h @@ -1,7 +1,7 @@ #ifndef RecoTracker_LSTCore_interface_LSTESData_h #define RecoTracker_LSTCore_interface_LSTESData_h -#include "RecoTracker/LSTCore/interface/Constants.h" +#include "RecoTracker/LSTCore/interface/Common.h" #include "RecoTracker/LSTCore/interface/EndcapGeometryDevHostCollection.h" #include "RecoTracker/LSTCore/interface/ModulesHostCollection.h" #include "RecoTracker/LSTCore/interface/PixelMap.h" @@ -21,6 +21,7 @@ namespace lst { unsigned int nEndCapMap; std::unique_ptr> modules; std::unique_ptr> endcapGeometry; + // Host-side object that is shared between the LSTESData objects for different devices std::shared_ptr pixelMapping; LSTESData(uint16_t const& nModulesIn, diff --git a/RecoTracker/LSTCore/interface/MiniDoubletsSoA.h b/RecoTracker/LSTCore/interface/MiniDoubletsSoA.h index c93a00e1a8aec..84375502c34b0 100644 --- a/RecoTracker/LSTCore/interface/MiniDoubletsSoA.h +++ b/RecoTracker/LSTCore/interface/MiniDoubletsSoA.h @@ -39,11 +39,11 @@ namespace lst { SOA_COLUMN(float, outerHighEdgeX), SOA_COLUMN(float, outerHighEdgeY), SOA_COLUMN(float, outerLowEdgeX), - SOA_COLUMN(float, outerLowEdgeY)); + SOA_COLUMN(float, outerLowEdgeY)) GENERATE_SOA_LAYOUT(MiniDoubletsOccupancySoALayout, SOA_COLUMN(unsigned int, nMDs), - SOA_COLUMN(unsigned int, totOccupancyMDs)); + SOA_COLUMN(unsigned int, totOccupancyMDs)) using MiniDoubletsSoA = MiniDoubletsSoALayout<>; using MiniDoubletsOccupancySoA = MiniDoubletsOccupancySoALayout<>; diff --git a/RecoTracker/LSTCore/interface/ModulesSoA.h b/RecoTracker/LSTCore/interface/ModulesSoA.h index 8bf1dc9232cd1..241dce953b293 100644 --- a/RecoTracker/LSTCore/interface/ModulesSoA.h +++ b/RecoTracker/LSTCore/interface/ModulesSoA.h @@ -4,7 +4,7 @@ #include "DataFormats/SoATemplate/interface/SoALayout.h" #include "DataFormats/Portable/interface/PortableCollection.h" -#include "RecoTracker/LSTCore/interface/Constants.h" +#include "RecoTracker/LSTCore/interface/Common.h" namespace lst { diff --git a/RecoTracker/LSTCore/interface/ObjectRangesSoA.h b/RecoTracker/LSTCore/interface/ObjectRangesSoA.h index 09371cd4b2b56..ccab6b23909f6 100644 --- a/RecoTracker/LSTCore/interface/ObjectRangesSoA.h +++ b/RecoTracker/LSTCore/interface/ObjectRangesSoA.h @@ -4,7 +4,7 @@ #include "DataFormats/SoATemplate/interface/SoALayout.h" #include "DataFormats/Portable/interface/PortableCollection.h" -#include "RecoTracker/LSTCore/interface/Constants.h" +#include "RecoTracker/LSTCore/interface/Common.h" namespace lst { diff --git a/RecoTracker/LSTCore/interface/PixelMap.h b/RecoTracker/LSTCore/interface/PixelMap.h index a0fd89387e7e4..2c3756d4c6251 100644 --- a/RecoTracker/LSTCore/interface/PixelMap.h +++ b/RecoTracker/LSTCore/interface/PixelMap.h @@ -4,7 +4,7 @@ #include #include -#include "RecoTracker/LSTCore/interface/Constants.h" +#include "RecoTracker/LSTCore/interface/Common.h" namespace lst { struct PixelMap { diff --git a/RecoTracker/LSTCore/interface/PixelQuintupletsSoA.h b/RecoTracker/LSTCore/interface/PixelQuintupletsSoA.h index 504594dae6d94..e8ea89b9a2547 100644 --- a/RecoTracker/LSTCore/interface/PixelQuintupletsSoA.h +++ b/RecoTracker/LSTCore/interface/PixelQuintupletsSoA.h @@ -5,7 +5,7 @@ #include "DataFormats/Common/interface/StdArray.h" #include "DataFormats/SoATemplate/interface/SoALayout.h" -#include "RecoTracker/LSTCore/interface/Constants.h" +#include "RecoTracker/LSTCore/interface/Common.h" namespace lst { GENERATE_SOA_LAYOUT(PixelQuintupletsSoALayout, diff --git a/RecoTracker/LSTCore/interface/PixelTripletsSoA.h b/RecoTracker/LSTCore/interface/PixelTripletsSoA.h index bf940e2cd3bd0..a0f2c9c416539 100644 --- a/RecoTracker/LSTCore/interface/PixelTripletsSoA.h +++ b/RecoTracker/LSTCore/interface/PixelTripletsSoA.h @@ -5,7 +5,7 @@ #include "DataFormats/Common/interface/StdArray.h" #include "DataFormats/SoATemplate/interface/SoALayout.h" -#include "RecoTracker/LSTCore/interface/Constants.h" +#include "RecoTracker/LSTCore/interface/Common.h" namespace lst { GENERATE_SOA_LAYOUT(PixelTripletsSoALayout, diff --git a/RecoTracker/LSTCore/interface/QuintupletsSoA.h b/RecoTracker/LSTCore/interface/QuintupletsSoA.h index 05da002e5e343..4ece80cd11ddd 100644 --- a/RecoTracker/LSTCore/interface/QuintupletsSoA.h +++ b/RecoTracker/LSTCore/interface/QuintupletsSoA.h @@ -5,7 +5,7 @@ #include "DataFormats/Common/interface/StdArray.h" #include "DataFormats/SoATemplate/interface/SoALayout.h" -#include "RecoTracker/LSTCore/interface/Constants.h" +#include "RecoTracker/LSTCore/interface/Common.h" namespace lst { GENERATE_SOA_LAYOUT(QuintupletsSoALayout, diff --git a/RecoTracker/LSTCore/interface/SegmentsSoA.h b/RecoTracker/LSTCore/interface/SegmentsSoA.h index b5154dea56e49..24df2fb5a42a0 100644 --- a/RecoTracker/LSTCore/interface/SegmentsSoA.h +++ b/RecoTracker/LSTCore/interface/SegmentsSoA.h @@ -4,7 +4,7 @@ #include "DataFormats/SoATemplate/interface/SoALayout.h" #include "DataFormats/Portable/interface/PortableCollection.h" -#include "RecoTracker/LSTCore/interface/Constants.h" +#include "RecoTracker/LSTCore/interface/Common.h" namespace lst { @@ -19,9 +19,7 @@ namespace lst { SOA_COLUMN(uint16_t, outerLowerModuleIndices), SOA_COLUMN(Params_LS::ArrayUxLayers, mdIndices), SOA_COLUMN(unsigned int, innerMiniDoubletAnchorHitIndices), - SOA_COLUMN(unsigned int, outerMiniDoubletAnchorHitIndices) - //SOA_SCALAR(unsigned int, nMemoryLocations) - ) + SOA_COLUMN(unsigned int, outerMiniDoubletAnchorHitIndices)) GENERATE_SOA_LAYOUT(SegmentsOccupancySoALayout, SOA_COLUMN(unsigned int, nSegments), //number of segments per inner lower module diff --git a/RecoTracker/LSTCore/interface/TrackCandidatesSoA.h b/RecoTracker/LSTCore/interface/TrackCandidatesSoA.h index 18bea1e51c6ba..b1fdecf75526a 100644 --- a/RecoTracker/LSTCore/interface/TrackCandidatesSoA.h +++ b/RecoTracker/LSTCore/interface/TrackCandidatesSoA.h @@ -5,7 +5,7 @@ #include "DataFormats/Common/interface/StdArray.h" #include "DataFormats/SoATemplate/interface/SoALayout.h" -#include "RecoTracker/LSTCore/interface/Constants.h" +#include "RecoTracker/LSTCore/interface/Common.h" namespace lst { GENERATE_SOA_LAYOUT(TrackCandidatesSoALayout, diff --git a/RecoTracker/LSTCore/interface/TripletsSoA.h b/RecoTracker/LSTCore/interface/TripletsSoA.h index e0407ef3a0912..69c2d97449df3 100644 --- a/RecoTracker/LSTCore/interface/TripletsSoA.h +++ b/RecoTracker/LSTCore/interface/TripletsSoA.h @@ -5,7 +5,7 @@ #include "DataFormats/Common/interface/StdArray.h" #include "DataFormats/SoATemplate/interface/SoALayout.h" -#include "RecoTracker/LSTCore/interface/Constants.h" +#include "RecoTracker/LSTCore/interface/Common.h" namespace lst { GENERATE_SOA_LAYOUT(TripletsSoALayout, diff --git a/RecoTracker/LSTCore/interface/alpaka/Constants.h b/RecoTracker/LSTCore/interface/alpaka/Common.h similarity index 90% rename from RecoTracker/LSTCore/interface/alpaka/Constants.h rename to RecoTracker/LSTCore/interface/alpaka/Common.h index 208f49cc52538..7a1feabfcf076 100644 --- a/RecoTracker/LSTCore/interface/alpaka/Constants.h +++ b/RecoTracker/LSTCore/interface/alpaka/Common.h @@ -1,7 +1,9 @@ -#ifndef RecoTracker_LSTCore_interface_alpaka_Constants_h -#define RecoTracker_LSTCore_interface_alpaka_Constants_h +#ifndef RecoTracker_LSTCore_interface_alpaka_Common_h +#define RecoTracker_LSTCore_interface_alpaka_Common_h -#include "RecoTracker/LSTCore/interface/Constants.h" +#include + +#include "RecoTracker/LSTCore/interface/Common.h" namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { @@ -34,6 +36,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { // expecting a reference (T const&) in the arguments. Hence, // ALPAKA_STATIC_ACC_MEM_GLOBAL needs to be used in addition to constexpr. + ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kPi = std::numbers::pi_v; // 15 MeV constant from the approximate Bethe-Bloch formula ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kMulsInGeV = 0.015; ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kMiniMulsPtScaleBarrel[6] = { @@ -54,8 +57,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kWidth2S = 0.009; ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kWidthPS = 0.01; ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kPt_betaMax = 7.0; - // Since C++ can't represent infinity, lst_INF = 123456789 was used to represent infinity in the data table - ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float lst_INF = 123456789.0; + // To be updated with std::numeric_limits::infinity() in the code and data files + ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kVerticalModuleSlope = 123456789.0; namespace t5dnn { diff --git a/RecoTracker/LSTCore/interface/alpaka/EndcapGeometryDevDeviceCollection.h b/RecoTracker/LSTCore/interface/alpaka/EndcapGeometryDevDeviceCollection.h index 002e1e0423804..12f510cf6b367 100644 --- a/RecoTracker/LSTCore/interface/alpaka/EndcapGeometryDevDeviceCollection.h +++ b/RecoTracker/LSTCore/interface/alpaka/EndcapGeometryDevDeviceCollection.h @@ -3,6 +3,7 @@ #include "DataFormats/Portable/interface/alpaka/PortableCollection.h" +#include "RecoTracker/LSTCore/interface/alpaka/Common.h" #include "RecoTracker/LSTCore/interface/EndcapGeometryDevSoA.h" namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { diff --git a/RecoTracker/LSTCore/interface/alpaka/HitsDeviceCollection.h b/RecoTracker/LSTCore/interface/alpaka/HitsDeviceCollection.h index 99494499271e0..5bafd9df246bc 100644 --- a/RecoTracker/LSTCore/interface/alpaka/HitsDeviceCollection.h +++ b/RecoTracker/LSTCore/interface/alpaka/HitsDeviceCollection.h @@ -3,6 +3,7 @@ #include "DataFormats/Portable/interface/alpaka/PortableCollection.h" +#include "RecoTracker/LSTCore/interface/alpaka/Common.h" #include "RecoTracker/LSTCore/interface/HitsSoA.h" namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { diff --git a/RecoTracker/LSTCore/interface/alpaka/LST.h b/RecoTracker/LSTCore/interface/alpaka/LST.h index df1319462432e..40d912de3f291 100644 --- a/RecoTracker/LSTCore/interface/alpaka/LST.h +++ b/RecoTracker/LSTCore/interface/alpaka/LST.h @@ -1,7 +1,7 @@ #ifndef RecoTracker_LSTCore_interface_alpaka_LST_h #define RecoTracker_LSTCore_interface_alpaka_LST_h -#include "RecoTracker/LSTCore/interface/alpaka/Constants.h" +#include "RecoTracker/LSTCore/interface/alpaka/Common.h" #include "RecoTracker/LSTCore/interface/LSTESData.h" #include @@ -9,7 +9,7 @@ #include namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { - class Event; + class LSTEvent; class LST { public: @@ -65,7 +65,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { std::vector const& ph2_y, std::vector const& ph2_z); - void getOutput(Event& event); + void getOutput(LSTEvent& event); // Input and output vectors std::vector in_trkX_; diff --git a/RecoTracker/LSTCore/interface/alpaka/MiniDoubletsDeviceCollection.h b/RecoTracker/LSTCore/interface/alpaka/MiniDoubletsDeviceCollection.h index 3011e1d2f87b7..7751f75ac5ec9 100644 --- a/RecoTracker/LSTCore/interface/alpaka/MiniDoubletsDeviceCollection.h +++ b/RecoTracker/LSTCore/interface/alpaka/MiniDoubletsDeviceCollection.h @@ -3,6 +3,7 @@ #include "DataFormats/Portable/interface/alpaka/PortableCollection.h" +#include "RecoTracker/LSTCore/interface/alpaka/Common.h" #include "RecoTracker/LSTCore/interface/MiniDoubletsSoA.h" namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { diff --git a/RecoTracker/LSTCore/interface/alpaka/ModulesDeviceCollection.h b/RecoTracker/LSTCore/interface/alpaka/ModulesDeviceCollection.h index a7510feb0d540..73152a47b6a42 100644 --- a/RecoTracker/LSTCore/interface/alpaka/ModulesDeviceCollection.h +++ b/RecoTracker/LSTCore/interface/alpaka/ModulesDeviceCollection.h @@ -3,6 +3,7 @@ #include "DataFormats/Portable/interface/alpaka/PortableCollection.h" +#include "RecoTracker/LSTCore/interface/alpaka/Common.h" #include "RecoTracker/LSTCore/interface/ModulesSoA.h" namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { diff --git a/RecoTracker/LSTCore/interface/alpaka/ObjectRangesDeviceCollection.h b/RecoTracker/LSTCore/interface/alpaka/ObjectRangesDeviceCollection.h index edeab720bdbaf..36c6584280fe0 100644 --- a/RecoTracker/LSTCore/interface/alpaka/ObjectRangesDeviceCollection.h +++ b/RecoTracker/LSTCore/interface/alpaka/ObjectRangesDeviceCollection.h @@ -3,6 +3,7 @@ #include "DataFormats/Portable/interface/alpaka/PortableCollection.h" +#include "RecoTracker/LSTCore/interface/alpaka/Common.h" #include "RecoTracker/LSTCore/interface/ObjectRangesSoA.h" namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { diff --git a/RecoTracker/LSTCore/interface/alpaka/PixelQuintupletsDeviceCollection.h b/RecoTracker/LSTCore/interface/alpaka/PixelQuintupletsDeviceCollection.h index e2553f7b42c50..e5feed7677c38 100644 --- a/RecoTracker/LSTCore/interface/alpaka/PixelQuintupletsDeviceCollection.h +++ b/RecoTracker/LSTCore/interface/alpaka/PixelQuintupletsDeviceCollection.h @@ -1,9 +1,11 @@ #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" +#include "RecoTracker/LSTCore/interface/alpaka/Common.h" +#include "RecoTracker/LSTCore/interface/PixelQuintupletsSoA.h" + namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { using PixelQuintupletsDeviceCollection = PortableCollection; } // namespace ALPAKA_ACCELERATOR_NAMESPACE::lst diff --git a/RecoTracker/LSTCore/interface/alpaka/PixelTripletsDeviceCollection.h b/RecoTracker/LSTCore/interface/alpaka/PixelTripletsDeviceCollection.h index ac010b9028ac4..a5938ed82bd8b 100644 --- a/RecoTracker/LSTCore/interface/alpaka/PixelTripletsDeviceCollection.h +++ b/RecoTracker/LSTCore/interface/alpaka/PixelTripletsDeviceCollection.h @@ -1,9 +1,11 @@ #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" +#include "RecoTracker/LSTCore/interface/alpaka/Common.h" +#include "RecoTracker/LSTCore/interface/PixelTripletsSoA.h" + namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { using PixelTripletsDeviceCollection = PortableCollection; } // namespace ALPAKA_ACCELERATOR_NAMESPACE::lst diff --git a/RecoTracker/LSTCore/interface/alpaka/QuintupletsDeviceCollection.h b/RecoTracker/LSTCore/interface/alpaka/QuintupletsDeviceCollection.h index df1aa2e554e2d..13fb5484ea0fd 100644 --- a/RecoTracker/LSTCore/interface/alpaka/QuintupletsDeviceCollection.h +++ b/RecoTracker/LSTCore/interface/alpaka/QuintupletsDeviceCollection.h @@ -1,9 +1,11 @@ #ifndef RecoTracker_LSTCore_interface_QuintupletsDeviceCollection_h #define RecoTracker_LSTCore_interface_QuintupletsDeviceCollection_h -#include "RecoTracker/LSTCore/interface/QuintupletsSoA.h" #include "DataFormats/Portable/interface/alpaka/PortableCollection.h" +#include "RecoTracker/LSTCore/interface/alpaka/Common.h" +#include "RecoTracker/LSTCore/interface/QuintupletsSoA.h" + namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { using QuintupletsDeviceCollection = PortableCollection2; } // namespace ALPAKA_ACCELERATOR_NAMESPACE::lst diff --git a/RecoTracker/LSTCore/interface/alpaka/SegmentsDeviceCollection.h b/RecoTracker/LSTCore/interface/alpaka/SegmentsDeviceCollection.h index ac634aa51bade..934e6314ae320 100644 --- a/RecoTracker/LSTCore/interface/alpaka/SegmentsDeviceCollection.h +++ b/RecoTracker/LSTCore/interface/alpaka/SegmentsDeviceCollection.h @@ -3,6 +3,7 @@ #include "DataFormats/Portable/interface/alpaka/PortableCollection.h" +#include "RecoTracker/LSTCore/interface/alpaka/Common.h" #include "RecoTracker/LSTCore/interface/SegmentsSoA.h" namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { diff --git a/RecoTracker/LSTCore/interface/alpaka/TrackCandidatesDeviceCollection.h b/RecoTracker/LSTCore/interface/alpaka/TrackCandidatesDeviceCollection.h index 057d86180d967..387ca5a108453 100644 --- a/RecoTracker/LSTCore/interface/alpaka/TrackCandidatesDeviceCollection.h +++ b/RecoTracker/LSTCore/interface/alpaka/TrackCandidatesDeviceCollection.h @@ -1,9 +1,11 @@ #ifndef RecoTracker_LSTCore_interface_TrackCandidatesDeviceCollection_h #define RecoTracker_LSTCore_interface_TrackCandidatesDeviceCollection_h -#include "RecoTracker/LSTCore/interface/TrackCandidatesSoA.h" #include "DataFormats/Portable/interface/alpaka/PortableCollection.h" +#include "RecoTracker/LSTCore/interface/alpaka/Common.h" +#include "RecoTracker/LSTCore/interface/TrackCandidatesSoA.h" + namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { using TrackCandidatesDeviceCollection = PortableCollection; } // namespace ALPAKA_ACCELERATOR_NAMESPACE::lst diff --git a/RecoTracker/LSTCore/interface/alpaka/TripletsDeviceCollection.h b/RecoTracker/LSTCore/interface/alpaka/TripletsDeviceCollection.h index ea709a7d78efd..6db827680cee3 100644 --- a/RecoTracker/LSTCore/interface/alpaka/TripletsDeviceCollection.h +++ b/RecoTracker/LSTCore/interface/alpaka/TripletsDeviceCollection.h @@ -1,9 +1,11 @@ #ifndef RecoTracker_LSTCore_interface_TripletsDeviceCollection_h #define RecoTracker_LSTCore_interface_TripletsDeviceCollection_h -#include "RecoTracker/LSTCore/interface/TripletsSoA.h" #include "DataFormats/Portable/interface/alpaka/PortableCollection.h" +#include "RecoTracker/LSTCore/interface/alpaka/Common.h" +#include "RecoTracker/LSTCore/interface/TripletsSoA.h" + namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { using TripletsDeviceCollection = PortableCollection2; } // namespace ALPAKA_ACCELERATOR_NAMESPACE::lst diff --git a/RecoTracker/LSTCore/src/LSTESData.cc b/RecoTracker/LSTCore/src/LSTESData.cc index 18fa3adf3a72f..4679d35f5b7aa 100644 --- a/RecoTracker/LSTCore/src/LSTESData.cc +++ b/RecoTracker/LSTCore/src/LSTESData.cc @@ -7,7 +7,7 @@ #include "ModuleMethods.h" namespace { - std::string trackLooperDir() { + std::string geometryDataDir() { const char* path_lst_base = std::getenv("LST_BASE"); const char* path_tracklooperdir = std::getenv("TRACKLOOPERDIR"); std::string path_str; @@ -31,7 +31,7 @@ namespace { } std::string get_absolute_path_after_check_file_exists(std::string const& name) { - std::filesystem::path fullpath = std::filesystem::absolute(name.c_str()); + std::filesystem::path fullpath = std::filesystem::absolute(name); if (not std::filesystem::exists(fullpath)) { throw std::runtime_error("Could not find the file = " + fullpath.string()); } @@ -44,18 +44,18 @@ namespace { lst::ModuleConnectionMap& moduleConnectionMap) { // Module orientation information (DrDz or phi angles) auto endcap_geom = - get_absolute_path_after_check_file_exists(trackLooperDir() + "/data/OT800_IT615_pt0.8/endcap_orientation.bin"); + get_absolute_path_after_check_file_exists(geometryDataDir() + "/data/OT800_IT615_pt0.8/endcap_orientation.bin"); auto tilted_geom = get_absolute_path_after_check_file_exists( - trackLooperDir() + "/data/OT800_IT615_pt0.8/tilted_barrel_orientation.bin"); + geometryDataDir() + "/data/OT800_IT615_pt0.8/tilted_barrel_orientation.bin"); // Module connection map (for line segment building) auto mappath = get_absolute_path_after_check_file_exists( - trackLooperDir() + "/data/OT800_IT615_pt0.8/module_connection_tracing_merged.bin"); + geometryDataDir() + "/data/OT800_IT615_pt0.8/module_connection_tracing_merged.bin"); endcapGeometry.load(endcap_geom); tiltedGeometry.load(tilted_geom); moduleConnectionMap.load(mappath); - auto pLSMapDir = trackLooperDir() + "/data/OT800_IT615_pt0.8/pixelmap/pLS_map"; + auto pLSMapDir = geometryDataDir() + "/data/OT800_IT615_pt0.8/pixelmap/pLS_map"; const std::array connects{ {"_layer1_subdet5", "_layer2_subdet5", "_layer1_subdet4", "_layer2_subdet4"}}; std::string path; @@ -97,7 +97,7 @@ std::unique_ptr> lst::loadAndFillESHost() endcapGeometry.nEndCapMap * sizeof(float)); auto path = - get_absolute_path_after_check_file_exists(trackLooperDir() + "/data/OT800_IT615_pt0.8/sensor_centroids.bin"); + get_absolute_path_after_check_file_exists(geometryDataDir() + "/data/OT800_IT615_pt0.8/sensor_centroids.bin"); auto modulesBuffers = lst::loadModulesFromFile(pLStoLayer, path.c_str(), nModules, diff --git a/RecoTracker/LSTCore/src/ModuleConnectionMap.cc b/RecoTracker/LSTCore/src/ModuleConnectionMap.cc index 881b2a66f6216..0da0f4cc4ac6f 100644 --- a/RecoTracker/LSTCore/src/ModuleConnectionMap.cc +++ b/RecoTracker/LSTCore/src/ModuleConnectionMap.cc @@ -26,6 +26,7 @@ void lst::ModuleConnectionMap::load(std::string const& filename) { if (ifile) { std::vector connected_detids; + connected_detids.reserve(number_of_connections); // Read the connections for the given detid for (unsigned int i = 0; i < number_of_connections; ++i) { @@ -42,7 +43,7 @@ void lst::ModuleConnectionMap::load(std::string const& filename) { } if (ifile) { - moduleConnections_[detid] = connected_detids; + moduleConnections_[detid] = std::move(connected_detids); } } else { if (!ifile.eof()) { @@ -66,6 +67,7 @@ void lst::ModuleConnectionMap::add(std::string const& filename) { std::stringstream ss(line); ss >> detid >> number_of_connections; + connected_detids.reserve(number_of_connections); for (int ii = 0; ii < number_of_connections; ++ii) { ss >> connected_detid; @@ -90,7 +92,7 @@ void lst::ModuleConnectionMap::print() { std::cout << "Printing ModuleConnectionMap" << std::endl; for (auto& pair : moduleConnections_) { unsigned int detid = pair.first; - std::vector connected_detids = pair.second; + std::vector const& connected_detids = pair.second; std::cout << " detid: " << detid << std::endl; for (auto& connected_detid : connected_detids) { std::cout << " connected_detid: " << connected_detid << std::endl; diff --git a/RecoTracker/LSTCore/src/ModuleMethods.h b/RecoTracker/LSTCore/src/ModuleMethods.h index aee17629c7e96..75abe04ec686d 100644 --- a/RecoTracker/LSTCore/src/ModuleMethods.h +++ b/RecoTracker/LSTCore/src/ModuleMethods.h @@ -4,7 +4,7 @@ #include #include -#include "RecoTracker/LSTCore/interface/Constants.h" +#include "RecoTracker/LSTCore/interface/Common.h" #include "RecoTracker/LSTCore/interface/ModulesSoA.h" #include "RecoTracker/LSTCore/interface/ModulesHostCollection.h" #include "RecoTracker/LSTCore/interface/TiltedGeometry.h" @@ -374,8 +374,8 @@ namespace lst { pixelMapping.pixelModuleIndex = mmd.detIdToIndex.at(1); auto modulesPixel_view = modulesHC->view(); - auto connectedPixels = alpaka::createView( - cms::alpakatools::host(), modulesPixel_view.connectedPixels(), modulesPixel_view.metadata().size()); + auto connectedPixels = + cms::alpakatools::make_host_view(modulesPixel_view.connectedPixels(), modulesPixel_view.metadata().size()); for (unsigned int icondet = 0; icondet < totalSizes; icondet++) { connectedPixels[icondet] = mmd.detIdToIndex.at(connectedModuleDetIds[icondet]); } diff --git a/RecoTracker/LSTCore/src/alpaka/Hit.h b/RecoTracker/LSTCore/src/alpaka/Hit.h index 758ea03afb992..166be95cb432f 100644 --- a/RecoTracker/LSTCore/src/alpaka/Hit.h +++ b/RecoTracker/LSTCore/src/alpaka/Hit.h @@ -1,7 +1,7 @@ #ifndef RecoTracker_LSTCore_src_alpaka_Hit_h #define RecoTracker_LSTCore_src_alpaka_Hit_h -#include "RecoTracker/LSTCore/interface/alpaka/Constants.h" +#include "RecoTracker/LSTCore/interface/alpaka/Common.h" #include "RecoTracker/LSTCore/interface/ModulesSoA.h" #include "RecoTracker/LSTCore/interface/alpaka/HitsDeviceCollection.h" @@ -17,17 +17,17 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { template ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE float phi_mpi_pi(TAcc const& acc, float x) { - if (alpaka::math::abs(acc, x) <= float(M_PI)) + if (alpaka::math::abs(acc, x) <= kPi) return x; - constexpr float o2pi = 1.f / (2.f * float(M_PI)); + constexpr float o2pi = 1.f / (2.f * kPi); float n = alpaka::math::round(acc, x * o2pi); - return x - n * float(2.f * float(M_PI)); + return x - n * float(2.f * kPi); } template ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE float phi(TAcc const& acc, float x, float y) { - return phi_mpi_pi(acc, float(M_PI) + alpaka::math::atan2(acc, -y, -x)); + return phi_mpi_pi(acc, kPi + alpaka::math::atan2(acc, -y, -x)); } template @@ -47,10 +47,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float dPhi = phi1 - phi2; // Normalize dPhi to be between -pi and pi - if (dPhi > float(M_PI)) { - dPhi -= 2 * float(M_PI); - } else if (dPhi < -float(M_PI)) { - dPhi += 2 * float(M_PI); + if (dPhi > kPi) { + dPhi -= 2 * kPi; + } else if (dPhi < -kPi) { + dPhi += 2 * kPi; } return dPhi; diff --git a/RecoTracker/LSTCore/src/alpaka/Kernels.h b/RecoTracker/LSTCore/src/alpaka/Kernels.h index 525d1bf23eecb..c642f2427fa84 100644 --- a/RecoTracker/LSTCore/src/alpaka/Kernels.h +++ b/RecoTracker/LSTCore/src/alpaka/Kernels.h @@ -1,7 +1,7 @@ #ifndef RecoTracker_LSTCore_src_alpaka_Kernels_h #define RecoTracker_LSTCore_src_alpaka_Kernels_h -#include "RecoTracker/LSTCore/interface/alpaka/Constants.h" +#include "RecoTracker/LSTCore/interface/alpaka/Common.h" #include "RecoTracker/LSTCore/interface/ModulesSoA.h" #include "RecoTracker/LSTCore/interface/ObjectRangesSoA.h" #include "RecoTracker/LSTCore/interface/MiniDoubletsSoA.h" diff --git a/RecoTracker/LSTCore/src/alpaka/LST.dev.cc b/RecoTracker/LSTCore/src/alpaka/LST.cc similarity index 75% rename from RecoTracker/LSTCore/src/alpaka/LST.dev.cc rename to RecoTracker/LSTCore/src/alpaka/LST.cc index 9ab82ec99f64d..3c1638677eab2 100644 --- a/RecoTracker/LSTCore/src/alpaka/LST.dev.cc +++ b/RecoTracker/LSTCore/src/alpaka/LST.cc @@ -1,6 +1,6 @@ #include "RecoTracker/LSTCore/interface/alpaka/LST.h" -#include "Event.h" +#include "LSTEvent.h" using namespace ALPAKA_ACCELERATOR_NAMESPACE::lst; @@ -26,26 +26,27 @@ namespace { std::vector hits; unsigned int maxNHits = 0; - if (trackCandidateType == 7) - maxNHits = Params_pT5::kHits; // pT5 - else if (trackCandidateType == 5) - maxNHits = Params_pT3::kHits; // pT3 - else if (trackCandidateType == 4) - maxNHits = Params_T5::kHits; // T5 - else if (trackCandidateType == 8) - maxNHits = Params_pLS::kHits; // pLS + if (trackCandidateType == LSTObjType::pT5) + maxNHits = Params_pT5::kHits; + else if (trackCandidateType == LSTObjType::pT3) + maxNHits = Params_pT3::kHits; + else if (trackCandidateType == LSTObjType::T5) + maxNHits = Params_T5::kHits; + else if (trackCandidateType == LSTObjType::pLS) + maxNHits = Params_pLS::kHits; for (unsigned int i = 0; i < maxNHits; i++) { unsigned int hitIdxDev = tcHitIndices[i]; unsigned int hitIdx = - (trackCandidateType == 8) + (trackCandidateType == LSTObjType::pLS) ? hitIdxDev : hitIndices[hitIdxDev]; // Hit indices are stored differently in the standalone for pLS. // For p objects, the 3rd and 4th hit maybe the same, // due to the way pLS hits are stored in the standalone. // This is because pixel seeds can be either triplets or quadruplets. - if (trackCandidateType != 4 && hits.size() == 3 && hits.back() == hitIdx) // Remove duplicate 4th hits. + if (trackCandidateType != LSTObjType::T5 && hits.size() == 3 && + hits.back() == hitIdx) // Remove duplicate 4th hits. continue; hits.push_back(hitIdx); @@ -75,49 +76,55 @@ void LST::prepareInput(std::vector const& see_px, std::vector const& ph2_x, std::vector const& ph2_y, std::vector const& ph2_z) { + in_trkX_.clear(); + in_trkY_.clear(); + in_trkZ_.clear(); + in_hitId_.clear(); + in_hitIdxs_.clear(); + in_hitIndices_vec0_.clear(); + in_hitIndices_vec1_.clear(); + in_hitIndices_vec2_.clear(); + in_hitIndices_vec3_.clear(); + in_deltaPhi_vec_.clear(); + in_ptIn_vec_.clear(); + in_ptErr_vec_.clear(); + in_px_vec_.clear(); + in_py_vec_.clear(); + in_pz_vec_.clear(); + in_eta_vec_.clear(); + in_etaErr_vec_.clear(); + in_phi_vec_.clear(); + in_charge_vec_.clear(); + in_seedIdx_vec_.clear(); + in_superbin_vec_.clear(); + in_pixelType_vec_.clear(); + in_isQuad_vec_.clear(); + unsigned int count = 0; auto n_see = see_stateTrajGlbPx.size(); - std::vector px_vec; - px_vec.reserve(n_see); - std::vector py_vec; - py_vec.reserve(n_see); - std::vector pz_vec; - pz_vec.reserve(n_see); - std::vector hitIndices_vec0; - hitIndices_vec0.reserve(n_see); - std::vector hitIndices_vec1; - hitIndices_vec1.reserve(n_see); - std::vector hitIndices_vec2; - hitIndices_vec2.reserve(n_see); - std::vector hitIndices_vec3; - hitIndices_vec3.reserve(n_see); - std::vector ptIn_vec; - ptIn_vec.reserve(n_see); - std::vector ptErr_vec; - ptErr_vec.reserve(n_see); - std::vector etaErr_vec; - etaErr_vec.reserve(n_see); - std::vector eta_vec; - eta_vec.reserve(n_see); - std::vector phi_vec; - phi_vec.reserve(n_see); - std::vector charge_vec; - charge_vec.reserve(n_see); - std::vector seedIdx_vec; - seedIdx_vec.reserve(n_see); - std::vector deltaPhi_vec; - deltaPhi_vec.reserve(n_see); - std::vector trkX = ph2_x; - std::vector trkY = ph2_y; - std::vector trkZ = ph2_z; - std::vector hitId = ph2_detId; - std::vector hitIdxs(ph2_detId.size()); - - std::vector superbin_vec; - std::vector pixelType_vec; - std::vector isQuad_vec; - std::iota(hitIdxs.begin(), hitIdxs.end(), 0); - const int hit_size = trkX.size(); + in_px_vec_.reserve(n_see); + in_py_vec_.reserve(n_see); + in_pz_vec_.reserve(n_see); + in_hitIndices_vec0_.reserve(n_see); + in_hitIndices_vec1_.reserve(n_see); + in_hitIndices_vec2_.reserve(n_see); + in_hitIndices_vec3_.reserve(n_see); + in_ptIn_vec_.reserve(n_see); + in_ptErr_vec_.reserve(n_see); + in_etaErr_vec_.reserve(n_see); + in_eta_vec_.reserve(n_see); + in_phi_vec_.reserve(n_see); + in_charge_vec_.reserve(n_see); + in_seedIdx_vec_.reserve(n_see); + in_deltaPhi_vec_.reserve(n_see); + in_trkX_ = ph2_x; + in_trkY_ = ph2_y; + in_trkZ_ = ph2_z; + in_hitId_ = ph2_detId; + in_hitIdxs_.resize(ph2_detId.size()); + + std::iota(in_hitIdxs_.begin(), in_hitIdxs_.end(), 0); + const int hit_size = in_trkX_.size(); for (size_t iSeed = 0; iSeed < n_see; iSeed++) { XYZVector p3LH(see_stateTrajGlbPx[iSeed], see_stateTrajGlbPy[iSeed], see_stateTrajGlbPz[iSeed]); @@ -164,98 +171,74 @@ void LST::prepareInput(std::vector const& see_px, count++; } - trkX.push_back(r3PCA.x()); - trkY.push_back(r3PCA.y()); - trkZ.push_back(r3PCA.z()); - trkX.push_back(p3PCA.rho()); + in_trkX_.push_back(r3PCA.x()); + in_trkY_.push_back(r3PCA.y()); + in_trkZ_.push_back(r3PCA.z()); + in_trkX_.push_back(p3PCA.rho()); float p3PCA_Eta = p3PCA.eta(); - trkY.push_back(p3PCA_Eta); + in_trkY_.push_back(p3PCA_Eta); float p3PCA_Phi = p3PCA.phi(); - trkZ.push_back(p3PCA_Phi); - trkX.push_back(r3LH.x()); - trkY.push_back(r3LH.y()); - trkZ.push_back(r3LH.z()); - hitId.push_back(1); - hitId.push_back(1); - hitId.push_back(1); + in_trkZ_.push_back(p3PCA_Phi); + in_trkX_.push_back(r3LH.x()); + in_trkY_.push_back(r3LH.y()); + in_trkZ_.push_back(r3LH.z()); + in_hitId_.push_back(1); + in_hitId_.push_back(1); + in_hitId_.push_back(1); if (see_hitIdx[iSeed].size() > 3) { - trkX.push_back(r3LH.x()); - trkY.push_back(see_dxy[iSeed]); - trkZ.push_back(see_dz[iSeed]); - hitId.push_back(1); + in_trkX_.push_back(r3LH.x()); + in_trkY_.push_back(see_dxy[iSeed]); + in_trkZ_.push_back(see_dz[iSeed]); + in_hitId_.push_back(1); } - px_vec.push_back(px); - py_vec.push_back(py); - pz_vec.push_back(pz); - - hitIndices_vec0.push_back(hitIdx0); - hitIndices_vec1.push_back(hitIdx1); - hitIndices_vec2.push_back(hitIdx2); - hitIndices_vec3.push_back(hitIdx3); - ptIn_vec.push_back(ptIn); - ptErr_vec.push_back(ptErr); - etaErr_vec.push_back(etaErr); - eta_vec.push_back(eta); + in_px_vec_.push_back(px); + in_py_vec_.push_back(py); + in_pz_vec_.push_back(pz); + + in_hitIndices_vec0_.push_back(hitIdx0); + in_hitIndices_vec1_.push_back(hitIdx1); + in_hitIndices_vec2_.push_back(hitIdx2); + in_hitIndices_vec3_.push_back(hitIdx3); + in_ptIn_vec_.push_back(ptIn); + in_ptErr_vec_.push_back(ptErr); + in_etaErr_vec_.push_back(etaErr); + in_eta_vec_.push_back(eta); float phi = p3LH.phi(); - phi_vec.push_back(phi); - charge_vec.push_back(charge); - seedIdx_vec.push_back(iSeed); - deltaPhi_vec.push_back(pixelSegmentDeltaPhiChange); - - hitIdxs.push_back(see_hitIdx[iSeed][0]); - hitIdxs.push_back(see_hitIdx[iSeed][1]); - hitIdxs.push_back(see_hitIdx[iSeed][2]); + in_phi_vec_.push_back(phi); + in_charge_vec_.push_back(charge); + in_seedIdx_vec_.push_back(iSeed); + in_deltaPhi_vec_.push_back(pixelSegmentDeltaPhiChange); + + in_hitIdxs_.push_back(see_hitIdx[iSeed][0]); + in_hitIdxs_.push_back(see_hitIdx[iSeed][1]); + in_hitIdxs_.push_back(see_hitIdx[iSeed][2]); char isQuad = false; if (see_hitIdx[iSeed].size() > 3) { isQuad = true; - hitIdxs.push_back(see_hitIdx[iSeed][3]); + in_hitIdxs_.push_back(see_hitIdx[iSeed][3]); } float neta = 25.; float nphi = 72.; float nz = 25.; int etabin = (p3PCA_Eta + 2.6) / ((2 * 2.6) / neta); - int phibin = (p3PCA_Phi + 3.14159265358979323846) / ((2. * 3.14159265358979323846) / nphi); + int phibin = (p3PCA_Phi + kPi) / ((2. * kPi) / nphi); int dzbin = (see_dz[iSeed] + 30) / (2 * 30 / nz); int isuperbin = (nz * nphi) * etabin + (nz)*phibin + dzbin; - superbin_vec.push_back(isuperbin); - pixelType_vec.push_back(pixtype); - isQuad_vec.push_back(isQuad); + in_superbin_vec_.push_back(isuperbin); + in_pixelType_vec_.push_back(pixtype); + in_isQuad_vec_.push_back(isQuad); } } - - in_trkX_ = trkX; - in_trkY_ = trkY; - in_trkZ_ = trkZ; - in_hitId_ = hitId; - in_hitIdxs_ = hitIdxs; - in_hitIndices_vec0_ = hitIndices_vec0; - in_hitIndices_vec1_ = hitIndices_vec1; - in_hitIndices_vec2_ = hitIndices_vec2; - in_hitIndices_vec3_ = hitIndices_vec3; - in_deltaPhi_vec_ = deltaPhi_vec; - in_ptIn_vec_ = ptIn_vec; - in_ptErr_vec_ = ptErr_vec; - in_px_vec_ = px_vec; - in_py_vec_ = py_vec; - in_pz_vec_ = pz_vec; - in_eta_vec_ = eta_vec; - in_etaErr_vec_ = etaErr_vec; - in_phi_vec_ = phi_vec; - in_charge_vec_ = charge_vec; - in_seedIdx_vec_ = seedIdx_vec; - in_superbin_vec_ = superbin_vec; - in_pixelType_vec_ = pixelType_vec; - in_isQuad_vec_ = isQuad_vec; } -void LST::getOutput(Event& event) { - std::vector> tc_hitIdxs; - std::vector tc_len; - std::vector tc_seedIdx; - std::vector tc_trackCandidateType; +void LST::getOutput(LSTEvent& event) { + out_tc_hitIdxs_.clear(); + out_tc_len_.clear(); + out_tc_seedIdx_.clear(); + out_tc_trackCandidateType_.clear(); - auto const hits = event.getHitsInCMSSW(false); // sync on next line - auto const& trackCandidates = event.getTrackCandidatesInCMSSW(); + auto const hits = event.getHits(/*inCMSSW*/ true, /*sync*/ false); // sync on next line + auto const& trackCandidates = event.getTrackCandidates(/*inCMSSW*/ true, /*sync*/ true); unsigned int nTrackCandidates = trackCandidates.nTrackCandidates(); @@ -263,16 +246,11 @@ void LST::getOutput(Event& event) { short trackCandidateType = trackCandidates.trackCandidateType()[idx]; std::vector hit_idx = getHitIdxs(trackCandidateType, trackCandidates.hitIndices()[idx], hits.idxs()); - tc_hitIdxs.push_back(hit_idx); - tc_len.push_back(hit_idx.size()); - tc_seedIdx.push_back(trackCandidates.pixelSeedIndex()[idx]); - tc_trackCandidateType.push_back(trackCandidateType); + out_tc_hitIdxs_.push_back(hit_idx); + out_tc_len_.push_back(hit_idx.size()); + out_tc_seedIdx_.push_back(trackCandidates.pixelSeedIndex()[idx]); + out_tc_trackCandidateType_.push_back(trackCandidateType); } - - out_tc_hitIdxs_ = tc_hitIdxs; - out_tc_len_ = tc_len; - out_tc_seedIdx_ = tc_seedIdx; - out_tc_trackCandidateType_ = tc_trackCandidateType; } void LST::run(Queue& queue, @@ -299,7 +277,7 @@ void LST::run(Queue& queue, std::vector const& ph2_z, bool no_pls_dupclean, bool tc_pls_triplets) { - auto event = Event(verbose, queue, deviceESData); + auto event = LSTEvent(verbose, queue, deviceESData); prepareInput(see_px, see_py, see_pz, @@ -433,6 +411,4 @@ void LST::run(Queue& queue, } getOutput(event); - - event.resetEventSync(); } diff --git a/RecoTracker/LSTCore/src/alpaka/Event.dev.cc b/RecoTracker/LSTCore/src/alpaka/LSTEvent.dev.cc similarity index 67% rename from RecoTracker/LSTCore/src/alpaka/Event.dev.cc rename to RecoTracker/LSTCore/src/alpaka/LSTEvent.dev.cc index 984f8ea5d1e9a..f43c053b8b785 100644 --- a/RecoTracker/LSTCore/src/alpaka/Event.dev.cc +++ b/RecoTracker/LSTCore/src/alpaka/LSTEvent.dev.cc @@ -1,6 +1,6 @@ #include "HeterogeneousCore/AlpakaInterface/interface/memory.h" -#include "Event.h" +#include "LSTEvent.h" #include "MiniDoublet.h" #include "PixelQuintuplet.h" @@ -17,9 +17,8 @@ using Acc3D = ALPAKA_ACCELERATOR_NAMESPACE::Acc3D; using namespace ALPAKA_ACCELERATOR_NAMESPACE::lst; -void Event::initSync(bool verbose) { +void LSTEvent::initSync() { alpaka::wait(queue_); // other calls can be asynchronous - addObjects_ = verbose; //reset the arrays for (int i = 0; i < 6; i++) { @@ -40,7 +39,7 @@ void Event::initSync(bool verbose) { } } -void Event::resetEventSync() { +void LSTEvent::resetEventSync() { alpaka::wait(queue_); // synchronize to reset consistently //reset the arrays for (int i = 0; i < 6; i++) { @@ -81,11 +80,11 @@ void Event::resetEventSync() { modulesHC_.reset(); } -void Event::addHitToEvent(std::vector const& x, - std::vector const& y, - std::vector const& z, - std::vector const& detId, - std::vector const& idxInNtuple) { +void LSTEvent::addHitToEvent(std::vector const& x, + std::vector const& y, + std::vector const& z, + std::vector const& detId, + std::vector const& idxInNtuple) { // Use the actual number of hits instead of a max. unsigned int nHits = x.size(); @@ -95,11 +94,16 @@ void Event::addHitToEvent(std::vector const& x, hitsDC_.emplace(hits_sizes, queue_); auto hitsRanges = hitsDC_->view(); - auto hitRanges_view = alpaka::createView(devAcc_, hitsRanges.hitRanges(), hitsRanges.metadata().size()); - auto hitRangesLower_view = alpaka::createView(devAcc_, hitsRanges.hitRangesLower(), hitsRanges.metadata().size()); - auto hitRangesUpper_view = alpaka::createView(devAcc_, hitsRanges.hitRangesUpper(), hitsRanges.metadata().size()); - auto hitRangesnLower_view = alpaka::createView(devAcc_, hitsRanges.hitRangesnLower(), hitsRanges.metadata().size()); - auto hitRangesnUpper_view = alpaka::createView(devAcc_, hitsRanges.hitRangesnUpper(), hitsRanges.metadata().size()); + auto hitRanges_view = + cms::alpakatools::make_device_view(queue_, hitsRanges.hitRanges(), hitsRanges.metadata().size()); + auto hitRangesLower_view = + cms::alpakatools::make_device_view(queue_, hitsRanges.hitRangesLower(), hitsRanges.metadata().size()); + auto hitRangesUpper_view = + cms::alpakatools::make_device_view(queue_, hitsRanges.hitRangesUpper(), hitsRanges.metadata().size()); + auto hitRangesnLower_view = + cms::alpakatools::make_device_view(queue_, hitsRanges.hitRangesnLower(), hitsRanges.metadata().size()); + auto hitRangesnUpper_view = + cms::alpakatools::make_device_view(queue_, hitsRanges.hitRangesnUpper(), hitsRanges.metadata().size()); alpaka::memset(queue_, hitRanges_view, 0xff); alpaka::memset(queue_, hitRangesLower_view, 0xff); alpaka::memset(queue_, hitRangesUpper_view, 0xff); @@ -115,11 +119,11 @@ void Event::addHitToEvent(std::vector const& x, // Copy the host arrays to the GPU. auto hits = hitsDC_->view(); - auto xs_d = alpaka::createView(devAcc_, hits.xs(), (Idx)hits.metadata().size()); - auto ys_d = alpaka::createView(devAcc_, hits.ys(), (Idx)hits.metadata().size()); - auto zs_d = alpaka::createView(devAcc_, hits.zs(), (Idx)hits.metadata().size()); - auto detId_d = alpaka::createView(devAcc_, hits.detid(), (Idx)hits.metadata().size()); - auto idxs_d = alpaka::createView(devAcc_, hits.idxs(), (Idx)hits.metadata().size()); + auto xs_d = cms::alpakatools::make_device_view(queue_, hits.xs(), (Idx)hits.metadata().size()); + auto ys_d = cms::alpakatools::make_device_view(queue_, hits.ys(), (Idx)hits.metadata().size()); + auto zs_d = cms::alpakatools::make_device_view(queue_, hits.zs(), (Idx)hits.metadata().size()); + auto detId_d = cms::alpakatools::make_device_view(queue_, hits.detid(), (Idx)hits.metadata().size()); + auto idxs_d = cms::alpakatools::make_device_view(queue_, hits.idxs(), (Idx)hits.metadata().size()); alpaka::memcpy(queue_, xs_d, x, (Idx)nHits); alpaka::memcpy(queue_, ys_d, y, (Idx)nHits); alpaka::memcpy(queue_, zs_d, z, (Idx)nHits); @@ -156,24 +160,24 @@ void Event::addHitToEvent(std::vector const& x, nLowerModules_); } -void Event::addPixelSegmentToEvent(std::vector const& hitIndices0, - std::vector const& hitIndices1, - std::vector const& hitIndices2, - std::vector const& hitIndices3, - std::vector const& dPhiChange, - std::vector const& ptIn, - std::vector const& ptErr, - std::vector const& px, - std::vector const& py, - std::vector const& pz, - std::vector const& eta, - std::vector const& etaErr, - std::vector const& phi, - std::vector const& charge, - std::vector const& seedIdx, - std::vector const& superbin, - std::vector const& pixelType, - std::vector const& isQuad) { +void LSTEvent::addPixelSegmentToEvent(std::vector const& hitIndices0, + std::vector const& hitIndices1, + std::vector const& hitIndices2, + std::vector const& hitIndices3, + std::vector const& dPhiChange, + std::vector const& ptIn, + std::vector const& ptErr, + std::vector const& px, + std::vector const& py, + std::vector const& pz, + std::vector const& eta, + std::vector const& etaErr, + std::vector const& phi, + std::vector const& charge, + std::vector const& seedIdx, + std::vector const& superbin, + std::vector const& pixelType, + std::vector const& isQuad) { unsigned int size = ptIn.size(); if (size > n_max_pixel_segments_per_module) { @@ -191,13 +195,11 @@ void Event::addPixelSegmentToEvent(std::vector const& hitIndices0, if (!miniDoubletsDC_) { // Create a view for the element nLowerModules_ inside rangesOccupancy->miniDoubletModuleOccupancy auto rangesOccupancy = rangesDC_->view(); - auto miniDoubletModuleOccupancy_view = alpaka::createView( - devAcc_, rangesOccupancy.miniDoubletModuleOccupancy(), (Idx)rangesOccupancy.metadata().size()); auto dst_view_miniDoubletModuleOccupancy = - alpaka::createSubView(miniDoubletModuleOccupancy_view, (Idx)1u, (Idx)nLowerModules_); + cms::alpakatools::make_device_view(queue_, rangesOccupancy.miniDoubletModuleOccupancy()[pixelModuleIndex]); // Create a host buffer for a value to be passed to the device - auto pixelMaxMDs_buf_h = cms::alpakatools::make_host_buffer(queue_, (Idx)1u); + auto pixelMaxMDs_buf_h = cms::alpakatools::make_host_buffer(queue_); *pixelMaxMDs_buf_h.data() = n_max_pixel_md_per_modules; alpaka::memcpy(queue_, dst_view_miniDoubletModuleOccupancy, pixelMaxMDs_buf_h); @@ -210,8 +212,8 @@ void Event::addPixelSegmentToEvent(std::vector const& hitIndices0, modules_.const_view(), rangesDC_->view()); - auto nTotalMDs_buf_h = cms::alpakatools::make_host_buffer(queue_, (Idx)1u); - auto nTotalMDs_buf_d = alpaka::createView(devAcc_, &rangesOccupancy.nTotalMDs(), (Idx)1u); + auto nTotalMDs_buf_h = cms::alpakatools::make_host_buffer(queue_); + auto nTotalMDs_buf_d = cms::alpakatools::make_device_view(queue_, rangesOccupancy.nTotalMDs()); alpaka::memcpy(queue_, nTotalMDs_buf_h, nTotalMDs_buf_d); alpaka::wait(queue_); // wait to get the data before manipulation @@ -222,9 +224,9 @@ void Event::addPixelSegmentToEvent(std::vector const& hitIndices0, miniDoubletsDC_.emplace(mds_sizes, queue_); auto mdsOccupancy = miniDoubletsDC_->view(); - auto nMDs_view = alpaka::createView(devAcc_, mdsOccupancy.nMDs(), mdsOccupancy.metadata().size()); + auto nMDs_view = cms::alpakatools::make_device_view(queue_, mdsOccupancy.nMDs(), mdsOccupancy.metadata().size()); auto totOccupancyMDs_view = - alpaka::createView(devAcc_, mdsOccupancy.totOccupancyMDs(), mdsOccupancy.metadata().size()); + cms::alpakatools::make_device_view(queue_, mdsOccupancy.totOccupancyMDs(), mdsOccupancy.metadata().size()); alpaka::memset(queue_, nMDs_view, 0u); alpaka::memset(queue_, totOccupancyMDs_view, 0u); } @@ -242,8 +244,8 @@ void Event::addPixelSegmentToEvent(std::vector const& hitIndices0, miniDoubletsDC_->const_view()); auto rangesOccupancy = rangesDC_->view(); - auto nTotalSegments_view_h = alpaka::createView(cms::alpakatools::host(), &nTotalSegments_, (Idx)1u); - auto nTotalSegments_view_d = alpaka::createView(devAcc_, &rangesOccupancy.nTotalSegs(), (Idx)1u); + auto nTotalSegments_view_h = cms::alpakatools::make_host_view(nTotalSegments_); + auto nTotalSegments_view_d = cms::alpakatools::make_device_view(queue_, rangesOccupancy.nTotalSegs()); alpaka::memcpy(queue_, nTotalSegments_view_h, nTotalSegments_view_d); alpaka::wait(queue_); // wait to get the value before manipulation @@ -256,18 +258,18 @@ void Event::addPixelSegmentToEvent(std::vector const& hitIndices0, auto segmentsOccupancy = segmentsDC_->view(); auto nSegments_view = - alpaka::createView(devAcc_, segmentsOccupancy.nSegments(), segmentsOccupancy.metadata().size()); - auto totOccupancySegments_view = - alpaka::createView(devAcc_, segmentsOccupancy.totOccupancySegments(), segmentsOccupancy.metadata().size()); + cms::alpakatools::make_device_view(queue_, segmentsOccupancy.nSegments(), segmentsOccupancy.metadata().size()); + auto totOccupancySegments_view = cms::alpakatools::make_device_view( + queue_, segmentsOccupancy.totOccupancySegments(), segmentsOccupancy.metadata().size()); alpaka::memset(queue_, nSegments_view, 0u); alpaka::memset(queue_, totOccupancySegments_view, 0u); } - auto hitIndices0_dev = allocBufWrapper(devAcc_, size, queue_); - auto hitIndices1_dev = allocBufWrapper(devAcc_, size, queue_); - auto hitIndices2_dev = allocBufWrapper(devAcc_, size, queue_); - auto hitIndices3_dev = allocBufWrapper(devAcc_, size, queue_); - auto dPhiChange_dev = allocBufWrapper(devAcc_, size, queue_); + auto hitIndices0_dev = cms::alpakatools::make_device_buffer(queue_, size); + auto hitIndices1_dev = cms::alpakatools::make_device_buffer(queue_, size); + auto hitIndices2_dev = cms::alpakatools::make_device_buffer(queue_, size); + auto hitIndices3_dev = cms::alpakatools::make_device_buffer(queue_, size); + auto dPhiChange_dev = cms::alpakatools::make_device_buffer(queue_, size); alpaka::memcpy(queue_, hitIndices0_dev, hitIndices0, size); alpaka::memcpy(queue_, hitIndices1_dev, hitIndices1, size); @@ -276,43 +278,38 @@ void Event::addPixelSegmentToEvent(std::vector const& hitIndices0, alpaka::memcpy(queue_, dPhiChange_dev, dPhiChange, size); SegmentsPixel segmentsPixel = segmentsDC_->view(); - alpaka::memcpy(queue_, alpaka::createView(devAcc_, segmentsPixel.ptIn(), size), ptIn, size); - alpaka::memcpy(queue_, alpaka::createView(devAcc_, segmentsPixel.ptErr(), size), ptErr, size); - alpaka::memcpy(queue_, alpaka::createView(devAcc_, segmentsPixel.px(), size), px, size); - alpaka::memcpy(queue_, alpaka::createView(devAcc_, segmentsPixel.py(), size), py, size); - alpaka::memcpy(queue_, alpaka::createView(devAcc_, segmentsPixel.pz(), size), pz, size); - alpaka::memcpy(queue_, alpaka::createView(devAcc_, segmentsPixel.etaErr(), size), etaErr, size); - alpaka::memcpy(queue_, alpaka::createView(devAcc_, segmentsPixel.isQuad(), size), isQuad, size); - alpaka::memcpy(queue_, alpaka::createView(devAcc_, segmentsPixel.eta(), size), eta, size); - alpaka::memcpy(queue_, alpaka::createView(devAcc_, segmentsPixel.phi(), size), phi, size); - alpaka::memcpy(queue_, alpaka::createView(devAcc_, segmentsPixel.charge(), size), charge, size); - alpaka::memcpy(queue_, alpaka::createView(devAcc_, segmentsPixel.seedIdx(), size), seedIdx, size); - alpaka::memcpy(queue_, alpaka::createView(devAcc_, segmentsPixel.superbin(), size), superbin, size); - alpaka::memcpy(queue_, alpaka::createView(devAcc_, segmentsPixel.pixelType(), size), pixelType, size); + alpaka::memcpy(queue_, cms::alpakatools::make_device_view(queue_, segmentsPixel.ptIn(), size), ptIn, size); + alpaka::memcpy(queue_, cms::alpakatools::make_device_view(queue_, segmentsPixel.ptErr(), size), ptErr, size); + alpaka::memcpy(queue_, cms::alpakatools::make_device_view(queue_, segmentsPixel.px(), size), px, size); + alpaka::memcpy(queue_, cms::alpakatools::make_device_view(queue_, segmentsPixel.py(), size), py, size); + alpaka::memcpy(queue_, cms::alpakatools::make_device_view(queue_, segmentsPixel.pz(), size), pz, size); + alpaka::memcpy(queue_, cms::alpakatools::make_device_view(queue_, segmentsPixel.etaErr(), size), etaErr, size); + alpaka::memcpy(queue_, cms::alpakatools::make_device_view(queue_, segmentsPixel.isQuad(), size), isQuad, size); + alpaka::memcpy(queue_, cms::alpakatools::make_device_view(queue_, segmentsPixel.eta(), size), eta, size); + alpaka::memcpy(queue_, cms::alpakatools::make_device_view(queue_, segmentsPixel.phi(), size), phi, size); + alpaka::memcpy(queue_, cms::alpakatools::make_device_view(queue_, segmentsPixel.charge(), size), charge, size); + alpaka::memcpy(queue_, cms::alpakatools::make_device_view(queue_, segmentsPixel.seedIdx(), size), seedIdx, size); + alpaka::memcpy(queue_, cms::alpakatools::make_device_view(queue_, segmentsPixel.superbin(), size), superbin, size); + alpaka::memcpy(queue_, cms::alpakatools::make_device_view(queue_, segmentsPixel.pixelType(), size), pixelType, size); // Create source views for size and mdSize - auto src_view_size = alpaka::createView(cms::alpakatools::host(), &size, (Idx)1u); - auto src_view_mdSize = alpaka::createView(cms::alpakatools::host(), &mdSize, (Idx)1u); + auto src_view_size = cms::alpakatools::make_host_view(size); + auto src_view_mdSize = cms::alpakatools::make_host_view(mdSize); auto segmentsOccupancy = segmentsDC_->view(); - auto nSegments_view = - alpaka::createView(devAcc_, segmentsOccupancy.nSegments(), (Idx)segmentsOccupancy.metadata().size()); - auto dst_view_segments = alpaka::createSubView(nSegments_view, (Idx)1u, (Idx)pixelModuleIndex); + auto dst_view_segments = cms::alpakatools::make_device_view(queue_, segmentsOccupancy.nSegments()[pixelModuleIndex]); alpaka::memcpy(queue_, dst_view_segments, src_view_size); - auto totOccupancySegments_view = - alpaka::createView(devAcc_, segmentsOccupancy.totOccupancySegments(), (Idx)segmentsOccupancy.metadata().size()); - auto dst_view_totOccupancySegments = alpaka::createSubView(totOccupancySegments_view, (Idx)1u, (Idx)pixelModuleIndex); + auto dst_view_totOccupancySegments = + cms::alpakatools::make_device_view(queue_, segmentsOccupancy.totOccupancySegments()[pixelModuleIndex]); alpaka::memcpy(queue_, dst_view_totOccupancySegments, src_view_size); auto mdsOccupancy = miniDoubletsDC_->view(); - auto nMDs_view = alpaka::createView(devAcc_, mdsOccupancy.nMDs(), (Idx)mdsOccupancy.metadata().size()); - auto dst_view_nMDs = alpaka::createSubView(nMDs_view, (Idx)1u, (Idx)pixelModuleIndex); + auto dst_view_nMDs = cms::alpakatools::make_device_view(queue_, mdsOccupancy.nMDs()[pixelModuleIndex]); alpaka::memcpy(queue_, dst_view_nMDs, src_view_mdSize); - auto totOccupancyMDs_view = - alpaka::createView(devAcc_, mdsOccupancy.totOccupancyMDs(), (Idx)mdsOccupancy.metadata().size()); - auto dst_view_totOccupancyMDs = alpaka::createSubView(totOccupancyMDs_view, (Idx)1u, (Idx)pixelModuleIndex); + auto dst_view_totOccupancyMDs = + cms::alpakatools::make_device_view(queue_, mdsOccupancy.totOccupancyMDs()[pixelModuleIndex]); alpaka::memcpy(queue_, dst_view_totOccupancyMDs, src_view_mdSize); alpaka::wait(queue_); // FIXME: remove synch after inputs refactored to be in pinned memory @@ -339,16 +336,14 @@ void Event::addPixelSegmentToEvent(std::vector const& hitIndices0, size); } -void Event::createMiniDoublets() { +void LSTEvent::createMiniDoublets() { // Create a view for the element nLowerModules_ inside rangesOccupancy->miniDoubletModuleOccupancy auto rangesOccupancy = rangesDC_->view(); - auto miniDoubletModuleOccupancy_view = - alpaka::createView(devAcc_, rangesOccupancy.miniDoubletModuleOccupancy(), (Idx)rangesOccupancy.metadata().size()); auto dst_view_miniDoubletModuleOccupancy = - alpaka::createSubView(miniDoubletModuleOccupancy_view, (Idx)1u, (Idx)nLowerModules_); + cms::alpakatools::make_device_view(queue_, rangesOccupancy.miniDoubletModuleOccupancy()[nLowerModules_]); // Create a host buffer for a value to be passed to the device - auto pixelMaxMDs_buf_h = cms::alpakatools::make_host_buffer(queue_, (Idx)1u); + auto pixelMaxMDs_buf_h = cms::alpakatools::make_host_buffer(queue_); *pixelMaxMDs_buf_h.data() = n_max_pixel_md_per_modules; alpaka::memcpy(queue_, dst_view_miniDoubletModuleOccupancy, pixelMaxMDs_buf_h); @@ -361,8 +356,8 @@ void Event::createMiniDoublets() { modules_.const_view(), rangesDC_->view()); - auto nTotalMDs_buf_h = cms::alpakatools::make_host_buffer(queue_, (Idx)1u); - auto nTotalMDs_buf_d = alpaka::createView(devAcc_, &rangesOccupancy.nTotalMDs(), (Idx)1u); + auto nTotalMDs_buf_h = cms::alpakatools::make_host_buffer(queue_); + auto nTotalMDs_buf_d = cms::alpakatools::make_device_view(queue_, rangesOccupancy.nTotalMDs()); alpaka::memcpy(queue_, nTotalMDs_buf_h, nTotalMDs_buf_d); alpaka::wait(queue_); // wait to get the data before manipulation @@ -374,9 +369,9 @@ void Event::createMiniDoublets() { miniDoubletsDC_.emplace(mds_sizes, queue_); auto mdsOccupancy = miniDoubletsDC_->view(); - auto nMDs_view = alpaka::createView(devAcc_, mdsOccupancy.nMDs(), mdsOccupancy.metadata().size()); + auto nMDs_view = cms::alpakatools::make_device_view(queue_, mdsOccupancy.nMDs(), mdsOccupancy.metadata().size()); auto totOccupancyMDs_view = - alpaka::createView(devAcc_, mdsOccupancy.totOccupancyMDs(), mdsOccupancy.metadata().size()); + cms::alpakatools::make_device_view(queue_, mdsOccupancy.totOccupancyMDs(), mdsOccupancy.metadata().size()); alpaka::memset(queue_, nMDs_view, 0u); alpaka::memset(queue_, totOccupancyMDs_view, 0u); } @@ -411,7 +406,7 @@ void Event::createMiniDoublets() { } } -void Event::createSegmentsWithModuleMap() { +void LSTEvent::createSegmentsWithModuleMap() { if (!segmentsDC_) { std::array const segments_sizes{{static_cast(nTotalSegments_), static_cast(nLowerModules_ + 1), @@ -420,9 +415,9 @@ void Event::createSegmentsWithModuleMap() { auto segmentsOccupancy = segmentsDC_->view(); auto nSegments_view = - alpaka::createView(devAcc_, segmentsOccupancy.nSegments(), segmentsOccupancy.metadata().size()); - auto totOccupancySegments_view = - alpaka::createView(devAcc_, segmentsOccupancy.totOccupancySegments(), segmentsOccupancy.metadata().size()); + cms::alpakatools::make_device_view(queue_, segmentsOccupancy.nSegments(), segmentsOccupancy.metadata().size()); + auto totOccupancySegments_view = cms::alpakatools::make_device_view( + queue_, segmentsOccupancy.totOccupancySegments(), segmentsOccupancy.metadata().size()); alpaka::memset(queue_, nSegments_view, 0u); alpaka::memset(queue_, totOccupancySegments_view, 0u); } @@ -456,7 +451,7 @@ void Event::createSegmentsWithModuleMap() { } } -void Event::createTriplets() { +void LSTEvent::createTriplets() { if (!tripletsDC_) { WorkDiv1D const createTripletArrayRanges_workDiv = createWorkDiv({1}, {1024}, {1}); @@ -469,8 +464,8 @@ void Event::createTriplets() { // TODO: Why are we pulling this back down only to put it back on the device in a new struct? auto rangesOccupancy = rangesDC_->view(); - auto maxTriplets_buf_h = cms::alpakatools::make_host_buffer(queue_, (Idx)1u); - auto maxTriplets_buf_d = alpaka::createView(devAcc_, &rangesOccupancy.nTotalTrips(), (Idx)1u); + auto maxTriplets_buf_h = cms::alpakatools::make_host_buffer(queue_); + auto maxTriplets_buf_d = cms::alpakatools::make_device_view(queue_, rangesOccupancy.nTotalTrips()); alpaka::memcpy(queue_, maxTriplets_buf_h, maxTriplets_buf_d); alpaka::wait(queue_); // wait to get the value before using it @@ -480,17 +475,17 @@ void Event::createTriplets() { auto tripletsOccupancy = tripletsDC_->view(); auto nTriplets_view = - alpaka::createView(devAcc_, tripletsOccupancy.nTriplets(), tripletsOccupancy.metadata().size()); + cms::alpakatools::make_device_view(queue_, tripletsOccupancy.nTriplets(), tripletsOccupancy.metadata().size()); alpaka::memset(queue_, nTriplets_view, 0u); - auto totOccupancyTriplets_view = - alpaka::createView(devAcc_, tripletsOccupancy.totOccupancyTriplets(), tripletsOccupancy.metadata().size()); + auto totOccupancyTriplets_view = cms::alpakatools::make_device_view( + queue_, tripletsOccupancy.totOccupancyTriplets(), tripletsOccupancy.metadata().size()); alpaka::memset(queue_, totOccupancyTriplets_view, 0u); auto triplets = tripletsDC_->view(); - auto partOfPT5_view = alpaka::createView(devAcc_, triplets.partOfPT5(), triplets.metadata().size()); + auto partOfPT5_view = cms::alpakatools::make_device_view(queue_, triplets.partOfPT5(), triplets.metadata().size()); alpaka::memset(queue_, partOfPT5_view, 0u); - auto partOfT5_view = alpaka::createView(devAcc_, triplets.partOfT5(), triplets.metadata().size()); + auto partOfT5_view = cms::alpakatools::make_device_view(queue_, triplets.partOfT5(), triplets.metadata().size()); alpaka::memset(queue_, partOfT5_view, 0u); - auto partOfPT3_view = alpaka::createView(devAcc_, triplets.partOfPT3(), triplets.metadata().size()); + auto partOfPT3_view = cms::alpakatools::make_device_view(queue_, triplets.partOfPT3(), triplets.metadata().size()); alpaka::memset(queue_, partOfPT3_view, 0u); } @@ -499,8 +494,8 @@ void Event::createTriplets() { // Allocate and copy nSegments from device to host (only nLowerModules in OT, not the +1 with pLSs) auto nSegments_buf_h = cms::alpakatools::make_host_buffer(queue_, nLowerModules_); - auto nSegments_buf_d = - alpaka::createView(devAcc_, segmentsDC_->const_view().nSegments(), nLowerModules_); + auto nSegments_buf_d = cms::alpakatools::make_device_view( + queue_, segmentsDC_->const_view().nSegments(), nLowerModules_); alpaka::memcpy(queue_, nSegments_buf_h, nSegments_buf_d, nLowerModules_); // ... same for module_nConnectedModules @@ -508,7 +503,7 @@ void Event::createTriplets() { auto modules = modules_.const_view(); auto module_nConnectedModules_buf_h = cms::alpakatools::make_host_buffer(queue_, nLowerModules_); auto module_nConnectedModules_buf_d = - alpaka::createView(devAcc_, modules.nConnectedModules(), nLowerModules_); // only lower modules + cms::alpakatools::make_device_view(queue_, modules.nConnectedModules(), nLowerModules_); // only lower modules alpaka::memcpy(queue_, module_nConnectedModules_buf_h, module_nConnectedModules_buf_d, nLowerModules_); alpaka::wait(queue_); // wait for nSegments and module_nConnectedModules before using @@ -531,7 +526,7 @@ void Event::createTriplets() { } // Allocate and copy to device index - auto index_gpu_buf = allocBufWrapper(devAcc_, nLowerModules_, queue_); + auto index_gpu_buf = cms::alpakatools::make_device_buffer(queue_, nLowerModules_); alpaka::memcpy(queue_, index_gpu_buf, index_buf_h, nonZeroModules); Vec3D const threadsPerBlockCreateTrip{1, 16, 16}; @@ -566,7 +561,7 @@ void Event::createTriplets() { } } -void Event::createTrackCandidates(bool no_pls_dupclean, bool tc_pls_triplets) { +void LSTEvent::createTrackCandidates(bool no_pls_dupclean, bool tc_pls_triplets) { if (!trackCandidatesDC_) { trackCandidatesDC_.emplace(n_max_nonpixel_track_candidates + n_max_pixel_track_candidates, queue_); auto buf = trackCandidatesDC_->buffer(); @@ -600,8 +595,8 @@ void Event::createTrackCandidates(bool no_pls_dupclean, bool tc_pls_triplets) { // Pull nEligibleT5Modules from the device. auto rangesOccupancy = rangesDC_->view(); - auto nEligibleModules_buf_h = cms::alpakatools::make_host_buffer(queue_, 1u); - auto nEligibleModules_buf_d = alpaka::createView(devAcc_, &rangesOccupancy.nEligibleT5Modules(), (Idx)1u); + auto nEligibleModules_buf_h = cms::alpakatools::make_host_buffer(queue_); + auto nEligibleModules_buf_d = cms::alpakatools::make_device_view(queue_, rangesOccupancy.nEligibleT5Modules()); alpaka::memcpy(queue_, nEligibleModules_buf_h, nEligibleModules_buf_d); alpaka::wait(queue_); // wait to get the value before using auto const nEligibleModules = *nEligibleModules_buf_h.data(); @@ -696,18 +691,22 @@ void Event::createTrackCandidates(bool no_pls_dupclean, bool tc_pls_triplets) { tc_pls_triplets); // Check if either n_max_pixel_track_candidates or n_max_nonpixel_track_candidates was reached - auto nTrackCanpT5Host_buf = allocBufWrapper(cms::alpakatools::host(), 1, queue_); - auto nTrackCanpT3Host_buf = allocBufWrapper(cms::alpakatools::host(), 1, queue_); - auto nTrackCanpLSHost_buf = allocBufWrapper(cms::alpakatools::host(), 1, queue_); - auto nTrackCanT5Host_buf = allocBufWrapper(cms::alpakatools::host(), 1, queue_); - alpaka::memcpy( - queue_, nTrackCanpT5Host_buf, alpaka::createView(devAcc_, &(*trackCandidatesDC_)->nTrackCandidatespT5(), 1u)); - alpaka::memcpy( - queue_, nTrackCanpT3Host_buf, alpaka::createView(devAcc_, &(*trackCandidatesDC_)->nTrackCandidatespT3(), 1u)); - alpaka::memcpy( - queue_, nTrackCanpLSHost_buf, alpaka::createView(devAcc_, &(*trackCandidatesDC_)->nTrackCandidatespLS(), 1u)); - alpaka::memcpy( - queue_, nTrackCanT5Host_buf, alpaka::createView(devAcc_, &(*trackCandidatesDC_)->nTrackCandidatesT5(), 1u)); + auto nTrackCanpT5Host_buf = cms::alpakatools::make_host_buffer(queue_); + auto nTrackCanpT3Host_buf = cms::alpakatools::make_host_buffer(queue_); + auto nTrackCanpLSHost_buf = cms::alpakatools::make_host_buffer(queue_); + auto nTrackCanT5Host_buf = cms::alpakatools::make_host_buffer(queue_); + alpaka::memcpy(queue_, + nTrackCanpT5Host_buf, + cms::alpakatools::make_device_view(queue_, (*trackCandidatesDC_)->nTrackCandidatespT5())); + alpaka::memcpy(queue_, + nTrackCanpT3Host_buf, + cms::alpakatools::make_device_view(queue_, (*trackCandidatesDC_)->nTrackCandidatespT3())); + alpaka::memcpy(queue_, + nTrackCanpLSHost_buf, + cms::alpakatools::make_device_view(queue_, (*trackCandidatesDC_)->nTrackCandidatespLS())); + alpaka::memcpy(queue_, + nTrackCanT5Host_buf, + cms::alpakatools::make_device_view(queue_, (*trackCandidatesDC_)->nTrackCandidatesT5())); alpaka::wait(queue_); // wait to get the values before using them auto nTrackCandidatespT5 = *nTrackCanpT5Host_buf.data(); @@ -725,43 +724,44 @@ void Event::createTrackCandidates(bool no_pls_dupclean, bool tc_pls_triplets) { } } -void Event::createPixelTriplets() { +void LSTEvent::createPixelTriplets() { if (!pixelTripletsDC_) { pixelTripletsDC_.emplace(n_max_pixel_triplets, queue_); - auto nPixelTriplets_view = alpaka::createView(devAcc_, &(*pixelTripletsDC_)->nPixelTriplets(), 1u); + auto nPixelTriplets_view = cms::alpakatools::make_device_view(queue_, (*pixelTripletsDC_)->nPixelTriplets()); alpaka::memset(queue_, nPixelTriplets_view, 0u); auto totOccupancyPixelTriplets_view = - alpaka::createView(devAcc_, &(*pixelTripletsDC_)->totOccupancyPixelTriplets(), 1u); + cms::alpakatools::make_device_view(queue_, (*pixelTripletsDC_)->totOccupancyPixelTriplets()); alpaka::memset(queue_, totOccupancyPixelTriplets_view, 0u); } SegmentsOccupancy segmentsOccupancy = segmentsDC_->view(); SegmentsPixelConst segmentsPixel = segmentsDC_->view(); - auto superbins_buf = allocBufWrapper(cms::alpakatools::host(), n_max_pixel_segments_per_module, queue_); - auto pixelTypes_buf = allocBufWrapper(cms::alpakatools::host(), n_max_pixel_segments_per_module, queue_); + auto superbins_buf = cms::alpakatools::make_host_buffer(queue_, n_max_pixel_segments_per_module); + auto pixelTypes_buf = cms::alpakatools::make_host_buffer(queue_, n_max_pixel_segments_per_module); + alpaka::memcpy(queue_, + superbins_buf, + cms::alpakatools::make_device_view(queue_, segmentsPixel.superbin(), n_max_pixel_segments_per_module)); alpaka::memcpy( - queue_, superbins_buf, alpaka::createView(devAcc_, segmentsPixel.superbin(), n_max_pixel_segments_per_module)); - alpaka::memcpy( - queue_, pixelTypes_buf, alpaka::createView(devAcc_, segmentsPixel.pixelType(), n_max_pixel_segments_per_module)); + queue_, + pixelTypes_buf, + cms::alpakatools::make_device_view(queue_, segmentsPixel.pixelType(), n_max_pixel_segments_per_module)); auto const* superbins = superbins_buf.data(); auto const* pixelTypes = pixelTypes_buf.data(); unsigned int nInnerSegments; - auto nInnerSegments_src_view = alpaka::createView(cms::alpakatools::host(), &nInnerSegments, (size_t)1u); + auto nInnerSegments_src_view = cms::alpakatools::make_host_view(nInnerSegments); // Create a sub-view for the device buffer - unsigned int totalModules = nLowerModules_ + 1; - auto dev_view_nSegments_buf = alpaka::createView(devAcc_, segmentsOccupancy.nSegments(), totalModules); - auto dev_view_nSegments = alpaka::createSubView(dev_view_nSegments_buf, (Idx)1u, (Idx)nLowerModules_); + auto dev_view_nSegments = cms::alpakatools::make_device_view(queue_, segmentsOccupancy.nSegments()[nLowerModules_]); alpaka::memcpy(queue_, nInnerSegments_src_view, dev_view_nSegments); alpaka::wait(queue_); // wait to get nInnerSegments (also superbins and pixelTypes) before using - auto connectedPixelSize_host_buf = allocBufWrapper(cms::alpakatools::host(), nInnerSegments, queue_); - auto connectedPixelIndex_host_buf = allocBufWrapper(cms::alpakatools::host(), nInnerSegments, queue_); - auto connectedPixelSize_dev_buf = allocBufWrapper(devAcc_, nInnerSegments, queue_); - auto connectedPixelIndex_dev_buf = allocBufWrapper(devAcc_, nInnerSegments, queue_); + auto connectedPixelSize_host_buf = cms::alpakatools::make_host_buffer(queue_, nInnerSegments); + auto connectedPixelIndex_host_buf = cms::alpakatools::make_host_buffer(queue_, nInnerSegments); + auto connectedPixelSize_dev_buf = cms::alpakatools::make_device_buffer(queue_, nInnerSegments); + auto connectedPixelIndex_dev_buf = cms::alpakatools::make_device_buffer(queue_, nInnerSegments); unsigned int* connectedPixelSize_host = connectedPixelSize_host_buf.data(); unsigned int* connectedPixelIndex_host = connectedPixelIndex_host_buf.data(); @@ -833,9 +833,10 @@ void Event::createPixelTriplets() { nInnerSegments); #ifdef WARNINGS - auto nPixelTriplets_buf = allocBufWrapper(cms::alpakatools::host(), 1, queue_); + auto nPixelTriplets_buf = cms::alpakatools::make_host_buffer(queue_); - alpaka::memcpy(queue_, nPixelTriplets_buf, alpaka::createView(devAcc_, &(*pixelTripletsDC_)->nPixelTriplets(), 1u)); + alpaka::memcpy( + queue_, nPixelTriplets_buf, cms::alpakatools::make_device_view(queue_, (*pixelTripletsDC_)->nPixelTriplets())); alpaka::wait(queue_); // wait to get the value before using it std::cout << "number of pixel triplets = " << *nPixelTriplets_buf.data() << std::endl; @@ -852,7 +853,7 @@ void Event::createPixelTriplets() { queue_, removeDupPixelTripletsFromMap_workDiv, RemoveDupPixelTripletsFromMap{}, pixelTripletsDC_->view()); } -void Event::createQuintuplets() { +void LSTEvent::createQuintuplets() { WorkDiv1D const createEligibleModulesListForQuintuplets_workDiv = createWorkDiv({1}, {1024}, {1}); alpaka::exec(queue_, @@ -862,11 +863,11 @@ void Event::createQuintuplets() { tripletsDC_->const_view(), rangesDC_->view()); - auto nEligibleT5Modules_buf = allocBufWrapper(cms::alpakatools::host(), 1, queue_); - auto nTotalQuintuplets_buf = allocBufWrapper(cms::alpakatools::host(), 1, queue_); + auto nEligibleT5Modules_buf = cms::alpakatools::make_host_buffer(queue_); + auto nTotalQuintuplets_buf = cms::alpakatools::make_host_buffer(queue_); auto rangesOccupancy = rangesDC_->view(); - auto nEligibleT5Modules_view_d = alpaka::createView(devAcc_, &rangesOccupancy.nEligibleT5Modules(), (Idx)1u); - auto nTotalQuintuplets_view_d = alpaka::createView(devAcc_, &rangesOccupancy.nTotalQuints(), (Idx)1u); + auto nEligibleT5Modules_view_d = cms::alpakatools::make_device_view(queue_, rangesOccupancy.nEligibleT5Modules()); + auto nTotalQuintuplets_view_d = cms::alpakatools::make_device_view(queue_, rangesOccupancy.nTotalQuints()); alpaka::memcpy(queue_, nEligibleT5Modules_buf, nEligibleT5Modules_view_d); alpaka::memcpy(queue_, nTotalQuintuplets_buf, nTotalQuintuplets_view_d); alpaka::wait(queue_); // wait for the values before using them @@ -878,18 +879,20 @@ void Event::createQuintuplets() { std::array const quintuplets_sizes{{static_cast(nTotalQuintuplets), static_cast(nLowerModules_)}}; quintupletsDC_.emplace(quintuplets_sizes, queue_); auto quintupletsOccupancy = quintupletsDC_->view(); - auto nQuintuplets_view = - alpaka::createView(devAcc_, quintupletsOccupancy.nQuintuplets(), quintupletsOccupancy.metadata().size()); + auto nQuintuplets_view = cms::alpakatools::make_device_view( + queue_, quintupletsOccupancy.nQuintuplets(), quintupletsOccupancy.metadata().size()); alpaka::memset(queue_, nQuintuplets_view, 0u); - auto totOccupancyQuintuplets_view = alpaka::createView( - devAcc_, quintupletsOccupancy.totOccupancyQuintuplets(), quintupletsOccupancy.metadata().size()); + auto totOccupancyQuintuplets_view = cms::alpakatools::make_device_view( + queue_, quintupletsOccupancy.totOccupancyQuintuplets(), quintupletsOccupancy.metadata().size()); alpaka::memset(queue_, totOccupancyQuintuplets_view, 0u); auto quintuplets = quintupletsDC_->view(); - auto isDup_view = alpaka::createView(devAcc_, quintuplets.isDup(), quintuplets.metadata().size()); + auto isDup_view = cms::alpakatools::make_device_view(queue_, quintuplets.isDup(), quintuplets.metadata().size()); alpaka::memset(queue_, isDup_view, 0u); - auto tightCutFlag_view = alpaka::createView(devAcc_, quintuplets.tightCutFlag(), quintuplets.metadata().size()); + auto tightCutFlag_view = + cms::alpakatools::make_device_view(queue_, quintuplets.tightCutFlag(), quintuplets.metadata().size()); alpaka::memset(queue_, tightCutFlag_view, 0u); - auto partOfPT5_view = alpaka::createView(devAcc_, quintuplets.partOfPT5(), quintuplets.metadata().size()); + auto partOfPT5_view = + cms::alpakatools::make_device_view(queue_, quintuplets.partOfPT5(), quintuplets.metadata().size()); alpaka::memset(queue_, partOfPT5_view, 0u); } @@ -938,7 +941,7 @@ void Event::createQuintuplets() { } } -void Event::pixelLineSegmentCleaning(bool no_pls_dupclean) { +void LSTEvent::pixelLineSegmentCleaning(bool no_pls_dupclean) { if (!no_pls_dupclean) { Vec3D const threadsPerBlockCheckHitspLS{1, 16, 16}; Vec3D const blocksPerGridCheckHitspLS{1, max_blocks * 4, max_blocks / 4}; @@ -955,13 +958,14 @@ void Event::pixelLineSegmentCleaning(bool no_pls_dupclean) { } } -void Event::createPixelQuintuplets() { +void LSTEvent::createPixelQuintuplets() { if (!pixelQuintupletsDC_) { pixelQuintupletsDC_.emplace(n_max_pixel_quintuplets, queue_); - auto nPixelQuintuplets_view = alpaka::createView(devAcc_, &(*pixelQuintupletsDC_)->nPixelQuintuplets(), 1u); + auto nPixelQuintuplets_view = + cms::alpakatools::make_device_view(queue_, (*pixelQuintupletsDC_)->nPixelQuintuplets()); alpaka::memset(queue_, nPixelQuintuplets_view, 0u); auto totOccupancyPixelQuintuplets_view = - alpaka::createView(devAcc_, &(*pixelQuintupletsDC_)->totOccupancyPixelQuintuplets(), 1u); + cms::alpakatools::make_device_view(queue_, (*pixelQuintupletsDC_)->totOccupancyPixelQuintuplets()); alpaka::memset(queue_, totOccupancyPixelQuintuplets_view, 0u); } if (!trackCandidatesDC_) { @@ -972,31 +976,34 @@ void Event::createPixelQuintuplets() { SegmentsOccupancy segmentsOccupancy = segmentsDC_->view(); SegmentsPixelConst segmentsPixel = segmentsDC_->view(); - auto superbins_buf = allocBufWrapper(cms::alpakatools::host(), n_max_pixel_segments_per_module, queue_); - auto pixelTypes_buf = allocBufWrapper(cms::alpakatools::host(), n_max_pixel_segments_per_module, queue_); + auto superbins_buf = cms::alpakatools::make_host_buffer(queue_, n_max_pixel_segments_per_module); + auto pixelTypes_buf = cms::alpakatools::make_host_buffer(queue_, n_max_pixel_segments_per_module); + alpaka::memcpy(queue_, + superbins_buf, + cms::alpakatools::make_device_view(queue_, segmentsPixel.superbin(), n_max_pixel_segments_per_module)); alpaka::memcpy( - queue_, superbins_buf, alpaka::createView(devAcc_, segmentsPixel.superbin(), n_max_pixel_segments_per_module)); - alpaka::memcpy( - queue_, pixelTypes_buf, alpaka::createView(devAcc_, segmentsPixel.pixelType(), n_max_pixel_segments_per_module)); + queue_, + pixelTypes_buf, + cms::alpakatools::make_device_view(queue_, segmentsPixel.pixelType(), n_max_pixel_segments_per_module)); auto const* superbins = superbins_buf.data(); auto const* pixelTypes = pixelTypes_buf.data(); unsigned int nInnerSegments; - auto nInnerSegments_src_view = alpaka::createView(cms::alpakatools::host(), &nInnerSegments, (size_t)1u); + auto nInnerSegments_src_view = cms::alpakatools::make_host_view(nInnerSegments); // Create a sub-view for the device buffer unsigned int totalModules = nLowerModules_ + 1; - auto dev_view_nSegments_buf = alpaka::createView(devAcc_, segmentsOccupancy.nSegments(), totalModules); - auto dev_view_nSegments = alpaka::createSubView(dev_view_nSegments_buf, (Idx)1u, (Idx)nLowerModules_); + auto dev_view_nSegments_buf = cms::alpakatools::make_device_view(queue_, segmentsOccupancy.nSegments(), totalModules); + auto dev_view_nSegments = cms::alpakatools::make_device_view(queue_, segmentsOccupancy.nSegments()[nLowerModules_]); alpaka::memcpy(queue_, nInnerSegments_src_view, dev_view_nSegments); alpaka::wait(queue_); // wait to get nInnerSegments (also superbins and pixelTypes) before using - auto connectedPixelSize_host_buf = allocBufWrapper(cms::alpakatools::host(), nInnerSegments, queue_); - auto connectedPixelIndex_host_buf = allocBufWrapper(cms::alpakatools::host(), nInnerSegments, queue_); - auto connectedPixelSize_dev_buf = allocBufWrapper(devAcc_, nInnerSegments, queue_); - auto connectedPixelIndex_dev_buf = allocBufWrapper(devAcc_, nInnerSegments, queue_); + auto connectedPixelSize_host_buf = cms::alpakatools::make_host_buffer(queue_, nInnerSegments); + auto connectedPixelIndex_host_buf = cms::alpakatools::make_host_buffer(queue_, nInnerSegments); + auto connectedPixelSize_dev_buf = cms::alpakatools::make_device_buffer(queue_, nInnerSegments); + auto connectedPixelIndex_dev_buf = cms::alpakatools::make_device_buffer(queue_, nInnerSegments); auto* connectedPixelSize_host = connectedPixelSize_host_buf.data(); auto* connectedPixelIndex_host = connectedPixelIndex_host_buf.data(); @@ -1090,36 +1097,41 @@ void Event::createPixelQuintuplets() { rangesDC_->const_view()); #ifdef WARNINGS - auto nPixelQuintuplets_buf = allocBufWrapper(cms::alpakatools::host(), 1, queue_); + auto nPixelQuintuplets_buf = cms::alpakatools::make_host_buffer(queue_); - alpaka::memcpy( - queue_, nPixelQuintuplets_buf, alpaka::createView(devAcc_, &(*pixelQuintupletsDC_)->nPixelQuintuplets(), 1u)); + alpaka::memcpy(queue_, + nPixelQuintuplets_buf, + cms::alpakatools::make_device_view(queue_, (*pixelQuintupletsDC_)->nPixelQuintuplets())); alpaka::wait(queue_); // wait to get the value before using it std::cout << "number of pixel quintuplets = " << *nPixelQuintuplets_buf.data() << std::endl; #endif } -void Event::addMiniDoubletsToEventExplicit() { - auto nMDsCPU_buf = allocBufWrapper(cms::alpakatools::host(), nLowerModules_, queue_); +void LSTEvent::addMiniDoubletsToEventExplicit() { + auto nMDsCPU_buf = cms::alpakatools::make_host_buffer(queue_, nLowerModules_); auto mdsOccupancy = miniDoubletsDC_->const_view(); - auto nMDs_view = alpaka::createView(devAcc_, mdsOccupancy.nMDs(), nLowerModules_); // exclude pixel part + auto nMDs_view = + cms::alpakatools::make_device_view(queue_, mdsOccupancy.nMDs(), nLowerModules_); // exclude pixel part alpaka::memcpy(queue_, nMDsCPU_buf, nMDs_view, nLowerModules_); auto modules = modules_.const_view(); // FIXME: replace by ES host data - auto module_subdets_buf = allocBufWrapper(cms::alpakatools::host(), nLowerModules_, queue_); - auto module_subdets_view = alpaka::createView(devAcc_, modules.subdets(), nLowerModules_); // only lower modules + auto module_subdets_buf = cms::alpakatools::make_host_buffer(queue_, nLowerModules_); + auto module_subdets_view = + cms::alpakatools::make_device_view(queue_, modules.subdets(), nLowerModules_); // only lower modules alpaka::memcpy(queue_, module_subdets_buf, module_subdets_view, nLowerModules_); - auto module_layers_buf = allocBufWrapper(cms::alpakatools::host(), nLowerModules_, queue_); - auto module_layers_view = alpaka::createView(devAcc_, modules.layers(), nLowerModules_); // only lower modules + auto module_layers_buf = cms::alpakatools::make_host_buffer(queue_, nLowerModules_); + auto module_layers_view = + cms::alpakatools::make_device_view(queue_, modules.layers(), nLowerModules_); // only lower modules alpaka::memcpy(queue_, module_layers_buf, module_layers_view, nLowerModules_); - auto module_hitRanges_buf = allocBufWrapper(cms::alpakatools::host(), nLowerModules_, queue_); + auto module_hitRanges_buf = cms::alpakatools::make_host_buffer(queue_, nLowerModules_); auto hits = hitsDC_->view(); - auto hitRanges_view = alpaka::createView(devAcc_, hits.hitRanges(), nLowerModules_); // only lower modules + auto hitRanges_view = + cms::alpakatools::make_device_view(queue_, hits.hitRanges(), nLowerModules_); // only lower modules alpaka::memcpy(queue_, module_hitRanges_buf, hitRanges_view, nLowerModules_); alpaka::wait(queue_); // wait for inputs before using them @@ -1140,21 +1152,23 @@ void Event::addMiniDoubletsToEventExplicit() { } } -void Event::addSegmentsToEventExplicit() { - auto nSegmentsCPU_buf = allocBufWrapper(cms::alpakatools::host(), nLowerModules_, queue_); - auto nSegments_buf = - alpaka::createView(devAcc_, segmentsDC_->const_view().nSegments(), nLowerModules_); +void LSTEvent::addSegmentsToEventExplicit() { + auto nSegmentsCPU_buf = cms::alpakatools::make_host_buffer(queue_, nLowerModules_); + auto nSegments_buf = cms::alpakatools::make_device_view( + queue_, segmentsDC_->const_view().nSegments(), nLowerModules_); alpaka::memcpy(queue_, nSegmentsCPU_buf, nSegments_buf, nLowerModules_); auto modules = modules_.const_view(); // FIXME: replace by ES host data - auto module_subdets_buf = allocBufWrapper(cms::alpakatools::host(), nLowerModules_, queue_); - auto module_subdets_view = alpaka::createView(devAcc_, modules.subdets(), nLowerModules_); // only lower modules + auto module_subdets_buf = cms::alpakatools::make_host_buffer(queue_, nLowerModules_); + auto module_subdets_view = + cms::alpakatools::make_device_view(queue_, modules.subdets(), nLowerModules_); // only lower modules alpaka::memcpy(queue_, module_subdets_buf, module_subdets_view, nLowerModules_); - auto module_layers_buf = allocBufWrapper(cms::alpakatools::host(), nLowerModules_, queue_); - auto module_layers_view = alpaka::createView(devAcc_, modules.layers(), nLowerModules_); // only lower modules + auto module_layers_buf = cms::alpakatools::make_host_buffer(queue_, nLowerModules_); + auto module_layers_view = + cms::alpakatools::make_device_view(queue_, modules.layers(), nLowerModules_); // only lower modules alpaka::memcpy(queue_, module_layers_buf, module_layers_view, nLowerModules_); alpaka::wait(queue_); // wait for inputs before using them @@ -1174,27 +1188,29 @@ void Event::addSegmentsToEventExplicit() { } } -void Event::addQuintupletsToEventExplicit() { +void LSTEvent::addQuintupletsToEventExplicit() { auto quintupletsOccupancy = quintupletsDC_->const_view(); - auto nQuintuplets_view = alpaka::createView(devAcc_, quintupletsOccupancy.nQuintuplets(), nLowerModules_); - auto nQuintupletsCPU_buf = allocBufWrapper(cms::alpakatools::host(), nLowerModules_, queue_); + auto nQuintuplets_view = + cms::alpakatools::make_device_view(queue_, quintupletsOccupancy.nQuintuplets(), nLowerModules_); + auto nQuintupletsCPU_buf = cms::alpakatools::make_host_buffer(queue_, nLowerModules_); alpaka::memcpy(queue_, nQuintupletsCPU_buf, nQuintuplets_view); auto modules = modules_.const_view(); // FIXME: replace by ES host data - auto module_subdets_buf = allocBufWrapper(cms::alpakatools::host(), nModules_, queue_); - auto module_subdets_view = alpaka::createView(devAcc_, modules.subdets(), modules.metadata().size()); + auto module_subdets_buf = cms::alpakatools::make_host_buffer(queue_, nLowerModules_); + auto module_subdets_view = cms::alpakatools::make_device_view(queue_, modules.subdets(), modules.metadata().size()); alpaka::memcpy(queue_, module_subdets_buf, module_subdets_view, nModules_); - auto module_layers_buf = allocBufWrapper(cms::alpakatools::host(), nLowerModules_, queue_); - auto module_layers_view = alpaka::createView(devAcc_, modules.layers(), nLowerModules_); // only lower modules + auto module_layers_buf = cms::alpakatools::make_host_buffer(queue_, nLowerModules_); + auto module_layers_view = + cms::alpakatools::make_device_view(queue_, modules.layers(), nLowerModules_); // only lower modules alpaka::memcpy(queue_, module_layers_buf, module_layers_view, nLowerModules_); - auto module_quintupletModuleIndices_buf = allocBufWrapper(cms::alpakatools::host(), nLowerModules_, queue_); + auto module_quintupletModuleIndices_buf = cms::alpakatools::make_host_buffer(queue_, nLowerModules_); auto rangesOccupancy = rangesDC_->view(); auto quintupletModuleIndices_view_d = - alpaka::createView(devAcc_, rangesOccupancy.quintupletModuleIndices(), nLowerModules_); + cms::alpakatools::make_device_view(queue_, rangesOccupancy.quintupletModuleIndices(), nLowerModules_); alpaka::memcpy(queue_, module_quintupletModuleIndices_buf, quintupletModuleIndices_view_d); alpaka::wait(queue_); // wait for inputs before using them @@ -1215,21 +1231,23 @@ void Event::addQuintupletsToEventExplicit() { } } -void Event::addTripletsToEventExplicit() { +void LSTEvent::addTripletsToEventExplicit() { auto tripletsOccupancy = tripletsDC_->const_view(); - auto nTriplets_view = alpaka::createView(devAcc_, tripletsOccupancy.nTriplets(), nLowerModules_); - auto nTripletsCPU_buf = allocBufWrapper(cms::alpakatools::host(), nLowerModules_, queue_); + auto nTriplets_view = cms::alpakatools::make_device_view(queue_, tripletsOccupancy.nTriplets(), nLowerModules_); + auto nTripletsCPU_buf = cms::alpakatools::make_host_buffer(queue_, nLowerModules_); alpaka::memcpy(queue_, nTripletsCPU_buf, nTriplets_view); auto modules = modules_.const_view(); // FIXME: replace by ES host data - auto module_subdets_buf = allocBufWrapper(cms::alpakatools::host(), nLowerModules_, queue_); - auto module_subdets_view = alpaka::createView(devAcc_, modules.subdets(), nLowerModules_); // only lower modules + auto module_subdets_buf = cms::alpakatools::make_host_buffer(queue_, nLowerModules_); + auto module_subdets_view = + cms::alpakatools::make_device_view(queue_, modules.subdets(), nLowerModules_); // only lower modules alpaka::memcpy(queue_, module_subdets_buf, module_subdets_view, nLowerModules_); - auto module_layers_buf = allocBufWrapper(cms::alpakatools::host(), nLowerModules_, queue_); - auto module_layers_view = alpaka::createView(devAcc_, modules.layers(), nLowerModules_); // only lower modules + auto module_layers_buf = cms::alpakatools::make_host_buffer(queue_, nLowerModules_); + auto module_layers_view = + cms::alpakatools::make_device_view(queue_, modules.layers(), nLowerModules_); // only lower modules alpaka::memcpy(queue_, module_layers_buf, module_layers_view, nLowerModules_); alpaka::wait(queue_); // wait for inputs before using them @@ -1249,7 +1267,7 @@ void Event::addTripletsToEventExplicit() { } } -unsigned int Event::getNumberOfHits() { +unsigned int LSTEvent::getNumberOfHits() { unsigned int hits = 0; for (auto& it : n_hits_by_layer_barrel_) { hits += it; @@ -1261,18 +1279,18 @@ unsigned int Event::getNumberOfHits() { return hits; } -unsigned int Event::getNumberOfHitsByLayer(unsigned int layer) { +unsigned int LSTEvent::getNumberOfHitsByLayer(unsigned int layer) { if (layer == 6) return n_hits_by_layer_barrel_[layer]; else return n_hits_by_layer_barrel_[layer] + n_hits_by_layer_endcap_[layer]; } -unsigned int Event::getNumberOfHitsByLayerBarrel(unsigned int layer) { return n_hits_by_layer_barrel_[layer]; } +unsigned int LSTEvent::getNumberOfHitsByLayerBarrel(unsigned int layer) { return n_hits_by_layer_barrel_[layer]; } -unsigned int Event::getNumberOfHitsByLayerEndcap(unsigned int layer) { return n_hits_by_layer_endcap_[layer]; } +unsigned int LSTEvent::getNumberOfHitsByLayerEndcap(unsigned int layer) { return n_hits_by_layer_endcap_[layer]; } -unsigned int Event::getNumberOfMiniDoublets() { +unsigned int LSTEvent::getNumberOfMiniDoublets() { unsigned int miniDoublets = 0; for (auto& it : n_minidoublets_by_layer_barrel_) { miniDoublets += it; @@ -1284,22 +1302,22 @@ unsigned int Event::getNumberOfMiniDoublets() { return miniDoublets; } -unsigned int Event::getNumberOfMiniDoubletsByLayer(unsigned int layer) { +unsigned int LSTEvent::getNumberOfMiniDoubletsByLayer(unsigned int layer) { if (layer == 6) return n_minidoublets_by_layer_barrel_[layer]; else return n_minidoublets_by_layer_barrel_[layer] + n_minidoublets_by_layer_endcap_[layer]; } -unsigned int Event::getNumberOfMiniDoubletsByLayerBarrel(unsigned int layer) { +unsigned int LSTEvent::getNumberOfMiniDoubletsByLayerBarrel(unsigned int layer) { return n_minidoublets_by_layer_barrel_[layer]; } -unsigned int Event::getNumberOfMiniDoubletsByLayerEndcap(unsigned int layer) { +unsigned int LSTEvent::getNumberOfMiniDoubletsByLayerEndcap(unsigned int layer) { return n_minidoublets_by_layer_endcap_[layer]; } -unsigned int Event::getNumberOfSegments() { +unsigned int LSTEvent::getNumberOfSegments() { unsigned int segments = 0; for (auto& it : n_segments_by_layer_barrel_) { segments += it; @@ -1311,18 +1329,22 @@ unsigned int Event::getNumberOfSegments() { return segments; } -unsigned int Event::getNumberOfSegmentsByLayer(unsigned int layer) { +unsigned int LSTEvent::getNumberOfSegmentsByLayer(unsigned int layer) { if (layer == 6) return n_segments_by_layer_barrel_[layer]; else return n_segments_by_layer_barrel_[layer] + n_segments_by_layer_endcap_[layer]; } -unsigned int Event::getNumberOfSegmentsByLayerBarrel(unsigned int layer) { return n_segments_by_layer_barrel_[layer]; } +unsigned int LSTEvent::getNumberOfSegmentsByLayerBarrel(unsigned int layer) { + return n_segments_by_layer_barrel_[layer]; +} -unsigned int Event::getNumberOfSegmentsByLayerEndcap(unsigned int layer) { return n_segments_by_layer_endcap_[layer]; } +unsigned int LSTEvent::getNumberOfSegmentsByLayerEndcap(unsigned int layer) { + return n_segments_by_layer_endcap_[layer]; +} -unsigned int Event::getNumberOfTriplets() { +unsigned int LSTEvent::getNumberOfTriplets() { unsigned int triplets = 0; for (auto& it : n_triplets_by_layer_barrel_) { triplets += it; @@ -1334,37 +1356,43 @@ unsigned int Event::getNumberOfTriplets() { return triplets; } -unsigned int Event::getNumberOfTripletsByLayer(unsigned int layer) { +unsigned int LSTEvent::getNumberOfTripletsByLayer(unsigned int layer) { if (layer == 6) return n_triplets_by_layer_barrel_[layer]; else return n_triplets_by_layer_barrel_[layer] + n_triplets_by_layer_endcap_[layer]; } -unsigned int Event::getNumberOfTripletsByLayerBarrel(unsigned int layer) { return n_triplets_by_layer_barrel_[layer]; } +unsigned int LSTEvent::getNumberOfTripletsByLayerBarrel(unsigned int layer) { + return n_triplets_by_layer_barrel_[layer]; +} -unsigned int Event::getNumberOfTripletsByLayerEndcap(unsigned int layer) { return n_triplets_by_layer_endcap_[layer]; } +unsigned int LSTEvent::getNumberOfTripletsByLayerEndcap(unsigned int layer) { + return n_triplets_by_layer_endcap_[layer]; +} -int Event::getNumberOfPixelTriplets() { - auto nPixelTriplets_buf_h = cms::alpakatools::make_host_buffer(queue_, 1u); +int LSTEvent::getNumberOfPixelTriplets() { + auto nPixelTriplets_buf_h = cms::alpakatools::make_host_buffer(queue_); - alpaka::memcpy(queue_, nPixelTriplets_buf_h, alpaka::createView(devAcc_, &(*pixelTripletsDC_)->nPixelTriplets(), 1u)); + alpaka::memcpy( + queue_, nPixelTriplets_buf_h, cms::alpakatools::make_device_view(queue_, (*pixelTripletsDC_)->nPixelTriplets())); alpaka::wait(queue_); return *nPixelTriplets_buf_h.data(); } -int Event::getNumberOfPixelQuintuplets() { - auto nPixelQuintuplets_buf_h = cms::alpakatools::make_host_buffer(queue_, 1u); +int LSTEvent::getNumberOfPixelQuintuplets() { + auto nPixelQuintuplets_buf_h = cms::alpakatools::make_host_buffer(queue_); - alpaka::memcpy( - queue_, nPixelQuintuplets_buf_h, alpaka::createView(devAcc_, &(*pixelQuintupletsDC_)->nPixelQuintuplets(), 1u)); + alpaka::memcpy(queue_, + nPixelQuintuplets_buf_h, + cms::alpakatools::make_device_view(queue_, (*pixelQuintupletsDC_)->nPixelQuintuplets())); alpaka::wait(queue_); return *nPixelQuintuplets_buf_h.data(); } -unsigned int Event::getNumberOfQuintuplets() { +unsigned int LSTEvent::getNumberOfQuintuplets() { unsigned int quintuplets = 0; for (auto& it : n_quintuplets_by_layer_barrel_) { quintuplets += it; @@ -1376,130 +1404,121 @@ unsigned int Event::getNumberOfQuintuplets() { return quintuplets; } -unsigned int Event::getNumberOfQuintupletsByLayer(unsigned int layer) { +unsigned int LSTEvent::getNumberOfQuintupletsByLayer(unsigned int layer) { if (layer == 6) return n_quintuplets_by_layer_barrel_[layer]; else return n_quintuplets_by_layer_barrel_[layer] + n_quintuplets_by_layer_endcap_[layer]; } -unsigned int Event::getNumberOfQuintupletsByLayerBarrel(unsigned int layer) { +unsigned int LSTEvent::getNumberOfQuintupletsByLayerBarrel(unsigned int layer) { return n_quintuplets_by_layer_barrel_[layer]; } -unsigned int Event::getNumberOfQuintupletsByLayerEndcap(unsigned int layer) { +unsigned int LSTEvent::getNumberOfQuintupletsByLayerEndcap(unsigned int layer) { return n_quintuplets_by_layer_endcap_[layer]; } -int Event::getNumberOfTrackCandidates() { - auto nTrackCandidates_buf_h = cms::alpakatools::make_host_buffer(queue_, 1u); +int LSTEvent::getNumberOfTrackCandidates() { + auto nTrackCandidates_buf_h = cms::alpakatools::make_host_buffer(queue_); - alpaka::memcpy( - queue_, nTrackCandidates_buf_h, alpaka::createView(devAcc_, &(*trackCandidatesDC_)->nTrackCandidates(), 1u)); + alpaka::memcpy(queue_, + nTrackCandidates_buf_h, + cms::alpakatools::make_device_view(queue_, (*trackCandidatesDC_)->nTrackCandidates())); alpaka::wait(queue_); return *nTrackCandidates_buf_h.data(); } -int Event::getNumberOfPT5TrackCandidates() { - auto nTrackCandidatesPT5_buf_h = cms::alpakatools::make_host_buffer(queue_, 1u); +int LSTEvent::getNumberOfPT5TrackCandidates() { + auto nTrackCandidatesPT5_buf_h = cms::alpakatools::make_host_buffer(queue_); alpaka::memcpy(queue_, nTrackCandidatesPT5_buf_h, - alpaka::createView(devAcc_, &(*trackCandidatesDC_)->nTrackCandidatespT5(), 1u)); + cms::alpakatools::make_device_view(queue_, (*trackCandidatesDC_)->nTrackCandidatespT5())); alpaka::wait(queue_); return *nTrackCandidatesPT5_buf_h.data(); } -int Event::getNumberOfPT3TrackCandidates() { - auto nTrackCandidatesPT3_buf_h = cms::alpakatools::make_host_buffer(queue_, 1u); +int LSTEvent::getNumberOfPT3TrackCandidates() { + auto nTrackCandidatesPT3_buf_h = cms::alpakatools::make_host_buffer(queue_); alpaka::memcpy(queue_, nTrackCandidatesPT3_buf_h, - alpaka::createView(devAcc_, &(*trackCandidatesDC_)->nTrackCandidatespT3(), 1u)); + cms::alpakatools::make_device_view(queue_, (*trackCandidatesDC_)->nTrackCandidatespT3())); alpaka::wait(queue_); return *nTrackCandidatesPT3_buf_h.data(); } -int Event::getNumberOfPLSTrackCandidates() { - auto nTrackCandidatesPLS_buf_h = cms::alpakatools::make_host_buffer(queue_, 1u); +int LSTEvent::getNumberOfPLSTrackCandidates() { + auto nTrackCandidatesPLS_buf_h = cms::alpakatools::make_host_buffer(queue_); alpaka::memcpy(queue_, nTrackCandidatesPLS_buf_h, - alpaka::createView(devAcc_, &(*trackCandidatesDC_)->nTrackCandidatespLS(), 1u)); + cms::alpakatools::make_device_view(queue_, (*trackCandidatesDC_)->nTrackCandidatespLS())); alpaka::wait(queue_); return *nTrackCandidatesPLS_buf_h.data(); } -int Event::getNumberOfPixelTrackCandidates() { - auto nTrackCandidates_buf_h = cms::alpakatools::make_host_buffer(queue_, 1u); - auto nTrackCandidatesT5_buf_h = cms::alpakatools::make_host_buffer(queue_, 1u); +int LSTEvent::getNumberOfPixelTrackCandidates() { + auto nTrackCandidates_buf_h = cms::alpakatools::make_host_buffer(queue_); + auto nTrackCandidatesT5_buf_h = cms::alpakatools::make_host_buffer(queue_); - alpaka::memcpy( - queue_, nTrackCandidates_buf_h, alpaka::createView(devAcc_, &(*trackCandidatesDC_)->nTrackCandidates(), 1u)); - alpaka::memcpy( - queue_, nTrackCandidatesT5_buf_h, alpaka::createView(devAcc_, &(*trackCandidatesDC_)->nTrackCandidatesT5(), 1u)); + alpaka::memcpy(queue_, + nTrackCandidates_buf_h, + cms::alpakatools::make_device_view(queue_, (*trackCandidatesDC_)->nTrackCandidates())); + alpaka::memcpy(queue_, + nTrackCandidatesT5_buf_h, + cms::alpakatools::make_device_view(queue_, (*trackCandidatesDC_)->nTrackCandidatesT5())); alpaka::wait(queue_); return (*nTrackCandidates_buf_h.data()) - (*nTrackCandidatesT5_buf_h.data()); } -int Event::getNumberOfT5TrackCandidates() { - auto nTrackCandidatesT5_buf_h = cms::alpakatools::make_host_buffer(queue_, 1u); +int LSTEvent::getNumberOfT5TrackCandidates() { + auto nTrackCandidatesT5_buf_h = cms::alpakatools::make_host_buffer(queue_); - alpaka::memcpy( - queue_, nTrackCandidatesT5_buf_h, alpaka::createView(devAcc_, &(*trackCandidatesDC_)->nTrackCandidatesT5(), 1u)); + alpaka::memcpy(queue_, + nTrackCandidatesT5_buf_h, + cms::alpakatools::make_device_view(queue_, (*trackCandidatesDC_)->nTrackCandidatesT5())); alpaka::wait(queue_); return *nTrackCandidatesT5_buf_h.data(); } template -typename TSoA::ConstView Event::getHits(bool sync) //std::shared_ptr should take care of garbage collection -{ - if constexpr (std::is_same_v) { - return hitsDC_->const_view(); - } else { - if (!hitsHC_) { - hitsHC_.emplace(cms::alpakatools::CopyToHost>::copyAsync( - queue_, *hitsDC_)); - if (sync) - alpaka::wait(queue_); // host consumers expect filled data - } - return hitsHC_->const_view(); - } -} -template HitsConst Event::getHits(bool); -template HitsRangesConst Event::getHits(bool); - -template -typename TSoA::ConstView Event::getHitsInCMSSW(bool sync) { +typename TSoA::ConstView LSTEvent::getHits(bool inCMSSW, bool sync) { if constexpr (std::is_same_v) { return hitsDC_->const_view(); } else { if (!hitsHC_) { - auto hits_d = hitsDC_->view(); - auto nHits = hits_d.metadata().size(); - std::array const hits_sizes{{static_cast(nHits), static_cast(nModules_)}}; - hitsHC_.emplace(hits_sizes, queue_); - auto hits_h = hitsHC_->view(); - auto idxs_h = alpaka::createView(cms::alpakatools::host(), hits_h.idxs(), nHits); - auto idxs_d = alpaka::createView(devAcc_, hits_d.idxs(), nHits); - alpaka::memcpy(queue_, idxs_h, idxs_d); + if (inCMSSW) { + auto hits_d = hitsDC_->view(); + auto nHits = hits_d.metadata().size(); + std::array const hits_sizes{{static_cast(nHits), static_cast(nModules_)}}; + hitsHC_.emplace(hits_sizes, queue_); + auto hits_h = hitsHC_->view(); + auto idxs_h = cms::alpakatools::make_host_view(hits_h.idxs(), nHits); + auto idxs_d = cms::alpakatools::make_device_view(queue_, hits_d.idxs(), nHits); + alpaka::memcpy(queue_, idxs_h, idxs_d); + } else { + hitsHC_.emplace(cms::alpakatools::CopyToHost>::copyAsync( + queue_, *hitsDC_)); + } if (sync) alpaka::wait(queue_); // host consumers expect filled data } return hitsHC_->const_view(); } } -template HitsConst Event::getHitsInCMSSW(bool); -template HitsRangesConst Event::getHitsInCMSSW(bool); +template HitsConst LSTEvent::getHits(bool, bool); +template HitsRangesConst LSTEvent::getHits(bool, bool); template -ObjectRangesConst Event::getRanges(bool sync) { +ObjectRangesConst LSTEvent::getRanges(bool sync) { if constexpr (std::is_same_v) { return rangesDC_->const_view(); } else { @@ -1512,10 +1531,10 @@ ObjectRangesConst Event::getRanges(bool sync) { return rangesHC_->const_view(); } } -template ObjectRangesConst Event::getRanges<>(bool); +template ObjectRangesConst LSTEvent::getRanges<>(bool); template -typename TSoA::ConstView Event::getMiniDoublets(bool sync) { +typename TSoA::ConstView LSTEvent::getMiniDoublets(bool sync) { if constexpr (std::is_same_v) { return miniDoubletsDC_->const_view(); } else { @@ -1530,11 +1549,11 @@ typename TSoA::ConstView Event::getMiniDoublets(bool sync) { return miniDoubletsHC_->const_view(); } } -template MiniDoubletsConst Event::getMiniDoublets(bool); -template MiniDoubletsOccupancyConst Event::getMiniDoublets(bool); +template MiniDoubletsConst LSTEvent::getMiniDoublets(bool); +template MiniDoubletsOccupancyConst LSTEvent::getMiniDoublets(bool); template -typename TSoA::ConstView Event::getSegments(bool sync) { +typename TSoA::ConstView LSTEvent::getSegments(bool sync) { if constexpr (std::is_same_v) { return segmentsDC_->const_view(); } else { @@ -1549,12 +1568,12 @@ typename TSoA::ConstView Event::getSegments(bool sync) { return segmentsHC_->const_view(); } } -template SegmentsConst Event::getSegments(bool); -template SegmentsOccupancyConst Event::getSegments(bool); -template SegmentsPixelConst Event::getSegments(bool); +template SegmentsConst LSTEvent::getSegments(bool); +template SegmentsOccupancyConst LSTEvent::getSegments(bool); +template SegmentsPixelConst LSTEvent::getSegments(bool); template -typename TSoA::ConstView Event::getTriplets(bool sync) { +typename TSoA::ConstView LSTEvent::getTriplets(bool sync) { if constexpr (std::is_same_v) { return tripletsDC_->const_view(); } else { @@ -1569,11 +1588,11 @@ typename TSoA::ConstView Event::getTriplets(bool sync) { } return tripletsHC_->const_view(); } -template TripletsConst Event::getTriplets(bool); -template TripletsOccupancyConst Event::getTriplets(bool); +template TripletsConst LSTEvent::getTriplets(bool); +template TripletsOccupancyConst LSTEvent::getTriplets(bool); template -typename TSoA::ConstView Event::getQuintuplets(bool sync) { +typename TSoA::ConstView LSTEvent::getQuintuplets(bool sync) { if constexpr (std::is_same_v) { return quintupletsDC_->const_view(); } else { @@ -1588,11 +1607,11 @@ typename TSoA::ConstView Event::getQuintuplets(bool sync) { } return quintupletsHC_->const_view(); } -template QuintupletsConst Event::getQuintuplets(bool); -template QuintupletsOccupancyConst Event::getQuintuplets(bool); +template QuintupletsConst LSTEvent::getQuintuplets(bool); +template QuintupletsOccupancyConst LSTEvent::getQuintuplets(bool); template -PixelTripletsConst Event::getPixelTriplets(bool sync) { +PixelTripletsConst LSTEvent::getPixelTriplets(bool sync) { if constexpr (std::is_same_v) { return pixelTripletsDC_->const_view(); } else { @@ -1606,10 +1625,10 @@ PixelTripletsConst Event::getPixelTriplets(bool sync) { } return pixelTripletsHC_->const_view(); } -template PixelTripletsConst Event::getPixelTriplets<>(bool); +template PixelTripletsConst LSTEvent::getPixelTriplets<>(bool); template -PixelQuintupletsConst Event::getPixelQuintuplets(bool sync) { +PixelQuintupletsConst LSTEvent::getPixelQuintuplets(bool sync) { if constexpr (std::is_same_v) { return pixelQuintupletsDC_->const_view(); } else { @@ -1624,48 +1643,49 @@ PixelQuintupletsConst Event::getPixelQuintuplets(bool sync) { } return pixelQuintupletsHC_->const_view(); } -template PixelQuintupletsConst Event::getPixelQuintuplets<>(bool); +template PixelQuintupletsConst LSTEvent::getPixelQuintuplets<>(bool); -const TrackCandidatesConst& Event::getTrackCandidatesWithSelection(bool inCMSSW, bool sync) { +const TrackCandidatesConst& LSTEvent::getTrackCandidates(bool inCMSSW, bool sync) { if (!trackCandidatesHC_) { // Get nTrackCanHost parameter to initialize host based instance - auto nTrackCanHost_buf_h = cms::alpakatools::make_host_buffer(queue_, 1u); - alpaka::memcpy( - queue_, nTrackCanHost_buf_h, alpaka::createView(devAcc_, &(*trackCandidatesDC_)->nTrackCandidates(), 1u)); + auto nTrackCanHost_buf_h = cms::alpakatools::make_host_buffer(queue_); + alpaka::memcpy(queue_, + nTrackCanHost_buf_h, + cms::alpakatools::make_device_view(queue_, (*trackCandidatesDC_)->nTrackCandidates())); alpaka::wait(queue_); // wait here before we get nTrackCanHost and trackCandidatesInCPU becomes usable auto const nTrackCanHost = *nTrackCanHost_buf_h.data(); trackCandidatesHC_.emplace(nTrackCanHost, queue_); (*trackCandidatesHC_)->nTrackCandidates() = nTrackCanHost; - alpaka::memcpy( - queue_, - alpaka::createView( - cms::alpakatools::host(), (*trackCandidatesHC_)->hitIndices()->data(), Params_pT5::kHits * nTrackCanHost), - alpaka::createView(devAcc_, (*trackCandidatesDC_)->hitIndices()->data(), Params_pT5::kHits * nTrackCanHost)); alpaka::memcpy(queue_, - alpaka::createView(cms::alpakatools::host(), (*trackCandidatesHC_)->pixelSeedIndex(), nTrackCanHost), - alpaka::createView(devAcc_, (*trackCandidatesDC_)->pixelSeedIndex(), nTrackCanHost)); + cms::alpakatools::make_host_view((*trackCandidatesHC_)->hitIndices()->data(), + Params_pT5::kHits * nTrackCanHost), + cms::alpakatools::make_device_view( + queue_, (*trackCandidatesDC_)->hitIndices()->data(), Params_pT5::kHits * nTrackCanHost)); + alpaka::memcpy(queue_, + cms::alpakatools::make_host_view((*trackCandidatesHC_)->pixelSeedIndex(), nTrackCanHost), + cms::alpakatools::make_device_view(queue_, (*trackCandidatesDC_)->pixelSeedIndex(), nTrackCanHost)); if (not inCMSSW) { alpaka::memcpy(queue_, - alpaka::createView(cms::alpakatools::host(), - (*trackCandidatesHC_)->logicalLayers()->data(), - Params_pT5::kLayers * nTrackCanHost), - alpaka::createView( - devAcc_, (*trackCandidatesDC_)->logicalLayers()->data(), Params_pT5::kLayers * nTrackCanHost)); + cms::alpakatools::make_host_view((*trackCandidatesHC_)->logicalLayers()->data(), + Params_pT5::kLayers * nTrackCanHost), + cms::alpakatools::make_device_view( + queue_, (*trackCandidatesDC_)->logicalLayers()->data(), Params_pT5::kLayers * nTrackCanHost)); alpaka::memcpy( queue_, - alpaka::createView(cms::alpakatools::host(), (*trackCandidatesHC_)->directObjectIndices(), nTrackCanHost), - alpaka::createView(devAcc_, (*trackCandidatesDC_)->directObjectIndices(), nTrackCanHost)); - alpaka::memcpy(queue_, - alpaka::createView( - cms::alpakatools::host(), (*trackCandidatesHC_)->objectIndices()->data(), 2 * nTrackCanHost), - alpaka::createView(devAcc_, (*trackCandidatesDC_)->objectIndices()->data(), 2 * nTrackCanHost)); + cms::alpakatools::make_host_view((*trackCandidatesHC_)->directObjectIndices(), nTrackCanHost), + cms::alpakatools::make_device_view(queue_, (*trackCandidatesDC_)->directObjectIndices(), nTrackCanHost)); + alpaka::memcpy( + queue_, + cms::alpakatools::make_host_view((*trackCandidatesHC_)->objectIndices()->data(), 2 * nTrackCanHost), + cms::alpakatools::make_device_view( + queue_, (*trackCandidatesDC_)->objectIndices()->data(), 2 * nTrackCanHost)); } alpaka::memcpy( queue_, - alpaka::createView(cms::alpakatools::host(), (*trackCandidatesHC_)->trackCandidateType(), nTrackCanHost), - alpaka::createView(devAcc_, (*trackCandidatesDC_)->trackCandidateType(), nTrackCanHost)); + cms::alpakatools::make_host_view((*trackCandidatesHC_)->trackCandidateType(), nTrackCanHost), + cms::alpakatools::make_device_view(queue_, (*trackCandidatesDC_)->trackCandidateType(), nTrackCanHost)); if (sync) alpaka::wait(queue_); // host consumers expect filled data } @@ -1673,7 +1693,7 @@ const TrackCandidatesConst& Event::getTrackCandidatesWithSelection(bool inCMSSW, } template -typename TSoA::ConstView Event::getModules(bool sync) { +typename TSoA::ConstView LSTEvent::getModules(bool sync) { if constexpr (std::is_same_v) { return modules_.const_view(); } else { @@ -1687,5 +1707,5 @@ typename TSoA::ConstView Event::getModules(bool sync) { return modulesHC_->const_view(); } } -template ModulesConst Event::getModules(bool); -template ModulesPixelConst Event::getModules(bool); +template ModulesConst LSTEvent::getModules(bool); +template ModulesPixelConst LSTEvent::getModules(bool); diff --git a/RecoTracker/LSTCore/src/alpaka/Event.h b/RecoTracker/LSTCore/src/alpaka/LSTEvent.h similarity index 84% rename from RecoTracker/LSTCore/src/alpaka/Event.h rename to RecoTracker/LSTCore/src/alpaka/LSTEvent.h index c692dd9ed43bb..ec11d9678c98a 100644 --- a/RecoTracker/LSTCore/src/alpaka/Event.h +++ b/RecoTracker/LSTCore/src/alpaka/LSTEvent.h @@ -1,5 +1,5 @@ -#ifndef RecoTracker_LSTCore_src_alpaka_Event_h -#define RecoTracker_LSTCore_src_alpaka_Event_h +#ifndef RecoTracker_LSTCore_src_alpaka_LSTEvent_h +#define RecoTracker_LSTCore_src_alpaka_LSTEvent_h #include @@ -13,7 +13,7 @@ #include "RecoTracker/LSTCore/interface/TripletsHostCollection.h" #include "RecoTracker/LSTCore/interface/ObjectRangesHostCollection.h" #include "RecoTracker/LSTCore/interface/ModulesHostCollection.h" -#include "RecoTracker/LSTCore/interface/alpaka/Constants.h" +#include "RecoTracker/LSTCore/interface/alpaka/Common.h" #include "RecoTracker/LSTCore/interface/alpaka/LST.h" #include "RecoTracker/LSTCore/interface/alpaka/MiniDoubletsDeviceCollection.h" #include "RecoTracker/LSTCore/interface/alpaka/PixelQuintupletsDeviceCollection.h" @@ -33,24 +33,22 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { - class Event { + class LSTEvent { private: Queue& queue_; - Device devAcc_; - bool addObjects_; - std::array n_hits_by_layer_barrel_; - std::array n_hits_by_layer_endcap_; - std::array n_minidoublets_by_layer_barrel_; - std::array n_minidoublets_by_layer_endcap_; - std::array n_segments_by_layer_barrel_; - std::array n_segments_by_layer_endcap_; - std::array n_triplets_by_layer_barrel_; - std::array n_triplets_by_layer_endcap_; - std::array n_trackCandidates_by_layer_barrel_; - std::array n_trackCandidates_by_layer_endcap_; - std::array n_quintuplets_by_layer_barrel_; - std::array n_quintuplets_by_layer_endcap_; + std::array n_hits_by_layer_barrel_{}; + std::array n_hits_by_layer_endcap_{}; + std::array n_minidoublets_by_layer_barrel_{}; + std::array n_minidoublets_by_layer_endcap_{}; + std::array n_segments_by_layer_barrel_{}; + std::array n_segments_by_layer_endcap_{}; + std::array n_triplets_by_layer_barrel_{}; + std::array n_triplets_by_layer_endcap_{}; + std::array n_trackCandidates_by_layer_barrel_{}; + std::array n_trackCandidates_by_layer_endcap_{}; + std::array n_quintuplets_by_layer_barrel_{}; + std::array n_quintuplets_by_layer_endcap_{}; unsigned int nTotalSegments_; //Device stuff @@ -76,8 +74,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { std::optional pixelTripletsHC_; std::optional pixelQuintupletsHC_; - void initSync(bool verbose); - const uint16_t nModules_; const uint16_t nLowerModules_; const unsigned int nPixels_; @@ -85,22 +81,22 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { ModulesDeviceCollection const& modules_; PixelMap const& pixelMapping_; EndcapGeometryDevDeviceCollection const& endcapGeometry_; + bool addObjects_; public: // Constructor used for CMSSW integration. Uses an external queue. - Event(bool verbose, Queue& q, const LSTESData* deviceESData) + LSTEvent(bool verbose, Queue& q, const LSTESData* deviceESData) : queue_(q), - devAcc_(alpaka::getDev(q)), nModules_(deviceESData->nModules), nLowerModules_(deviceESData->nLowerModules), nPixels_(deviceESData->nPixels), nEndCapMap_(deviceESData->nEndCapMap), modules_(*deviceESData->modules), pixelMapping_(*deviceESData->pixelMapping), - endcapGeometry_(*deviceESData->endcapGeometry) { - initSync(verbose); - } - void resetEventSync(); // synchronizes + endcapGeometry_(*deviceESData->endcapGeometry), + addObjects_(verbose) {} + void initSync(); // synchronizes, for standalone usage + void resetEventSync(); // synchronizes, for standalone usage void wait() const { alpaka::wait(queue_); } // Calls the appropriate hit function, then increments the counter @@ -184,9 +180,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { // set to false may allow faster operation with concurrent calls of get* // HANDLE WITH CARE template - typename TSoA::ConstView getHits(bool sync = true); - template - typename TSoA::ConstView getHitsInCMSSW(bool sync = true); + typename TSoA::ConstView getHits(bool inCMSSW = false, bool sync = true); template ObjectRangesConst getRanges(bool sync = true); template @@ -201,13 +195,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { 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); - } - const TrackCandidatesConst& getTrackCandidatesInCMSSW(bool sync = true) { - return getTrackCandidatesWithSelection(true, sync); - } + const TrackCandidatesConst& getTrackCandidates(bool inCMSSW = false, bool sync = true); template typename TSoA::ConstView getModules(bool sync = true); }; diff --git a/RecoTracker/LSTCore/src/alpaka/MiniDoublet.h b/RecoTracker/LSTCore/src/alpaka/MiniDoublet.h index 94adbd43dedb7..e236758a70fb5 100644 --- a/RecoTracker/LSTCore/src/alpaka/MiniDoublet.h +++ b/RecoTracker/LSTCore/src/alpaka/MiniDoublet.h @@ -3,7 +3,7 @@ #include "HeterogeneousCore/AlpakaInterface/interface/workdivision.h" -#include "RecoTracker/LSTCore/interface/alpaka/Constants.h" +#include "RecoTracker/LSTCore/interface/alpaka/Common.h" #include "RecoTracker/LSTCore/interface/MiniDoubletsSoA.h" #include "RecoTracker/LSTCore/interface/alpaka/MiniDoubletsDeviceCollection.h" #include "RecoTracker/LSTCore/interface/ModulesSoA.h" @@ -308,7 +308,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { angleA = alpaka::math::abs(acc, alpaka::math::atan(acc, rtp / zp)); angleB = ((isEndcap) - ? float(M_PI) / 2.f + ? kPi / 2.f : alpaka::math::atan( acc, drdz_)); // The tilt module on the positive z-axis has negative drdz slope in r-z plane and vice versa @@ -323,18 +323,18 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { drprime = (moduleSeparation / alpaka::math::sin(acc, angleA + angleB)) * alpaka::math::sin(acc, angleA); // Compute arctan of the slope and take care of the slope = infinity case - absArctanSlope = ((slope != lst_INF) ? fabs(alpaka::math::atan(acc, slope)) : float(M_PI) / 2.f); + absArctanSlope = ((slope != kVerticalModuleSlope) ? fabs(alpaka::math::atan(acc, slope)) : kPi / 2.f); // Depending on which quadrant the pixel hit lies, we define the angleM by shifting them slightly differently if (xp > 0 and yp > 0) { angleM = absArctanSlope; } else if (xp > 0 and yp < 0) { - angleM = float(M_PI) - absArctanSlope; + angleM = kPi - absArctanSlope; } else if (xp < 0 and yp < 0) { - angleM = float(M_PI) + absArctanSlope; + angleM = kPi + absArctanSlope; } else // if (xp < 0 and yp > 0) { - angleM = 2.f * float(M_PI) - absArctanSlope; + angleM = 2.f * kPi - absArctanSlope; } // Then since the angleM sign is taken care of properly @@ -347,7 +347,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { // Compute the new strip hit position (if the slope value is in special condition take care of the exceptions) if (slope == - lst_INF) // Designated for tilted module when the slope is exactly infinity (module lying along y-axis) + kVerticalModuleSlope) // Designated for tilted module when the slope is infinity (module lying along y-axis) { xn = xa; // New x point is simply where the anchor is yn = yo; // No shift in y @@ -807,15 +807,13 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } alpaka::syncBlockThreads(acc); - // Create variables outside of the for loop. - int occupancy, category_number, eta_number; - for (uint16_t i = globalThreadIdx[0]; i < modules.nLowerModules(); i += gridThreadExtent[0]) { short module_rings = modules.rings()[i]; short module_layers = modules.layers()[i]; short module_subdets = modules.subdets()[i]; float module_eta = alpaka::math::abs(acc, modules.eta()[i]); + int category_number; if (module_layers <= 3 && module_subdets == 5) category_number = 0; else if (module_layers >= 4 && module_subdets == 5) @@ -831,6 +829,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { else category_number = -1; + int eta_number; if (module_eta < 0.75f) eta_number = 0; else if (module_eta < 1.5f) @@ -842,6 +841,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { else eta_number = -1; + int occupancy; if (category_number == 0 && eta_number == 0) occupancy = 49; else if (category_number == 0 && eta_number == 1) diff --git a/RecoTracker/LSTCore/src/alpaka/NeuralNetwork.h b/RecoTracker/LSTCore/src/alpaka/NeuralNetwork.h index e027222890702..42605c80e9434 100644 --- a/RecoTracker/LSTCore/src/alpaka/NeuralNetwork.h +++ b/RecoTracker/LSTCore/src/alpaka/NeuralNetwork.h @@ -1,7 +1,7 @@ #ifndef RecoTracker_LSTCore_src_alpaka_NeuralNetwork_h #define RecoTracker_LSTCore_src_alpaka_NeuralNetwork_h -#include "RecoTracker/LSTCore/interface/alpaka/Constants.h" +#include "RecoTracker/LSTCore/interface/alpaka/Common.h" #include "RecoTracker/LSTCore/interface/ModulesSoA.h" #include "RecoTracker/LSTCore/interface/HitsSoA.h" #include "RecoTracker/LSTCore/interface/MiniDoubletsSoA.h" diff --git a/RecoTracker/LSTCore/src/alpaka/PixelQuintuplet.h b/RecoTracker/LSTCore/src/alpaka/PixelQuintuplet.h index 30a48ac101b54..08feb0dfe3384 100644 --- a/RecoTracker/LSTCore/src/alpaka/PixelQuintuplet.h +++ b/RecoTracker/LSTCore/src/alpaka/PixelQuintuplet.h @@ -1,7 +1,7 @@ #ifndef RecoTracker_LSTCore_src_alpaka_PixelQuintuplet_h #define RecoTracker_LSTCore_src_alpaka_PixelQuintuplet_h -#include "RecoTracker/LSTCore/interface/alpaka/Constants.h" +#include "RecoTracker/LSTCore/interface/alpaka/Common.h" #include "RecoTracker/LSTCore/interface/ModulesSoA.h" #include "RecoTracker/LSTCore/interface/ObjectRangesSoA.h" #include "RecoTracker/LSTCore/interface/MiniDoubletsSoA.h" @@ -267,22 +267,22 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float f, float radius) { /* - Given values of (g, f, radius) and a set of points (and its uncertainties) compute chi squared - */ + Given values of (g, f, radius) and a set of points (and its uncertainties) compute chi squared + */ float c = g * g + f * f - radius * radius; float chiSquared = 0.f; float absArctanSlope, angleM, xPrime, yPrime, sigma2; for (size_t i = 0; i < nPoints; i++) { - absArctanSlope = - ((slopes[i] != lst_INF) ? alpaka::math::abs(acc, alpaka::math::atan(acc, slopes[i])) : 0.5f * float(M_PI)); + absArctanSlope = ((slopes[i] != kVerticalModuleSlope) ? alpaka::math::abs(acc, alpaka::math::atan(acc, slopes[i])) + : kPi / 2.f); if (xs[i] > 0 and ys[i] > 0) { - angleM = 0.5f * float(M_PI) - absArctanSlope; + angleM = kPi / 2.f - absArctanSlope; } else if (xs[i] < 0 and ys[i] > 0) { - angleM = absArctanSlope + 0.5f * float(M_PI); + angleM = absArctanSlope + kPi / 2.f; } else if (xs[i] < 0 and ys[i] < 0) { - angleM = -(absArctanSlope + 0.5f * float(M_PI)); + angleM = -(absArctanSlope + kPi / 2.f); } else if (xs[i] > 0 and ys[i] < 0) { - angleM = -(0.5f * float(M_PI) - absArctanSlope); + angleM = -(kPi / 2.f - absArctanSlope); } else { angleM = 0; } @@ -311,13 +311,13 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { unsigned int nPoints = 5, bool anchorHits = true) { /* - bool anchorHits required to deal with a weird edge case wherein - the hits ultimately used in the regression are anchor hits, but the - lower modules need not all be Pixel Modules (in case of PS). Similarly, - when we compute the chi squared for the non-anchor hits, the "partner module" - need not always be a PS strip module, but all non-anchor hits sit on strip - modules. - */ + bool anchorHits required to deal with a weird edge case wherein + the hits ultimately used in the regression are anchor hits, but the + lower modules need not all be Pixel Modules (in case of PS). Similarly, + when we compute the chi squared for the non-anchor hits, the "partner module" + need not always be a PS strip module, but all non-anchor hits sit on strip + modules. + */ ModuleType moduleType; short moduleSubdet, moduleSide; float inv1 = kWidthPS / kWidth2S; @@ -359,10 +359,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { delta1[i] = inv1; isFlat[i] = false; /* - despite the type of the module layer of the lower module index, - all anchor hits are on the pixel side and all non-anchor hits are - on the strip side! - */ + despite the type of the module layer of the lower module index, + all anchor hits are on the pixel side and all non-anchor hits are + on the strip side! + */ if (anchorHits) { delta2[i] = inv2; } else { @@ -396,8 +396,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float* xs, float* ys) { /* - Compute circle parameters from 3 pixel hits, and then use them to compute the chi squared for the outer hits - */ + Compute circle parameters from 3 pixel hits, and then use them to compute the chi squared for the outer hits + */ float delta1[5], delta2[5], slopes[5]; bool isFlat[5]; @@ -412,8 +412,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { ALPAKA_FN_ACC ALPAKA_FN_INLINE float computePT5RPhiChiSquaredInwards( float g, float f, float r, float* xPix, float* yPix) { /* - Using the computed regression center and radius, compute the chi squared for the pixels - */ + Using the computed regression center and radius, compute the chi squared for the pixels + */ float chiSquared = 0; for (size_t i = 0; i < 2; i++) { diff --git a/RecoTracker/LSTCore/src/alpaka/PixelTriplet.h b/RecoTracker/LSTCore/src/alpaka/PixelTriplet.h index 71822bb2544cb..a8be90fff5227 100644 --- a/RecoTracker/LSTCore/src/alpaka/PixelTriplet.h +++ b/RecoTracker/LSTCore/src/alpaka/PixelTriplet.h @@ -1,7 +1,7 @@ #ifndef RecoTracker_LSTCore_src_alpaka_PixelTriplet_h #define RecoTracker_LSTCore_src_alpaka_PixelTriplet_h -#include "RecoTracker/LSTCore/interface/alpaka/Constants.h" +#include "RecoTracker/LSTCore/interface/alpaka/Common.h" #include "RecoTracker/LSTCore/interface/ModulesSoA.h" #include "RecoTracker/LSTCore/interface/ObjectRangesSoA.h" #include "RecoTracker/LSTCore/interface/MiniDoubletsSoA.h" @@ -108,7 +108,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { pixelTriplets.rPhiChiSquared()[pixelTripletIndex] = rPhiChiSquared; pixelTriplets.rPhiChiSquaredInwards()[pixelTripletIndex] = rPhiChiSquaredInwards; pixelTriplets.rzChiSquared()[pixelTripletIndex] = rzChiSquared; - }; + } template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runPixelTrackletDefaultAlgopT3(TAcc const& acc, @@ -166,7 +166,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { fourthMDIndex); } return false; - }; + } ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT3RZChiSquaredCuts(ModulesConst modules, uint16_t lowerModuleIndex1, @@ -191,12 +191,12 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { return rzChiSquared < 3.9263f; } /* - else if(layer1 == 7 and layer2 == 8 and layer3 == 14) - { - // PS+PS+2S in endcap layers 1+2+3, which is not really feasible in the current geometry, - // without skipping barrel layers 1 and 2 (not allowed by algorithm logic). - } - */ + else if(layer1 == 7 and layer2 == 8 and layer3 == 14) + { + // PS+PS+2S in endcap layers 1+2+3, which is not really feasible in the current geometry, + // without skipping barrel layers 1 and 2 (not allowed by algorithm logic). + } + */ else if (layer1 == 1 and layer2 == 2 and layer3 == 3) { return rzChiSquared < 9.4377f; } else if (layer1 == 1 and layer2 == 2 and layer3 == 7) { @@ -217,7 +217,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { //default - category not found! return true; - }; + } template ALPAKA_FN_ACC ALPAKA_FN_INLINE float computeChiSquaredpT3(TAcc const& acc, @@ -237,16 +237,16 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float chiSquared = 0.f; float absArctanSlope, angleM, xPrime, yPrime, sigma2; for (size_t i = 0; i < nPoints; i++) { - absArctanSlope = - ((slopes[i] != lst_INF) ? alpaka::math::abs(acc, alpaka::math::atan(acc, slopes[i])) : 0.5f * float(M_PI)); + absArctanSlope = ((slopes[i] != kVerticalModuleSlope) ? alpaka::math::abs(acc, alpaka::math::atan(acc, slopes[i])) + : kPi / 2.f); if (xs[i] > 0 and ys[i] > 0) { - angleM = 0.5f * float(M_PI) - absArctanSlope; + angleM = kPi / 2.f - absArctanSlope; } else if (xs[i] < 0 and ys[i] > 0) { - angleM = absArctanSlope + 0.5f * float(M_PI); + angleM = absArctanSlope + kPi / 2.f; } else if (xs[i] < 0 and ys[i] < 0) { - angleM = -(absArctanSlope + 0.5f * float(M_PI)); + angleM = -(absArctanSlope + kPi / 2.f); } else if (xs[i] > 0 and ys[i] < 0) { - angleM = -(0.5f * float(M_PI) - absArctanSlope); + angleM = -(kPi / 2.f - absArctanSlope); } else { angleM = 0; } @@ -263,7 +263,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { (xs[i] * xs[i] + ys[i] * ys[i] - 2 * g * xs[i] - 2 * f * ys[i] + c) / sigma2; } return chiSquared; - }; + } //TODO: merge this one and the pT5 function later into a single function template @@ -275,7 +275,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float radius, float* xs, float* ys) { - float delta1[3]{}, delta2[3]{}, slopes[3]; + float delta1[3]{}, delta2[3]{}, slopes[3]{}; bool isFlat[3]{}; float chiSquared = 0; float inv1 = kWidthPS / kWidth2S; @@ -312,9 +312,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { isFlat[i] = false; /* - despite the type of the module layer of the lower module index, all anchor - hits are on the pixel side and all non-anchor hits are on the strip side! - */ + despite the type of the module layer of the lower module index, all anchor + hits are on the pixel side and all non-anchor hits are on the strip side! + */ delta2[i] = inv2; } //category 5 - endcap 2S @@ -335,7 +335,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { chiSquared = computeChiSquaredpT3(acc, 3, xs, ys, delta1, delta2, slopes, isFlat, g, f, radius); return chiSquared; - }; + } ALPAKA_FN_ACC ALPAKA_FN_INLINE float computePT3RPhiChiSquaredInwards( float g, float f, float r, float* xPix, float* yPix) { @@ -346,7 +346,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { chiSquared *= 0.5f; return chiSquared; - }; + } //90pc threshold ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT3RPhiChiSquaredCuts(ModulesConst modules, @@ -391,7 +391,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } return true; - }; + } ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT3RPhiChiSquaredInwardsCuts(ModulesConst modules, uint16_t lowerModuleIndex1, @@ -447,14 +447,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } return true; - }; + } ALPAKA_FN_ACC ALPAKA_FN_INLINE bool checkIntervalOverlappT3(float firstMin, float firstMax, float secondMin, float secondMax) { return ((firstMin <= secondMin) && (secondMin < firstMax)) || ((secondMin < firstMin) && (firstMin < secondMax)); - }; + } /*bounds for high Pt taken from : http://uaf-10.t2.ucsd.edu/~bsathian/SDL/T5_efficiency/efficiencies/new_efficiencies/efficiencies_20210513_T5_recovering_high_Pt_efficiencies/highE_radius_matching/highE_bounds.txt */ template @@ -479,7 +479,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { alpaka::math::min(acc, (1 - pixelInvRadiusErrorBound) / pixelRadius, 1.f / (pixelRadius + pixelRadiusError)); return checkIntervalOverlappT3(tripletRadiusInvMin, tripletRadiusInvMax, pixelRadiusInvMin, pixelRadiusInvMax); - }; + } template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passRadiusCriterionBBE(TAcc const& acc, @@ -503,7 +503,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { alpaka::math::min(acc, (1 - pixelInvRadiusErrorBound) / pixelRadius, 1.f / (pixelRadius + pixelRadiusError)); return checkIntervalOverlappT3(tripletRadiusInvMin, tripletRadiusInvMax, pixelRadiusInvMin, pixelRadiusInvMax); - }; + } template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passRadiusCriterionBEE(TAcc const& acc, @@ -529,7 +529,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { pixelRadiusInvMin = alpaka::math::max(acc, pixelRadiusInvMin, 0.0f); return checkIntervalOverlappT3(tripletRadiusInvMin, tripletRadiusInvMax, pixelRadiusInvMin, pixelRadiusInvMax); - }; + } template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passRadiusCriterionEEE(TAcc const& acc, @@ -555,7 +555,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { pixelRadiusInvMin = alpaka::math::max(acc, 0.0f, pixelRadiusInvMin); return checkIntervalOverlappT3(tripletRadiusInvMin, tripletRadiusInvMax, pixelRadiusInvMin, pixelRadiusInvMax); - }; + } template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passRadiusCriterion(TAcc const& acc, @@ -575,7 +575,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } else { return passRadiusCriterionBBB(acc, pixelRadius, pixelRadiusError, tripletRadius); } - }; + } template ALPAKA_FN_ACC ALPAKA_FN_INLINE float computePT3RZChiSquared(TAcc const& acc, @@ -664,7 +664,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { RMSE = alpaka::math::sqrt(acc, 0.2f * RMSE); // Divided by the degree of freedom 5. return RMSE; - }; + } template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runPixelTripletDefaultAlgo(TAcc const& acc, @@ -819,7 +819,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { centerX = 0; centerY = 0; return true; - }; + } struct CreatePixelTripletsFromMap { template @@ -1101,7 +1101,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float rt_InOut = rt_InUp; - if (alpaka::math::abs(acc, deltaPhi(acc, x_InUp, y_InUp, x_OutLo, y_OutLo)) > 0.5f * float(M_PI)) + if (alpaka::math::abs(acc, deltaPhi(acc, x_InUp, y_InUp, x_OutLo, y_OutLo)) > kPi / 2.f) return false; unsigned int pixelSegmentArrayIndex = innerSegmentIndex - ranges.segmentModuleIndices()[pixelModuleIndex]; diff --git a/RecoTracker/LSTCore/src/alpaka/Quintuplet.h b/RecoTracker/LSTCore/src/alpaka/Quintuplet.h index e5388851ce8aa..24ce2d1d53e22 100644 --- a/RecoTracker/LSTCore/src/alpaka/Quintuplet.h +++ b/RecoTracker/LSTCore/src/alpaka/Quintuplet.h @@ -8,7 +8,7 @@ #include "RecoTracker/LSTCore/interface/SegmentsSoA.h" #include "RecoTracker/LSTCore/interface/TripletsSoA.h" #include "RecoTracker/LSTCore/interface/QuintupletsSoA.h" -#include "RecoTracker/LSTCore/interface/alpaka/Constants.h" +#include "RecoTracker/LSTCore/interface/alpaka/Common.h" #include "RecoTracker/LSTCore/interface/ModulesSoA.h" #include "RecoTracker/LSTCore/interface/EndcapGeometry.h" #include "RecoTracker/LSTCore/interface/ObjectRangesSoA.h" @@ -194,19 +194,19 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float innerRadius, float g, float f, - bool& TightCutFlag) { + bool& tightCutFlag) { //(g,f) is the center of the circle fitted by the innermost 3 points on x,y coordinates - const float& rt1 = mds.anchorRt()[firstMDIndex] / 100; //in the unit of m instead of cm - const float& rt2 = mds.anchorRt()[secondMDIndex] / 100; - const float& rt3 = mds.anchorRt()[thirdMDIndex] / 100; - const float& rt4 = mds.anchorRt()[fourthMDIndex] / 100; - const float& rt5 = mds.anchorRt()[fifthMDIndex] / 100; - - const float& z1 = mds.anchorZ()[firstMDIndex] / 100; - const float& z2 = mds.anchorZ()[secondMDIndex] / 100; - const float& z3 = mds.anchorZ()[thirdMDIndex] / 100; - const float& z4 = mds.anchorZ()[fourthMDIndex] / 100; - const float& z5 = mds.anchorZ()[fifthMDIndex] / 100; + const float rt1 = mds.anchorRt()[firstMDIndex] / 100; //in the unit of m instead of cm + const float rt2 = mds.anchorRt()[secondMDIndex] / 100; + const float rt3 = mds.anchorRt()[thirdMDIndex] / 100; + const float rt4 = mds.anchorRt()[fourthMDIndex] / 100; + const float rt5 = mds.anchorRt()[fifthMDIndex] / 100; + + const float z1 = mds.anchorZ()[firstMDIndex] / 100; + const float z2 = mds.anchorZ()[secondMDIndex] / 100; + const float z3 = mds.anchorZ()[thirdMDIndex] / 100; + const float z4 = mds.anchorZ()[fourthMDIndex] / 100; + const float z5 = mds.anchorZ()[fifthMDIndex] / 100; // Using lst_layer numbering convention defined in ModuleMethods.h const int layer1 = modules.lstLayers()[lowerModuleIndex1]; @@ -222,14 +222,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { const int moduleType4 = modules.moduleType()[lowerModuleIndex4]; const int moduleType5 = modules.moduleType()[lowerModuleIndex5]; - const float& x1 = mds.anchorX()[firstMDIndex] / 100; - const float& x2 = mds.anchorX()[secondMDIndex] / 100; - const float& x3 = mds.anchorX()[thirdMDIndex] / 100; - const float& x4 = mds.anchorX()[fourthMDIndex] / 100; - const float& y1 = mds.anchorY()[firstMDIndex] / 100; - const float& y2 = mds.anchorY()[secondMDIndex] / 100; - const float& y3 = mds.anchorY()[thirdMDIndex] / 100; - const float& y4 = mds.anchorY()[fourthMDIndex] / 100; + const float x1 = mds.anchorX()[firstMDIndex] / 100; + const float x2 = mds.anchorX()[secondMDIndex] / 100; + const float x3 = mds.anchorX()[thirdMDIndex] / 100; + const float x4 = mds.anchorX()[fourthMDIndex] / 100; + const float y1 = mds.anchorY()[firstMDIndex] / 100; + const float y2 = mds.anchorY()[secondMDIndex] / 100; + const float y3 = mds.anchorY()[thirdMDIndex] / 100; + const float y4 = mds.anchorY()[fourthMDIndex] / 100; float residual = 0; float error2 = 0; @@ -388,7 +388,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { continue; } - // calculation is copied from PixelTriplet.cc computePT3RZChiSquared + // calculation is copied from PixelTriplet.h computePT3RZChiSquared float diffr = 0, diffz = 0; float rou = a / p; @@ -413,7 +413,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float solz2 = alpaka::math::asin(acc, sol2) / rou * Pz / p + z_init; float diffz1 = (solz1 - zsi) * 100; float diffz2 = (solz2 - zsi) * 100; - // Alpaka : Needs to be moved over if (alpaka::math::isnan(acc, diffz1)) diffz = diffz2; else if (alpaka::math::isnan(acc, diffz2)) @@ -461,7 +460,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } // for set rzchi2 cut // if the 5 points are linear, helix calculation gives nan - // Alpaka : Needs to be moved over if (inner_pt > 100 || alpaka::math::isnan(acc, rzChiSquared)) { float slope; if (moduleType1 == 0 and moduleType2 == 0 and moduleType3 == 1) //PSPS2S @@ -485,124 +483,124 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } // when building T5, apply 99% chi2 cuts as default, and add to pT5 collection. But when adding T5 to TC collections, apply 95% cut to reduce the fake rate - TightCutFlag = false; + tightCutFlag = false; // The category numbers are related to module regions and layers, decoding of the region numbers can be found here in slide 2 table. https://github.com/SegmentLinking/TrackLooper/files/11420927/part.2.pdf // The commented numbers after each case is the region code, and can look it up from the table to see which category it belongs to. For example, //0 means T5 built with Endcap 1,2,3,4,5 ps modules if (layer1 == 7 and layer2 == 8 and layer3 == 9 and layer4 == 10 and layer5 == 11) //0 { if (rzChiSquared < 94.470f) - TightCutFlag = true; + tightCutFlag = true; return true; } else if (layer1 == 7 and layer2 == 8 and layer3 == 9 and layer4 == 10 and layer5 == 16) //1 { if (rzChiSquared < 22.099f) - TightCutFlag = true; + tightCutFlag = true; return rzChiSquared < 37.956f; } else if (layer1 == 7 and layer2 == 8 and layer3 == 9 and layer4 == 15 and layer5 == 16) //2 { if (rzChiSquared < 7.992f) - TightCutFlag = true; + tightCutFlag = true; return rzChiSquared < 11.622f; } else if (layer1 == 1 and layer2 == 7 and layer3 == 8 and layer4 == 9) { if (layer5 == 10) //3 { if (rzChiSquared < 111.390f) - TightCutFlag = true; + tightCutFlag = true; return true; } if (layer5 == 15) //4 { if (rzChiSquared < 18.351f) - TightCutFlag = true; + tightCutFlag = true; return rzChiSquared < 37.941f; } } else if (layer1 == 1 and layer2 == 2 and layer3 == 7) { if (layer4 == 8 and layer5 == 9) //5 { if (rzChiSquared < 116.148f) - TightCutFlag = true; + tightCutFlag = true; return true; } if (layer4 == 8 and layer5 == 14) //6 { if (rzChiSquared < 19.352f) - TightCutFlag = true; + tightCutFlag = true; return rzChiSquared < 52.561f; } else if (layer4 == 13 and layer5 == 14) //7 { if (rzChiSquared < 10.392f) - TightCutFlag = true; + tightCutFlag = true; return rzChiSquared < 13.76f; } } else if (layer1 == 1 and layer2 == 2 and layer3 == 3) { if (layer4 == 7 and layer5 == 8) //8 { if (rzChiSquared < 27.824f) - TightCutFlag = true; + tightCutFlag = true; return rzChiSquared < 44.247f; } else if (layer4 == 7 and layer5 == 13) //9 { if (rzChiSquared < 18.145f) - TightCutFlag = true; + tightCutFlag = true; return rzChiSquared < 33.752f; } else if (layer4 == 12 and layer5 == 13) //10 { if (rzChiSquared < 13.308f) - TightCutFlag = true; + tightCutFlag = true; return rzChiSquared < 21.213f; } else if (layer4 == 4 and layer5 == 5) //11 { if (rzChiSquared < 15.627f) - TightCutFlag = true; + tightCutFlag = true; return rzChiSquared < 29.035f; } else if (layer4 == 4 and layer5 == 12) //12 { if (rzChiSquared < 14.64f) - TightCutFlag = true; + tightCutFlag = true; return rzChiSquared < 23.037f; } } else if (layer1 == 2 and layer2 == 7 and layer3 == 8) { if (layer4 == 9 and layer5 == 15) //14 { if (rzChiSquared < 24.662f) - TightCutFlag = true; + tightCutFlag = true; return rzChiSquared < 41.036f; } else if (layer4 == 14 and layer5 == 15) //15 { if (rzChiSquared < 8.866f) - TightCutFlag = true; + tightCutFlag = true; return rzChiSquared < 14.092f; } } else if (layer1 == 2 and layer2 == 3 and layer3 == 7) { if (layer4 == 8 and layer5 == 14) //16 { if (rzChiSquared < 23.730f) - TightCutFlag = true; + tightCutFlag = true; return rzChiSquared < 23.748f; } if (layer4 == 13 and layer5 == 14) //17 { if (rzChiSquared < 10.772f) - TightCutFlag = true; + tightCutFlag = true; return rzChiSquared < 17.945f; } } else if (layer1 == 2 and layer2 == 3 and layer3 == 4) { if (layer4 == 5 and layer5 == 6) //18 { if (rzChiSquared < 6.065f) - TightCutFlag = true; + tightCutFlag = true; return rzChiSquared < 8.803f; } else if (layer4 == 5 and layer5 == 12) //19 { if (rzChiSquared < 5.693f) - TightCutFlag = true; + tightCutFlag = true; return rzChiSquared < 7.930f; } else if (layer4 == 12 and layer5 == 13) //20 { if (rzChiSquared < 5.473f) - TightCutFlag = true; + tightCutFlag = true; return rzChiSquared < 7.626f; } } @@ -637,7 +635,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { //brute force float candidateRadius; float g, f; - minimumRadius = lst_INF; + minimumRadius = kVerticalModuleSlope; maximumRadius = 0.f; for (size_t i = 0; i < 3; i++) { float x1 = x1Vec[i]; @@ -691,7 +689,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float innerInvRadiusErrorBound = 0.1512f; float bridgeInvRadiusErrorBound = 0.1781f; - if (innerRadius > 2.0f / (2.f * k2Rinv1GeVf)) { + if (innerRadius * k2Rinv1GeVf > 1.f) { innerInvRadiusErrorBound = 0.4449f; bridgeInvRadiusErrorBound = 0.4033f; } @@ -715,7 +713,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float innerInvRadiusErrorBound = 0.1781f; float bridgeInvRadiusErrorBound = 0.2167f; - if (innerRadius > 2.0f / (2.f * k2Rinv1GeVf)) { + if (innerRadius * k2Rinv1GeVf > 1.f) { innerInvRadiusErrorBound = 0.4750f; bridgeInvRadiusErrorBound = 0.3903f; } @@ -789,7 +787,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float innerInvRadiusErrorBound = 0.6376f; float bridgeInvRadiusErrorBound = 2.1381f; - if (innerRadius > 2.0f / (2.f * k2Rinv1GeVf)) //as good as no selections! + if (innerRadius * k2Rinv1GeVf > 1.f) //as good as no selections! { innerInvRadiusErrorBound = 12.9173f; bridgeInvRadiusErrorBound = 5.1700f; @@ -821,7 +819,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float innerInvRadiusErrorBound = 1.9382f; float bridgeInvRadiusErrorBound = 3.7280f; - if (innerRadius > 2.0f / (2.f * k2Rinv1GeVf)) { + if (innerRadius * k2Rinv1GeVf > 1.f) { innerInvRadiusErrorBound = 23.2713f; bridgeInvRadiusErrorBound = 21.7980f; } @@ -832,10 +830,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { bridgeInvRadiusMax = (1.f + bridgeInvRadiusErrorBound) / bridgeRadius; bridgeInvRadiusMin = alpaka::math::max(acc, 0.f, (1.f - bridgeInvRadiusErrorBound) / bridgeRadius); - return checkIntervalOverlap(alpaka::math::min(acc, innerInvRadiusMin, 1.0 / innerRadiusMax2S), - alpaka::math::max(acc, innerInvRadiusMax, 1.0 / innerRadiusMin2S), - alpaka::math::min(acc, bridgeInvRadiusMin, 1.0 / bridgeRadiusMax2S), - alpaka::math::max(acc, bridgeInvRadiusMax, 1.0 / bridgeRadiusMin2S)); + return checkIntervalOverlap(alpaka::math::min(acc, innerInvRadiusMin, 1.0f / innerRadiusMax2S), + alpaka::math::max(acc, innerInvRadiusMax, 1.0f / innerRadiusMin2S), + alpaka::math::min(acc, bridgeInvRadiusMin, 1.0f / bridgeRadiusMax2S), + alpaka::math::max(acc, bridgeInvRadiusMax, 1.0f / bridgeRadiusMin2S)); } template @@ -852,7 +850,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float innerInvRadiusErrorBound = 1.9382f; float bridgeInvRadiusErrorBound = 2.2091f; - if (innerRadius > 2.0f / (2.f * k2Rinv1GeVf)) { + if (innerRadius * k2Rinv1GeVf > 1.f) { innerInvRadiusErrorBound = 22.5226f; bridgeInvRadiusErrorBound = 21.0966f; } @@ -863,10 +861,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { bridgeInvRadiusMax = (1.f + bridgeInvRadiusErrorBound) / bridgeRadius; bridgeInvRadiusMin = alpaka::math::max(acc, 0.f, (1.f - bridgeInvRadiusErrorBound) / bridgeRadius); - return checkIntervalOverlap(alpaka::math::min(acc, innerInvRadiusMin, 1.0 / innerRadiusMax2S), - alpaka::math::max(acc, innerInvRadiusMax, 1.0 / innerRadiusMin2S), - alpaka::math::min(acc, bridgeInvRadiusMin, 1.0 / bridgeRadiusMax2S), - alpaka::math::max(acc, bridgeInvRadiusMax, 1.0 / bridgeRadiusMin2S)); + return checkIntervalOverlap(alpaka::math::min(acc, innerInvRadiusMin, 1.0f / innerRadiusMax2S), + alpaka::math::max(acc, innerInvRadiusMax, 1.0f / innerRadiusMin2S), + alpaka::math::min(acc, bridgeInvRadiusMin, 1.0f / bridgeRadiusMax2S), + alpaka::math::max(acc, bridgeInvRadiusMax, 1.0f / bridgeRadiusMin2S)); } template @@ -880,13 +878,13 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { unsigned int nPoints = 5, bool anchorHits = true) { /* - Bool anchorHits required to deal with a weird edge case wherein - the hits ultimately used in the regression are anchor hits, but the - lower modules need not all be Pixel Modules (in case of PS). Similarly, - when we compute the chi squared for the non-anchor hits, the "partner module" - need not always be a PS strip module, but all non-anchor hits sit on strip - modules. - */ + Bool anchorHits required to deal with a weird edge case wherein + the hits ultimately used in the regression are anchor hits, but the + lower modules need not all be Pixel Modules (in case of PS). Similarly, + when we compute the chi squared for the non-anchor hits, the "partner module" + need not always be a PS strip module, but all non-anchor hits sit on strip + modules. + */ ModuleType moduleType; short moduleSubdet, moduleSide; @@ -930,10 +928,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { isFlat[i] = false; /* - despite the type of the module layer of the lower module index, - all anchor hits are on the pixel side and all non-anchor hits are - on the strip side! - */ + despite the type of the module layer of the lower module index, + all anchor hits are on the pixel side and all non-anchor hits are + on the strip side! + */ if (anchorHits) { delta2[i] = inv2; } else { @@ -989,17 +987,17 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { // Computing sigmas is a very tricky affair // if the module is tilted or endcap, we need to use the slopes properly! - absArctanSlope = - ((slopes[i] != lst_INF) ? alpaka::math::abs(acc, alpaka::math::atan(acc, slopes[i])) : 0.5f * float(M_PI)); + absArctanSlope = ((slopes[i] != kVerticalModuleSlope) ? alpaka::math::abs(acc, alpaka::math::atan(acc, slopes[i])) + : kPi / 2.f); if (xs[i] > 0 and ys[i] > 0) { - angleM = 0.5f * float(M_PI) - absArctanSlope; + angleM = kPi / 2.f - absArctanSlope; } else if (xs[i] < 0 and ys[i] > 0) { - angleM = absArctanSlope + 0.5f * float(M_PI); + angleM = absArctanSlope + kPi / 2.f; } else if (xs[i] < 0 and ys[i] < 0) { - angleM = -(absArctanSlope + 0.5f * float(M_PI)); + angleM = -(absArctanSlope + kPi / 2.f); } else if (xs[i] > 0 and ys[i] < 0) { - angleM = -(0.5f * float(M_PI) - absArctanSlope); + angleM = -(kPi / 2.f - absArctanSlope); } else { angleM = 0; } @@ -1072,16 +1070,16 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float chiSquared = 0.f; float absArctanSlope, angleM, xPrime, yPrime, sigma2; for (size_t i = 0; i < nPoints; i++) { - absArctanSlope = - ((slopes[i] != lst_INF) ? alpaka::math::abs(acc, alpaka::math::atan(acc, slopes[i])) : 0.5f * float(M_PI)); + absArctanSlope = ((slopes[i] != kVerticalModuleSlope) ? alpaka::math::abs(acc, alpaka::math::atan(acc, slopes[i])) + : kPi / 2.f); if (xs[i] > 0 and ys[i] > 0) { - angleM = 0.5f * float(M_PI) - absArctanSlope; + angleM = kPi / 2.f - absArctanSlope; } else if (xs[i] < 0 and ys[i] > 0) { - angleM = absArctanSlope + 0.5f * float(M_PI); + angleM = absArctanSlope + kPi / 2.f; } else if (xs[i] < 0 and ys[i] < 0) { - angleM = -(absArctanSlope + 0.5f * float(M_PI)); + angleM = -(absArctanSlope + kPi / 2.f); } else if (xs[i] > 0 and ys[i] < 0) { - angleM = -(0.5f * float(M_PI) - absArctanSlope); + angleM = -(kPi / 2.f - absArctanSlope); } else { angleM = 0; } @@ -2038,7 +2036,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float& rzChiSquared, float& chiSquared, float& nonAnchorChiSquared, - bool& TightCutFlag) { + bool& tightCutFlag) { unsigned int firstSegmentIndex = triplets.segmentIndices()[innerTripletIndex][0]; unsigned int secondSegmentIndex = triplets.segmentIndices()[innerTripletIndex][1]; unsigned int thirdSegmentIndex = triplets.segmentIndices()[outerTripletIndex][0]; @@ -2173,7 +2171,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { g = triplets.centerX()[innerTripletIndex]; f = triplets.centerY()[innerTripletIndex]; -#ifdef USE_RZCHI2 float inner_pt = 2 * k2Rinv1GeVf * innerRadius; if (not passT5RZConstraint(acc, @@ -2194,11 +2191,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { innerRadius, g, f, - TightCutFlag)) + tightCutFlag)) return false; -#else - rzChiSquared = -1; -#endif + if (innerRadius < 0.95f * ptCut / (2.f * k2Rinv1GeVf)) return false; @@ -2280,7 +2275,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { sigmas2, chiSquared); -#ifdef USE_T5_DNN unsigned int mdIndices[] = {firstMDIndex, secondMDIndex, thirdMDIndex, fourthMDIndex, fifthMDIndex}; float inference = t5dnn::runInference(acc, modules, @@ -2296,24 +2290,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { innerRadius, outerRadius, bridgeRadius); - TightCutFlag = TightCutFlag and (inference > t5dnn::kLSTWp2); // T5-in-TC cut + tightCutFlag = tightCutFlag and (inference > t5dnn::kLSTWp2); // T5-in-TC cut if (inference <= t5dnn::kLSTWp2) // T5-building cut return false; -#endif - -#ifdef USE_RPHICHI2 - // extra chi squared cuts! - if (regressionRadius < 5.0f / (2.f * k2Rinv1GeVf)) { - if (not passChiSquaredConstraint(modules, - lowerModuleIndex1, - lowerModuleIndex2, - lowerModuleIndex3, - lowerModuleIndex4, - lowerModuleIndex5, - chiSquared)) - return false; - } -#endif //compute the other chisquared //non anchor is always shifted for tilted and endcap! @@ -2396,7 +2375,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { float innerRadius, outerRadius, bridgeRadius, regressionG, regressionF, regressionRadius, rzChiSquared, chiSquared, nonAnchorChiSquared; //required for making distributions - bool TightCutFlag = false; + bool tightCutFlag = false; bool success = runQuintupletDefaultAlgo(acc, modules, mds, @@ -2418,7 +2397,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { rzChiSquared, chiSquared, nonAnchorChiSquared, - TightCutFlag); + tightCutFlag); if (success) { int totOccupancyQuintuplets = alpaka::atomicAdd( @@ -2467,7 +2446,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { scores, layer, quintupletIndex, - TightCutFlag); + tightCutFlag); triplets.partOfT5()[quintuplets.tripletIndices()[quintupletIndex][0]] = true; triplets.partOfT5()[quintuplets.tripletIndices()[quintupletIndex][1]] = true; @@ -2502,9 +2481,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } alpaka::syncBlockThreads(acc); - // Create variables outside of the for loop. - int occupancy, category_number, eta_number; - for (int i = globalThreadIdx[0]; i < modules.nLowerModules(); i += gridThreadExtent[0]) { // Condition for a quintuple to exist for a module // TCs don't exist for layers 5 and 6 barrel, and layers 2,3,4,5 endcap @@ -2522,6 +2498,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { int nEligibleT5Modules = alpaka::atomicAdd(acc, &nEligibleT5Modulesx, 1, alpaka::hierarchy::Threads{}); + int category_number; if (module_layers <= 3 && module_subdets == 5) category_number = 0; else if (module_layers >= 4 && module_subdets == 5) @@ -2537,6 +2514,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { else category_number = -1; + int eta_number; if (module_eta < 0.75f) eta_number = 0; else if (module_eta < 1.5f) @@ -2548,6 +2526,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { else eta_number = -1; + int occupancy; if (category_number == 0 && eta_number == 0) occupancy = 336; else if (category_number == 0 && eta_number == 1) diff --git a/RecoTracker/LSTCore/src/alpaka/Segment.h b/RecoTracker/LSTCore/src/alpaka/Segment.h index b1c2c6d815dde..ad5521bd6a8c2 100644 --- a/RecoTracker/LSTCore/src/alpaka/Segment.h +++ b/RecoTracker/LSTCore/src/alpaka/Segment.h @@ -3,7 +3,7 @@ #include "HeterogeneousCore/AlpakaInterface/interface/workdivision.h" -#include "RecoTracker/LSTCore/interface/alpaka/Constants.h" +#include "RecoTracker/LSTCore/interface/alpaka/Common.h" #include "RecoTracker/LSTCore/interface/SegmentsSoA.h" #include "RecoTracker/LSTCore/interface/alpaka/SegmentsDeviceCollection.h" #include "RecoTracker/LSTCore/interface/ModulesSoA.h" @@ -255,8 +255,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { //computing circle parameters /* - The two anchor hits are r3PCA and r3LH. p3PCA pt, eta, phi is hitIndex1 x, y, z - */ + The two anchor hits are r3PCA and r3LH. p3PCA pt, eta, phi is hitIndex1 x, y, z + */ float circleRadius = mds.outerX()[innerMDIndex] / (2 * k2Rinv1GeVf); float circlePhi = mds.outerZ()[innerMDIndex]; float candidateCenterXs[] = {mds.anchorX()[innerMDIndex] + circleRadius * alpaka::math::sin(acc, circlePhi), @@ -265,7 +265,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { mds.anchorY()[innerMDIndex] + circleRadius * alpaka::math::cos(acc, circlePhi)}; //check which of the circles can accommodate r3LH better (we won't get perfect agreement) - float bestChiSquared = lst_INF; + float bestChiSquared = kVerticalModuleSlope; float chiSquared; size_t bestIndex; for (size_t i = 0; i < 2; i++) { @@ -418,7 +418,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { return false; float dz = zOut - zIn; - // Alpaka: Needs to be moved over float dLum = alpaka::math::copysign(acc, kDeltaZLum, zIn); float drtDzScale = sdSlope / alpaka::math::tan(acc, sdSlope); @@ -653,9 +652,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } alpaka::syncBlockThreads(acc); - // Create variables outside of the for loop. - int occupancy, category_number, eta_number; - for (uint16_t i = globalThreadIdx[0]; i < modules.nLowerModules(); i += gridThreadExtent[0]) { if (modules.nConnectedModules()[i] == 0) { ranges.segmentModuleIndices()[i] = nTotalSegments; @@ -668,6 +664,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { short module_subdets = modules.subdets()[i]; float module_eta = alpaka::math::abs(acc, modules.eta()[i]); + int category_number; if (module_layers <= 3 && module_subdets == 5) category_number = 0; else if (module_layers >= 4 && module_subdets == 5) @@ -683,6 +680,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { else category_number = -1; + int eta_number; if (module_eta < 0.75f) eta_number = 0; else if (module_eta < 1.5f) @@ -694,6 +692,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { else eta_number = -1; + int occupancy; if (category_number == 0 && eta_number == 0) occupancy = 572; else if (category_number == 0 && eta_number == 1) diff --git a/RecoTracker/LSTCore/src/alpaka/TrackCandidate.h b/RecoTracker/LSTCore/src/alpaka/TrackCandidate.h index 9bbf2de9c2cee..1863f262ffd7d 100644 --- a/RecoTracker/LSTCore/src/alpaka/TrackCandidate.h +++ b/RecoTracker/LSTCore/src/alpaka/TrackCandidate.h @@ -1,7 +1,7 @@ #ifndef RecoTracker_LSTCore_src_alpaka_TrackCandidate_h #define RecoTracker_LSTCore_src_alpaka_TrackCandidate_h -#include "RecoTracker/LSTCore/interface/alpaka/Constants.h" +#include "RecoTracker/LSTCore/interface/alpaka/Common.h" #include "RecoTracker/LSTCore/interface/ModulesSoA.h" #include "RecoTracker/LSTCore/interface/MiniDoubletsSoA.h" #include "RecoTracker/LSTCore/interface/PixelQuintupletsSoA.h" @@ -19,7 +19,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { unsigned int trackCandidateIndex, uint4 hitIndices, int pixelSeedIndex) { - cands.trackCandidateType()[trackCandidateIndex] = 8; // type for pLS + cands.trackCandidateType()[trackCandidateIndex] = LSTObjType::pLS; cands.directObjectIndices()[trackCandidateIndex] = trackletIndex; cands.pixelSeedIndex()[trackCandidateIndex] = pixelSeedIndex; @@ -53,9 +53,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { cands.objectIndices()[trackCandidateIndex][0] = innerTrackletIndex; cands.objectIndices()[trackCandidateIndex][1] = outerTrackletIndex; - size_t limits = trackCandidateType == 7 - ? Params_pT5::kLayers - : Params_pT3::kLayers; // 7 means pT5, Params_pT3::kLayers = Params_T5::kLayers = 5 + size_t limits = trackCandidateType == LSTObjType::pT5 ? Params_pT5::kLayers : Params_pT3::kLayers; //send the starting pointer to the logicalLayer and hitIndices for (size_t i = 0; i < limits; i++) { @@ -175,7 +173,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { // Don't add duplicate T5s or T5s that are accounted in pT5s if (quintuplets.isDup()[quintupletIndex] or quintuplets.partOfPT5()[quintupletIndex]) continue; -#ifdef Crossclean_T5 unsigned int loop_bound = pixelQuintuplets.nPixelQuintuplets() + pixelTriplets.nPixelTriplets(); // Cross cleaning step float eta1 = __H2F(quintuplets.eta()[quintupletIndex]); @@ -198,7 +195,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { if (dR2 < 1e-3f) quintuplets.isDup()[quintupletIndex] = true; } -#endif } } } @@ -236,8 +232,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { trackCandidateIndex += gridThreadExtent[1]) { short type = cands.trackCandidateType()[trackCandidateIndex]; unsigned int innerTrackletIdx = cands.objectIndices()[trackCandidateIndex][0]; - if (type == 4) // T5 - { + if (type == LSTObjType::T5) { unsigned int quintupletIndex = innerTrackletIdx; // T5 index float eta2 = __H2F(quintuplets.eta()[quintupletIndex]); float phi2 = __H2F(quintuplets.phi()[quintupletIndex]); @@ -248,8 +243,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { if (dR2 < 1e-3f) segmentsPixel.isDup()[pixelArrayIndex] = true; } - if (type == 5) // pT3 - { + if (type == LSTObjType::pT3) { int pLSIndex = pixelTriplets.pixelSegmentIndices()[innerTrackletIdx]; int npMatched = checkPixelHits(prefix + pixelArrayIndex, pLSIndex, mds, segments, hits); if (npMatched > 0) @@ -265,8 +259,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { if (dR2 < 0.000001f) segmentsPixel.isDup()[pixelArrayIndex] = true; } - if (type == 7) // pT5 - { + if (type == LSTObjType::pT5) { unsigned int pLSIndex = innerTrackletIdx; int npMatched = checkPixelHits(prefix + pixelArrayIndex, pLSIndex, mds, segments, hits); if (npMatched > 0) { @@ -326,7 +319,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { __H2F(pixelTriplets.tripletRadius()[pixelTripletIndex])); unsigned int pT3PixelIndex = pixelTriplets.pixelSegmentIndices()[pixelTripletIndex]; addTrackCandidateToMemory(cands, - 5 /*track candidate type pT3=5*/, + LSTObjType::pT3, pixelTripletIndex, pixelTripletIndex, pixelTriplets.logicalLayers()[pixelTripletIndex].data(), @@ -379,7 +372,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } else { alpaka::atomicAdd(acc, &cands.nTrackCandidatesT5(), 1u, alpaka::hierarchy::Threads{}); addTrackCandidateToMemory(cands, - 4 /*track candidate type T5=4*/, + LSTObjType::T5, quintupletIndex, quintupletIndex, quintuplets.logicalLayers()[quintupletIndex].data(), @@ -477,7 +470,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { __H2F(pixelQuintuplets.quintupletRadius()[pixelQuintupletIndex])); unsigned int pT5PixelIndex = pixelQuintuplets.pixelSegmentIndices()[pixelQuintupletIndex]; addTrackCandidateToMemory(cands, - 7 /*track candidate type pT5=7*/, + LSTObjType::pT5, pT5PixelIndex, pixelQuintuplets.quintupletIndices()[pixelQuintupletIndex], pixelQuintuplets.logicalLayers()[pixelQuintupletIndex].data(), diff --git a/RecoTracker/LSTCore/src/alpaka/Triplet.h b/RecoTracker/LSTCore/src/alpaka/Triplet.h index d01641f75c22c..9192edbd9a186 100644 --- a/RecoTracker/LSTCore/src/alpaka/Triplet.h +++ b/RecoTracker/LSTCore/src/alpaka/Triplet.h @@ -3,7 +3,7 @@ #include "HeterogeneousCore/AlpakaInterface/interface/workdivision.h" -#include "RecoTracker/LSTCore/interface/alpaka/Constants.h" +#include "RecoTracker/LSTCore/interface/alpaka/Common.h" #include "RecoTracker/LSTCore/interface/ModulesSoA.h" #include "RecoTracker/LSTCore/interface/ObjectRangesSoA.h" #include "RecoTracker/LSTCore/interface/TripletsSoA.h" @@ -621,7 +621,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { unsigned int secondMDIndex = segments.mdIndices()[outerSegmentIndex][0]; unsigned int thirdMDIndex = segments.mdIndices()[outerSegmentIndex][1]; - if (not(passRZConstraint(acc, + if (not passRZConstraint(acc, modules, mds, innerInnerLowerModuleIndex, @@ -629,9 +629,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { outerOuterLowerModuleIndex, firstMDIndex, secondMDIndex, - thirdMDIndex))) + thirdMDIndex)) return false; - if (not(passPointingConstraint(acc, + if (not passPointingConstraint(acc, modules, mds, segments, @@ -647,7 +647,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { innerSegmentIndex, outerSegmentIndex, betaIn, - betaInCut))) + betaInCut)) return false; float x1 = mds.anchorX()[firstMDIndex]; @@ -784,9 +784,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { } alpaka::syncBlockThreads(acc); - // Create variables outside of the for loop. - int occupancy, category_number, eta_number; - for (uint16_t i = globalThreadIdx[0]; i < modules.nLowerModules(); i += gridThreadExtent[0]) { if (segmentsOccupancy.nSegments()[i] == 0) { ranges.tripletModuleIndices()[i] = nTotalTriplets; @@ -799,6 +796,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { short module_subdets = modules.subdets()[i]; float module_eta = alpaka::math::abs(acc, modules.eta()[i]); + int category_number; if (module_layers <= 3 && module_subdets == 5) category_number = 0; else if (module_layers >= 4 && module_subdets == 5) @@ -814,6 +812,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { else category_number = -1; + int eta_number; if (module_eta < 0.75f) eta_number = 0; else if (module_eta < 1.5f) @@ -825,6 +824,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst { else eta_number = -1; + int occupancy; if (category_number == 0 && eta_number == 0) occupancy = 543; else if (category_number == 0 && eta_number == 1) diff --git a/RecoTracker/LSTCore/standalone/LST/Makefile b/RecoTracker/LSTCore/standalone/LST/Makefile index 3dd0483edfeb6..ee6f82ecccde1 100644 --- a/RecoTracker/LSTCore/standalone/LST/Makefile +++ b/RecoTracker/LSTCore/standalone/LST/Makefile @@ -3,15 +3,15 @@ # CCSOURCES=$(wildcard ../../src/*.cc) -ALPAKACCSOURCES=$(filter-out ../../src.alpaka/LST.dev.cc, $(wildcard ../../src/alpaka/*.dev.cc)) +ALPAKACCSOURCES=$(wildcard ../../src/alpaka/*.dev.cc) CCOBJECTS_CPU=$(patsubst ../../src/alpaka/%.dev.cc, %_cpu.o, $(ALPAKACCSOURCES)) $(patsubst ../../src/%.cc, %_cpu.o, $(CCSOURCES)) CCOBJECTS_CUDA=$(patsubst ../../src/alpaka/%.dev.cc, %_cuda.o, $(ALPAKACCSOURCES)) $(patsubst ../../src/%.cc, %_cuda.o, $(CCSOURCES)) CCOBJECTS_ROCM=$(patsubst ../../src/alpaka/%.dev.cc, %_rocm.o, $(ALPAKACCSOURCES)) $(patsubst ../../src/%.cc, %_rocm.o, $(CCSOURCES)) -LSTSOURCES=../../src/alpaka/LST.dev.cc -LSTOBJECTS_CPU=$(patsubst ../../src/alpaka/%.dev.cc, %_cpu.o, $(LSTSOURCES)) -LSTOBJECTS_CUDA=$(patsubst ../../src/alpaka/%.dev.cc, %_cuda.o, $(LSTSOURCES)) -LSTOBJECTS_ROCM=$(patsubst ../../src/alpaka/%.dev.cc, %_rocm.o, $(LSTSOURCES)) +LSTSOURCES=../../src/alpaka/LST.cc +LSTOBJECTS_CPU=$(patsubst ../../src/alpaka/%.cc, %_cpu.o, $(LSTSOURCES)) +LSTOBJECTS_CUDA=$(patsubst ../../src/alpaka/%.cc, %_cuda.o, $(LSTSOURCES)) +LSTOBJECTS_ROCM=$(patsubst ../../src/alpaka/%.cc, %_rocm.o, $(LSTSOURCES)) # Default to CPU and CUDA backends ifeq ($(BACKEND),) @@ -51,15 +51,12 @@ CMSSWINCLUDE := -I${TRACKLOOPERDIR}/../../../ -I${CMSSW_BASE}/src ifdef CMSSW_RELEASE_BASE CMSSWINCLUDE := ${CMSSWINCLUDE} -I${CMSSW_RELEASE_BASE}/src endif -ALPAKAINCLUDE = -I${ALPAKA_ROOT}/include -I/${BOOST_ROOT}/include -std=c++17 ${CMSSWINCLUDE} +ALPAKAINCLUDE = -I${ALPAKA_ROOT}/include -I/${BOOST_ROOT}/include -std=c++20 ${CMSSWINCLUDE} ALPAKASERIAL = -DALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED -DALPAKA_DISABLE_VENDOR_RNG -DALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT=128 ALPAKACUDA = -DALPAKA_ACC_GPU_CUDA_ENABLED -DALPAKA_ACC_GPU_CUDA_ONLY -DALPAKA_DISABLE_VENDOR_RNG -DALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT=128 --expt-relaxed-constexpr -ALPAKAROCM = -DALPAKA_ACC_GPU_HIP_ENABLED -DALPAKA_ACC_GPU_HIP_ONLY -DALPAKA_DISABLE_VENDOR_RNG -DALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT=128 +ALPAKAROCM = -DALPAKA_ACC_GPU_HIP_ENABLED -DALPAKA_ACC_GPU_HIP_ONLY -DALPAKA_DISABLE_VENDOR_RNG -DALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT=128 -DGNU_GCC -D_GNU_SOURCE --target=x86_64-redhat-linux-gnu --gcc-toolchain=$(patsubst %/bin/gcc,%,$(shell command -v gcc)) ROOTINCLUDE = -I$(ROOT_ROOT)/include ROOTCFLAGS = -pthread -m64 $(ROOTINCLUDE) -PRINTFLAG = -DT4FromT3 -DUPLICATES = -DDUP_pLS -DDUP_T5 -DDUP_pT5 -DDUP_pT3 -DCrossclean_T5 -DCrossclean_pT3 #-DFP16_Base -CACHEFLAG = PTCUTFLAG = LSTWARNINGSFLAG = CMSSW_WERRORS_CPU = -Werror=pointer-arith -Werror=overlength-strings -Werror=return-type -Werror=missing-braces -Werror=unused-value -Werror=unused-label \ @@ -70,7 +67,6 @@ CMSSW_WERRORS_CPU = -Werror=pointer-arith -Werror=overlength-strings -Werror= -Wno-unused-parameter -Wno-unused-local-typedefs -Wno-attributes CMSSW_WERRORS_CUDA = $(patsubst %,-Xcompiler %,$(CMSSW_WERRORS_CPU)) CMSSW_WERRORS_ROCM = $(CMSSW_WERRORS_CPU) -CACHEFLAG_FLAGS = -DCACHE_ALLOC T5CUTFLAGS = $(T5DNNFLAG) $(T5RZCHI2FLAG) $(T5RPHICHI2FLAG) LD_CPU = g++ @@ -92,22 +88,31 @@ CUTVALUEFLAG = CUTVALUEFLAG_FLAGS = -DCUT_VALUE_DEBUG %_cpu.o: ../../src/alpaka/%.dev.cc - $(COMPILE_CMD_CPU) $(CXXFLAGS_CPU) $(ROOTINCLUDE) $(PRINTFLAG) $(CACHEFLAG) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_CPU) $(T5CUTFLAGS) $(PTCUTFLAG) $(DUPLICATES) $(ALPAKAINCLUDE) $(ALPAKABACKEND_CPU) $< -o $@ + $(COMPILE_CMD_CPU) $(CXXFLAGS_CPU) $(ROOTINCLUDE) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_CPU) $(T5CUTFLAGS) $(PTCUTFLAG) $(ALPAKAINCLUDE) $(ALPAKABACKEND_CPU) $< -o $@ %_cuda.o: ../../src/alpaka/%.dev.cc - $(COMPILE_CMD_CUDA) $(CXXFLAGS_CUDA) $(ROOTINCLUDE) $(PRINTFLAG) $(CACHEFLAG) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_CUDA) $(T5CUTFLAGS) $(PTCUTFLAG) $(DUPLICATES) $(ALPAKAINCLUDE) $(ALPAKABACKEND_CUDA) $< -o $@ + $(COMPILE_CMD_CUDA) $(CXXFLAGS_CUDA) $(ROOTINCLUDE) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_CUDA) $(T5CUTFLAGS) $(PTCUTFLAG) $(ALPAKAINCLUDE) $(ALPAKABACKEND_CUDA) $< -o $@ %_rocm.o: ../../src/alpaka/%.dev.cc - $(COMPILE_CMD_ROCM) $(CXXFLAGS_ROCM) $(ROOTINCLUDE) $(PRINTFLAG) $(CACHEFLAG) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_ROCM) $(T5CUTFLAGS) $(PTCUTFLAG) $(DUPLICATES) $(ALPAKAINCLUDE) $(ALPAKABACKEND_ROCM) $< -o $@ + $(COMPILE_CMD_ROCM) $(CXXFLAGS_ROCM) $(ROOTINCLUDE) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_ROCM) $(T5CUTFLAGS) $(PTCUTFLAG) $(ALPAKAINCLUDE) $(ALPAKABACKEND_ROCM) $< -o $@ + +%_cpu.o: ../../src/alpaka/%.cc + $(COMPILE_CMD_CPU) $(CXXFLAGS_CPU) $(ROOTINCLUDE) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_CPU) $(T5CUTFLAGS) $(PTCUTFLAG) $(ALPAKAINCLUDE) $(ALPAKABACKEND_CPU) $< -o $@ + +%_cuda.o: ../../src/alpaka/%.cc + $(COMPILE_CMD_CUDA) $(CXXFLAGS_CUDA) $(ROOTINCLUDE) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_CUDA) $(T5CUTFLAGS) $(PTCUTFLAG) $(ALPAKAINCLUDE) $(ALPAKABACKEND_CUDA) $< -o $@ + +%_rocm.o: ../../src/alpaka/%.cc + $(COMPILE_CMD_ROCM) $(CXXFLAGS_ROCM) $(ROOTINCLUDE) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_ROCM) $(T5CUTFLAGS) $(PTCUTFLAG) $(ALPAKAINCLUDE) $(ALPAKABACKEND_ROCM) $< -o $@ %_cpu.o: ../../src/%.cc - $(COMPILE_CMD_CPU) $(CXXFLAGS_CPU) $(ROOTINCLUDE) $(PRINTFLAG) $(CACHEFLAG) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_CPU) $(T5CUTFLAGS) $(PTCUTFLAG) $(DUPLICATES) $(ALPAKAINCLUDE) $(ALPAKABACKEND_CPU) $< -o $@ + $(COMPILE_CMD_CPU) $(CXXFLAGS_CPU) $(ROOTINCLUDE) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_CPU) $(T5CUTFLAGS) $(PTCUTFLAG) $(ALPAKAINCLUDE) $(ALPAKABACKEND_CPU) $< -o $@ %_cuda.o: ../../src/%.cc - $(COMPILE_CMD_CUDA) $(CXXFLAGS_CUDA) $(ROOTINCLUDE) $(PRINTFLAG) $(CACHEFLAG) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_CUDA) $(T5CUTFLAGS) $(PTCUTFLAG) $(DUPLICATES) $(ALPAKAINCLUDE) $(ALPAKABACKEND_CUDA) $< -o $@ + $(COMPILE_CMD_CUDA) $(CXXFLAGS_CUDA) $(ROOTINCLUDE) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_CUDA) $(T5CUTFLAGS) $(PTCUTFLAG) $(ALPAKAINCLUDE) $(ALPAKABACKEND_CUDA) $< -o $@ %_rocm.o: ../../src/%.cc - $(COMPILE_CMD_ROCM) $(CXXFLAGS_ROCM) $(ROOTINCLUDE) $(PRINTFLAG) $(CACHEFLAG) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_ROCM) $(T5CUTFLAGS) $(PTCUTFLAG) $(DUPLICATES) $(ALPAKAINCLUDE) $(ALPAKABACKEND_ROCM) $< -o $@ + $(COMPILE_CMD_ROCM) $(CXXFLAGS_ROCM) $(ROOTINCLUDE) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_ROCM) $(T5CUTFLAGS) $(PTCUTFLAG) $(ALPAKAINCLUDE) $(ALPAKABACKEND_ROCM) $< -o $@ $(LIB_CPU): $(CCOBJECTS_CPU) $(LSTOBJECTS_CPU) $(LD_CPU) $(SOFLAGS_CPU) $^ -o $@ @@ -120,12 +125,8 @@ $(LIB_ROCM): $(CCOBJECTS_ROCM) $(LSTOBJECTS_ROCM) explicit: $(LIBS) -explicit_cache: CACHEFLAG += $(CACHEFLAG_FLAGS) -explicit_cache: $(LIBS) - -explicit_cache_cutvalue: CUTVALUEFLAG = $(CUTVALUEFLAG_FLAGS) -explicit_cache_cutvalue: CACHEFLAG += $(CACHEFLAG_FLAGS) -explicit_cache_cutvalue: $(LIBS) +explicit_cutvalue: CUTVALUEFLAG = $(CUTVALUEFLAG_FLAGS) +explicit_cutvalue: $(LIBS) clean: rm -f *.opp @@ -133,7 +134,7 @@ clean: rm -f *.d rm -f *.so -.PHONY: clean explicit explicit_cache explicit_cache_cutvalue format check check-fix +.PHONY: clean explicit explicit_cutvalue format check check-fix format: clang-format --style=file:../.clang-format -i *.cc *.h @@ -141,7 +142,7 @@ format: # Collect all the include paths from the compiler. # The .../gcc/x86_64-redhat-linux-gnu/*/include path is excluded since .../gcc/x86_64-redhat-linux-gnu/*/include-fixed should be used instead. TIDYINCLUDEFLAGS := $(shell g++ -E -x c++ - -v < /dev/null 2>&1 | awk '/#include <...>/,/^End of search/{if (/^ / && !/x86_64-redhat-linux-gnu\/[0-9.]+\/include$$/) print "-I"$$1}' | tr '\n' ' ') -TIDYFLAGS := --language=c++ $(CXXFLAGS_CPU) $(ALPAKAINCLUDE) $(ALPAKASERIAL) $(ROOTCFLAGS) $(PRINTFLAG) $(DUPLICATED) $(CACHEFLAG_FLAGS) $(TIDYINCLUDEFLAGS) +TIDYFLAGS := --language=c++ $(CXXFLAGS_CPU) $(ALPAKAINCLUDE) $(ALPAKASERIAL) $(ROOTCFLAGS) $(DUPLICATED) $(TIDYINCLUDEFLAGS) check: clang-tidy --config-file=../.clang-tidy *.cc *.h -- $(TIDYFLAGS) diff --git a/RecoTracker/LSTCore/standalone/Makefile b/RecoTracker/LSTCore/standalone/Makefile index 8eb677611513e..b98df31df1b5e 100644 --- a/RecoTracker/LSTCore/standalone/Makefile +++ b/RecoTracker/LSTCore/standalone/Makefile @@ -9,7 +9,7 @@ OBJECTS_ROCM=$(SOURCES:.cc=_rocm.o) OBJECTS=$(OBJECTS_CPU) $(OBJECTS_CUDA) $(OBJECTS_ROCM) CXX = g++ -CXXFLAGS = -g -O2 -Wall -fPIC -Woverloaded-virtual -Wno-unused-function -fno-var-tracking -std=c++17 +CXXFLAGS = -g -O2 -Wall -fPIC -Woverloaded-virtual -Wno-unused-function -fno-var-tracking -std=c++20 INCLUDEFLAGS= -ILST -I$(shell pwd) -Icode -Icode/core -I${ALPAKA_ROOT}/include -I/${BOOST_ROOT}/include $(shell rooutil-config --include) -I$(shell root-config --incdir) -I${TRACKLOOPERDIR}/../../../ -I${CMSSW_BASE}/src -I../interface/ -I../interface/alpaka/ -I../src/ -I../src/alpaka/ ifdef CMSSW_RELEASE_BASE INCLUDEFLAGS:= ${INCLUDEFLAGS} -I${CMSSW_RELEASE_BASE}/src diff --git a/RecoTracker/LSTCore/standalone/bin/lst.cc b/RecoTracker/LSTCore/standalone/bin/lst.cc index ca8126c8ae4c4..369680bc4309e 100644 --- a/RecoTracker/LSTCore/standalone/bin/lst.cc +++ b/RecoTracker/LSTCore/standalone/bin/lst.cc @@ -2,7 +2,7 @@ #include -using LSTEvent = ALPAKA_ACCELERATOR_NAMESPACE::lst::Event; +using LSTEvent = ALPAKA_ACCELERATOR_NAMESPACE::lst::LSTEvent; using namespace ::lst; //___________________________________________________________________________________________________________________________________________________________________________________________ @@ -415,6 +415,7 @@ void run_lst() { if (ana.verbose >= 1) std::cout << "Running Event number = " << evt << " " << omp_get_thread_num() << std::endl; + events.at(omp_get_thread_num())->initSync(); timing_input_loading = addInputsToEventPreLoad(events.at(omp_get_thread_num()), false, out_trkX.at(evt), diff --git a/RecoTracker/LSTCore/standalone/bin/lst.h b/RecoTracker/LSTCore/standalone/bin/lst.h index 5a951552ba647..e800aee6a0ce9 100644 --- a/RecoTracker/LSTCore/standalone/bin/lst.h +++ b/RecoTracker/LSTCore/standalone/bin/lst.h @@ -1,7 +1,7 @@ #ifndef lst_h #define lst_h -#include "Event.h" +#include "LSTEvent.h" #include "LST.h" #include diff --git a/RecoTracker/LSTCore/standalone/bin/lst_make_tracklooper b/RecoTracker/LSTCore/standalone/bin/lst_make_tracklooper index bb77aa67cdf7f..7686b3df42bf5 100755 --- a/RecoTracker/LSTCore/standalone/bin/lst_make_tracklooper +++ b/RecoTracker/LSTCore/standalone/bin/lst_make_tracklooper @@ -19,7 +19,6 @@ usage() echo echo "Options:" echo " -h Help (Display this message)" - echo " -c cache (Make library with cache enabled)" echo " -s show log (Full compilation script to stdout)" echo " -m make clean binaries (Make clean binaries before remake. e.g. when header files changed in LST/*.h)" echo " -d cut value ntuple (With extra variables in a debug ntuple file)" @@ -43,7 +42,6 @@ while getopts ":cxgsmdp3NCGRA2ehwP:" OPTION; do m) MAKECLEANBINARIES=true;; d) MAKECUTVALUES=true;; p) PRIMITIVE=true;; - N) DONTUSENN=true;; G) CUDABACKEND=true;; C) CPUBACKEND=true;; R) ROCMBACKEND=true;; @@ -61,7 +59,6 @@ if [ -z ${SHOWLOG} ]; then SHOWLOG=false; fi if [ -z ${MAKECLEANBINARIES} ]; then MAKECLEANBINARIES=false; fi if [ -z ${MAKECUTVALUES} ]; then MAKECUTVALUES=false; fi if [ -z ${PRIMITIVE} ]; then PRIMITIVE=false; fi -if [ -z ${DONTUSENN} ]; then DONTUSENN=false; fi if [ -z ${CPUBACKEND} ]; then CPUBACKEND=false; fi if [ -z ${CUDABACKEND} ]; then CUDABACKEND=false; fi if [ -z ${ROCMBACKEND} ]; then ROCMBACKEND=false; fi @@ -96,12 +93,10 @@ echo "Line Segment Tracking Compilation Script " | tee -a ${LOG} echo "=====================================================" | tee -a ${LOG} echo "Compilation options set to..." | tee -a ${LOG} echo "" | tee -a ${LOG} -echo " MAKECACHE : ${MAKECACHE}" | tee -a ${LOG} echo " SHOWLOG : ${SHOWLOG}" | tee -a ${LOG} echo " MAKECLEANBINARIES : ${MAKECLEANBINARIES}" | tee -a ${LOG} echo " MAKECUTVALUES : ${MAKECUTVALUES}" | tee -a ${LOG} echo " PRIMITIVE : ${PRIMITIVE}" | tee -a ${LOG} -echo " DONTUSENN : ${DONTUSENN}" | tee -a ${LOG} echo " CPUBACKEND : ${CPUBACKEND}" | tee -a ${LOG} echo " CUDABACKEND : ${CUDABACKEND}" | tee -a ${LOG} echo " ROCMBACKEND : ${ROCMBACKEND}" | tee -a ${LOG} @@ -116,10 +111,8 @@ TRACKLOOPERTARGET= # If make explicit is true then make library with explicit memory on GPU MAKETARGET=explicit; -# If make cache is true then make library with cache enabled -if $MAKECACHE; then MAKETARGET=${MAKETARGET}_cache; fi - -# If make cache is true then make library with cache enabled +# Show deprecation warning for cache flag +if $MAKECACHE; then echo "Warning: the -c flag is deprecated"; fi # If make clean binaries are called then first make clean before making if $MAKECLEANBINARIES; then @@ -141,13 +134,6 @@ if $PRIMITIVE; then echo "debug : MAKETARGET=${MAKETARGET}" fi -T5CUTOPT= -if $DONTUSENN; then - T5CUTOPT="T5RZCHI2FLAG=-DUSE_RZCHI2 T5RPHICHI2FLAG=-DUSE_RPHICHI2" -else - T5CUTOPT="T5RZCHI2FLAG=-DUSE_RZCHI2 T5DNNFLAG=-DUSE_T5_DNN" -fi - BACKENDOPT="BACKEND=" EXES= if [ "${ALLBACKENDS}" == true ]; then @@ -175,6 +161,10 @@ fi PTCUTOPT="PTCUTFLAG=-DPT_CUT=${PTCUTVALUE}" +if [ -z "${MAXMAKETHREADS}" ]; then + MAXMAKETHREADS=32 +fi + ### ### ### Making Line Segment Tracking Library @@ -187,9 +177,9 @@ echo "-------------------------------------------------------------------------- echo "---------------------------------------------------------------------------------------------" >> ${LOG} 2>&1 echo "---------------------------------------------------------------------------------------------" >> ${LOG} 2>&1 if $SHOWLOG; then - (cd LST && make clean && make ${T5CUTOPT} ${BACKENDOPT} ${PRINTWARNINGSOPT} ${PTCUTOPT} -j 32 ${MAKETARGET} && cd -) 2>&1 | tee -a ${LOG} + (cd LST && make clean && make ${BACKENDOPT} ${PRINTWARNINGSOPT} ${PTCUTOPT} -j ${MAXMAKETHREADS} ${MAKETARGET} && cd -) 2>&1 | tee -a ${LOG} else - (cd LST && make clean && make ${T5CUTOPT} ${BACKENDOPT} ${PRINTWARNINGSOPT} ${PTCUTOPT} -j 32 ${MAKETARGET} && cd -) >> ${LOG} 2>&1 + (cd LST && make clean && make ${BACKENDOPT} ${PRINTWARNINGSOPT} ${PTCUTOPT} -j ${MAXMAKETHREADS} ${MAKETARGET} && cd -) >> ${LOG} 2>&1 fi if ([[ "$BACKENDOPT" == *"all"* ]] || [[ "$BACKENDOPT" == *"cpu"* ]]) && [ ! -f LST/liblst_cpu.so ]; then @@ -224,9 +214,9 @@ echo "-------------------------------------------------------------------------- echo "---------------------------------------------------------------------------------------------" >> ${LOG} 2>&1 echo "---------------------------------------------------------------------------------------------" >> ${LOG} 2>&1 if $SHOWLOG; then - make EXES="${EXES}" ${TRACKLOOPERTARGET} ${PTCUTOPT} -j 2>&1 | tee -a ${LOG} + make EXES="${EXES}" ${TRACKLOOPERTARGET} ${PTCUTOPT} -j ${MAXMAKETHREADS} 2>&1 | tee -a ${LOG} else - make EXES="${EXES}" ${TRACKLOOPERTARGET} ${PTCUTOPT} -j >> ${LOG} 2>&1 + make EXES="${EXES}" ${TRACKLOOPERTARGET} ${PTCUTOPT} -j ${MAXMAKETHREADS} >> ${LOG} 2>&1 fi if ([[ "$BACKENDOPT" == *"all"* ]] || [[ "$BACKENDOPT" == *"cpu"* ]]) && [ ! -f bin/lst_cpu ]; then diff --git a/RecoTracker/LSTCore/standalone/code/core/AccessHelper.cc b/RecoTracker/LSTCore/standalone/code/core/AccessHelper.cc index 634f0ed753b71..ed0ff994f5941 100644 --- a/RecoTracker/LSTCore/standalone/code/core/AccessHelper.cc +++ b/RecoTracker/LSTCore/standalone/code/core/AccessHelper.cc @@ -8,7 +8,7 @@ using namespace ALPAKA_ACCELERATOR_NAMESPACE::lst; //____________________________________________________________________________________________ std::tuple, std::vector> convertHitsToHitIdxsAndHitTypes( - Event* event, std::vector hits) { + LSTEvent* event, std::vector hits) { auto hitsEvt = event->getHits(); std::vector hitidxs; std::vector hittypes; @@ -27,7 +27,7 @@ std::tuple, std::vector> convertHitsToHi // =============== //____________________________________________________________________________________________ -std::vector getPixelHitsFrompLS(Event* event, unsigned int pLS) { +std::vector getPixelHitsFrompLS(LSTEvent* event, unsigned int pLS) { SegmentsConst segments = event->getSegments(); MiniDoubletsConst miniDoublets = event->getMiniDoublets(); auto ranges = event->getRanges(); @@ -46,7 +46,7 @@ std::vector getPixelHitsFrompLS(Event* event, unsigned int pLS) { } //____________________________________________________________________________________________ -std::vector getPixelHitIdxsFrompLS(Event* event, unsigned int pLS) { +std::vector getPixelHitIdxsFrompLS(LSTEvent* event, unsigned int pLS) { auto hitsEvt = event->getHits(); std::vector hits = getPixelHitsFrompLS(event, pLS); std::vector hitidxs; @@ -56,14 +56,14 @@ std::vector getPixelHitIdxsFrompLS(Event* event, unsigned int pLS) } //____________________________________________________________________________________________ -std::vector getPixelHitTypesFrompLS(Event* event, unsigned int pLS) { +std::vector getPixelHitTypesFrompLS(LSTEvent* event, unsigned int pLS) { std::vector hits = getPixelHitsFrompLS(event, pLS); std::vector hittypes(hits.size(), 0); return hittypes; } //____________________________________________________________________________________________ -std::tuple, std::vector> getHitIdxsAndHitTypesFrompLS(Event* event, +std::tuple, std::vector> getHitIdxsAndHitTypesFrompLS(LSTEvent* event, unsigned pLS) { return convertHitsToHitIdxsAndHitTypes(event, getPixelHitsFrompLS(event, pLS)); } @@ -73,7 +73,7 @@ std::tuple, std::vector> getHitIdxsAndHi // ============== //____________________________________________________________________________________________ -std::vector getHitsFromMD(Event* event, unsigned int MD) { +std::vector getHitsFromMD(LSTEvent* event, unsigned int MD) { MiniDoubletsConst miniDoublets = event->getMiniDoublets(); unsigned int hit_1 = miniDoublets.anchorHitIndices()[MD]; unsigned int hit_2 = miniDoublets.outerHitIndices()[MD]; @@ -81,7 +81,7 @@ std::vector getHitsFromMD(Event* event, unsigned int MD) { } //____________________________________________________________________________________________ -std::tuple, std::vector> getHitIdxsAndHitTypesFromMD(Event* event, +std::tuple, std::vector> getHitIdxsAndHitTypesFromMD(LSTEvent* event, unsigned MD) { return convertHitsToHitIdxsAndHitTypes(event, getHitsFromMD(event, MD)); } @@ -91,7 +91,7 @@ std::tuple, std::vector> getHitIdxsAndHi // ============== //____________________________________________________________________________________________ -std::vector getMDsFromLS(Event* event, unsigned int LS) { +std::vector getMDsFromLS(LSTEvent* event, unsigned int LS) { SegmentsConst segments = event->getSegments(); unsigned int MD_1 = segments.mdIndices()[LS][0]; unsigned int MD_2 = segments.mdIndices()[LS][1]; @@ -99,7 +99,7 @@ std::vector getMDsFromLS(Event* event, unsigned int LS) { } //____________________________________________________________________________________________ -std::vector getHitsFromLS(Event* event, unsigned int LS) { +std::vector getHitsFromLS(LSTEvent* event, unsigned int LS) { std::vector MDs = getMDsFromLS(event, LS); std::vector hits_0 = getHitsFromMD(event, MDs[0]); std::vector hits_1 = getHitsFromMD(event, MDs[1]); @@ -107,7 +107,7 @@ std::vector getHitsFromLS(Event* event, unsigned int LS) { } //____________________________________________________________________________________________ -std::tuple, std::vector> getHitIdxsAndHitTypesFromLS(Event* event, +std::tuple, std::vector> getHitIdxsAndHitTypesFromLS(LSTEvent* event, unsigned LS) { return convertHitsToHitIdxsAndHitTypes(event, getHitsFromLS(event, LS)); } @@ -117,7 +117,7 @@ std::tuple, std::vector> getHitIdxsAndHi // ============== //____________________________________________________________________________________________ -std::vector getLSsFromT3(Event* event, unsigned int t3) { +std::vector getLSsFromT3(LSTEvent* event, unsigned int t3) { auto const triplets = event->getTriplets(); unsigned int ls_1 = triplets.segmentIndices()[t3][0]; unsigned int ls_2 = triplets.segmentIndices()[t3][1]; @@ -125,7 +125,7 @@ std::vector getLSsFromT3(Event* event, unsigned int t3) { } //____________________________________________________________________________________________ -std::vector getMDsFromT3(Event* event, unsigned int T3) { +std::vector getMDsFromT3(LSTEvent* event, unsigned int T3) { std::vector LSs = getLSsFromT3(event, T3); std::vector MDs_0 = getMDsFromLS(event, LSs[0]); std::vector MDs_1 = getMDsFromLS(event, LSs[1]); @@ -133,7 +133,7 @@ std::vector getMDsFromT3(Event* event, unsigned int T3) { } //____________________________________________________________________________________________ -std::vector getHitsFromT3(Event* event, unsigned int T3) { +std::vector getHitsFromT3(LSTEvent* event, unsigned int T3) { std::vector MDs = getMDsFromT3(event, T3); std::vector hits_0 = getHitsFromMD(event, MDs[0]); std::vector hits_1 = getHitsFromMD(event, MDs[1]); @@ -142,7 +142,7 @@ std::vector getHitsFromT3(Event* event, unsigned int T3) { } //____________________________________________________________________________________________ -std::tuple, std::vector> getHitIdxsAndHitTypesFromT3(Event* event, +std::tuple, std::vector> getHitIdxsAndHitTypesFromT3(LSTEvent* event, unsigned T3) { return convertHitsToHitIdxsAndHitTypes(event, getHitsFromT3(event, T3)); } @@ -152,7 +152,7 @@ std::tuple, std::vector> getHitIdxsAndHi // ============== //____________________________________________________________________________________________ -std::vector getT3sFromT5(Event* event, unsigned int t5) { +std::vector getT3sFromT5(LSTEvent* event, unsigned int t5) { auto const quintuplets = event->getQuintuplets(); unsigned int t3_1 = quintuplets.tripletIndices()[t5][0]; unsigned int t3_2 = quintuplets.tripletIndices()[t5][1]; @@ -160,7 +160,7 @@ std::vector getT3sFromT5(Event* event, unsigned int t5) { } //____________________________________________________________________________________________ -std::vector getLSsFromT5(Event* event, unsigned int T5) { +std::vector getLSsFromT5(LSTEvent* event, unsigned int T5) { std::vector T3s = getT3sFromT5(event, T5); std::vector LSs_0 = getLSsFromT3(event, T3s[0]); std::vector LSs_1 = getLSsFromT3(event, T3s[1]); @@ -168,7 +168,7 @@ std::vector getLSsFromT5(Event* event, unsigned int T5) { } //____________________________________________________________________________________________ -std::vector getMDsFromT5(Event* event, unsigned int T5) { +std::vector getMDsFromT5(LSTEvent* event, unsigned int T5) { std::vector LSs = getLSsFromT5(event, T5); std::vector MDs_0 = getMDsFromLS(event, LSs[0]); std::vector MDs_1 = getMDsFromLS(event, LSs[1]); @@ -178,7 +178,7 @@ std::vector getMDsFromT5(Event* event, unsigned int T5) { } //____________________________________________________________________________________________ -std::vector getHitsFromT5(Event* event, unsigned int T5) { +std::vector getHitsFromT5(LSTEvent* event, unsigned int T5) { std::vector MDs = getMDsFromT5(event, T5); std::vector hits_0 = getHitsFromMD(event, MDs[0]); std::vector hits_1 = getHitsFromMD(event, MDs[1]); @@ -189,7 +189,7 @@ std::vector getHitsFromT5(Event* event, unsigned int T5) { } //____________________________________________________________________________________________ -std::vector getHitIdxsFromT5(Event* event, unsigned int T5) { +std::vector getHitIdxsFromT5(LSTEvent* event, unsigned int T5) { auto hitsEvt = event->getHits(); std::vector hits = getHitsFromT5(event, T5); std::vector hitidxs; @@ -198,7 +198,7 @@ std::vector getHitIdxsFromT5(Event* event, unsigned int T5) { return hitidxs; } //____________________________________________________________________________________________ -std::vector getModuleIdxsFromT5(Event* event, unsigned int T5) { +std::vector getModuleIdxsFromT5(LSTEvent* event, unsigned int T5) { std::vector hits = getHitsFromT5(event, T5); std::vector module_idxs; auto hitsEvt = event->getHits(); @@ -208,13 +208,13 @@ std::vector getModuleIdxsFromT5(Event* event, unsigned int T5) { return module_idxs; } //____________________________________________________________________________________________ -std::vector getHitTypesFromT5(Event* event, unsigned int T5) { +std::vector getHitTypesFromT5(LSTEvent* event, unsigned int T5) { return {4, 4, 4, 4, 4, 4, 4, 4, 4, 4}; ; } //____________________________________________________________________________________________ -std::tuple, std::vector> getHitIdxsAndHitTypesFromT5(Event* event, +std::tuple, std::vector> getHitIdxsAndHitTypesFromT5(LSTEvent* event, unsigned T5) { return convertHitsToHitIdxsAndHitTypes(event, getHitsFromT5(event, T5)); } @@ -224,7 +224,7 @@ std::tuple, std::vector> getHitIdxsAndHi // =============== //____________________________________________________________________________________________ -unsigned int getPixelLSFrompT3(Event* event, unsigned int pT3) { +unsigned int getPixelLSFrompT3(LSTEvent* event, unsigned int pT3) { auto const pixelTriplets = event->getPixelTriplets(); auto ranges = event->getRanges(); auto modulesEvt = event->getModules(); @@ -233,37 +233,37 @@ unsigned int getPixelLSFrompT3(Event* event, unsigned int pT3) { } //____________________________________________________________________________________________ -unsigned int getT3FrompT3(Event* event, unsigned int pT3) { +unsigned int getT3FrompT3(LSTEvent* event, unsigned int pT3) { auto const pixelTriplets = event->getPixelTriplets(); return pixelTriplets.tripletIndices()[pT3]; } //____________________________________________________________________________________________ -std::vector getLSsFrompT3(Event* event, unsigned int pT3) { +std::vector getLSsFrompT3(LSTEvent* event, unsigned int pT3) { unsigned int T3 = getT3FrompT3(event, pT3); return getLSsFromT3(event, T3); } //____________________________________________________________________________________________ -std::vector getMDsFrompT3(Event* event, unsigned int pT3) { +std::vector getMDsFrompT3(LSTEvent* event, unsigned int pT3) { unsigned int T3 = getT3FrompT3(event, pT3); return getMDsFromT3(event, T3); } //____________________________________________________________________________________________ -std::vector getOuterTrackerHitsFrompT3(Event* event, unsigned int pT3) { +std::vector getOuterTrackerHitsFrompT3(LSTEvent* event, unsigned int pT3) { unsigned int T3 = getT3FrompT3(event, pT3); return getHitsFromT3(event, T3); } //____________________________________________________________________________________________ -std::vector getPixelHitsFrompT3(Event* event, unsigned int pT3) { +std::vector getPixelHitsFrompT3(LSTEvent* event, unsigned int pT3) { unsigned int pLS = getPixelLSFrompT3(event, pT3); return getPixelHitsFrompLS(event, pLS); } //____________________________________________________________________________________________ -std::vector getHitsFrompT3(Event* event, unsigned int pT3) { +std::vector getHitsFrompT3(LSTEvent* event, unsigned int pT3) { unsigned int pLS = getPixelLSFrompT3(event, pT3); unsigned int T3 = getT3FrompT3(event, pT3); std::vector pixelHits = getPixelHitsFrompLS(event, pLS); @@ -273,7 +273,7 @@ std::vector getHitsFrompT3(Event* event, unsigned int pT3) { } //____________________________________________________________________________________________ -std::vector getHitIdxsFrompT3(Event* event, unsigned int pT3) { +std::vector getHitIdxsFrompT3(LSTEvent* event, unsigned int pT3) { auto hitsEvt = event->getHits(); std::vector hits = getHitsFrompT3(event, pT3); std::vector hitidxs; @@ -282,7 +282,7 @@ std::vector getHitIdxsFrompT3(Event* event, unsigned int pT3) { return hitidxs; } //____________________________________________________________________________________________ -std::vector getModuleIdxsFrompT3(Event* event, unsigned int pT3) { +std::vector getModuleIdxsFrompT3(LSTEvent* event, unsigned int pT3) { std::vector hits = getOuterTrackerHitsFrompT3(event, pT3); std::vector module_idxs; auto hitsEvt = event->getHits(); @@ -292,7 +292,7 @@ std::vector getModuleIdxsFrompT3(Event* event, unsigned int pT3) { return module_idxs; } //____________________________________________________________________________________________ -std::vector getHitTypesFrompT3(Event* event, unsigned int pT3) { +std::vector getHitTypesFrompT3(LSTEvent* event, unsigned int pT3) { unsigned int pLS = getPixelLSFrompT3(event, pT3); std::vector pixelHits = getPixelHitsFrompLS(event, pLS); // pixel Hits list will be either 3 or 4 and depending on it return accordingly @@ -303,7 +303,7 @@ std::vector getHitTypesFrompT3(Event* event, unsigned int pT3) { } //____________________________________________________________________________________________ -std::tuple, std::vector> getHitIdxsAndHitTypesFrompT3(Event* event, +std::tuple, std::vector> getHitIdxsAndHitTypesFrompT3(LSTEvent* event, unsigned pT3) { return convertHitsToHitIdxsAndHitTypes(event, getHitsFrompT3(event, pT3)); } @@ -313,7 +313,7 @@ std::tuple, std::vector> getHitIdxsAndHi // =============== //____________________________________________________________________________________________ -unsigned int getPixelLSFrompT5(Event* event, unsigned int pT5) { +unsigned int getPixelLSFrompT5(LSTEvent* event, unsigned int pT5) { auto const pixelQuintuplets = event->getPixelQuintuplets(); auto ranges = event->getRanges(); auto modulesEvt = event->getModules(); @@ -322,43 +322,43 @@ unsigned int getPixelLSFrompT5(Event* event, unsigned int pT5) { } //____________________________________________________________________________________________ -unsigned int getT5FrompT5(Event* event, unsigned int pT5) { +unsigned int getT5FrompT5(LSTEvent* event, unsigned int pT5) { auto const pixelQuintuplets = event->getPixelQuintuplets(); return pixelQuintuplets.quintupletIndices()[pT5]; } //____________________________________________________________________________________________ -std::vector getT3sFrompT5(Event* event, unsigned int pT5) { +std::vector getT3sFrompT5(LSTEvent* event, unsigned int pT5) { unsigned int T5 = getT5FrompT5(event, pT5); return getT3sFromT5(event, T5); } //____________________________________________________________________________________________ -std::vector getLSsFrompT5(Event* event, unsigned int pT5) { +std::vector getLSsFrompT5(LSTEvent* event, unsigned int pT5) { unsigned int T5 = getT5FrompT5(event, pT5); return getLSsFromT5(event, T5); } //____________________________________________________________________________________________ -std::vector getMDsFrompT5(Event* event, unsigned int pT5) { +std::vector getMDsFrompT5(LSTEvent* event, unsigned int pT5) { unsigned int T5 = getT5FrompT5(event, pT5); return getMDsFromT5(event, T5); } //____________________________________________________________________________________________ -std::vector getOuterTrackerHitsFrompT5(Event* event, unsigned int pT5) { +std::vector getOuterTrackerHitsFrompT5(LSTEvent* event, unsigned int pT5) { unsigned int T5 = getT5FrompT5(event, pT5); return getHitsFromT5(event, T5); } //____________________________________________________________________________________________ -std::vector getPixelHitsFrompT5(Event* event, unsigned int pT5) { +std::vector getPixelHitsFrompT5(LSTEvent* event, unsigned int pT5) { unsigned int pLS = getPixelLSFrompT5(event, pT5); return getPixelHitsFrompLS(event, pLS); } //____________________________________________________________________________________________ -std::vector getHitsFrompT5(Event* event, unsigned int pT5) { +std::vector getHitsFrompT5(LSTEvent* event, unsigned int pT5) { unsigned int pLS = getPixelLSFrompT5(event, pT5); unsigned int T5 = getT5FrompT5(event, pT5); std::vector pixelHits = getPixelHitsFrompLS(event, pLS); @@ -368,7 +368,7 @@ std::vector getHitsFrompT5(Event* event, unsigned int pT5) { } //____________________________________________________________________________________________ -std::vector getHitIdxsFrompT5(Event* event, unsigned int pT5) { +std::vector getHitIdxsFrompT5(LSTEvent* event, unsigned int pT5) { auto hitsEvt = event->getHits(); std::vector hits = getHitsFrompT5(event, pT5); std::vector hitidxs; @@ -378,7 +378,7 @@ std::vector getHitIdxsFrompT5(Event* event, unsigned int pT5) { } //____________________________________________________________________________________________ -std::vector getModuleIdxsFrompT5(Event* event, unsigned int pT5) { +std::vector getModuleIdxsFrompT5(LSTEvent* event, unsigned int pT5) { std::vector hits = getOuterTrackerHitsFrompT5(event, pT5); std::vector module_idxs; auto hitsEvt = event->getHits(); @@ -389,7 +389,7 @@ std::vector getModuleIdxsFrompT5(Event* event, unsigned int pT5) { } //____________________________________________________________________________________________ -std::vector getHitTypesFrompT5(Event* event, unsigned int pT5) { +std::vector getHitTypesFrompT5(LSTEvent* event, unsigned int pT5) { unsigned int pLS = getPixelLSFrompT5(event, pT5); std::vector pixelHits = getPixelHitsFrompLS(event, pLS); // pixel Hits list will be either 3 or 4 and depending on it return accordingly @@ -400,7 +400,7 @@ std::vector getHitTypesFrompT5(Event* event, unsigned int pT5) { } //____________________________________________________________________________________________ -std::tuple, std::vector> getHitIdxsAndHitTypesFrompT5(Event* event, +std::tuple, std::vector> getHitIdxsAndHitTypesFrompT5(LSTEvent* event, unsigned pT5) { return convertHitsToHitIdxsAndHitTypes(event, getHitsFrompT5(event, pT5)); } @@ -410,45 +410,45 @@ std::tuple, std::vector> getHitIdxsAndHi // ============== //____________________________________________________________________________________________ -std::vector getLSsFromTC(Event* event, unsigned int iTC) { +std::vector getLSsFromTC(LSTEvent* event, unsigned int iTC) { // Get the type of the track candidate auto const& trackCandidates = event->getTrackCandidates(); short type = trackCandidates.trackCandidateType()[iTC]; unsigned int objidx = trackCandidates.directObjectIndices()[iTC]; switch (type) { - case kpT5: + case lst::LSTObjType::pT5: return getLSsFrompT5(event, objidx); break; - case kpT3: + case lst::LSTObjType::pT3: return getLSsFrompT3(event, objidx); break; - case kT5: + case lst::LSTObjType::T5: return getLSsFromT5(event, objidx); break; - case kpLS: + case lst::LSTObjType::pLS: return std::vector(); break; } } //____________________________________________________________________________________________ -std::tuple, std::vector> getHitIdxsAndHitTypesFromTC(Event* event, +std::tuple, std::vector> getHitIdxsAndHitTypesFromTC(LSTEvent* event, unsigned iTC) { // Get the type of the track candidate auto const& trackCandidates = event->getTrackCandidates(); short type = trackCandidates.trackCandidateType()[iTC]; unsigned int objidx = trackCandidates.directObjectIndices()[iTC]; switch (type) { - case kpT5: + case lst::LSTObjType::pT5: return getHitIdxsAndHitTypesFrompT5(event, objidx); break; - case kpT3: + case lst::LSTObjType::pT3: return getHitIdxsAndHitTypesFrompT3(event, objidx); break; - case kT5: + case lst::LSTObjType::T5: return getHitIdxsAndHitTypesFromT5(event, objidx); break; - case kpLS: + case lst::LSTObjType::pLS: return getHitIdxsAndHitTypesFrompLS(event, objidx); break; } diff --git a/RecoTracker/LSTCore/standalone/code/core/AccessHelper.h b/RecoTracker/LSTCore/standalone/code/core/AccessHelper.h index 6c856b22915d4..dbec129a60562 100644 --- a/RecoTracker/LSTCore/standalone/code/core/AccessHelper.h +++ b/RecoTracker/LSTCore/standalone/code/core/AccessHelper.h @@ -3,11 +3,9 @@ #include #include -#include "Event.h" +#include "LSTEvent.h" -using LSTEvent = ALPAKA_ACCELERATOR_NAMESPACE::lst::Event; - -enum { kpT5 = 7, kpT3 = 5, kT5 = 4, kpLS = 8 }; +using LSTEvent = ALPAKA_ACCELERATOR_NAMESPACE::lst::LSTEvent; // ----* Hit *---- std::tuple, std::vector> convertHitsToHitIdxsAndHitTypes( diff --git a/RecoTracker/LSTCore/standalone/code/core/trkCore.h b/RecoTracker/LSTCore/standalone/code/core/trkCore.h index be18f02af2329..e1ff0a00bd002 100644 --- a/RecoTracker/LSTCore/standalone/code/core/trkCore.h +++ b/RecoTracker/LSTCore/standalone/code/core/trkCore.h @@ -1,7 +1,7 @@ #ifndef trkCore_h #define trkCore_h -#include "Event.h" +#include "LSTEvent.h" #include "Trktree.h" #include "TCanvas.h" @@ -12,7 +12,7 @@ #include #include -using LSTEvent = ALPAKA_ACCELERATOR_NAMESPACE::lst::Event; +using LSTEvent = ALPAKA_ACCELERATOR_NAMESPACE::lst::LSTEvent; using ::lst::PixelType; // --------------------- ======================== --------------------- diff --git a/RecoTracker/LSTCore/standalone/code/core/write_lst_ntuple.cc b/RecoTracker/LSTCore/standalone/code/core/write_lst_ntuple.cc index f1269840c9170..60f0cfd32a444 100644 --- a/RecoTracker/LSTCore/standalone/code/core/write_lst_ntuple.cc +++ b/RecoTracker/LSTCore/standalone/code/core/write_lst_ntuple.cc @@ -9,7 +9,7 @@ void createOutputBranches() { } //________________________________________________________________________________________________________________________________ -void fillOutputBranches(Event* event) { +void fillOutputBranches(LSTEvent* event) { setOutputBranches(event); setOptionalOutputBranches(event); if (ana.gnn_ntuple) @@ -183,7 +183,7 @@ void createGnnNtupleBranches() { } //________________________________________________________________________________________________________________________________ -void setOutputBranches(Event* event) { +void setOutputBranches(LSTEvent* event) { // ============ Sim tracks ============= int n_accepted_simtrk = 0; for (unsigned int isimtrk = 0; isimtrk < trk.sim_pt().size(); ++isimtrk) { @@ -278,7 +278,7 @@ void setOutputBranches(Event* event) { } //________________________________________________________________________________________________________________________________ -void setOptionalOutputBranches(Event* event) { +void setOptionalOutputBranches(LSTEvent* event) { #ifdef CUT_VALUE_DEBUG setPixelQuintupletOutputBranches(event); @@ -289,7 +289,7 @@ void setOptionalOutputBranches(Event* event) { } //________________________________________________________________________________________________________________________________ -void setPixelQuintupletOutputBranches(Event* event) { +void setPixelQuintupletOutputBranches(LSTEvent* event) { // ============ pT5 ============= auto const pixelQuintuplets = event->getPixelQuintuplets(); auto const quintuplets = event->getQuintuplets(); @@ -364,7 +364,7 @@ void setPixelQuintupletOutputBranches(Event* event) { } //________________________________________________________________________________________________________________________________ -void setQuintupletOutputBranches(Event* event) { +void setQuintupletOutputBranches(LSTEvent* event) { auto const quintuplets = event->getQuintuplets(); auto const quintupletsOccupancy = event->getQuintuplets(); auto ranges = event->getRanges(); @@ -436,7 +436,7 @@ void setQuintupletOutputBranches(Event* event) { } //________________________________________________________________________________________________________________________________ -void setPixelTripletOutputBranches(Event* event) { +void setPixelTripletOutputBranches(LSTEvent* event) { auto const pixelTriplets = event->getPixelTriplets(); auto modules = event->getModules(); SegmentsPixelConst segmentsPixel = event->getSegments(); @@ -499,7 +499,7 @@ void setPixelTripletOutputBranches(Event* event) { } //________________________________________________________________________________________________________________________________ -void setGnnNtupleBranches(Event* event) { +void setGnnNtupleBranches(LSTEvent* event) { // Get relevant information SegmentsOccupancyConst segmentsOccupancy = event->getSegments(); MiniDoubletsOccupancyConst miniDoublets = event->getMiniDoublets(); @@ -640,7 +640,7 @@ void setGnnNtupleBranches(Event* event) { } //________________________________________________________________________________________________________________________________ -void setGnnNtupleMiniDoublet(Event* event, unsigned int MD) { +void setGnnNtupleMiniDoublet(LSTEvent* event, unsigned int MD) { // Get relevant information MiniDoubletsConst miniDoublets = event->getMiniDoublets(); auto hitsEvt = event->getHits(); @@ -708,27 +708,25 @@ void setGnnNtupleMiniDoublet(Event* event, unsigned int MD) { } //________________________________________________________________________________________________________________________________ -std::tuple> parseTrackCandidate(Event* event, unsigned int idx) { +std::tuple> parseTrackCandidate(LSTEvent* event, unsigned int idx) { // Get the type of the track candidate auto const& trackCandidates = event->getTrackCandidates(); short type = trackCandidates.trackCandidateType()[idx]; - enum { pT5 = 7, pT3 = 5, T5 = 4, pLS = 8 }; - // Compute pt eta phi and hit indices that will be used to figure out whether the TC matched float pt, eta, phi; std::vector hit_idx, hit_type; switch (type) { - case pT5: + case lst::LSTObjType::pT5: std::tie(pt, eta, phi, hit_idx, hit_type) = parsepT5(event, idx); break; - case pT3: + case lst::LSTObjType::pT3: std::tie(pt, eta, phi, hit_idx, hit_type) = parsepT3(event, idx); break; - case T5: + case lst::LSTObjType::T5: std::tie(pt, eta, phi, hit_idx, hit_type) = parseT5(event, idx); break; - case pLS: + case lst::LSTObjType::pLS: std::tie(pt, eta, phi, hit_idx, hit_type) = parsepLS(event, idx); break; } @@ -741,7 +739,7 @@ std::tuple> parseTrackCandidate( } //________________________________________________________________________________________________________________________________ -std::tuple, std::vector> parsepT5(Event* event, +std::tuple, std::vector> parsepT5(LSTEvent* event, unsigned int idx) { // Get relevant information auto const trackCandidates = event->getTrackCandidates(); @@ -853,7 +851,7 @@ std::tuple, std::vector, std::vector> parsepT3(Event* event, +std::tuple, std::vector> parsepT3(LSTEvent* event, unsigned int idx) { // Get relevant information auto const trackCandidates = event->getTrackCandidates(); @@ -888,7 +886,7 @@ std::tuple, std::vector, std::vector> parseT5(Event* event, +std::tuple, std::vector> parseT5(LSTEvent* event, unsigned int idx) { auto const trackCandidates = event->getTrackCandidates(); auto const quintuplets = event->getQuintuplets(); @@ -922,7 +920,7 @@ std::tuple, std::vector, std::vector> parsepLS(Event* event, +std::tuple, std::vector> parsepLS(LSTEvent* event, unsigned int idx) { auto const& trackCandidates = event->getTrackCandidates(); SegmentsPixelConst segmentsPixel = event->getSegments(); @@ -943,7 +941,7 @@ std::tuple, std::vectorgetModules(); auto hitRanges = event->getHits(); @@ -958,7 +956,7 @@ void printHitMultiplicities(Event* event) { } //________________________________________________________________________________________________________________________________ -void printMiniDoubletMultiplicities(Event* event) { +void printMiniDoubletMultiplicities(LSTEvent* event) { MiniDoubletsOccupancyConst miniDoublets = event->getMiniDoublets(); auto modules = event->getModules(); @@ -977,7 +975,7 @@ void printMiniDoubletMultiplicities(Event* event) { } //________________________________________________________________________________________________________________________________ -void printAllObjects(Event* event) { +void printAllObjects(LSTEvent* event) { printMDs(event); printLSs(event); printpLSs(event); @@ -985,7 +983,7 @@ void printAllObjects(Event* event) { } //________________________________________________________________________________________________________________________________ -void printMDs(Event* event) { +void printMDs(LSTEvent* event) { MiniDoubletsConst miniDoublets = event->getMiniDoublets(); MiniDoubletsOccupancyConst miniDoubletsOccupancy = event->getMiniDoublets(); auto hitsEvt = event->getHits(); @@ -1008,7 +1006,7 @@ void printMDs(Event* event) { } //________________________________________________________________________________________________________________________________ -void printLSs(Event* event) { +void printLSs(LSTEvent* event) { SegmentsConst segments = event->getSegments(); SegmentsOccupancyConst segmentsOccupancy = event->getSegments(); MiniDoubletsConst miniDoublets = event->getMiniDoublets(); @@ -1041,7 +1039,7 @@ void printLSs(Event* event) { } //________________________________________________________________________________________________________________________________ -void printpLSs(Event* event) { +void printpLSs(LSTEvent* event) { SegmentsConst segments = event->getSegments(); SegmentsOccupancyConst segmentsOccupancy = event->getSegments(); MiniDoubletsConst miniDoublets = event->getMiniDoublets(); @@ -1072,7 +1070,7 @@ void printpLSs(Event* event) { } //________________________________________________________________________________________________________________________________ -void printT3s(Event* event) { +void printT3s(LSTEvent* event) { auto const triplets = event->getTriplets(); auto const tripletsOccupancy = event->getTriplets(); SegmentsConst segments = event->getSegments(); diff --git a/RecoTracker/LSTCore/standalone/code/core/write_lst_ntuple.h b/RecoTracker/LSTCore/standalone/code/core/write_lst_ntuple.h index 3f04ec59ad554..314096f72679e 100644 --- a/RecoTracker/LSTCore/standalone/code/core/write_lst_ntuple.h +++ b/RecoTracker/LSTCore/standalone/code/core/write_lst_ntuple.h @@ -5,13 +5,13 @@ #include #include "lst_math.h" -#include "Event.h" +#include "LSTEvent.h" #include "AnalysisConfig.h" #include "trkCore.h" #include "AccessHelper.h" -using LSTEvent = ALPAKA_ACCELERATOR_NAMESPACE::lst::Event; +using LSTEvent = ALPAKA_ACCELERATOR_NAMESPACE::lst::LSTEvent; // Common void createOutputBranches(); diff --git a/RecoTracker/LSTCore/standalone/efficiency/bin/lst_timing b/RecoTracker/LSTCore/standalone/efficiency/bin/lst_timing index 0a359d1fe0fe6..b3f9d1d8966e8 100755 --- a/RecoTracker/LSTCore/standalone/efficiency/bin/lst_timing +++ b/RecoTracker/LSTCore/standalone/efficiency/bin/lst_timing @@ -144,9 +144,6 @@ rm -f timing_temp.txt if [ -z "${SPECIFICGPUVERSION}" ] || [[ "${SPECIFICGPUVERSION}" == "explicit" ]]; then $run_func explicit "${SAMPLE}" "${NEVENTS}" fi -if [ -z "${SPECIFICGPUVERSION}" ] || [[ "${SPECIFICGPUVERSION}" == "explicit_cache" ]]; then - $run_func explicit_cache "${SAMPLE}" "${NEVENTS}" -c -fi echo "Total Timing Summary" grep -h "Time for map " timing_temp.txt | cut -d " " -f 6 | awk '{ SUM += $1} END { print "Average time for map loading =",SUM/5,"ms" }' # 5 is the number of stream values run diff --git a/RecoTracker/LSTCore/standalone/setup.sh b/RecoTracker/LSTCore/standalone/setup.sh index d509a37e814d8..1a35fa8e69bdf 100644 --- a/RecoTracker/LSTCore/standalone/setup.sh +++ b/RecoTracker/LSTCore/standalone/setup.sh @@ -14,7 +14,7 @@ elif [[ $ARCH == "aarch64" || $ARCH == "arm64" ]]; then else export SCRAM_ARCH=el8_amd64_gcc12 fi -export CMSSW_VERSION=CMSSW_14_2_0_pre1 +export CMSSW_VERSION=CMSSW_14_2_0_pre3 source /cvmfs/cms.cern.ch/cmsset_default.sh cd /cvmfs/cms.cern.ch/$SCRAM_ARCH/cms/cmssw/$CMSSW_VERSION/src