[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 |
---|
[1639] | 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 | |
---|
[1054] | 35 | // Functions to set/get buffers |
---|
[1757] | 36 | bool getBuffers(const size_t timeLine, const list<int>& serverList, const list<int>& sizeList, list<CBufferOut*>& retBuffers, bool nonBlocking = false); |
---|
[595] | 37 | void newBuffer(int rank); |
---|
| 38 | bool checkBuffers(list<int>& ranks); |
---|
| 39 | bool checkBuffers(void); |
---|
| 40 | void releaseBuffers(void); |
---|
[1130] | 41 | bool havePendingRequests(void); |
---|
[512] | 42 | |
---|
[595] | 43 | bool isServerLeader(void) const; |
---|
[1021] | 44 | bool isServerNotLeader(void) const; |
---|
[595] | 45 | const std::list<int>& getRanksServerLeader(void) const; |
---|
[1021] | 46 | const std::list<int>& getRanksServerNotLeader(void) const; |
---|
[512] | 47 | |
---|
[704] | 48 | bool isAttachedModeEnabled() const; |
---|
| 49 | |
---|
[1232] | 50 | static void computeLeader(int clientRank, int clientSize, int serverSize, |
---|
| 51 | std::list<int>& rankRecvLeader, |
---|
| 52 | std::list<int>& rankRecvNotLeader); |
---|
| 53 | |
---|
[595] | 54 | // Close and finalize context client |
---|
[1054] | 55 | // void closeContext(void); Never been implemented. |
---|
[1757] | 56 | bool isNotifiedFinalized(void) ; |
---|
[595] | 57 | void finalize(void); |
---|
[300] | 58 | |
---|
[917] | 59 | void setBufferSize(const std::map<int,StdSize>& mapSize, const std::map<int,StdSize>& maxEventSize); |
---|
[726] | 60 | |
---|
[512] | 61 | public: |
---|
[595] | 62 | CContext* context; //!< Context for client |
---|
[509] | 63 | |
---|
[595] | 64 | size_t timeLine; //!< Timeline of each event |
---|
[509] | 65 | |
---|
[595] | 66 | int clientRank; //!< Rank of current client |
---|
[300] | 67 | |
---|
[595] | 68 | int clientSize; //!< Size of client group |
---|
[300] | 69 | |
---|
[595] | 70 | int serverSize; //!< Size of server group |
---|
[300] | 71 | |
---|
[1757] | 72 | MPI_Comm interComm; //!< Communicator of server group (interCommunicator) |
---|
[300] | 73 | |
---|
[1757] | 74 | MPI_Comm interCommMerged; //!< Communicator of the client group + server group (intraCommunicator) needed for one sided communication. |
---|
| 75 | |
---|
[1639] | 76 | MPI_Comm intraComm; //!< Communicator of client group |
---|
[300] | 77 | |
---|
[1757] | 78 | MPI_Comm commSelf; //!< Communicator of the client alone. Needed to create a new communicator between 1 proc client and 1 proc server for one sided communication |
---|
| 79 | |
---|
[1158] | 80 | map<int,CClientBuffer*> buffers; //!< Buffers for connection to servers |
---|
[300] | 81 | |
---|
[1757] | 82 | bool pureOneSided ; //!< if true, client will communicated with servers only trough one sided communication. Otherwise the hybrid mode P2P /One sided is used. |
---|
| 83 | |
---|
[512] | 84 | private: |
---|
[1757] | 85 | void lockBuffers(list<int>& ranks) ; |
---|
| 86 | void unlockBuffers(list<int>& ranks) ; |
---|
| 87 | |
---|
[512] | 88 | //! Mapping of server and buffer size for each connection to server |
---|
[595] | 89 | std::map<int,StdSize> mapBufferSize_; |
---|
[1201] | 90 | //! Maximum event sizes estimated for each connection to server |
---|
| 91 | std::map<int,StdSize> maxEventSizes; |
---|
[917] | 92 | //! Maximum number of events that can be buffered |
---|
| 93 | StdSize maxBufferedEvents; |
---|
[300] | 94 | |
---|
[512] | 95 | //! Context for server (Only used in attached mode) |
---|
| 96 | CContext* parentServer; |
---|
| 97 | |
---|
[595] | 98 | //! List of server ranks for which the client is leader |
---|
| 99 | std::list<int> ranksServerLeader; |
---|
| 100 | |
---|
[1021] | 101 | //! List of server ranks for which the client is not leader |
---|
| 102 | std::list<int> ranksServerNotLeader; |
---|
| 103 | |
---|
[1757] | 104 | std::vector<std::vector<MPI_Win> >windows ; //! one sided mpi windows to expose client buffers to servers == windows[nbServers][2] |
---|
| 105 | |
---|
| 106 | |
---|
[595] | 107 | }; |
---|
[512] | 108 | } |
---|
| 109 | |
---|
| 110 | #endif // __CONTEXT_CLIENT_HPP__ |
---|