1 | #ifndef __BUFFER_CLIENT_HPP__ |
---|
2 | #define __BUFFER_CLIENT_HPP__ |
---|
3 | |
---|
4 | #include "buffer_cs_base.hpp" |
---|
5 | #include "xios_spl.hpp" |
---|
6 | #include "buffer_out.hpp" |
---|
7 | #include "mpi.hpp" |
---|
8 | #include "cxios.hpp" |
---|
9 | |
---|
10 | namespace xios |
---|
11 | { |
---|
12 | class CClientBuffer : public CBufferClientServerBase |
---|
13 | { |
---|
14 | public: |
---|
15 | static size_t maxRequestSize; |
---|
16 | |
---|
17 | CClientBuffer(MPI_Comm intercomm, int serverRank, StdSize bufferSize, StdSize estimatedMaxEventSize); |
---|
18 | ~CClientBuffer(); |
---|
19 | // void createWindows(MPI_Comm oneSidedComm) ; |
---|
20 | void freeWindows(void) ; |
---|
21 | void lockBuffer(void) ; |
---|
22 | void unlockBuffer(void) ; |
---|
23 | |
---|
24 | bool isBufferFree(StdSize size); |
---|
25 | CBufferOut* getBuffer(size_t timeLine, StdSize size); |
---|
26 | bool checkBuffer(bool send=false); |
---|
27 | bool hasPendingRequest(void); |
---|
28 | StdSize remain(void); |
---|
29 | MPI_Aint getWinAddress(int numWindows) ; |
---|
30 | void infoBuffer(void) ; |
---|
31 | bool isNotifiedFinalized(void) ; |
---|
32 | void setGrowableBuffer(double growFactor) { growFactor_=growFactor ; isGrowableBuffer_=true ;} |
---|
33 | void fixBufferSize(size_t bufferSize) { newBufferSize_=bufferSize ; isGrowableBuffer_=false ; resizingBufferStep_=1 ;} |
---|
34 | void fixBuffer(void) { isGrowableBuffer_=false ;} |
---|
35 | void attachWindows(vector<MPI_Win>& windows) ; |
---|
36 | private: |
---|
37 | void resizeBuffer(size_t newSize) ; |
---|
38 | void resizeBufferNotify(void) ; |
---|
39 | bool isNotifiedChangeBufferSize(void) ; |
---|
40 | |
---|
41 | |
---|
42 | char* buffer[2]; |
---|
43 | char* bufferHeader[2]; |
---|
44 | size_t* firstTimeLine[2] ; |
---|
45 | size_t* bufferCount[2] ; |
---|
46 | size_t* control[2] ; |
---|
47 | size_t* notify[2] ; |
---|
48 | bool winState[2] ; |
---|
49 | int current; |
---|
50 | |
---|
51 | double growFactor_=1.2 ; |
---|
52 | bool isGrowableBuffer_=true ; |
---|
53 | |
---|
54 | int resizingBufferStep_ = 0 ; |
---|
55 | size_t newBufferSize_ ; |
---|
56 | StdSize count; |
---|
57 | StdSize maxEventSize; |
---|
58 | StdSize bufferSize; |
---|
59 | const StdSize estimatedMaxEventSize; |
---|
60 | bool isFinalized_=false ; |
---|
61 | |
---|
62 | const int serverRank; |
---|
63 | const int clientRank_; |
---|
64 | bool pending; |
---|
65 | |
---|
66 | MPI_Request request; |
---|
67 | |
---|
68 | CBufferOut* retBuffer; |
---|
69 | const MPI_Comm interComm; |
---|
70 | std::vector<MPI_Win> windows_ ; |
---|
71 | bool hasWindows ; |
---|
72 | |
---|
73 | double latency_=0 ; |
---|
74 | double lastCheckedWithNothing_=0 ; |
---|
75 | double lastCheckedNotify_=0 ; |
---|
76 | }; |
---|
77 | } |
---|
78 | #endif |
---|