Changeset 732
- Timestamp:
- 10/13/15 15:14:23 (8 years ago)
- Location:
- XIOS/trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/buffer_client.cpp
r591 r732 10 10 namespace xios 11 11 { 12 size_t CClientBuffer::maxRequestSize = 0; 12 13 13 size_t maxRequestSize=0 ; 14 15 CClientBuffer::CClientBuffer(MPI_Comm interComm_,int serverRank_, StdSize bfSize) 14 CClientBuffer::CClientBuffer(MPI_Comm interComm_, int serverRank_, StdSize bfSize) 16 15 { 17 bufferSizeByServer=bfSize; //CXios::bufferSize ; 18 info(10)<<"bufferSizeByServer "<<bufferSizeByServer<<endl ; 19 interComm=interComm_ ; 20 serverRank=serverRank_ ; 21 bufferSize=bufferSizeByServer; //2 ; 22 buffer[0]=new char[bufferSize] ; // transform it with MPI_ALLOC_MEM later 23 buffer[1]=new char[bufferSize] ; 24 current=0 ; 25 count=0 ; 26 pending=false ; 27 retBuffer=new CBufferOut(buffer[current],bufferSize) ; 16 interComm = interComm_; 17 serverRank = serverRank_; 18 bufferSize = bfSize; 19 buffer[0] = new char[bufferSize]; // transform it with MPI_ALLOC_MEM later 20 buffer[1] = new char[bufferSize]; 21 current = 0; 22 count = 0; 23 pending = false; 24 retBuffer = new CBufferOut(buffer[current], bufferSize); 25 info(10) << "CClientBuffer: allocated " << bufferSize << " bytes for server " << serverRank_ << endl; 28 26 } 29 27 30 28 CClientBuffer::~CClientBuffer() 31 29 { 32 delete [] buffer[0] 33 delete [] buffer[1] 34 delete retBuffer 30 delete [] buffer[0]; 31 delete [] buffer[1]; 32 delete retBuffer; 35 33 } 36 34 37 35 int CClientBuffer::remain(void) 38 36 { 39 return bufferSize -count;37 return bufferSize - count; 40 38 } 41 39 42 40 bool CClientBuffer::isBufferFree(int size) 43 41 { 44 if (size >maxRequestSize) maxRequestSize=size;42 if (size > maxRequestSize) maxRequestSize = size; 45 43 46 if (size >bufferSize) ERROR("CClientBuffer::hasSpace(int size)",47 <<"request size is too big for buffer, increase buffer client size"<<endl48 <<"buffer_size must be > "<<size*2<<endl)44 if (size > bufferSize) 45 ERROR("bool CClientBuffer::isBufferFree(int size)", 46 << "The requested size (" << size << " bytes) is too big to fit the buffer (" << bufferSize << " bytes), please increase the client buffer size." << endl); 49 47 50 if (size<=remain()) return true ; 51 else return false ; 48 return (size <= remain()); 52 49 } 53 50 54 51 55 CBufferOut* 52 CBufferOut* CClientBuffer::getBuffer(int size) 56 53 { 57 if (size <=remain())54 if (size <= remain()) 58 55 { 59 retBuffer->realloc(buffer[current] +count,size);60 count +=size;61 return retBuffer 56 retBuffer->realloc(buffer[current] + count, size); 57 count += size; 58 return retBuffer; 62 59 } 63 60 else 64 61 { 65 ERROR("CBufferOut* CClientBuffer::getSpace(int size) ;",66 <<"No ennough space in buffer, that may not happen...");67 return NULL;62 ERROR("CBufferOut* CClientBuffer::getBuffer(int size)", 63 << "Not enough space in buffer, this should not have happened..."); 64 return NULL; 68 65 } 69 70 66 } 71 67 72 68 bool CClientBuffer::checkBuffer(void) 73 69 { 74 MPI_Status status 75 int flag 70 MPI_Status status; 71 int flag; 76 72 77 73 if (pending) 78 74 { 79 traceOff() 80 MPI_Test(&request, &flag,&status);81 traceOn() 82 if (flag ==true) pending=false;75 traceOff(); 76 MPI_Test(&request, &flag, &status); 77 traceOn(); 78 if (flag == true) pending = false; 83 79 } 84 80 85 81 if (!pending) 86 82 { 87 if (count >0)83 if (count > 0) 88 84 { 89 MPI_Issend(buffer[current], count,MPI_CHAR,serverRank,20,interComm,&request);90 pending =true;91 if (current ==1) current=0;92 else current =1;93 count =0;85 MPI_Issend(buffer[current], count, MPI_CHAR, serverRank, 20, interComm, &request); 86 pending = true; 87 if (current == 1) current = 0; 88 else current = 1; 89 count = 0; 94 90 } 95 91 } 96 return pending ; 92 93 return pending; 97 94 } 98 95 99 96 bool CClientBuffer::hasPendingRequest(void) 100 97 { 101 if (pending) return true ; 102 else if (count>0) return true ; 103 else return false ; 98 return (pending || count > 0); 104 99 } 105 106 107 108 100 } 109 -
XIOS/trunk/src/buffer_client.hpp
r591 r732 9 9 namespace xios 10 10 { 11 extern size_t maxRequestSize ;12 13 11 class CClientBuffer 14 12 { 13 public: 14 static size_t maxRequestSize; 15 15 16 public: 16 CClientBuffer(MPI_Comm intercomm,int serverRank, StdSize bfSize = 0); 17 ~CClientBuffer(); 17 18 18 CClientBuffer(MPI_Comm intercomm,int serverRank, StdSize bfSize = 0) ; 19 ~CClientBuffer() ; 20 bool isBufferFree(int size) ; 21 CBufferOut* getBuffer(int size) ; 22 bool checkBuffer(void) ; 23 bool hasPendingRequest(void) ; 19 bool isBufferFree(int size); 20 CBufferOut* getBuffer(int size); 21 bool checkBuffer(void); 22 bool hasPendingRequest(void); 23 int remain(void); 24 24 25 char* buffer[2] ;26 int remain(void);25 private: 26 char* buffer[2]; 27 27 28 int current;29 int count;30 int bufferSize;31 int serverRank;32 bool pending;28 int current; 29 int count; 30 int bufferSize; 31 int serverRank; 32 bool pending; 33 33 34 size_t bufferSizeByServer;34 MPI_Request request; 35 35 36 MPI_Request request ; 37 38 CBufferOut* retBuffer; 39 MPI_Comm interComm ; 40 } ; 41 36 CBufferOut* retBuffer; 37 MPI_Comm interComm; 38 }; 42 39 } 43 40 44 41 #endif 45 -
XIOS/trunk/src/client.cpp
r697 r732 252 252 report(0)<< " Performance report : This ratio must be close to zero. Otherwise it may be usefull to increase buffer size or numbers of server"<<endl ; 253 253 // report(0)<< " Memory report : Current buffer_size : "<<CXios::bufferSize<<endl ; 254 report(0)<< " Memory report : Minimum buffer size required : " <<maxRequestSize*2<< " bytes" << endl ;254 report(0)<< " Memory report : Minimum buffer size required : " << CClientBuffer::maxRequestSize << " bytes" << endl ; 255 255 report(0)<< " Memory report : increasing it by a factor will increase performance, depending of the volume of data wrote in file at each time step of the file"<<endl ; 256 256 }
Note: See TracChangeset
for help on using the changeset viewer.