ATLAS Offline Software
Loading...
Searching...
No Matches
Preparation.py
Go to the documentation of this file.
2import AthenaCommon.Include as AthCIncMod
3if opts.showincludes:
4 AthCIncMod.marker = ' -#-' # distinguish bootstrap from other jo-code
5
6
7if opts.interactive:
8 from AthenaCommon.Interactive import configureInteractivePrompt
9 configureInteractivePrompt()
10 del configureInteractivePrompt
11
12
13from AthenaCommon.Debugging import hookDebugger, allowPtrace
14allowPtrace()
15
16
17from AthenaCommon.Configurable import *
18
19
20from AthenaCommon.Constants import *
21# namespace these constants: Lvl.INFO
22# so we can write e.g: Units.GeV
23import AthenaCommon.Constants as Lvl
24import AthenaCommon.SystemOfUnits as Units
25
26
27from AthenaCommon import CfgMgr
28from AthenaCommon.AppMgr import ( athAlgSeq, theApp, ToolSvc, theAuditorSvc,
29 ServiceMgr, ServiceMgr as svcMgr )
30from AthenaCommon.Logging import log
31
32# load all entries so far into the workspace of include()
33
34if opts.interactive: # i.e. interactive
35 theApp.EventLoop = "PyAthenaEventLoopMgr" # from AthenaServices
36
37
38theApp.setOutputLevel( globals()[opts.loglevel] )
39theApp._opts = opts # FIXME
40
41
42if not "POOL_OUTMSG_LEVEL" in os.environ:
43 os.environ[ "POOL_OUTMSG_LEVEL" ] = str(globals()[opts.loglevel])
44
45
46import AthenaCommon.AtlasUnixStandardJob
47
48from PyUtils.Helpers import ROOTSetup
49ROOTSetup(batch=not opts.interactive)
50# Make sure that batch mode gets set properly.
51# ROOTSetup will set things up so that whenever we do an `import ROOT',
52# then gROOT.SetBatch will be called properly.
53# However, if someone instead writes `from ROOT import gSystem'
54# (or anything other than gROOT), then the ROOT python update thread
55# will be started before ROOTSetup calls SetBatch.
56# (This was then problematic for some MP jobs which used python
57# algorithms.)
58# So include the import here explictly to ensure that batch mode gets set.
59# The following call to SetBatch is strictly redundant, but included
60# for clarity.
61import ROOT
62ROOT.gROOT.SetBatch(not opts.interactive)
63
64
65
69
70
71from AthenaCommon.Include import IncludeError
72try:
73 include( "$HOME/.athenarc" )
74except IncludeError:
75 pass
76
77
78from AthenaCommon.ResourceLimits import SetMaxLimits
79SetMaxLimits()
80del SetMaxLimits
81del sys.modules[ 'AthenaCommon.ResourceLimits' ]
82
83
84if opts.interactive:
85 import atexit
86
87 # finalize on exit (^D)
88 atexit.register( theApp.exit )
89
90 del atexit
91
92if opts.command:
93 _msg.info( 'executing CLI (-c) command: "%s"' % opts.command )
94 exec (opts.command)
95
96if DbgStage.value == "conf":
97 hookDebugger()
98
99if opts.showincludes:
100 AthCIncMod.marker = AthCIncMod.__marker__ # reset
101del AthCIncMod
102
103if opts.do_leak_chk:
104 from Hephaestus.Auditor import HephaestusAuditor
105 theApp.AuditAlgorithms = True
106 svcMgr.AuditorSvc += HephaestusAuditor(
107 mode = opts.memchk_mode, auditOn = opts.do_leak_chk )
108
109
110
111from AthenaCommon.ConcurrencyFlags import jobproperties as jps
112if opts.nprocs and (opts.nprocs >= 1 or opts.nprocs==-1):
113 # MPI and AthenaMP don't mix
114 if opts.mpi:
115 _msg.error("Cannot run AthenaMP with MPI")
116 sys.exit()
117 jps.ConcurrencyFlags.NumProcs = opts.nprocs
118 _msg.info ("configuring AthenaMP with [%s] sub-workers",
119 jps.ConcurrencyFlags.NumProcs())
120
121 if (opts.debug_worker is True) :
122 jps.ConcurrencyFlags.DebugWorkers = True
123 _msg.info (" Workers will pause after fork until SIGUSR1 signal received")
124
125if (opts.threads or opts.concurrent_events) :
126
127 if (opts.threads is None and opts.concurrent_events is not None) :
128
129 jps.ConcurrencyFlags.NumThreads = opts.concurrent_events
130 jps.ConcurrencyFlags.NumConcurrentEvents = opts.concurrent_events
131 elif (opts.threads is not None and opts.concurrent_events is None) :
132
133 jps.ConcurrencyFlags.NumThreads = opts.threads
134 jps.ConcurrencyFlags.NumConcurrentEvents = opts.threads
135 else :
136
137 jps.ConcurrencyFlags.NumThreads = opts.threads
138 jps.ConcurrencyFlags.NumConcurrentEvents = opts.concurrent_events
139
140
141 if (jps.ConcurrencyFlags.NumProcs() > 0) :
142 _msg.info ("configuring hybrid AthenaMP/AthenaMT with [%s] concurrent threads and [%s] concurrent events per AthenaMP worker", jps.ConcurrencyFlags.NumThreads, jps.ConcurrencyFlags.NumConcurrentEvents)
143 elif (jps.ConcurrencyFlags.NumProcs() == 0) :
144 _msg.info ("configuring AthenaHive with [%s] concurrent threads and [%s] concurrent events", jps.ConcurrencyFlags.NumThreads(), jps.ConcurrencyFlags.NumConcurrentEvents())
145 else:
146 # we should never get here
147 _msg.error ("ConcurrencyFlags.NumProcs() cannot == -1 !!")
148 sys.exit()
149
150 import AthenaCommon.AtlasThreadedJob