ATLAS Offline Software
MPIClusterSvc.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 #ifndef ATHENASERVICES_MPICLUSTERSVC_H_
5 #define ATHENASERVICES_MPICLUSTERSVC_H_
6 
7 #include <memory>
8 #include <string>
9 
13 
14 #include "GaudiKernel/IIncidentListener.h"
15 
17 #include "SQLiteDBSvc/Statement.h"
18 #include "mpi3/environment.hpp"
19 
20 namespace mpi3 = boost::mpi3;
21 
26 class MPIClusterSvc : public extends<AthService, IMPIClusterSvc, IIncidentListener> {
27  public:
29  MPIClusterSvc(const std::string& name, ISvcLocator* svcLoc)
30  : extends(name, svcLoc) {}
31 
33  virtual StatusCode initialize() override final;
34 
36  virtual StatusCode finalize() override final;
37 
39  virtual void handle(const Incident& inc) override;
40 
42  virtual int numRanks() const override final;
43 
45  virtual int rank() const override final;
46 
49  virtual void barrier() override final;
50 
52  virtual void abort() override final;
53 
55  virtual void sendMessage(
56  int destRank, ClusterMessage message,
57  ClusterComm communicator = ClusterComm::Default) override final;
58 
61  ClusterComm communicator = ClusterComm::Default) override final;
62 
64  virtual mpi3::communicator& data_communicator() override final {
65  return m_datacom;
66  }
67 
69  virtual void log_addEvent(int eventIdx, std::int64_t run_number,
70  std::int64_t event_number,
71  std::int64_t request_time_ns,
72  std::size_t slot) override final;
74  virtual void log_completeEvent(std::int64_t run_number,
75  std::int64_t event_number,
76  std::int64_t status) override final;
77 
78  private:
79  std::unique_ptr<mpi3::environment> m_env;
80  mpi3::communicator m_world;
81  // Communicator for payload of event data messages
82  mpi3::communicator m_datacom;
83  int m_rank = -1;
84 
85  // MPI Log DB
86  ServiceHandle<ISQLiteDBSvc> m_mpiLog{this, "LogDatabaseSvc", "",
87  "SQLiteDBSvc for the MPI event log"};
91 
92  // Hold current input filename hash for each slot
93  std::int64_t m_lastInputFileHash{};
94  std::map<std::size_t, std::int64_t> m_inputFileSlotMap{};
95 };
96 #endif // ATHENASERVICES_MPICLUSTERSVC_H_
MPIClusterSvc::handle
virtual void handle(const Incident &inc) override
IIncidentListener handle.
Definition: MPIClusterSvc.cxx:82
plotting.plot_kinematics.run_number
run_number
Definition: plot_kinematics.py:29
MPIClusterSvc::MPIClusterSvc
MPIClusterSvc(const std::string &name, ISvcLocator *svcLoc)
Constructor.
Definition: MPIClusterSvc.h:29
MPIClusterSvc::log_addEvent
virtual void log_addEvent(int eventIdx, std::int64_t run_number, std::int64_t event_number, std::int64_t request_time_ns, std::size_t slot) override final
Add (begin) an event in the log.
Definition: MPIClusterSvc.cxx:202
SQLite::Statement
SQLite prepared statement.
Definition: Statement.h:50
Statement.h
MPIClusterSvc::numRanks
virtual int numRanks() const override final
Return number of ranks.
Definition: MPIClusterSvc.cxx:106
MPIClusterSvc
A service managing communications within a cluster using MPI.
Definition: MPIClusterSvc.h:26
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
MPIClusterSvc::sendMessage
virtual void sendMessage(int destRank, ClusterMessage message, ClusterComm communicator=ClusterComm::Default) override final
Send an MPI message.
Definition: MPIClusterSvc.cxx:123
ReweightUtils.message
message
Definition: ReweightUtils.py:15
MPIClusterSvc::m_mpiLog_addFile
SQLite::Statement m_mpiLog_addFile
Definition: MPIClusterSvc.h:90
MPIClusterSvc::data_communicator
virtual mpi3::communicator & data_communicator() override final
Return the data communicator.
Definition: MPIClusterSvc.h:64
MPIClusterSvc::abort
virtual void abort() override final
Abort the MPI run.
Definition: MPIClusterSvc.cxx:119
boost::mpi3
Definition: IMPIClusterSvc.h:14
MPIClusterSvc::finalize
virtual StatusCode finalize() override final
Finalize.
Definition: MPIClusterSvc.cxx:72
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MPIClusterSvc::m_mpiLog_addEvent
SQLite::Statement m_mpiLog_addEvent
Definition: MPIClusterSvc.h:88
MPIClusterSvc::m_lastInputFileHash
std::int64_t m_lastInputFileHash
Definition: MPIClusterSvc.h:93
MPIClusterSvc::initialize
virtual StatusCode initialize() override final
Initialize.
Definition: MPIClusterSvc.cxx:11
ISQLiteDBSvc.h
columnar::final
CM final
Definition: ColumnAccessor.h:106
ClusterMessage
A class describing a message sent between nodes in a cluster.
Definition: ClusterMessage.h:30
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
MPIClusterSvc::waitReceiveMessage
virtual ClusterMessage waitReceiveMessage(ClusterComm communicator=ClusterComm::Default) override final
Block until we receive an MPI message.
Definition: MPIClusterSvc.cxx:165
ClusterComm
ClusterComm
Definition: IMPIClusterSvc.h:18
MPIClusterSvc::rank
virtual int rank() const override final
Return our rank.
Definition: MPIClusterSvc.cxx:110
MPIClusterSvc::m_mpiLog_completeEvent
SQLite::Statement m_mpiLog_completeEvent
Definition: MPIClusterSvc.h:89
MPIClusterSvc::m_inputFileSlotMap
std::map< std::size_t, std::int64_t > m_inputFileSlotMap
Definition: MPIClusterSvc.h:94
MPIClusterSvc::m_mpiLog
ServiceHandle< ISQLiteDBSvc > m_mpiLog
Definition: MPIClusterSvc.h:86
MPIClusterSvc::m_datacom
mpi3::communicator m_datacom
Definition: MPIClusterSvc.h:82
MPIClusterSvc::log_completeEvent
virtual void log_completeEvent(std::int64_t run_number, std::int64_t event_number, std::int64_t status) override final
Complete an event in the log.
Definition: MPIClusterSvc.cxx:211
AthService.h
MPIClusterSvc::m_rank
int m_rank
Definition: MPIClusterSvc.h:83
MPIClusterSvc::m_world
mpi3::communicator m_world
Definition: MPIClusterSvc.h:80
merge.status
status
Definition: merge.py:16
IMPIClusterSvc.h
Default
ClusterMessage.h
MPIClusterSvc::barrier
virtual void barrier() override final
Insert a barrier No rank will continue until all ranks reach this point.
Definition: MPIClusterSvc.cxx:114
ServiceHandle< ISQLiteDBSvc >
MPIClusterSvc::m_env
std::unique_ptr< mpi3::environment > m_env
Definition: MPIClusterSvc.h:79