[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) ; |
---|
[2326] | 27 | void processEvents(bool enableEventsProcessing) ; |
---|
[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) ; |
---|
[2258] | 36 | void freeWindows(void) ; // !<< free Windows for one sided communication |
---|
[1757] | 37 | |
---|
[1639] | 38 | MPI_Comm intraComm ; |
---|
[300] | 39 | int intraCommSize ; |
---|
| 40 | int intraCommRank ; |
---|
[511] | 41 | |
---|
[1639] | 42 | MPI_Comm interComm ; |
---|
[300] | 43 | int commSize ; |
---|
[2258] | 44 | int clientSize_ ; |
---|
[511] | 45 | |
---|
[2259] | 46 | MPI_Comm interCommMerged_; //!< Communicator of the client group + server group (intraCommunicator) needed for one sided communication. |
---|
| 47 | MPI_Comm commSelf_ ; //!< Communicator for proc alone from interCommMerged |
---|
[1757] | 48 | |
---|
[300] | 49 | map<int,CServerBuffer*> buffers ; |
---|
[1757] | 50 | map<int,size_t> lastTimeLine ; //!< last event time line for a processed request |
---|
| 51 | map<int,size_t>::iterator itLastTimeLine ; //!< iterator on lastTimeLine |
---|
[2246] | 52 | map<int, list<std::pair<MPI_Message,MPI_Status> > > pendingProbe; |
---|
[1639] | 53 | map<int,MPI_Request> pendingRequest ; |
---|
[300] | 54 | map<int,char*> bufferRequest ; |
---|
[511] | 55 | |
---|
[300] | 56 | map<size_t,CEventServer*> events ; |
---|
| 57 | size_t currentTimeLine ; |
---|
[345] | 58 | CContext* context ; |
---|
[697] | 59 | |
---|
[300] | 60 | bool finished ; |
---|
| 61 | bool pendingEvent ; |
---|
[492] | 62 | bool scheduled ; /*!< event of current timeline is alreading scheduled ? */ |
---|
[1757] | 63 | bool attachedMode ; //! true if attached mode is enabled otherwise false |
---|
| 64 | bool pureOneSided ; //!< if true, client will communicated with servers only trough one sided communication. Otherwise the hybrid mode P2P /One sided is used. |
---|
| 65 | |
---|
[492] | 66 | size_t hashId ; |
---|
[1054] | 67 | |
---|
[1853] | 68 | void setAssociatedClient(CContextClient* associatedClient) {associatedClient_=associatedClient ;} |
---|
| 69 | CContextClient* getAssociatedClient(void) { return associatedClient_ ;} |
---|
| 70 | |
---|
[511] | 71 | ~CContextServer() ; |
---|
| 72 | |
---|
| 73 | private: |
---|
[2259] | 74 | |
---|
[1158] | 75 | std::map<int, StdSize> mapBufferSize_; |
---|
[2259] | 76 | std::map<int,MPI_Comm> winComm_ ; //! Window communicators |
---|
| 77 | std::map<int,std::vector<MPI_Win> >windows_ ; //! one sided mpi windows to expose client buffers to servers ; No memory will be attached on server side. |
---|
[1761] | 78 | CEventScheduler* eventScheduler_ ; |
---|
[1764] | 79 | bool isProcessingEvent_ ; |
---|
[1853] | 80 | CContextClient* associatedClient_ ; |
---|
[2130] | 81 | size_t remoteHashId_; //!< the hash is of the calling context client |
---|
[2230] | 82 | |
---|
| 83 | MPI_Comm processEventBarrier_ ; |
---|
| 84 | bool eventScheduled_=false; |
---|
| 85 | MPI_Request processEventRequest_ ; |
---|
[300] | 86 | } ; |
---|
| 87 | |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | #endif |
---|