1 | #ifndef __CONTEXT_SERVER_HPP__ |
---|
2 | #define __CONTEXT_SERVER_HPP__ |
---|
3 | #include "xios_spl.hpp" |
---|
4 | #include "event_server.hpp" |
---|
5 | #include "buffer_server.hpp" |
---|
6 | #include "mpi.hpp" |
---|
7 | #include "event_scheduler.hpp" |
---|
8 | |
---|
9 | namespace xios |
---|
10 | { |
---|
11 | class CContext ; |
---|
12 | class CContextClient; |
---|
13 | |
---|
14 | class CContextServer |
---|
15 | { |
---|
16 | public: |
---|
17 | |
---|
18 | CContextServer(CContext* parent,MPI_Comm intraComm,MPI_Comm interComm) ; |
---|
19 | bool eventLoop(bool enableEventsProcessing = true); |
---|
20 | void listen(void) ; |
---|
21 | // bool listenPendingRequest(MPI_Status& status) ; |
---|
22 | bool listenPendingRequest(MPI_Message &message, MPI_Status& status) ; |
---|
23 | void checkPendingProbe(void) ; |
---|
24 | void checkPendingRequest(void) ; |
---|
25 | void getBufferFromClient(size_t timeLine) ; |
---|
26 | void processRequest(int rank, char* buff,int count) ; |
---|
27 | void processEvents(bool enableEventsProcessing) ; |
---|
28 | bool hasFinished(void); |
---|
29 | void dispatchEvent(CEventServer& event) ; |
---|
30 | bool isCollectiveEvent(CEventServer& event) ; |
---|
31 | void setPendingEvent(void) ; |
---|
32 | bool hasPendingEvent(void) ; |
---|
33 | bool isAttachedModeEnabled() const; |
---|
34 | void releaseBuffers(void) ; |
---|
35 | void notifyClientsFinalize(void) ; |
---|
36 | void freeWindows(void) ; // !<< free Windows for one sided communication |
---|
37 | |
---|
38 | MPI_Comm intraComm ; |
---|
39 | int intraCommSize ; |
---|
40 | int intraCommRank ; |
---|
41 | |
---|
42 | MPI_Comm interComm ; |
---|
43 | int commSize ; |
---|
44 | int clientSize_ ; |
---|
45 | |
---|
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 |
---|
48 | |
---|
49 | map<int,CServerBuffer*> buffers ; |
---|
50 | map<int,size_t> lastTimeLine ; //!< last event time line for a processed request |
---|
51 | map<int,size_t>::iterator itLastTimeLine ; //!< iterator on lastTimeLine |
---|
52 | map<int, list<std::pair<MPI_Message,MPI_Status> > > pendingProbe; |
---|
53 | map<int,MPI_Request> pendingRequest ; |
---|
54 | map<int,char*> bufferRequest ; |
---|
55 | |
---|
56 | map<size_t,CEventServer*> events ; |
---|
57 | size_t currentTimeLine ; |
---|
58 | CContext* context ; |
---|
59 | |
---|
60 | bool finished ; |
---|
61 | bool pendingEvent ; |
---|
62 | bool scheduled ; /*!< event of current timeline is alreading scheduled ? */ |
---|
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 | |
---|
66 | size_t hashId ; |
---|
67 | |
---|
68 | void setAssociatedClient(CContextClient* associatedClient) {associatedClient_=associatedClient ;} |
---|
69 | CContextClient* getAssociatedClient(void) { return associatedClient_ ;} |
---|
70 | |
---|
71 | ~CContextServer() ; |
---|
72 | |
---|
73 | private: |
---|
74 | |
---|
75 | std::map<int, StdSize> mapBufferSize_; |
---|
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. |
---|
78 | CEventScheduler* eventScheduler_ ; |
---|
79 | bool isProcessingEvent_ ; |
---|
80 | CContextClient* associatedClient_ ; |
---|
81 | size_t remoteHashId_; //!< the hash is of the calling context client |
---|
82 | |
---|
83 | MPI_Comm processEventBarrier_ ; |
---|
84 | bool eventScheduled_=false; |
---|
85 | MPI_Request processEventRequest_ ; |
---|
86 | } ; |
---|
87 | |
---|
88 | } |
---|
89 | |
---|
90 | #endif |
---|