[2343] | 1 | #ifndef __ONE_SIDED_CONTEXT_CLIENT_HPP__ |
---|
| 2 | #define __ONE_SIDED_CONTEXT_CLIENT_HPP__ |
---|
| 3 | |
---|
| 4 | #include "xios_spl.hpp" |
---|
| 5 | #include "buffer_out.hpp" |
---|
| 6 | #include "buffer_in.hpp" |
---|
| 7 | #include "one_sided_client_buffer.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 CContextClient |
---|
| 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 | CContextClient processes and sends events from client to server where CContextServer receives these events |
---|
| 24 | and processes them. |
---|
| 25 | */ |
---|
| 26 | class COneSidedContextClient : public CContextClient |
---|
| 27 | { |
---|
| 28 | public: |
---|
| 29 | // Contructor |
---|
| 30 | COneSidedContextClient(CContext* parent, MPI_Comm intraComm, MPI_Comm interComm, CContext* parentServer = 0); |
---|
| 31 | |
---|
| 32 | // Send event to server |
---|
| 33 | void sendEvent(CEventClient& event); |
---|
| 34 | bool havePendingRequests(void); |
---|
| 35 | void releaseBuffers(void); |
---|
| 36 | bool isNotifiedFinalized(void) ; |
---|
| 37 | void finalize(void); |
---|
| 38 | void setBufferSize(const std::map<int,StdSize>& mapSize); |
---|
| 39 | |
---|
| 40 | private: |
---|
| 41 | |
---|
| 42 | // Functions to set/get buffers |
---|
[2455] | 43 | // bool getBuffers(const size_t timeLine, const list<int>& serverList, const list<int>& sizeList, list<CBufferOut*>& retBuffers, bool nonBlocking = false); |
---|
[2343] | 44 | void newBuffer(int rank); |
---|
| 45 | bool checkBuffers(list<int>& ranks); |
---|
| 46 | bool checkBuffers(void); |
---|
| 47 | void eventLoop(void) ; |
---|
| 48 | void callGlobalEventLoop() ; |
---|
| 49 | bool havePendingRequests(list<int>& ranks) ; |
---|
| 50 | |
---|
| 51 | |
---|
| 52 | |
---|
| 53 | void setGrowableBuffer(void) { isGrowableBuffer_=true;} |
---|
| 54 | void setFixedBuffer(void) { isGrowableBuffer_=false;} |
---|
| 55 | |
---|
| 56 | size_t timeLine; //!< Timeline of each event |
---|
| 57 | |
---|
| 58 | MPI_Comm interCommMerged_; //!< Communicator of the client group + server group (intraCommunicator) needed for one sided communication. |
---|
| 59 | MPI_Comm commSelf_ ; //!< Communicator for proc alone from interCommMerged |
---|
| 60 | map<int,COneSidedClientBuffer*> buffers; //!< Buffers for connection to servers |
---|
| 61 | |
---|
| 62 | bool pureOneSided ; //!< if true, client will communicated with servers only trough one sided communication. Otherwise the hybrid mode P2P /One sided is used. |
---|
| 63 | |
---|
| 64 | private: |
---|
| 65 | |
---|
| 66 | //! Mapping of server and buffer size for each connection to server |
---|
| 67 | std::map<int,StdSize> mapBufferSize_; |
---|
| 68 | //! Maximum event sizes estimated for each connection to server |
---|
| 69 | std::map<int,StdSize> maxEventSizes; |
---|
| 70 | //! Maximum number of events that can be buffered |
---|
| 71 | StdSize maxBufferedEvents; |
---|
| 72 | |
---|
| 73 | std::map<int, MPI_Comm> winComm_ ; //! Window communicators |
---|
| 74 | std::map<int, MPI_Win >window_ ; //! one sided mpi windows to expose client buffers to servers == windows[nbServers][2] |
---|
| 75 | |
---|
| 76 | bool isGrowableBuffer_ = true ; |
---|
| 77 | double growingFactor_ = 1.25 ; |
---|
| 78 | |
---|
| 79 | double latency_=0e-2 ; |
---|
| 80 | |
---|
| 81 | bool locked_ = false ; //!< The context client is locked to avoid recursive checkBuffer |
---|
| 82 | }; |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | #endif // __ONE_SIDED_CONTEXT_CLIENT_HPP__ |
---|