[2343] | 1 | #ifndef __LEGACY_CONTEXT_CLIENT_HPP__ |
---|
| 2 | #define __LEGACY_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 | #include "context_client.hpp" |
---|
| 13 | |
---|
| 14 | namespace xios |
---|
| 15 | { |
---|
| 16 | class CContext; |
---|
| 17 | class CContextServer ; |
---|
| 18 | /*! |
---|
| 19 | \class CLegacyContextClient |
---|
| 20 | A context can be both on client and on server side. In order to differenciate the role of |
---|
| 21 | context on each side, e.x client sending events, server receiving and processing events, there is a need of |
---|
| 22 | concrete "context" classes for both sides. |
---|
| 23 | CLegacyContextClient processes and sends events from client to server where CContextServer receives these events |
---|
| 24 | and processes them. |
---|
| 25 | */ |
---|
| 26 | class CLegacyContextClient : public CContextClient |
---|
| 27 | { |
---|
| 28 | public: |
---|
| 29 | // Contructor |
---|
| 30 | CLegacyContextClient(CContext* parent, MPI_Comm intraComm, MPI_Comm interComm, CContext* parentServer = 0); |
---|
| 31 | |
---|
| 32 | // Send event to server |
---|
[2507] | 33 | ETransport getType(void) {return legacy ;} |
---|
[2343] | 34 | void sendEvent(CEventClient& event); |
---|
| 35 | void eventLoop(void) ; |
---|
| 36 | void releaseBuffers(void); |
---|
| 37 | bool havePendingRequests(void); |
---|
| 38 | |
---|
| 39 | bool isNotifiedFinalized(void) ; |
---|
| 40 | void finalize(void); |
---|
| 41 | |
---|
| 42 | void setBufferSize(const std::map<int,StdSize>& mapSize); |
---|
| 43 | |
---|
| 44 | |
---|
| 45 | private: |
---|
| 46 | |
---|
| 47 | // Functions to set/get buffers |
---|
[2458] | 48 | void getBuffers(const size_t timeLine, const list<int>& serverList, const list<int>& sizeList, list<CBufferOut*>& retBuffers); |
---|
[2343] | 49 | void newBuffer(int rank); |
---|
[2458] | 50 | void checkAttachWindows(CClientBuffer* buffer , int rank) ; |
---|
[2343] | 51 | bool checkBuffers(list<int>& ranks); |
---|
| 52 | bool checkBuffers(void); |
---|
| 53 | void callGlobalEventLoop() ; |
---|
| 54 | bool havePendingRequests(list<int>& ranks) ; |
---|
| 55 | void setGrowableBuffer(void) { isGrowableBuffer_=true;} |
---|
| 56 | void setFixedBuffer(void) { isGrowableBuffer_=false;} |
---|
| 57 | void lockBuffers(list<int>& ranks) ; |
---|
| 58 | void unlockBuffers(list<int>& ranks) ; |
---|
| 59 | |
---|
| 60 | |
---|
| 61 | size_t timeLine; //!< Timeline of each event |
---|
| 62 | |
---|
| 63 | MPI_Comm interCommMerged_; //!< Communicator of the client group + server group (intraCommunicator) needed for one sided communication. |
---|
| 64 | MPI_Comm commSelf_ ; //!< Communicator for proc alone from interCommMerged |
---|
| 65 | |
---|
| 66 | map<int,CClientBuffer*> buffers; //!< Buffers for connection to servers |
---|
| 67 | |
---|
| 68 | bool pureOneSided ; //!< if true, client will communicated with servers only trough one sided communication. Otherwise the hybrid mode P2P /One sided is used. |
---|
| 69 | |
---|
| 70 | //! Mapping of server and buffer size for each connection to server |
---|
| 71 | std::map<int,StdSize> mapBufferSize_; |
---|
| 72 | //! Maximum event sizes estimated for each connection to server |
---|
| 73 | std::map<int,StdSize> maxEventSizes; |
---|
| 74 | //! Maximum number of events that can be buffered |
---|
| 75 | StdSize maxBufferedEvents; |
---|
| 76 | |
---|
| 77 | std::map<int, MPI_Comm> winComm_ ; //! Window communicators |
---|
| 78 | std::map<int, std::vector<MPI_Win> >windows_ ; //! one sided mpi windows to expose client buffers to servers == windows[nbServers][2] |
---|
| 79 | bool isGrowableBuffer_ = true ; |
---|
| 80 | |
---|
| 81 | double latency_=0e-2 ; |
---|
| 82 | |
---|
| 83 | bool locked_ = false ; //!< The context client is locked to avoid recursive checkBuffer |
---|
| 84 | }; |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | #endif // __LEGACY_CONTEXT_CLIENT_HPP__ |
---|