Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-06-25 22:35:15

0001 import FWCore.ParameterSet.Config as cms
0002 from HeterogeneousCore.AlpakaCore.functions import *
0003 from HeterogeneousCore.CUDACore.SwitchProducerCUDA import SwitchProducerCUDA
0004 from Configuration.ProcessModifiers.gpu_cff import gpu
0005 from Configuration.ProcessModifiers.alpaka_cff import alpaka
0006 
0007 # legacy pixel rechit producer
0008 siPixelRecHits = cms.EDProducer("SiPixelRecHitConverter",
0009     src = cms.InputTag("siPixelClusters"),
0010     CPE = cms.string('PixelCPEGeneric'),
0011     VerboseLevel = cms.untracked.int32(0)
0012 )
0013 
0014 # SwitchProducer wrapping the legacy pixel rechit producer
0015 siPixelRecHitsPreSplitting = SwitchProducerCUDA(
0016     cpu = siPixelRecHits.clone(
0017         src = 'siPixelClustersPreSplitting'
0018     )
0019 )
0020 
0021 # phase 2 tracker modifier
0022 from Configuration.Eras.Modifier_phase2_tracker_cff import phase2_tracker
0023 # HIon modifiers
0024 from Configuration.ProcessModifiers.pp_on_AA_cff import pp_on_AA
0025 
0026 # convert the pixel rechits from legacy to SoA format on CPU
0027 from RecoLocalTracker.SiPixelRecHits.siPixelRecHitSoAFromLegacyPhase1_cfi import siPixelRecHitSoAFromLegacyPhase1 as _siPixelRecHitsPreSplittingSoA
0028 from RecoLocalTracker.SiPixelRecHits.siPixelRecHitSoAFromLegacyPhase2_cfi import siPixelRecHitSoAFromLegacyPhase2 as _siPixelRecHitsPreSplittingSoAPhase2
0029 from RecoLocalTracker.SiPixelRecHits.siPixelRecHitSoAFromLegacyHIonPhase1_cfi import siPixelRecHitSoAFromLegacyHIonPhase1 as _siPixelRecHitsPreSplittingSoAHIonPhase1
0030 
0031 siPixelRecHitsPreSplittingCPU = _siPixelRecHitsPreSplittingSoA.clone(convertToLegacy=True)
0032 (pp_on_AA & ~phase2_tracker).toReplaceWith(siPixelRecHitsPreSplittingCPU, _siPixelRecHitsPreSplittingSoAHIonPhase1.clone(convertToLegacy=True, CPE = cms.string('PixelCPEFastHIonPhase1')))
0033 phase2_tracker.toReplaceWith(siPixelRecHitsPreSplittingCPU, _siPixelRecHitsPreSplittingSoAPhase2.clone(convertToLegacy=True, CPE = cms.string('PixelCPEFastPhase2')))
0034 
0035 # modifier used to prompt patatrack pixel tracks reconstruction on cpu
0036 from Configuration.ProcessModifiers.pixelNtupletFit_cff import pixelNtupletFit
0037 pixelNtupletFit.toModify(siPixelRecHitsPreSplitting,
0038     cpu = cms.EDAlias(
0039             siPixelRecHitsPreSplittingCPU = cms.VPSet(
0040                  cms.PSet(type = cms.string("SiPixelRecHitedmNewDetSetVector")),
0041                  cms.PSet(type = cms.string("uintAsHostProduct"))
0042              )
0043 ))
0044 
0045 
0046 siPixelRecHitsPreSplittingTask = cms.Task(
0047     # SwitchProducer wrapping the legacy pixel rechit producer or the cpu SoA producer
0048     siPixelRecHitsPreSplitting
0049 )
0050 
0051 # reconstruct the pixel rechits on the gpu
0052 from RecoLocalTracker.SiPixelRecHits.siPixelRecHitCUDAPhase1_cfi import siPixelRecHitCUDAPhase1 as _siPixelRecHitCUDAPhase1
0053 from RecoLocalTracker.SiPixelRecHits.siPixelRecHitCUDAPhase2_cfi import siPixelRecHitCUDAPhase2 as _siPixelRecHitCUDAPhase2
0054 from RecoLocalTracker.SiPixelRecHits.siPixelRecHitCUDAHIonPhase1_cfi import siPixelRecHitCUDAHIonPhase1 as _siPixelRecHitCUDAHIonPhase1
0055 
0056 siPixelRecHitsPreSplittingCUDA = _siPixelRecHitCUDAPhase1.clone(
0057     beamSpot = "offlineBeamSpotToCUDA"
0058 )
0059 (pp_on_AA & ~phase2_tracker).toReplaceWith(siPixelRecHitsPreSplittingCUDA,_siPixelRecHitCUDAHIonPhase1.clone(
0060     beamSpot = "offlineBeamSpotToCUDA"
0061 ))
0062 phase2_tracker.toReplaceWith(siPixelRecHitsPreSplittingCUDA,_siPixelRecHitCUDAPhase2.clone(
0063     beamSpot = "offlineBeamSpotToCUDA"
0064 ))
0065 
0066 #this is an alias for the SoA on GPU or CPU to be used for DQM
0067 siPixelRecHitsPreSplittingSoA = SwitchProducerCUDA(
0068     cpu = cms.EDAlias(
0069             siPixelRecHitsPreSplittingCPU = cms.VPSet(
0070                  cms.PSet(type = cms.string("pixelTopologyPhase1TrackingRecHitSoAHost")),
0071                  cms.PSet(type = cms.string("uintAsHostProduct"))
0072              )),
0073 )
0074 
0075 (pp_on_AA & ~phase2_tracker).toModify(siPixelRecHitsPreSplittingSoA,
0076     cpu = cms.EDAlias(
0077         siPixelRecHitsPreSplittingCPU = cms.VPSet(
0078              cms.PSet(type = cms.string("pixelTopologyHIonPhase1TrackingRecHitSoAHost")),
0079              cms.PSet(type = cms.string("uintAsHostProduct"))
0080          )))
0081 
0082 phase2_tracker.toModify(siPixelRecHitsPreSplittingSoA,
0083     cpu = cms.EDAlias(
0084         siPixelRecHitsPreSplittingCPU = cms.VPSet(
0085              cms.PSet(type = cms.string("pixelTopologyPhase2TrackingRecHitSoAHost")),
0086              cms.PSet(type = cms.string("uintAsHostProduct"))
0087          )))
0088 
0089 from RecoLocalTracker.SiPixelRecHits.siPixelRecHitSoAFromCUDAPhase1_cfi import siPixelRecHitSoAFromCUDAPhase1 as _siPixelRecHitSoAFromCUDA
0090 from RecoLocalTracker.SiPixelRecHits.siPixelRecHitSoAFromCUDAHIonPhase1_cfi import siPixelRecHitSoAFromCUDAHIonPhase1 as _siPixelRecHitSoAFromCUDAHIonPhase1
0091 from RecoLocalTracker.SiPixelRecHits.siPixelRecHitSoAFromCUDAPhase2_cfi import siPixelRecHitSoAFromCUDAPhase2 as _siPixelRecHitSoAFromCUDAPhase2
0092 
0093 (gpu & pixelNtupletFit).toModify(siPixelRecHitsPreSplittingSoA, cuda = _siPixelRecHitSoAFromCUDA.clone())
0094 (gpu & pixelNtupletFit & phase2_tracker).toModify(siPixelRecHitsPreSplittingSoA, cuda = _siPixelRecHitSoAFromCUDAPhase2.clone())
0095 
0096 # transfer the pixel rechits to the host and convert them from SoA
0097 from RecoLocalTracker.SiPixelRecHits.siPixelRecHitFromCUDAPhase1_cfi import siPixelRecHitFromCUDAPhase1 as _siPixelRecHitFromCUDA
0098 from RecoLocalTracker.SiPixelRecHits.siPixelRecHitFromCUDAHIonPhase1_cfi import siPixelRecHitFromCUDAHIonPhase1 as _siPixelRecHitFromCUDAHIonPhase1
0099 from RecoLocalTracker.SiPixelRecHits.siPixelRecHitFromCUDAPhase2_cfi import siPixelRecHitFromCUDAPhase2 as _siPixelRecHitFromCUDAPhase2
0100 
0101 (gpu & pixelNtupletFit).toModify(siPixelRecHitsPreSplitting, cuda = _siPixelRecHitFromCUDA.clone())
0102 (gpu & pixelNtupletFit & pp_on_AA).toModify(siPixelRecHitsPreSplitting, cuda = _siPixelRecHitFromCUDAHIonPhase1.clone())
0103 (gpu & pixelNtupletFit & phase2_tracker).toModify(siPixelRecHitsPreSplitting, cuda = _siPixelRecHitFromCUDAPhase2.clone())
0104 
0105 
0106 pixelNtupletFit.toReplaceWith(siPixelRecHitsPreSplittingTask, cms.Task(
0107     cms.Task(
0108         # reconstruct the pixel rechits on the cpu
0109         siPixelRecHitsPreSplittingCPU,
0110         # SwitchProducer wrapping an EDAlias on cpu or the converter from SoA to legacy on gpu
0111         siPixelRecHitsPreSplittingTask.copy(),
0112         # producing and converting on cpu (if needed)
0113         siPixelRecHitsPreSplittingSoA)
0114         )
0115         )
0116 
0117 (gpu & pixelNtupletFit).toReplaceWith(siPixelRecHitsPreSplittingTask, cms.Task(
0118     # reconstruct the pixel rechits on the gpu or on the cpu
0119     # (normally only one of the two is run because only one is consumed from later stages)
0120     siPixelRecHitsPreSplittingCUDA,
0121     siPixelRecHitsPreSplittingCPU,
0122     # SwitchProducer wrapping an EDAlias on cpu or the converter from SoA to legacy on gpu
0123     siPixelRecHitsPreSplittingTask.copy(),
0124     # producing and converting on cpu (if needed)
0125     siPixelRecHitsPreSplittingSoA
0126 ))
0127 
0128 ######################################################################
0129 
0130 ### Alpaka Pixel Hits Reco
0131 from RecoLocalTracker.SiPixelRecHits.siPixelRecHitAlpakaPhase1_cfi import siPixelRecHitAlpakaPhase1 as _siPixelRecHitAlpakaPhase1
0132 from RecoLocalTracker.SiPixelRecHits.siPixelRecHitAlpakaPhase2_cfi import siPixelRecHitAlpakaPhase2 as _siPixelRecHitAlpakaPhase2
0133 from RecoLocalTracker.SiPixelRecHits.siPixelRecHitAlpakaHIonPhase1_cfi import siPixelRecHitAlpakaHIonPhase1 as _siPixelRecHitAlpakaHIonPhase1
0134 
0135 
0136 # Hit SoA producer on the device
0137 siPixelRecHitsPreSplittingAlpaka = _siPixelRecHitAlpakaPhase1.clone(
0138     src = "siPixelClustersPreSplittingAlpaka"
0139 )
0140 phase2_tracker.toReplaceWith(siPixelRecHitsPreSplittingAlpaka,_siPixelRecHitAlpakaPhase2.clone(
0141     src = "siPixelClustersPreSplittingAlpaka"
0142 ))
0143 (pp_on_AA & ~phase2_tracker).toReplaceWith(siPixelRecHitsPreSplittingAlpaka,_siPixelRecHitAlpakaHIonPhase1.clone(
0144     src = "siPixelClustersPreSplittingAlpaka"
0145 ))
0146 
0147 # Hit SoA producer on the cpu, for validation
0148 siPixelRecHitsPreSplittingAlpakaSerial = makeSerialClone(siPixelRecHitsPreSplittingAlpaka,
0149     src = "siPixelClustersPreSplittingAlpakaSerial"
0150 )
0151 
0152 from RecoLocalTracker.SiPixelRecHits.siPixelRecHitFromSoAAlpakaPhase1_cfi import siPixelRecHitFromSoAAlpakaPhase1 as _siPixelRecHitFromSoAAlpakaPhase1
0153 from RecoLocalTracker.SiPixelRecHits.siPixelRecHitFromSoAAlpakaPhase2_cfi import siPixelRecHitFromSoAAlpakaPhase2 as _siPixelRecHitFromSoAAlpakaPhase2
0154 from RecoLocalTracker.SiPixelRecHits.siPixelRecHitFromSoAAlpakaHIonPhase1_cfi import siPixelRecHitFromSoAAlpakaHIonPhase1 as _siPixelRecHitFromSoAAlpakaHIonPhase1
0155 
0156 (alpaka & ~phase2_tracker).toModify(siPixelRecHitsPreSplitting,
0157     cpu = _siPixelRecHitFromSoAAlpakaPhase1.clone(
0158             pixelRecHitSrc = cms.InputTag('siPixelRecHitsPreSplittingAlpaka'),
0159             src = cms.InputTag('siPixelClustersPreSplitting'))
0160 )
0161 
0162 (alpaka & phase2_tracker).toModify(siPixelRecHitsPreSplitting,
0163     cpu = _siPixelRecHitFromSoAAlpakaPhase2.clone(
0164             pixelRecHitSrc = cms.InputTag('siPixelRecHitsPreSplittingAlpaka'),
0165             src = cms.InputTag('siPixelClustersPreSplitting'))
0166 )
0167 
0168 (alpaka & pp_on_AA & ~phase2_tracker).toModify(siPixelRecHitsPreSplitting,
0169     cpu = _siPixelRecHitFromSoAAlpakaHIonPhase1.clone(
0170             pixelRecHitSrc = cms.InputTag('siPixelRecHitsPreSplittingAlpaka'),
0171             src = cms.InputTag('siPixelClustersPreSplitting'))
0172 )
0173 
0174 
0175 alpaka.toReplaceWith(siPixelRecHitsPreSplittingTask, cms.Task(
0176                         # Reconstruct the pixel hits with alpaka on the device
0177                         siPixelRecHitsPreSplittingAlpaka,
0178                         # Reconstruct the pixel hits with alpaka on the cpu (if requested by the validation)
0179                         siPixelRecHitsPreSplittingAlpakaSerial,
0180                         # Convert hit soa on host to legacy formats
0181                         siPixelRecHitsPreSplitting))