ATLAS Offline Software
Loading...
Searching...
No Matches
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
18#include "mpi3/environment.hpp"
19
20namespace mpi3 = boost::mpi3;
21
26class 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_
ClusterComm
std::int64_t m_lastInputFileHash
virtual ClusterMessage waitReceiveMessage(ClusterComm communicator=ClusterComm::Default) override final
Block until we receive an MPI message.
virtual void barrier() override final
Insert a barrier No rank will continue until all ranks reach this point.
virtual mpi3::communicator & data_communicator() override final
Return the data communicator.
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.
SQLite::Statement m_mpiLog_addFile
std::unique_ptr< mpi3::environment > m_env
SQLite::Statement m_mpiLog_addEvent
virtual void handle(const Incident &inc) override
IIncidentListener handle.
virtual void abort() override final
Abort the MPI run.
virtual int rank() const override final
Return our rank.
MPIClusterSvc(const std::string &name, ISvcLocator *svcLoc)
Constructor.
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.
mpi3::communicator m_world
virtual StatusCode initialize() override final
Initialize.
mpi3::communicator m_datacom
virtual StatusCode finalize() override final
Finalize.
SQLite::Statement m_mpiLog_completeEvent
virtual void sendMessage(int destRank, ClusterMessage message, ClusterComm communicator=ClusterComm::Default) override final
Send an MPI message.
ServiceHandle< ISQLiteDBSvc > m_mpiLog
virtual int numRanks() const override final
Return number of ranks.
std::map< std::size_t, std::int64_t > m_inputFileSlotMap
SQLite prepared statement.
Definition Statement.h:50
A class describing a message sent between nodes in a cluster.