[300] | 1 | #ifndef __CONTEXT_CLIENT_HPP__ |
---|
| 2 | #define __CONTEXT_CLIENT_HPP__ |
---|
| 3 | |
---|
[591] | 4 | #include "xios_spl.hpp" |
---|
[300] | 5 | #include "buffer_out.hpp" |
---|
[697] | 6 | #include "buffer_in.hpp" |
---|
[300] | 7 | #include "buffer_client.hpp" |
---|
| 8 | #include "event_client.hpp" |
---|
[697] | 9 | #include "event_server.hpp" |
---|
[382] | 10 | #include "mpi.hpp" |
---|
[697] | 11 | #include "registry.hpp" |
---|
[300] | 12 | |
---|
[335] | 13 | namespace xios |
---|
[300] | 14 | { |
---|
[595] | 15 | class CContext; |
---|
[509] | 16 | |
---|
[512] | 17 | /*! |
---|
| 18 | \class CContextClient |
---|
| 19 | A context can be both on client and on server side. In order to differenciate the role of |
---|
| 20 | context on each side, e.x client sending events, server receiving and processing events, there is a need of |
---|
| 21 | concrete "context" classes for both sides. |
---|
| 22 | CContextClient processes and sends events from client to server where CContextServer receives these events |
---|
| 23 | and processes them. |
---|
| 24 | */ |
---|
[300] | 25 | class CContextClient |
---|
| 26 | { |
---|
| 27 | public: |
---|
[595] | 28 | // Contructor |
---|
| 29 | CContextClient(CContext* parent, MPI_Comm intraComm, MPI_Comm interComm, CContext* parentServer = 0); |
---|
[300] | 30 | |
---|
[595] | 31 | // Send event to server |
---|
| 32 | void sendEvent(CEventClient& event); |
---|
| 33 | void waitEvent(list<int>& ranks); |
---|
[300] | 34 | |
---|
[595] | 35 | // Functions relates to set/get buffers |
---|
| 36 | list<CBufferOut*> getBuffers(list<int>& serverlist, list<int>& sizeList); |
---|
| 37 | void newBuffer(int rank); |
---|
| 38 | bool checkBuffers(list<int>& ranks); |
---|
| 39 | bool checkBuffers(void); |
---|
| 40 | void releaseBuffers(void); |
---|
[512] | 41 | |
---|
[595] | 42 | bool isServerLeader(void) const; |
---|
[1021] | 43 | bool isServerNotLeader(void) const; |
---|
[595] | 44 | const std::list<int>& getRanksServerLeader(void) const; |
---|
[1021] | 45 | const std::list<int>& getRanksServerNotLeader(void) const; |
---|
[512] | 46 | |
---|
[704] | 47 | bool isAttachedModeEnabled() const; |
---|
| 48 | |
---|
[595] | 49 | // Close and finalize context client |
---|
| 50 | void closeContext(void); |
---|
| 51 | void finalize(void); |
---|
[300] | 52 | |
---|
[917] | 53 | void setBufferSize(const std::map<int,StdSize>& mapSize, const std::map<int,StdSize>& maxEventSize); |
---|
[726] | 54 | |
---|
[512] | 55 | public: |
---|
[595] | 56 | CContext* context; //!< Context for client |
---|
[509] | 57 | |
---|
[595] | 58 | size_t timeLine; //!< Timeline of each event |
---|
[509] | 59 | |
---|
[595] | 60 | int clientRank; //!< Rank of current client |
---|
[300] | 61 | |
---|
[595] | 62 | int clientSize; //!< Size of client group |
---|
[300] | 63 | |
---|
[595] | 64 | int serverSize; //!< Size of server group |
---|
[300] | 65 | |
---|
[595] | 66 | MPI_Comm interComm; //!< Communicator of server group |
---|
[300] | 67 | |
---|
[595] | 68 | MPI_Comm intraComm; //!< Communicator of client group |
---|
[300] | 69 | |
---|
[595] | 70 | map<int,CClientBuffer*> buffers; //!< Buffers for connection to servers |
---|
[300] | 71 | |
---|
[512] | 72 | private: |
---|
| 73 | //! Mapping of server and buffer size for each connection to server |
---|
[595] | 74 | std::map<int,StdSize> mapBufferSize_; |
---|
[917] | 75 | //! Maximum number of events that can be buffered |
---|
| 76 | StdSize maxBufferedEvents; |
---|
[300] | 77 | |
---|
[512] | 78 | //! Context for server (Only used in attached mode) |
---|
| 79 | CContext* parentServer; |
---|
| 80 | |
---|
[595] | 81 | //! List of server ranks for which the client is leader |
---|
| 82 | std::list<int> ranksServerLeader; |
---|
| 83 | |
---|
[1021] | 84 | //! List of server ranks for which the client is not leader |
---|
| 85 | std::list<int> ranksServerNotLeader; |
---|
| 86 | |
---|
[512] | 87 | public: // Some function should be removed in the future |
---|
[595] | 88 | // void registerEvent(CEventClient& event); |
---|
| 89 | // list<CBufferOut*> newEvent(CEventClient& event,list<int>& sizes); |
---|
| 90 | // bool locked; |
---|
| 91 | // set<int> connectedServer; |
---|
[512] | 92 | |
---|
[595] | 93 | }; |
---|
[512] | 94 | } |
---|
| 95 | |
---|
| 96 | #endif // __CONTEXT_CLIENT_HPP__ |
---|