[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 | { |
---|
| 12 | class CServer |
---|
| 13 | { |
---|
[523] | 14 | public: |
---|
| 15 | static void initialize(void); |
---|
| 16 | static void finalize(void); |
---|
| 17 | static void eventLoop(void); |
---|
[1378] | 18 | static void contextEventLoop(bool enableEventsProcessing=true); |
---|
[523] | 19 | static void listenContext(void); |
---|
| 20 | static void listenFinalize(void); |
---|
| 21 | static void recvContextMessage(void* buff,int count); |
---|
| 22 | static void listenRootContext(void); |
---|
| 23 | static void listenRootFinalize(void); |
---|
[1054] | 24 | static void registerContext(void* buff,int count, int leaderRank=0); |
---|
[490] | 25 | |
---|
[523] | 26 | static MPI_Comm intraComm; |
---|
[1180] | 27 | static std::list<MPI_Comm> interCommLeft; // interComm between server (primary, classical or secondary) and its client (client or primary server) |
---|
| 28 | static std::list<MPI_Comm> interCommRight; // interComm between primary server and secondary server (non-empty only for primary server pool) |
---|
[1071] | 29 | static std::list<MPI_Comm> contextInterComms; // list of context intercomms |
---|
| 30 | static std::list<MPI_Comm> contextIntraComms; // list of context intercomms (needed only in case of secondary servers) |
---|
[523] | 31 | static CEventScheduler* eventScheduler; |
---|
[983] | 32 | |
---|
[1021] | 33 | static int serverLevel ; |
---|
[1009] | 34 | |
---|
[523] | 35 | struct contextMessage |
---|
| 36 | { |
---|
| 37 | int nbRecv; |
---|
| 38 | int leaderRank; |
---|
| 39 | }; |
---|
[300] | 40 | |
---|
[523] | 41 | static bool isRoot; |
---|
[490] | 42 | |
---|
[1054] | 43 | static map<string,CContext*> contextList; |
---|
[523] | 44 | static bool finished; |
---|
| 45 | static bool is_MPI_Initialized; |
---|
[490] | 46 | |
---|
[523] | 47 | public: |
---|
[1243] | 48 | //! Get rank of the current process in the intraComm |
---|
[523] | 49 | static int getRank(); |
---|
[490] | 50 | |
---|
[1180] | 51 | //!< Get global ranks of secondary server processes |
---|
[1168] | 52 | static vector<int>& getSecondaryServerGlobalRanks(); |
---|
| 53 | |
---|
[523] | 54 | //! Open a file stream to write the info logs |
---|
[490] | 55 | static void openInfoStream(const StdString& fileName); |
---|
[523] | 56 | //! Write the info logs to standard output |
---|
[490] | 57 | static void openInfoStream(); |
---|
[523] | 58 | //! Close the info logs file if it opens |
---|
[490] | 59 | static void closeInfoStream(); |
---|
| 60 | |
---|
[523] | 61 | //! Open a file stream to write the error log |
---|
| 62 | static void openErrorStream(const StdString& fileName); |
---|
| 63 | //! Write the error log to standard error output |
---|
| 64 | static void openErrorStream(); |
---|
| 65 | //! Close the error log file if it opens |
---|
| 66 | static void closeErrorStream(); |
---|
| 67 | |
---|
| 68 | private: |
---|
[1243] | 69 | static vector<int> sndServerGlobalRanks; //!< Global ranks of pool leaders on the secondary server |
---|
| 70 | static int rank_; //!< If (!oasis) global rank, else rank in the intraComm returned by oasis |
---|
| 71 | static int nbContexts; //!< Number of contexts registered by server |
---|
[490] | 72 | static StdOFStream m_infoStream; |
---|
[523] | 73 | static StdOFStream m_errorStream; |
---|
| 74 | |
---|
| 75 | static void openStream(const StdString& fileName, const StdString& ext, std::filebuf* fb); |
---|
| 76 | }; |
---|
[300] | 77 | } |
---|
| 78 | |
---|
| 79 | #endif |
---|