Skip to content

Commit

Permalink
Make the Pixel 'gpu' workflow use a GPU if available, and fall-back t…
Browse files Browse the repository at this point in the history
…o CPU otherwise
  • Loading branch information
fwyzard committed Apr 14, 2021
1 parent 2af23d6 commit b955402
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 23 deletions.
21 changes: 13 additions & 8 deletions RecoPixelVertexing/Configuration/python/RecoPixelVertexing_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,24 @@
#
from RecoPixelVertexing.PixelVertexFinding.PixelVertexes_cff import *
#from RecoVertex.PrimaryVertexProducer.OfflinePixel3DPrimaryVertices_cfi import *
recopixelvertexingTask = cms.Task(pixelTracksTask,pixelVertices)
recopixelvertexing = cms.Sequence(recopixelvertexingTask)
recopixelvertexingTask = cms.Task(pixelTracksTask, pixelVertices)

from Configuration.ProcessModifiers.gpu_cff import gpu
_recopixelvertexingTask_gpu = recopixelvertexingTask.copy()

from RecoPixelVertexing.PixelVertexFinding.pixelVertexCUDA_cfi import pixelVertexCUDA
_recopixelvertexingTask_gpu.add(pixelVertexCUDA)

from RecoPixelVertexing.PixelVertexFinding.pixelVertexSoA_cfi import pixelVertexSoA
from RecoPixelVertexing.PixelVertexFinding.pixelVertexFromSoA_cfi import pixelVertexFromSoA as _pixelVertexFromSoA
_recopixelvertexingTask_gpu.add(pixelVertexSoA)

_pixelVertexingCUDATask = cms.Task(pixelTracksTask,pixelVertexCUDA,pixelVertexSoA,pixelVertices)
from RecoPixelVertexing.PixelVertexFinding.pixelVertexFromSoA_cfi import pixelVertexFromSoA as _pixelVertexFromSoA
# this is needed because the 'pixelTrack' EDAlias will not contain the 'ushorts' collections
_pixelVertexFromSoA.TrackCollection = 'pixelTrackFromSoA'
gpu.toModify(pixelVertices,
cuda = _pixelVertexFromSoA
)

# pixelVertexSoAonCPU = pixelVertexCUDA.clone()
# pixelVertexSoAonCPU.onGPU = False;
gpu.toReplaceWith(recopixelvertexingTask, _recopixelvertexingTask_gpu)

gpu.toReplaceWith(pixelVertices,_pixelVertexFromSoA)
gpu.toReplaceWith(recopixelvertexingTask,_pixelVertexingCUDATask)
recopixelvertexing = cms.Sequence(recopixelvertexingTask)
34 changes: 21 additions & 13 deletions RecoPixelVertexing/PixelTrackFitting/python/PixelTracks_cff.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import FWCore.ParameterSet.Config as cms
from HeterogeneousCore.CUDACore.SwitchProducerCUDA import SwitchProducerCUDA

from RecoLocalTracker.SiStripRecHitConverter.StripCPEfromTrackAngle_cfi import *
from RecoLocalTracker.SiStripRecHitConverter.SiStripRecHitMatcher_cfi import *
Expand Down Expand Up @@ -59,10 +60,12 @@
)
)

pixelTracks = _pixelTracks.clone(
SeedingHitSets = "pixelTracksHitQuadruplets"
pixelTracks = SwitchProducerCUDA(
cpu = _pixelTracks.clone(
SeedingHitSets = "pixelTracksHitQuadruplets"
)
)
trackingLowPU.toModify(pixelTracks, SeedingHitSets = "pixelTracksHitTriplets")
trackingLowPU.toModify(pixelTracks.cpu, SeedingHitSets = "pixelTracksHitTriplets")

pixelTracksTask = cms.Task(
pixelTracksTrackingRegions,
Expand All @@ -79,7 +82,7 @@

# Use ntuple fit and substitute previous Fitter producer with the ntuple one
from Configuration.ProcessModifiers.pixelNtupleFit_cff import pixelNtupleFit as ntupleFit
ntupleFit.toModify(pixelTracks, Fitter = "pixelNtupletsFitter")
ntupleFit.toModify(pixelTracks.cpu, Fitter = "pixelNtupletsFitter")
_pixelTracksTask_ntupleFit = pixelTracksTask.copy()
_pixelTracksTask_ntupleFit.replace(pixelFitterByHelixProjections, pixelNtupletsFitter)
ntupleFit.toReplaceWith(pixelTracksTask, _pixelTracksTask_ntupleFit)
Expand All @@ -88,15 +91,20 @@
from Configuration.ProcessModifiers.gpu_cff import gpu
from RecoPixelVertexing.PixelTriplets.caHitNtupletCUDA_cfi import caHitNtupletCUDA
from RecoPixelVertexing.PixelTrackFitting.pixelTrackSoA_cfi import pixelTrackSoA
from RecoPixelVertexing.PixelTrackFitting.pixelTrackProducerFromSoA_cfi import pixelTrackProducerFromSoA as _pixelTrackFromSoA
_pixelTracksGPUTask = cms.Task(
caHitNtupletCUDA,
pixelTrackSoA,
pixelTracks # FromSoA
from RecoPixelVertexing.PixelTrackFitting.pixelTrackProducerFromSoA_cfi import pixelTrackProducerFromSoA as pixelTrackFromSoA
_pixelTracksTask_gpu = pixelTracksTask.copy()
_pixelTracksTask_gpu.add(caHitNtupletCUDA, pixelTrackSoA, pixelTrackFromSoA)
# this is needed (instead of simply using pixelTracks.cuda = pixelTrackFromSoA.clone()) because
# the PixelTrackProducerFromSoA produces an additional 'ushorts' collection
gpu.toModify(pixelTracks,
cuda = cms.EDAlias(
pixelTrackFromSoA = cms.VPSet(
cms.PSet(type = cms.string("recoTracks")),
cms.PSet(type = cms.string("recoTrackExtras")),
cms.PSet(type = cms.string("TrackingRecHitsOwned"))
)
)
)

gpu.toReplaceWith(pixelTracksTask, _pixelTracksGPUTask)
gpu.toReplaceWith(pixelTracks,_pixelTrackFromSoA)

gpu.toReplaceWith(pixelTracksTask, _pixelTracksTask_gpu)

pixelTracksSequence = cms.Sequence(pixelTracksTask)
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import FWCore.ParameterSet.Config as cms
from HeterogeneousCore.CUDACore.SwitchProducerCUDA import SwitchProducerCUDA

from RecoPixelVertexing.PixelVertexFinding.PixelVertexes_cfi import *

from RecoPixelVertexing.PixelVertexFinding.PixelVertexes_cfi import pvClusterComparer, pixelVertices as _pixelVertices
pixelVertices = SwitchProducerCUDA(
cpu = _pixelVertices.clone()
)

0 comments on commit b955402

Please sign in to comment.