[300] | 1 | #ifndef __CONTEXT_SERVER_HPP__ |
---|
[327] | 2 | #define __CONTEXT_SERVER_HPP__ |
---|
[591] | 3 | #include "xios_spl.hpp" |
---|
[300] | 4 | #include "event_server.hpp" |
---|
| 5 | #include "buffer_server.hpp" |
---|
[382] | 6 | #include "mpi.hpp" |
---|
[1761] | 7 | #include "event_scheduler.hpp" |
---|
[300] | 8 | |
---|
[335] | 9 | namespace xios |
---|
[300] | 10 | { |
---|
[345] | 11 | class CContext ; |
---|
[1853] | 12 | class CContextClient; |
---|
[511] | 13 | |
---|
[300] | 14 | class CContextServer |
---|
| 15 | { |
---|
| 16 | public: |
---|
[511] | 17 | |
---|
[1639] | 18 | CContextServer(CContext* parent,MPI_Comm intraComm,MPI_Comm interComm) ; |
---|
[1054] | 19 | bool eventLoop(bool enableEventsProcessing = true); |
---|
[300] | 20 | void listen(void) ; |
---|
[2246] | 21 | // bool listenPendingRequest(MPI_Status& status) ; |
---|
| 22 | bool listenPendingRequest(MPI_Message &message, MPI_Status& status) ; |
---|
| 23 | void checkPendingProbe(void) ; |
---|
[300] | 24 | void checkPendingRequest(void) ; |
---|
[1757] | 25 | void getBufferFromClient(size_t timeLine) ; |
---|
[1158] | 26 | void processRequest(int rank, char* buff,int count) ; |
---|
[300] | 27 | void processEvents(void) ; |
---|
[1054] | 28 | bool hasFinished(void); |
---|
[300] | 29 | void dispatchEvent(CEventServer& event) ; |
---|
[2230] | 30 | bool isCollectiveEvent(CEventServer& event) ; |
---|
[300] | 31 | void setPendingEvent(void) ; |
---|
| 32 | bool hasPendingEvent(void) ; |
---|
[1757] | 33 | bool isAttachedModeEnabled() const; |
---|
| 34 | void releaseBuffers(void) ; |
---|
| 35 | void notifyClientsFinalize(void) ; |
---|
| 36 | |
---|
[1639] | 37 | MPI_Comm intraComm ; |
---|
[300] | 38 | int intraCommSize ; |
---|
| 39 | int intraCommRank ; |
---|
[511] | 40 | |
---|
[1639] | 41 | MPI_Comm interComm ; |
---|
[300] | 42 | int commSize ; |
---|
[511] | 43 | |
---|
[1757] | 44 | MPI_Comm interCommMerged; //!< Communicator of the client group + server group (intraCommunicator) needed for one sided communication. |
---|
| 45 | |
---|
[300] | 46 | map<int,CServerBuffer*> buffers ; |
---|
[1757] | 47 | map<int,size_t> lastTimeLine ; //!< last event time line for a processed request |
---|
| 48 | map<int,size_t>::iterator itLastTimeLine ; //!< iterator on lastTimeLine |
---|
[2246] | 49 | map<int, list<std::pair<MPI_Message,MPI_Status> > > pendingProbe; |
---|
[1639] | 50 | map<int,MPI_Request> pendingRequest ; |
---|
[300] | 51 | map<int,char*> bufferRequest ; |
---|
[511] | 52 | |
---|
[300] | 53 | map<size_t,CEventServer*> events ; |
---|
| 54 | size_t currentTimeLine ; |
---|
[345] | 55 | CContext* context ; |
---|
[697] | 56 | |
---|
[300] | 57 | bool finished ; |
---|
| 58 | bool pendingEvent ; |
---|
[492] | 59 | bool scheduled ; /*!< event of current timeline is alreading scheduled ? */ |
---|
[1757] | 60 | bool attachedMode ; //! true if attached mode is enabled otherwise false |
---|
| 61 | bool pureOneSided ; //!< if true, client will communicated with servers only trough one sided communication. Otherwise the hybrid mode P2P /One sided is used. |
---|
| 62 | |
---|
[492] | 63 | size_t hashId ; |
---|
[1054] | 64 | |
---|
[1853] | 65 | void setAssociatedClient(CContextClient* associatedClient) {associatedClient_=associatedClient ;} |
---|
| 66 | CContextClient* getAssociatedClient(void) { return associatedClient_ ;} |
---|
| 67 | |
---|
[511] | 68 | ~CContextServer() ; |
---|
| 69 | |
---|
| 70 | private: |
---|
[2230] | 71 | |
---|
[1158] | 72 | std::map<int, StdSize> mapBufferSize_; |
---|
[1757] | 73 | vector<MPI_Win> windows ; //! one sided mpi windows to expose client buffers to servers ; No memory will be attached on server side. |
---|
[1761] | 74 | CEventScheduler* eventScheduler_ ; |
---|
[1764] | 75 | bool isProcessingEvent_ ; |
---|
[1853] | 76 | CContextClient* associatedClient_ ; |
---|
[2130] | 77 | size_t remoteHashId_; //!< the hash is of the calling context client |
---|
[2230] | 78 | |
---|
| 79 | MPI_Comm processEventBarrier_ ; |
---|
| 80 | bool eventScheduled_=false; |
---|
| 81 | MPI_Request processEventRequest_ ; |
---|
[300] | 82 | } ; |
---|
| 83 | |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | #endif |
---|