342def MainServicesCfg(flags, createEventLoopMgr=True):
343 """Configuration of main services. An appropriate EventLoopMgr is configured (MT/MP/etc).
344 If you have configured your own EventLoopMgr set createEventLoopMgr to False."""
345
346
347 from AthenaCommon.Logging import log
348 log.setLevel(flags.Exec.OutputLevel)
349
350
351 if flags.Exec.MPI:
352 if flags.Concurrency.NumThreads < 1:
353 raise Exception("Erroneous configuration for MPI: "
354 f"Concurrency.NumThreads = {flags.Concurrency.NumThreads}, must be >= 1")
355 if flags.Concurrency.NumProcs > 0:
356 raise Exception("Erroneous configuration for MPI: "
357 f"Concurrency.NumProcs = {flags.Concurrency.NumProcs}, must be 0")
358
359 if flags.Concurrency.NumThreads > 0 and flags.Concurrency.NumConcurrentEvents==0:
360 raise Exception("Requested Concurrency.NumThreads>0 and Concurrency.NumConcurrentEvents==0, "
361 "which will not process events!")
362
363
364 cfg = AppMgrCfg(flags)
365
366
367 addMainSequences(flags, cfg)
368
369
370 cfg.addService(CompFactory.ClassIDSvc(CLIDDBFiles = ['clid.db','Gaudi_clid.db']))
371
372 cfg.addService(CompFactory.AlgContextSvc(BypassIncidents=True))
373 cfg.addAuditor(CompFactory.AlgContextAuditor())
374
375 cfg.addService(CompFactory.StoreGateSvc(Dump=flags.Debug.DumpEvtStore))
376 cfg.addService(CompFactory.StoreGateSvc("DetectorStore",Dump=flags.Debug.DumpDetStore))
377 cfg.addService(CompFactory.StoreGateSvc("HistoryStore"))
378 cfg.addService(CompFactory.StoreGateSvc("ConditionStore",Dump=flags.Debug.DumpCondStore))
379
380 cfg.merge(MessageSvcCfg(flags))
381
382 from AthenaServices.FPEAndCoreDumpConfig import FPEAndCoreDumpCfg
383 cfg.merge(FPEAndCoreDumpCfg(flags))
384
385 if flags.Debug.NameAuditor:
386 cfg.addAuditor(CompFactory.NameAuditor())
387
388
389
390
391 cfg.addService(CompFactory.ExceptionSvc(Catch="NONE"))
392
393
394
395
396
397 cfg.addService(CompFactory.AthEnvironmentSvc(), create=True)
398
399 if flags.Exec.DebugStage != "":
400 cfg.setDebugStage(flags.Exec.DebugStage)
401
402 cfg.interactive = flags.Exec.Interactive
403
404
405 if flags.Exec.EventTimeOut > 0:
406 timeoutAlg = CompFactory.TimeoutAlg(
407 Timeout = flags.Exec.EventTimeOut,
408 AbortJob = True,
409 DumpSchedulerState = False)
410 cfg.addEventAlgo(timeoutAlg, sequenceName='AthBeginSeq')
411
412
413 if flags.Exec.Interactive == "run":
414 cfg.merge(PyAthenaEventLoopMgrCfg(flags))
415 log.info("Interactive mode, switching to PyAthenaEventLoopMgr")
416
417 elif flags.Concurrency.NumProcs > 0:
418 cfg.merge(AthenaMpEventLoopMgrCfg(flags))
419
420 elif createEventLoopMgr is False:
421 pass
422
423 elif flags.Concurrency.NumThreads > 0:
424
425 cfg.addAuditor( CompFactory.SGCommitAuditor() )
426
427 if flags.Exec.MTEventService:
428 cfg.merge(AthenaMtesEventLoopMgrCfg(flags,True,flags.Exec.MTEventServiceChannel))
429 elif flags.Exec.MPI:
430 cfg.merge(MPIHiveEventLoopMgrCfg(flags))
431 else:
432 cfg.merge(AthenaHiveEventLoopMgrCfg(flags))
433
434 elif flags.Concurrency.NumThreads == 0:
435 cfg.merge(AthenaEventLoopMgrCfg(flags))
436
437
438 if flags.PerfMon.doFastMonMT or flags.PerfMon.doFullMonMT:
439 from PerfMonComps.PerfMonCompsConfig import PerfMonMTSvcCfg
440 cfg.merge(PerfMonMTSvcCfg(flags))
441
442 if flags.PerfMon.doGPerfProf:
443 from PerfMonGPerfTools.GPT_ProfilerServiceConfig import GPT_ProfilerServiceCfg
444 cfg.merge(GPT_ProfilerServiceCfg(flags))
445
446 if len(flags.PerfMon.Valgrind.ProfiledAlgs)>0:
447 from Valkyrie.ValkyrieConfig import ValgrindServiceCfg
448 cfg.merge(ValgrindServiceCfg(flags))
449
450 return cfg
451
452