ATLAS Offline Software
AthenaMPToolBase.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 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 
17 
18 #include <filesystem>
19 
20 class IEvtSelector;
21 
23  , public 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 
45  virtual void killChildren() override;
46 
47  // _________IMessageDecoder_________
48  virtual std::unique_ptr<AthenaInterprocess::ScheduledWork> operator() ATLAS_NOT_THREAD_SAFE (const AthenaInterprocess::ScheduledWork&) override;
49 
50  // _____ Actual working horses ________
51  virtual std::unique_ptr<AthenaInterprocess::ScheduledWork> bootstrap_func() = 0;
52  virtual std::unique_ptr<AthenaInterprocess::ScheduledWork> exec_func() = 0;
53  virtual std::unique_ptr<AthenaInterprocess::ScheduledWork> fin_func() = 0;
54 
55  protected:
63  };
64 
65  enum Func_Flag {
69  };
70 
72  int redirectLog(const std::string& rundir, bool addTimeStamp = true);
73  int updateIoReg(const std::string& rundir);
74  std::string fmterror(int errnum);
75 
76  int reopenFds();
77  int handleSavedPfc(const std::filesystem::path& dest_path);
78 
79  void waitForSignal();
80 
81  IEvtSelector* evtSelector() { return m_evtSelector; }
82 
83  int m_nprocs; // Number of workers spawned by the master process
84  std::string m_subprocTopDir; // Top run directory for subprocesses
85  std::string m_subprocDirPrefix; // For ex. "worker__"
86  std::string m_evtSelName; // Name of the event selector
87 
89 
94  SmartIF<IEvtSelector> m_evtSelector;
95  std::string m_fileMgrLog;
96  std::shared_ptr<AthenaInterprocess::FdsRegistry> m_fdsRegistry;
97  std::string m_randStr;
98 
99  Gaudi::Property<bool> m_isPileup {this, "IsPileup", false, "Flag for configuring PileUpEventLoopMgr"};
100 
101  private:
105  int reopenFd(int fd, const std::string& name); // reopen individual descriptor
106 
107 };
108 
109 #endif
AthenaMPToolBase::killChildren
virtual void killChildren() override
Definition: AthenaMPToolBase.cxx:213
python.DQPostProcessMod.rundir
def rundir(fname)
Definition: DQPostProcessMod.py:116
pid_t
int32_t pid_t
Definition: FPGATrackSimTypes.h:19
AthenaInterprocess
Definition: FdsRegistry.h:11
AthenaMPToolBase::waitForSignal
void waitForSignal()
Definition: AthenaMPToolBase.cxx:428
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:62
AthenaMPToolBase::m_processGroup
AthenaInterprocess::ProcessGroup * m_processGroup
Definition: AthenaMPToolBase.h:88
AthenaMPToolBase::~AthenaMPToolBase
virtual ~AthenaMPToolBase() override
Definition: AthenaMPToolBase.cxx:51
AthenaMPToolBase::exec_func
virtual std::unique_ptr< AthenaInterprocess::ScheduledWork > exec_func()=0
AthenaMPToolBase::m_randStr
std::string m_randStr
Definition: AthenaMPToolBase.h:97
AthenaMPToolBase::m_nprocs
int m_nprocs
Definition: AthenaMPToolBase.h:83
AthenaMPToolBase::ESRange_Status
ESRange_Status
Definition: AthenaMPToolBase.h:56
AthenaMPToolBase::FUNC_FIN
@ FUNC_FIN
Definition: AthenaMPToolBase.h:68
AthenaMPToolBase::setRandString
virtual void setRandString(const std::string &randStr) override
Definition: AthenaMPToolBase.cxx:208
AthenaMPToolBase
Definition: AthenaMPToolBase.h:25
AthenaMPToolBase::fmterror
std::string fmterror(int errnum)
Definition: AthenaMPToolBase.cxx:358
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:131
AthenaMPToolBase::m_evtSelName
std::string m_evtSelName
Definition: AthenaMPToolBase.h:86
AthenaMPToolBase::finalize
virtual StatusCode finalize() override
Definition: AthenaMPToolBase.cxx:99
ProcessGroup.h
AthenaMPToolBase::ESRANGE_SEEKFAILED
@ ESRANGE_SEEKFAILED
Definition: AthenaMPToolBase.h:59
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
AthenaMPToolBase::m_fileMgrLog
std::string m_fileMgrLog
Definition: AthenaMPToolBase.h:95
protected
#define protected
Definition: DetDescrConditionsDict_dict_fixes.cxx:14
AthenaMPToolBase::FUNC_EXEC
@ FUNC_EXEC
Definition: AthenaMPToolBase.h:67
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:94
AthenaMPToolBase::m_appMgr
ServiceHandle< IAppMgrUI > m_appMgr
Definition: AthenaMPToolBase.h:91
AthenaMPToolBase::m_isPileup
Gaudi::Property< bool > m_isPileup
Definition: AthenaMPToolBase.h:99
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::Func_Flag
Func_Flag
Definition: AthenaMPToolBase.h:65
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:203
master.flag
bool flag
Definition: master.py:29
AthAlgTool.h
AthenaMPToolBase::reopenFd
int reopenFd(int fd, const std::string &name)
Definition: AthenaMPToolBase.cxx:444
AthenaMPToolBase::AthenaMPToolBase
AthenaMPToolBase()
ParticleGun_EoverP_Config.pid
pid
Definition: ParticleGun_EoverP_Config.py:62
AthenaMPToolBase::evtSelector
IEvtSelector * evtSelector()
Definition: AthenaMPToolBase.h:81
test_pyathena.parent
parent
Definition: test_pyathena.py:15
AthenaMPToolBase::ESRANGE_SUCCESS
@ ESRANGE_SUCCESS
Definition: AthenaMPToolBase.h:57
IAthenaMPTool
Definition: IAthenaMPTool.h:34
AthenaMPToolBase::updateIoReg
int updateIoReg(const std::string &rundir)
Definition: AthenaMPToolBase.cxx:337
AthenaMPToolBase::initialize
virtual StatusCode initialize() override
Definition: AthenaMPToolBase.cxx:55
ReadFromCoolCompare.fd
fd
Definition: ReadFromCoolCompare.py:196
AthenaInterprocess::IMessageDecoder
Definition: IMessageDecoder.h:18
AthenaMPToolBase::ESRANGE_PROCFAILED
@ ESRANGE_PROCFAILED
Definition: AthenaMPToolBase.h:60
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
AthenaMPToolBase::m_ioMgr
ServiceHandle< IIoComponentMgr > m_ioMgr
Definition: AthenaMPToolBase.h:93
AthenaMPToolBase::redirectLog
int redirectLog(const std::string &rundir, bool addTimeStamp=true)
Definition: AthenaMPToolBase.cxx:281
IAthenaMPTool.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
AthenaMP::AllWorkerOutputs_ptr
std::unique_ptr< AllWorkerOutputs > AllWorkerOutputs_ptr
Definition: IAthenaMPTool.h:28
AthenaMPToolBase::reportSubprocessStatuses
virtual void reportSubprocessStatuses() override
Definition: AthenaMPToolBase.cxx:123
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
Definition: AthenaMPToolBase.h:85
AthenaMPToolBase::m_subprocTopDir
std::string m_subprocTopDir
Definition: AthenaMPToolBase.h:84
AthAlgTool
Definition: AthAlgTool.h:26
IAthenaMPTool::ATLAS_NOT_THREAD_SAFE
virtual StatusCode exec ATLAS_NOT_THREAD_SAFE()=0
AthenaMPToolBase::ESRANGE_NOTFOUND
@ ESRANGE_NOTFOUND
Definition: AthenaMPToolBase.h:58
AthenaMPToolBase::handleSavedPfc
int handleSavedPfc(const std::filesystem::path &dest_path)
Definition: AthenaMPToolBase.cxx:421
AthenaMPToolBase::m_fileMgr
ServiceHandle< IFileMgr > m_fileMgr
Definition: AthenaMPToolBase.h:92
AthenaMPToolBase::FUNC_BOOTSTRAP
@ FUNC_BOOTSTRAP
Definition: AthenaMPToolBase.h:66
AthenaMPToolBase::reopenFds
int reopenFds()
Definition: AthenaMPToolBase.cxx:365
AthenaMPToolBase::ESRANGE_FILENOTMADE
@ ESRANGE_FILENOTMADE
Definition: AthenaMPToolBase.h:61
AthenaMPToolBase::m_fdsRegistry
std::shared_ptr< AthenaInterprocess::FdsRegistry > m_fdsRegistry
Definition: AthenaMPToolBase.h:96
ServiceHandle< IEventProcessor >
AthenaMPToolBase::m_evtProcessor
ServiceHandle< IEventProcessor > m_evtProcessor
Definition: AthenaMPToolBase.h:90