ATLAS Offline Software
AthenaMPToolBase.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ATHENAMPTOOLS_ATHENAMPTOOLBASE_H
6 #define ATHENAMPTOOLS_ATHENAMPTOOLBASE_H
7 
10 #include "GaudiKernel/IEventProcessor.h"
11 #include "GaudiKernel/IAppMgrUI.h"
12 #include "GaudiKernel/IFileMgr.h"
13 #include "GaudiKernel/IIoComponentMgr.h"
14 
18 
19 #include <filesystem>
20 
21 class IEvtSelector;
22 
23 class AthenaMPToolBase : public extends<AthAlgTool, IAthenaMPTool>,
25 {
26  public:
27  AthenaMPToolBase(const std::string& type
28  , const std::string& name
29  , const IInterface* parent);
30 
31  virtual ~AthenaMPToolBase() override;
32 
33  virtual StatusCode initialize() override;
34  virtual StatusCode finalize() override;
35 
36  // _________IAthenaMPTool_________
37  virtual StatusCode wait_once ATLAS_NOT_THREAD_SAFE (pid_t& pid) override;
38 
39  virtual void reportSubprocessStatuses() override;
41 
42  virtual void useFdsRegistry(std::shared_ptr<AthenaInterprocess::FdsRegistry>) override;
43  virtual void setRandString(const std::string& randStr) override;
44  virtual void setMaxEvt(int maxEvt) override {m_maxEvt=maxEvt;}
45  virtual void setMPRunStop(const AthenaInterprocess::IMPRunStop* runStop) override {m_mpRunStop=runStop;}
46 
47  virtual void killChildren() override;
48 
49  // _________IMessageDecoder_________
50  virtual std::unique_ptr<AthenaInterprocess::ScheduledWork> operator() ATLAS_NOT_THREAD_SAFE (const AthenaInterprocess::ScheduledWork&) override;
51 
52  // _____ Actual working horses ________
53  virtual std::unique_ptr<AthenaInterprocess::ScheduledWork> bootstrap_func() = 0;
54  virtual std::unique_ptr<AthenaInterprocess::ScheduledWork> exec_func() = 0;
55  virtual std::unique_ptr<AthenaInterprocess::ScheduledWork> fin_func() = 0;
56 
57  protected:
65  };
66 
67  enum Func_Flag {
71  };
72 
74  int redirectLog(const std::string& rundir, bool addTimeStamp = true);
75  int updateIoReg(const std::string& rundir);
76  std::string fmterror(int errnum);
77 
78  int reopenFds();
79  int handleSavedPfc(const std::filesystem::path& dest_path);
80 
81  void waitForSignal();
82 
83  IEvtSelector* evtSelector() { return m_evtSelector; }
84 
85  int m_nprocs{-1};
86  int m_maxEvt{-1};
87  std::string m_subprocTopDir;
88  std::string m_subprocDirPrefix;
89  std::string m_evtSelName;
90 
93 
98  SmartIF<IEvtSelector> m_evtSelector;
99  std::string m_fileMgrLog;
100  std::shared_ptr<AthenaInterprocess::FdsRegistry> m_fdsRegistry;
101  std::string m_randStr;
102 
103  Gaudi::Property<bool> m_isPileup {this, "IsPileup", false, "Flag for configuring PileUpEventLoopMgr"};
104 
105  private:
109  int reopenFd(int fd, const std::string& name); // reopen individual descriptor
110 
111 };
112 
113 #endif
AthenaMPToolBase::killChildren
virtual void killChildren() override
Definition: AthenaMPToolBase.cxx:201
python.DQPostProcessMod.rundir
def rundir(fname)
Definition: DQPostProcessMod.py:115
pid_t
int32_t pid_t
Definition: FPGATrackSimTypes.h:19
AthenaInterprocess
Definition: FdsRegistry.h:11
AthenaMPToolBase::waitForSignal
void waitForSignal()
Definition: AthenaMPToolBase.cxx:403
IMessageDecoder.h
AthenaMPToolBase::fin_func
virtual std::unique_ptr< AthenaInterprocess::ScheduledWork > fin_func()=0
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:128
AthenaMPToolBase::ESRANGE_BADINPFILE
@ ESRANGE_BADINPFILE
Definition: AthenaMPToolBase.h:64
AthenaMPToolBase::m_processGroup
AthenaInterprocess::ProcessGroup * m_processGroup
Definition: AthenaMPToolBase.h:91
AthenaMPToolBase::~AthenaMPToolBase
virtual ~AthenaMPToolBase() override
Definition: AthenaMPToolBase.cxx:44
AthenaMPToolBase::exec_func
virtual std::unique_ptr< AthenaInterprocess::ScheduledWork > exec_func()=0
AthenaMPToolBase::m_randStr
std::string m_randStr
Definition: AthenaMPToolBase.h:101
AthenaMPToolBase::m_nprocs
int m_nprocs
Number of workers spawned by the master process.
Definition: AthenaMPToolBase.h:85
AthenaMPToolBase::ESRange_Status
ESRange_Status
Definition: AthenaMPToolBase.h:58
AthenaMPToolBase::FUNC_FIN
@ FUNC_FIN
Definition: AthenaMPToolBase.h:70
AthenaMPToolBase::setRandString
virtual void setRandString(const std::string &randStr) override
Definition: AthenaMPToolBase.cxx:196
AthenaMPToolBase
Definition: AthenaMPToolBase.h:25
AthenaMPToolBase::fmterror
std::string fmterror(int errnum)
Definition: AthenaMPToolBase.cxx:333
AthenaMPToolBase::ATLAS_NOT_THREAD_SAFE
int mapAsyncFlag ATLAS_NOT_THREAD_SAFE(Func_Flag flag, pid_t pid=0)
AthenaMPToolBase::generateOutputReport
virtual AthenaMP::AllWorkerOutputs_ptr generateOutputReport() override
Definition: AthenaMPToolBase.cxx:119
AthenaMPToolBase::m_evtSelName
std::string m_evtSelName
Name of the event selector.
Definition: AthenaMPToolBase.h:89
AthenaMPToolBase::finalize
virtual StatusCode finalize() override
Definition: AthenaMPToolBase.cxx:87
ProcessGroup.h
AthenaMPToolBase::ESRANGE_SEEKFAILED
@ ESRANGE_SEEKFAILED
Definition: AthenaMPToolBase.h:61
AthenaMPToolBase::setMaxEvt
virtual void setMaxEvt(int maxEvt) override
Definition: AthenaMPToolBase.h:44
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
AthenaMPToolBase::m_fileMgrLog
std::string m_fileMgrLog
Definition: AthenaMPToolBase.h:99
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
AthenaMPToolBase::FUNC_EXEC
@ FUNC_EXEC
Definition: AthenaMPToolBase.h:69
AthenaInterprocess::IMessageDecoder::operator
virtual std::unique_ptr< ScheduledWork > operator() ATLAS_NOT_THREAD_SAFE(const ScheduledWork &)=0
AthenaMPToolBase::m_evtSelector
SmartIF< IEvtSelector > m_evtSelector
Definition: AthenaMPToolBase.h:98
AthenaMPToolBase::m_appMgr
ServiceHandle< IAppMgrUI > m_appMgr
Definition: AthenaMPToolBase.h:95
AthenaMPToolBase::m_isPileup
Gaudi::Property< bool > m_isPileup
Definition: AthenaMPToolBase.h:103
AthenaMPToolBase::AthenaMPToolBase
AthenaMPToolBase(const AthenaMPToolBase &)
AthenaMPToolBase::bootstrap_func
virtual std::unique_ptr< AthenaInterprocess::ScheduledWork > virtual operator() ATLAS_NOT_THREAD_SAFE(const AthenaInterprocess std::unique_ptr< AthenaInterprocess::ScheduledWork > bootstrap_func()=0
AthenaMPToolBase::setMPRunStop
virtual void setMPRunStop(const AthenaInterprocess::IMPRunStop *runStop) override
Definition: AthenaMPToolBase.h:45
AthenaMPToolBase::Func_Flag
Func_Flag
Definition: AthenaMPToolBase.h:67
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthenaInterprocess::ProcessGroup
Definition: ProcessGroup.h:27
AthenaMPToolBase::useFdsRegistry
virtual void useFdsRegistry(std::shared_ptr< AthenaInterprocess::FdsRegistry >) override
Definition: AthenaMPToolBase.cxx:191
master.flag
bool flag
Definition: master.py:29
AthAlgTool.h
AthenaMPToolBase::reopenFd
int reopenFd(int fd, const std::string &name)
Definition: AthenaMPToolBase.cxx:419
AthenaMPToolBase::AthenaMPToolBase
AthenaMPToolBase()
ParticleGun_EoverP_Config.pid
pid
Definition: ParticleGun_EoverP_Config.py:62
AthenaMPToolBase::evtSelector
IEvtSelector * evtSelector()
Definition: AthenaMPToolBase.h:83
test_pyathena.parent
parent
Definition: test_pyathena.py:15
AthenaMPToolBase::ESRANGE_SUCCESS
@ ESRANGE_SUCCESS
Definition: AthenaMPToolBase.h:59
AthenaMPToolBase::updateIoReg
int updateIoReg(const std::string &rundir)
Definition: AthenaMPToolBase.cxx:322
AthenaMPToolBase::initialize
virtual StatusCode initialize() override
Definition: AthenaMPToolBase.cxx:48
AthenaMPToolBase::m_mpRunStop
const AthenaInterprocess::IMPRunStop * m_mpRunStop
Definition: AthenaMPToolBase.h:92
ReadFromCoolCompare.fd
fd
Definition: ReadFromCoolCompare.py:196
AthenaInterprocess::IMessageDecoder
Definition: IMessageDecoder.h:18
AthenaMPToolBase::ESRANGE_PROCFAILED
@ ESRANGE_PROCFAILED
Definition: AthenaMPToolBase.h:62
protected
#define protected
Definition: GenEventCnv_p1.h:26
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
AthenaMPToolBase::m_ioMgr
ServiceHandle< IIoComponentMgr > m_ioMgr
Definition: AthenaMPToolBase.h:97
AthenaMPToolBase::redirectLog
int redirectLog(const std::string &rundir, bool addTimeStamp=true)
Definition: AthenaMPToolBase.cxx:269
AthenaMPToolBase::m_maxEvt
int m_maxEvt
Maximum number of events assigned to the job.
Definition: AthenaMPToolBase.h:86
IAthenaMPTool.h
AthenaMP::AllWorkerOutputs_ptr
std::unique_ptr< AllWorkerOutputs > AllWorkerOutputs_ptr
Definition: IAthenaMPTool.h:32
AthenaMPToolBase::reportSubprocessStatuses
virtual void reportSubprocessStatuses() override
Definition: AthenaMPToolBase.cxx:111
AthenaMPToolBase::ATLAS_NOT_THREAD_SAFE
virtual StatusCode wait_once ATLAS_NOT_THREAD_SAFE(pid_t &pid) override
AthenaMPToolBase::operator=
AthenaMPToolBase & operator=(const AthenaMPToolBase &)
AthenaMPToolBase::m_subprocDirPrefix
std::string m_subprocDirPrefix
For ex. "worker__".
Definition: AthenaMPToolBase.h:88
AthenaMPToolBase::m_subprocTopDir
std::string m_subprocTopDir
Top run directory for subprocesses.
Definition: AthenaMPToolBase.h:87
AthenaMPToolBase::ESRANGE_NOTFOUND
@ ESRANGE_NOTFOUND
Definition: AthenaMPToolBase.h:60
AthenaInterprocess::IMPRunStop
Definition: IMPRunStop.h:10
AthenaMPToolBase::handleSavedPfc
int handleSavedPfc(const std::filesystem::path &dest_path)
Definition: AthenaMPToolBase.cxx:396
AthenaMPToolBase::m_fileMgr
ServiceHandle< IFileMgr > m_fileMgr
Definition: AthenaMPToolBase.h:96
AthenaMPToolBase::FUNC_BOOTSTRAP
@ FUNC_BOOTSTRAP
Definition: AthenaMPToolBase.h:68
IMPRunStop.h
AthenaMPToolBase::reopenFds
int reopenFds()
Definition: AthenaMPToolBase.cxx:340
AthenaMPToolBase::ESRANGE_FILENOTMADE
@ ESRANGE_FILENOTMADE
Definition: AthenaMPToolBase.h:63
AthenaMPToolBase::m_fdsRegistry
std::shared_ptr< AthenaInterprocess::FdsRegistry > m_fdsRegistry
Definition: AthenaMPToolBase.h:100
ServiceHandle< IEventProcessor >
AthenaMPToolBase::m_evtProcessor
ServiceHandle< IEventProcessor > m_evtProcessor
Definition: AthenaMPToolBase.h:94