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