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(void) ; |
---|
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 | |
---|
37 | MPI_Comm intraComm ; |
---|
38 | int intraCommSize ; |
---|
39 | int intraCommRank ; |
---|
40 | |
---|
41 | MPI_Comm interComm ; |
---|
42 | int commSize ; |
---|
43 | |
---|
44 | MPI_Comm interCommMerged; //!< Communicator of the client group + server group (intraCommunicator) needed for one sided communication. |
---|
45 | |
---|
46 | map<int,CServerBuffer*> buffers ; |
---|
47 | map<int,size_t> lastTimeLine ; //!< last event time line for a processed request |
---|
48 | map<int,size_t>::iterator itLastTimeLine ; //!< iterator on lastTimeLine |
---|
49 | map<int, list<std::pair<MPI_Message,MPI_Status> > > pendingProbe; |
---|
50 | map<int,MPI_Request> pendingRequest ; |
---|
51 | map<int,char*> bufferRequest ; |
---|
52 | |
---|
53 | map<size_t,CEventServer*> events ; |
---|
54 | size_t currentTimeLine ; |
---|
55 | CContext* context ; |
---|
56 | |
---|
57 | bool finished ; |
---|
58 | bool pendingEvent ; |
---|
59 | bool scheduled ; /*!< event of current timeline is alreading scheduled ? */ |
---|
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 | |
---|
63 | size_t hashId ; |
---|
64 | |
---|
65 | void setAssociatedClient(CContextClient* associatedClient) {associatedClient_=associatedClient ;} |
---|
66 | CContextClient* getAssociatedClient(void) { return associatedClient_ ;} |
---|
67 | |
---|
68 | ~CContextServer() ; |
---|
69 | |
---|
70 | private: |
---|
71 | |
---|
72 | std::map<int, StdSize> mapBufferSize_; |
---|
73 | vector<MPI_Win> windows ; //! one sided mpi windows to expose client buffers to servers ; No memory will be attached on server side. |
---|
74 | CEventScheduler* eventScheduler_ ; |
---|
75 | bool isProcessingEvent_ ; |
---|
76 | CContextClient* associatedClient_ ; |
---|
77 | size_t remoteHashId_; //!< the hash is of the calling context client |
---|
78 | |
---|
79 | MPI_Comm processEventBarrier_ ; |
---|
80 | bool eventScheduled_=false; |
---|
81 | MPI_Request processEventRequest_ ; |
---|
82 | } ; |
---|
83 | |
---|
84 | } |
---|
85 | |
---|
86 | #endif |
---|