[342] | 1 | #ifndef __SERVER_HPP__ |
---|
| 2 | #define __SERVER_HPP__ |
---|
[300] | 3 | |
---|
[591] | 4 | #include "xios_spl.hpp" |
---|
[300] | 5 | #include "context.hpp" |
---|
[697] | 6 | #include "context_client.hpp" |
---|
[382] | 7 | #include "mpi.hpp" |
---|
[492] | 8 | #include "event_scheduler.hpp" |
---|
[300] | 9 | |
---|
[335] | 10 | namespace xios |
---|
[300] | 11 | { |
---|
[1761] | 12 | class CServersRessource ; |
---|
| 13 | |
---|
[300] | 14 | class CServer |
---|
| 15 | { |
---|
[523] | 16 | public: |
---|
| 17 | static void initialize(void); |
---|
[1761] | 18 | static void xiosGlobalCommByFileExchange(MPI_Comm serverComm) ; |
---|
| 19 | static void xiosGlobalCommByPublishing(MPI_Comm serverComm) ; |
---|
| 20 | |
---|
[2333] | 21 | static void listenRootOasisEnddef(void); |
---|
| 22 | static void listenOasisEnddef(void); |
---|
| 23 | |
---|
[523] | 24 | static void finalize(void); |
---|
| 25 | static void eventLoop(void); |
---|
[1765] | 26 | |
---|
[2332] | 27 | static MPI_Comm intraComm_; |
---|
[1761] | 28 | static MPI_Comm serversComm_; |
---|
[1639] | 29 | static std::list<MPI_Comm> interCommLeft; // interComm between server (primary, classical or secondary) and its client (client or primary server) |
---|
| 30 | static std::list<MPI_Comm> interCommRight; // interComm between primary server and secondary server (non-empty only for primary server pool) |
---|
| 31 | static std::list<MPI_Comm> contextInterComms; // list of context intercomms |
---|
| 32 | static std::list<MPI_Comm> contextIntraComms; // list of context intercomms (needed only in case of secondary servers) |
---|
[523] | 33 | static CEventScheduler* eventScheduler; |
---|
[983] | 34 | |
---|
[1021] | 35 | static int serverLevel ; |
---|
[1009] | 36 | |
---|
[523] | 37 | struct contextMessage |
---|
| 38 | { |
---|
| 39 | int nbRecv; |
---|
| 40 | int leaderRank; |
---|
| 41 | }; |
---|
[300] | 42 | |
---|
[523] | 43 | static bool isRoot; |
---|
[490] | 44 | |
---|
[1054] | 45 | static map<string,CContext*> contextList; |
---|
[523] | 46 | static bool finished; |
---|
| 47 | static bool is_MPI_Initialized; |
---|
[490] | 48 | |
---|
[523] | 49 | public: |
---|
[1243] | 50 | //! Get rank of the current process in the intraComm |
---|
[523] | 51 | static int getRank(); |
---|
[490] | 52 | |
---|
[1180] | 53 | //!< Get global ranks of secondary server processes |
---|
[1168] | 54 | static vector<int>& getSecondaryServerGlobalRanks(); |
---|
| 55 | |
---|
[523] | 56 | //! Open a file stream to write the info logs |
---|
[490] | 57 | static void openInfoStream(const StdString& fileName); |
---|
[523] | 58 | //! Write the info logs to standard output |
---|
[490] | 59 | static void openInfoStream(); |
---|
[523] | 60 | //! Close the info logs file if it opens |
---|
[490] | 61 | static void closeInfoStream(); |
---|
| 62 | |
---|
[523] | 63 | //! Open a file stream to write the error log |
---|
| 64 | static void openErrorStream(const StdString& fileName); |
---|
| 65 | //! Write the error log to standard error output |
---|
| 66 | static void openErrorStream(); |
---|
| 67 | //! Close the error log file if it opens |
---|
| 68 | static void closeErrorStream(); |
---|
| 69 | |
---|
[1761] | 70 | static CServersRessource* getServersRessource(void) { return serversRessource_;} |
---|
| 71 | static void launchServersRessource(MPI_Comm commServer) ; |
---|
[2274] | 72 | static void finalizeServersRessource(void) ; |
---|
[2212] | 73 | static void openStream(const StdString& fileName, const StdString& ext, std::filebuf* fb); |
---|
[1761] | 74 | |
---|
[523] | 75 | private: |
---|
[1243] | 76 | static vector<int> sndServerGlobalRanks; //!< Global ranks of pool leaders on the secondary server |
---|
| 77 | static int rank_; //!< If (!oasis) global rank, else rank in the intraComm returned by oasis |
---|
| 78 | static int nbContexts; //!< Number of contexts registered by server |
---|
[490] | 79 | static StdOFStream m_infoStream; |
---|
[523] | 80 | static StdOFStream m_errorStream; |
---|
[2274] | 81 | static CServersRessource* serversRessource_ ; |
---|
[523] | 82 | }; |
---|
[300] | 83 | } |
---|
| 84 | |
---|
| 85 | #endif |
---|