Skip to content

Commit

Permalink
batch8 of updates for LST integration in CMSSW (#113)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Manos Vourliotis <[email protected]>
  • Loading branch information
3 people authored Nov 4, 2024
1 parent 4d603ca commit 476d3aa
Show file tree
Hide file tree
Showing 60 changed files with 880 additions and 945 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions RecoTracker/IterativeTracking/python/HighPtTripletStep_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion RecoTracker/LST/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
<use name="RecoTracker/LST"/>
<use name="RecoTracker/LSTCore"/>
<use name="RecoTracker/Record"/>
<flags CXXFLAGS="-DLST_IS_CMSSW_PACKAGE"/>
<flags ALPAKA_BACKENDS="1"/>
<flags EDM_PLUGIN="1"/>
</library>
Expand Down
8 changes: 4 additions & 4 deletions RecoTracker/LST/plugins/LSTOutputConverter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -25,15 +25,15 @@
#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;

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<LSTOutput> lstOutputToken_;
const edm::EDGetTokenT<LSTPhase2OTHitsInput> lstPhase2OTHitsInputToken_;
Expand Down Expand Up @@ -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_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion RecoTracker/LSTCore/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<use name="boost_header"/>
<use name="root"/>
<use name="HeterogeneousCore/AlpakaInterface"/>
<flags CXXFLAGS="-DCACHE_ALLOC -DT4FromT3 -DUSE_RZCHI2 -DUSE_T5_DNN -DPT_CUT=0.8 -DDUP_pLS -DDUP_T5 -DDUP_pT5 -DDUP_pT3 -DCrossclean_T5 -DCrossclean_pT3"/>
<flags CXXFLAGS="-DPT_CUT=0.8"/>
<use name="RecoTracker/LSTCore" for="alpaka"/>
<flags ALPAKA_BACKENDS="1"/>
<export>
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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 <typename TDev, typename TData>
using Buf = alpaka::Buf<TDev, TData, alpaka_common::Dim1D, alpaka_common::Idx>;

// Allocation wrapper function to make integration of the caching allocator easier and reduce code boilerplate.
template <typename T, typename TDev, typename TSize, typename TQueue>
ALPAKA_FN_HOST ALPAKA_FN_INLINE Buf<TDev, T> allocBufWrapper(TDev const& dev, TSize nElements, TQueue queue) {
#ifdef CACHE_ALLOC
return cms::alpakatools::allocCachedBuf<T, alpaka_common::Idx>(
dev, queue, alpaka_common::Vec1D(static_cast<alpaka_common::Idx>(nElements)));
#else
return alpaka::allocBuf<T, alpaka_common::Idx>(dev,
alpaka_common::Vec1D(static_cast<alpaka_common::Idx>(nElements)));
#endif
}

// Second allocation wrapper function when queue is not given. Reduces code boilerplate.
template <typename T, typename TDev, typename TSize>
ALPAKA_FN_HOST ALPAKA_FN_INLINE Buf<TDev, T> allocBufWrapper(TDev const& dev, TSize nElements) {
return alpaka::allocBuf<T, alpaka_common::Idx>(dev,
alpaka_common::Vec1D(static_cast<alpaka_common::Idx>(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;
Expand Down
2 changes: 1 addition & 1 deletion RecoTracker/LSTCore/interface/HitsSoA.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
3 changes: 2 additions & 1 deletion RecoTracker/LSTCore/interface/LSTESData.h
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -21,6 +21,7 @@ namespace lst {
unsigned int nEndCapMap;
std::unique_ptr<const PortableMultiCollection<TDev, ModulesSoA, ModulesPixelSoA>> modules;
std::unique_ptr<const PortableCollection<EndcapGeometryDevSoA, TDev>> endcapGeometry;
// Host-side object that is shared between the LSTESData<TDev> objects for different devices
std::shared_ptr<const PixelMap> pixelMapping;

LSTESData(uint16_t const& nModulesIn,
Expand Down
4 changes: 2 additions & 2 deletions RecoTracker/LSTCore/interface/MiniDoubletsSoA.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<>;
Expand Down
2 changes: 1 addition & 1 deletion RecoTracker/LSTCore/interface/ModulesSoA.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
2 changes: 1 addition & 1 deletion RecoTracker/LSTCore/interface/ObjectRangesSoA.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
2 changes: 1 addition & 1 deletion RecoTracker/LSTCore/interface/PixelMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <vector>
#include <cstdint>

#include "RecoTracker/LSTCore/interface/Constants.h"
#include "RecoTracker/LSTCore/interface/Common.h"

namespace lst {
struct PixelMap {
Expand Down
2 changes: 1 addition & 1 deletion RecoTracker/LSTCore/interface/PixelQuintupletsSoA.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion RecoTracker/LSTCore/interface/PixelTripletsSoA.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion RecoTracker/LSTCore/interface/QuintupletsSoA.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 2 additions & 4 deletions RecoTracker/LSTCore/interface/SegmentsSoA.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion RecoTracker/LSTCore/interface/TrackCandidatesSoA.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion RecoTracker/LSTCore/interface/TripletsSoA.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <numbers>

#include "RecoTracker/LSTCore/interface/Common.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {

Expand Down Expand Up @@ -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<float>;
// 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] = {
Expand All @@ -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<float>::infinity() in the code and data files
ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kVerticalModuleSlope = 123456789.0;

namespace t5dnn {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions RecoTracker/LSTCore/interface/alpaka/LST.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#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 <cstdlib>
#include <numeric>
#include <alpaka/alpaka.hpp>

namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
class Event;
class LSTEvent;

class LST {
public:
Expand Down Expand Up @@ -65,7 +65,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
std::vector<float> const& ph2_y,
std::vector<float> const& ph2_z);

void getOutput(Event& event);
void getOutput(LSTEvent& event);

// Input and output vectors
std::vector<float> in_trkX_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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<PixelQuintupletsSoA>;
} // namespace ALPAKA_ACCELERATOR_NAMESPACE::lst
Expand Down
Original file line number Diff line number Diff line change
@@ -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<PixelTripletsSoA>;
} // namespace ALPAKA_ACCELERATOR_NAMESPACE::lst
Expand Down
Loading

0 comments on commit 476d3aa

Please sign in to comment.