diff --git a/RecoTracker/IterativeTracking/python/HighPtTripletStep_cff.py b/RecoTracker/IterativeTracking/python/HighPtTripletStep_cff.py index dd2050f33e099..e37c10dd2bc89 100644 --- a/RecoTracker/IterativeTracking/python/HighPtTripletStep_cff.py +++ b/RecoTracker/IterativeTracking/python/HighPtTripletStep_cff.py @@ -387,14 +387,9 @@ from RecoTracker.LST.lstSeedTracks_cfi import lstInitialStepSeedTracks,lstHighPtTripletStepSeedTracks from RecoTracker.LST.lstPixelSeedInputProducer_cfi import lstPixelSeedInputProducer from RecoTracker.LST.lstPhase2OTHitsInputProducer_cfi import lstPhase2OTHitsInputProducer -from RecoTracker.LST.lstProducer_cfi import lstProducer as _lstProducer -# Define lstProducer like this to be able to run the serial version explicitly -lstProducer = _lstProducer.clone( - alpaka = cms.untracked.PSet(backend = cms.untracked.string('serial_sync')) -) -from Configuration.ProcessModifiers.gpu_cff import gpu -gpu.toReplaceWith(lstProducer,_lstProducer.clone()) -_HighPtTripletStepTask_LST.add(siPhase2RecHits, lstInitialStepSeedTracks, lstHighPtTripletStepSeedTracks, lstPixelSeedInputProducer, lstPhase2OTHitsInputProducer, lstProducer) +from RecoTracker.LST.lstProducer_cff import * +_HighPtTripletStepTask_LST.add(siPhase2RecHits, lstInitialStepSeedTracks, lstHighPtTripletStepSeedTracks, lstPixelSeedInputProducer, lstPhase2OTHitsInputProducer, + lstProducer, lstModulesDevESProducer) (trackingPhase2PU140 & trackingLST).toReplaceWith(HighPtTripletStepTask, _HighPtTripletStepTask_LST) # fast tracking mask producer diff --git a/RecoTracker/LST/BuildFile.xml b/RecoTracker/LST/BuildFile.xml index be3ea4bb8a366..5495e48778569 100644 --- a/RecoTracker/LST/BuildFile.xml +++ b/RecoTracker/LST/BuildFile.xml @@ -1,5 +1,9 @@ + + + + - + diff --git a/RecoTracker/LST/plugins/BuildFile.xml b/RecoTracker/LST/plugins/BuildFile.xml index 3ed7d76eb7fba..da6bc17a3e5df 100644 --- a/RecoTracker/LST/plugins/BuildFile.xml +++ b/RecoTracker/LST/plugins/BuildFile.xml @@ -5,6 +5,7 @@ + @@ -13,6 +14,7 @@ + @@ -31,6 +33,7 @@ + @@ -44,6 +47,7 @@ + diff --git a/RecoTracker/LST/plugins/alpaka/LSTModulesDevESProducer.cc b/RecoTracker/LST/plugins/alpaka/LSTModulesDevESProducer.cc new file mode 100644 index 0000000000000..6913976072120 --- /dev/null +++ b/RecoTracker/LST/plugins/alpaka/LSTModulesDevESProducer.cc @@ -0,0 +1,57 @@ +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "HeterogeneousCore/AlpakaCore/interface/alpaka/ESProducer.h" +#include "HeterogeneousCore/AlpakaCore/interface/alpaka/ModuleFactory.h" +#include "HeterogeneousCore/AlpakaInterface/interface/config.h" +#include "HeterogeneousCore/AlpakaInterface/interface/memory.h" + +#include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h" + +// LST includes +#include +#include +#include + +namespace cms::alpakatools { + template <> + struct CopyToDevice> { + template + static auto copyAsync(TQueue& queue, SDL::modulesBuffer const& srcData) { + return SDL::modulesBuffer>(queue, srcData); + } + }; +} //namespace cms::alpakatools +namespace ALPAKA_ACCELERATOR_NAMESPACE { + +class LSTModulesDevESProducer : public ESProducer { +public: + LSTModulesDevESProducer(const edm::ParameterSet &iConfig); + + static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); + + std::optional> produce(const TrackerRecoGeometryRecord &iRecord); + +}; + +LSTModulesDevESProducer::LSTModulesDevESProducer(const edm::ParameterSet &iConfig) + : ESProducer(iConfig) +{ + setWhatProduced(this, iConfig.getParameter("ComponentName")); +} + +void LSTModulesDevESProducer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) { + edm::ParameterSetDescription desc; + desc.add("ComponentName", "")->setComment("Product label"); + descriptions.addWithDefaultLabel(desc); +} + + std::optional> LSTModulesDevESProducer::produce(const TrackerRecoGeometryRecord &iRecord) { + SDL::modulesBuffer modules(cms::alpakatools::host()); + alpaka::QueueCpuBlocking queue(cms::alpakatools::host()); + SDL::LST::loadAndFillES(queue, &modules); + return modules; +} + +} // namespace ALPAKA_ACCELERATOR_NAMESPACE + +DEFINE_FWK_EVENTSETUP_ALPAKA_MODULE(LSTModulesDevESProducer); diff --git a/RecoTracker/LST/plugins/alpaka/LSTProducer.cc b/RecoTracker/LST/plugins/alpaka/LSTProducer.cc index 3705e780db0ee..1ed4d11de975f 100644 --- a/RecoTracker/LST/plugins/alpaka/LSTProducer.cc +++ b/RecoTracker/LST/plugins/alpaka/LSTProducer.cc @@ -1,5 +1,6 @@ #include +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" @@ -16,6 +17,8 @@ #include "RecoTracker/LST/interface/LSTPhase2OTHitsInput.h" #include "RecoTracker/LST/interface/LSTPixelSeedInput.h" +#include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h" + #include "SDL/LST.h" namespace ALPAKA_ACCELERATOR_NAMESPACE { @@ -26,6 +29,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { : lstPixelSeedInputToken_{consumes(config.getParameter("pixelSeedInput"))}, lstPhase2OTHitsInputToken_{ consumes(config.getParameter("phase2OTHitsInput"))}, + modulesESToken_{esConsumes()}, verbose_(config.getParameter("verbose")), lstOutputToken_{produces()} {} @@ -35,7 +39,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { auto const& pixelSeeds = event.get(lstPixelSeedInputToken_); auto const& phase2OTHits = event.get(lstPhase2OTHitsInputToken_); - lst_.eventSetup(); + auto const& modulesData = setup.getData(modulesESToken_); + SDL::modulesBuffersES = &modulesData; + SDL::modulesInGPU->setData(modulesData); lst_.run(event.queue(), verbose_, pixelSeeds.px(), @@ -79,6 +85,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { private: edm::EDGetTokenT lstPixelSeedInputToken_; edm::EDGetTokenT lstPhase2OTHitsInputToken_; + device::ESGetToken, TrackerRecoGeometryRecord> modulesESToken_; const int verbose_; edm::EDPutTokenT lstOutputToken_; diff --git a/RecoTracker/LST/python/lstProducer_cff.py b/RecoTracker/LST/python/lstProducer_cff.py new file mode 100644 index 0000000000000..61280c6b3ad04 --- /dev/null +++ b/RecoTracker/LST/python/lstProducer_cff.py @@ -0,0 +1,9 @@ +import FWCore.ParameterSet.Config as cms + +from RecoTracker.LST.lstProducer_cfi import lstProducer + +from Configuration.ProcessModifiers.gpu_cff import gpu +(~gpu).toModify(lstProducer.alpaka, backend = 'serial_sync') + +from RecoTracker.LST.lstModulesDevESProducer_cfi import lstModulesDevESProducer +(~gpu).toModify(lstModulesDevESProducer.alpaka, backend = 'serial_sync') diff --git a/RecoTracker/LST/src/alpaka/ES_ModulesDev.cc b/RecoTracker/LST/src/alpaka/ES_ModulesDev.cc new file mode 100644 index 0000000000000..be4eb17effb3e --- /dev/null +++ b/RecoTracker/LST/src/alpaka/ES_ModulesDev.cc @@ -0,0 +1,7 @@ +#include +#include "HeterogeneousCore/AlpakaCore/interface/alpaka/typelookup.h" + +// Temporary hack: The DevHost instantiation is needed in both CPU and GPU plugins, +// whereas the (non-host-)Device instantiation only in the GPU plugin +TYPELOOKUP_DATA_REG(SDL::modulesBuffer); +TYPELOOKUP_ALPAKA_TEMPLATED_DATA_REG(SDL::modulesBuffer); diff --git a/RecoTracker/LST/test/LSTAlpakaTester.py b/RecoTracker/LST/test/LSTAlpakaTester.py index 1893e0c62a26e..44013a0690b5b 100644 --- a/RecoTracker/LST/test/LSTAlpakaTester.py +++ b/RecoTracker/LST/test/LSTAlpakaTester.py @@ -34,10 +34,8 @@ ) process.options = cms.untracked.PSet( - FailPath = cms.untracked.vstring(), IgnoreCompletely = cms.untracked.vstring(), Rethrow = cms.untracked.vstring(), - SkipEvent = cms.untracked.vstring(), accelerators = cms.untracked.vstring('*'), allowUnscheduled = cms.obsolete.untracked.bool, canDeleteEarly = cms.untracked.vstring(), @@ -91,8 +89,7 @@ # Main LST Producer process.load('Configuration.StandardSequences.Accelerators_cff') process.load("HeterogeneousCore.AlpakaCore.ProcessAcceleratorAlpaka_cfi") -from RecoTracker.LST.lstProducer_cfi import lstProducer as _lstProducer -process.lstProducer = _lstProducer.clone() +process.load("RecoTracker.LST.lstProducer_cff") # Track Fitting import RecoTracker.TrackProducer.TrackProducer_cfi