[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 | |
---|
[1037] | 10 | #ifdef _usingEP |
---|
| 11 | #include "ep_declaration.hpp" |
---|
| 12 | #endif |
---|
| 13 | |
---|
[335] | 14 | namespace xios |
---|
[300] | 15 | { |
---|
| 16 | class CServer |
---|
| 17 | { |
---|
[523] | 18 | public: |
---|
| 19 | static void initialize(void); |
---|
| 20 | static void finalize(void); |
---|
| 21 | static void eventLoop(void); |
---|
| 22 | static void contextEventLoop(void); |
---|
| 23 | static void listenContext(void); |
---|
| 24 | static void listenFinalize(void); |
---|
| 25 | static void recvContextMessage(void* buff,int count); |
---|
| 26 | static void listenRootContext(void); |
---|
| 27 | static void listenRootFinalize(void); |
---|
| 28 | static void registerContext(void* buff,int count, int leaderRank=0); |
---|
[490] | 29 | |
---|
[523] | 30 | static MPI_Comm intraComm; |
---|
[1072] | 31 | //#pragma omp threadprivate(intraComm) |
---|
| 32 | |
---|
[523] | 33 | static list<MPI_Comm> interComm; |
---|
[1072] | 34 | //#pragma omp threadprivate(interComm) |
---|
| 35 | |
---|
[655] | 36 | static std::list<MPI_Comm> contextInterComms; |
---|
[523] | 37 | static CEventScheduler* eventScheduler; |
---|
[1072] | 38 | //#pragma omp threadprivate(eventScheduler) |
---|
[697] | 39 | |
---|
[523] | 40 | struct contextMessage |
---|
| 41 | { |
---|
| 42 | int nbRecv; |
---|
| 43 | int leaderRank; |
---|
| 44 | }; |
---|
[300] | 45 | |
---|
[523] | 46 | static bool isRoot; |
---|
[1072] | 47 | //#pragma omp threadprivate(isRoot) |
---|
[490] | 48 | |
---|
[523] | 49 | static map<string,CContext*> contextList; |
---|
| 50 | static bool finished; |
---|
[1072] | 51 | //#pragma omp threadprivate(finished) |
---|
| 52 | |
---|
[523] | 53 | static bool is_MPI_Initialized; |
---|
[1072] | 54 | //#pragma omp threadprivate(is_MPI_Initialized) |
---|
[490] | 55 | |
---|
[523] | 56 | public: |
---|
| 57 | //! Get rank of the current process |
---|
| 58 | static int getRank(); |
---|
[490] | 59 | |
---|
[523] | 60 | //! Open a file stream to write the info logs |
---|
[490] | 61 | static void openInfoStream(const StdString& fileName); |
---|
[523] | 62 | //! Write the info logs to standard output |
---|
[490] | 63 | static void openInfoStream(); |
---|
[523] | 64 | //! Close the info logs file if it opens |
---|
[490] | 65 | static void closeInfoStream(); |
---|
| 66 | |
---|
[523] | 67 | //! Open a file stream to write the error log |
---|
| 68 | static void openErrorStream(const StdString& fileName); |
---|
| 69 | //! Write the error log to standard error output |
---|
| 70 | static void openErrorStream(); |
---|
| 71 | //! Close the error log file if it opens |
---|
| 72 | static void closeErrorStream(); |
---|
| 73 | |
---|
| 74 | private: |
---|
| 75 | static int rank; |
---|
[1072] | 76 | //#pragma omp threadprivate(rank) |
---|
| 77 | |
---|
[490] | 78 | static StdOFStream m_infoStream; |
---|
[1072] | 79 | //#pragma omp threadprivate(m_infoStream) |
---|
| 80 | |
---|
[523] | 81 | static StdOFStream m_errorStream; |
---|
[1072] | 82 | //#pragma omp threadprivate(m_errorStream) |
---|
[523] | 83 | |
---|
| 84 | static void openStream(const StdString& fileName, const StdString& ext, std::filebuf* fb); |
---|
| 85 | }; |
---|
[300] | 86 | } |
---|
| 87 | |
---|
| 88 | #endif |
---|