1 | #ifndef __CONTEXT_CLIENT_HPP__ |
---|
2 | #define __CONTEXT_CLIENT_HPP__ |
---|
3 | |
---|
4 | #include "xios_spl.hpp" |
---|
5 | #include "buffer_out.hpp" |
---|
6 | #include "buffer_in.hpp" |
---|
7 | #include "buffer_client.hpp" |
---|
8 | #include "event_client.hpp" |
---|
9 | #include "event_server.hpp" |
---|
10 | #include "mpi.hpp" |
---|
11 | #include "registry.hpp" |
---|
12 | |
---|
13 | namespace xios |
---|
14 | { |
---|
15 | class CContext; |
---|
16 | |
---|
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 | */ |
---|
25 | class CContextClient |
---|
26 | { |
---|
27 | public: |
---|
28 | // Contructor |
---|
29 | CContextClient(CContext* parent, MPI_Comm intraComm, MPI_Comm interComm, CContext* parentServer = 0); |
---|
30 | |
---|
31 | // Send event to server |
---|
32 | void sendEvent(CEventClient& event); |
---|
33 | void waitEvent(list<int>& ranks); |
---|
34 | |
---|
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); |
---|
41 | |
---|
42 | bool isServerLeader(void) const; |
---|
43 | const std::list<int>& getRanksServerLeader(void) const; |
---|
44 | |
---|
45 | bool isAttachedModeEnabled() const; |
---|
46 | |
---|
47 | // Close and finalize context client |
---|
48 | void closeContext(void); |
---|
49 | void finalize(void); |
---|
50 | |
---|
51 | void setBufferSize(const std::map<int,StdSize>& mapSize, const std::map<int,StdSize>& maxEventSize); |
---|
52 | |
---|
53 | public: |
---|
54 | CContext* context; //!< Context for client |
---|
55 | |
---|
56 | size_t timeLine; //!< Timeline of each event |
---|
57 | |
---|
58 | int clientRank; //!< Rank of current client |
---|
59 | |
---|
60 | int clientSize; //!< Size of client group |
---|
61 | |
---|
62 | int serverSize; //!< Size of server group |
---|
63 | |
---|
64 | MPI_Comm interComm; //!< Communicator of server group |
---|
65 | |
---|
66 | MPI_Comm intraComm; //!< Communicator of client group |
---|
67 | |
---|
68 | map<int,CClientBuffer*> buffers; //!< Buffers for connection to servers |
---|
69 | |
---|
70 | private: |
---|
71 | //! Mapping of server and buffer size for each connection to server |
---|
72 | std::map<int,StdSize> mapBufferSize_; |
---|
73 | //! Maximum number of events that can be buffered |
---|
74 | StdSize maxBufferedEvents; |
---|
75 | |
---|
76 | //! Context for server (Only used in attached mode) |
---|
77 | CContext* parentServer; |
---|
78 | |
---|
79 | //! List of server ranks for which the client is leader |
---|
80 | std::list<int> ranksServerLeader; |
---|
81 | |
---|
82 | public: // Some function should be removed in the future |
---|
83 | // void registerEvent(CEventClient& event); |
---|
84 | // list<CBufferOut*> newEvent(CEventClient& event,list<int>& sizes); |
---|
85 | // bool locked; |
---|
86 | // set<int> connectedServer; |
---|
87 | |
---|
88 | }; |
---|
89 | } |
---|
90 | |
---|
91 | #endif // __CONTEXT_CLIENT_HPP__ |
---|