Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load CUDAService from Services_cff, and only if gpu modifier is active #432

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Configuration/Applications/python/ConfigBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,8 +921,6 @@ def define_Configs(self):
self.loadAndRemember('SimGeneral.HepPDTESSource.'+self._options.particleTable+'_cfi')

self.loadAndRemember('FWCore/MessageService/MessageLogger_cfi')
# Eventually replace with some more generic file to load
self.loadAndRemember('HeterogeneousCore/CUDAServices/CUDAService_cfi')

self.ALCADefaultCFF="Configuration/StandardSequences/AlCaRecoStreams_cff"
self.GENDefaultCFF="Configuration/StandardSequences/Generator_cff"
Expand Down
5 changes: 5 additions & 0 deletions Configuration/StandardSequences/python/Services_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@
#an "intermediate layer" remains, just in case somebody is using it...
# from Configuration.StandardSequences.SimulationRandomNumberGeneratorSeeds_cff import *
from DQMServices.Core.DQMStore_cfg import *

from Configuration.ProcessModifiers.gpu_cff import gpu
def loadCUDAService(process):
process.load("HeterogeneousCore.CUDAServices.CUDAService_cfi")
modifyConfigurationStandardSequencesServicesCUDAService = gpu.makeProcessModifier(loadCUDAService)
11 changes: 6 additions & 5 deletions RecoVertex/BeamSpotProducer/python/BeamSpot_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
from RecoVertex.BeamSpotProducer.BeamSpot_cfi import *
from RecoVertex.BeamSpotProducer.beamSpotToCUDA_cfi import beamSpotToCUDA as _beamSpotToCUDA

offlineBeamSpotCUDA = _beamSpotToCUDA.clone()
offlineBeamSpotTask = cms.Task(offlineBeamSpot)

offlineBeamSpotTask = cms.Task(
offlineBeamSpot,
offlineBeamSpotCUDA
)
from Configuration.ProcessModifiers.gpu_cff import gpu
offlineBeamSpotCUDA = _beamSpotToCUDA.clone()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not suggesting to change this, just trying to understand: would it be equivalent to replace

from RecoVertex.BeamSpotProducer.beamSpotToCUDA_cfi import beamSpotToCUDA as _beamSpotToCUDA
offlineBeamSpotCUDA = _beamSpotToCUDA.clone()

with

from RecoVertex.BeamSpotProducer.beamSpotToCUDA_cfi import beamSpotToCUDA as offlineBeamSpotCUDA

?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two are not equivalent. The first one creates a copy/clone of RecoVertex.BeamSpotProducer.beamSpotToCUDA_cfi.beamSpotToCUDA, so if the BeamSpot_cff.py would do something along

offlineBeamSpotCUDA.src = "foo"

that change does not propagate to other configurations making use of RecoVertex.BeamSpotProducer.beamSpotToCUDA_cfi.beamSpotToCUDA.

The second one uses the very same object as RecoVertex.BeamSpotProducer.beamSpotToCUDA_cfi.beamSpotToCUDA, and any changes to offlineBeamSpotCUDA do propagate to other configurations making use of RecoVertex.BeamSpotProducer.beamSpotToCUDA_cfi.beamSpotToCUDA, which could be perceived as unexpected.

In this specific case there is little practical difference, so the choice of cloning is more of a following the recommended general pattern (and also protects for the case that someone else would use the second approach and modify a parameter).

_offlineBeamSpotTask_gpu = offlineBeamSpotTask.copy()
_offlineBeamSpotTask_gpu.add(offlineBeamSpotCUDA)
gpu.toReplaceWith(offlineBeamSpotTask, _offlineBeamSpotTask_gpu)