Changeset 732


Ignore:
Timestamp:
10/13/15 15:14:23 (6 years ago)
Author:
rlacroix
Message:

CClientBuffer: Improve the error messages.

Location:
XIOS/trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/buffer_client.cpp

    r591 r732  
    1010namespace xios 
    1111{ 
     12  size_t CClientBuffer::maxRequestSize = 0; 
    1213 
    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) 
    1615  { 
    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; 
    2826  } 
    2927 
    3028  CClientBuffer::~CClientBuffer() 
    3129  { 
    32    delete [] buffer[0] ; 
    33    delete [] buffer[1] ; 
    34    delete retBuffer ; 
     30   delete [] buffer[0]; 
     31   delete [] buffer[1]; 
     32   delete retBuffer; 
    3533  } 
    3634 
    3735  int CClientBuffer::remain(void) 
    3836  { 
    39     return bufferSize-count ; 
     37    return bufferSize - count; 
    4038  } 
    4139 
    4240  bool CClientBuffer::isBufferFree(int size) 
    4341  { 
    44     if (size>maxRequestSize) maxRequestSize=size ; 
     42    if (size > maxRequestSize) maxRequestSize = size; 
    4543 
    46     if (size>bufferSize) ERROR("CClientBuffer::hasSpace(int size)", 
    47                                <<"request size is too big for buffer, increase buffer client size"<<endl 
    48                                <<"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); 
    4947 
    50     if (size<=remain()) return true ; 
    51     else return false ; 
     48    return (size <= remain()); 
    5249  } 
    5350 
    5451 
    55   CBufferOut*  CClientBuffer::getBuffer(int size) 
     52  CBufferOut* CClientBuffer::getBuffer(int size) 
    5653  { 
    57     if (size<=remain()) 
     54    if (size <= remain()) 
    5855    { 
    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; 
    6259    } 
    6360    else 
    6461    { 
    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; 
    6865    } 
    69  
    7066  } 
    7167 
    7268  bool CClientBuffer::checkBuffer(void) 
    7369  { 
    74     MPI_Status status ; 
    75     int flag ; 
     70    MPI_Status status; 
     71    int flag; 
    7672 
    7773    if (pending) 
    7874    { 
    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; 
    8379    } 
    8480 
    8581    if (!pending) 
    8682    { 
    87       if (count>0) 
     83      if (count > 0) 
    8884      { 
    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; 
    9490      } 
    9591    } 
    96     return pending ; 
     92 
     93    return pending; 
    9794  } 
    9895 
    9996  bool CClientBuffer::hasPendingRequest(void) 
    10097  { 
    101     if (pending) return true ; 
    102     else if (count>0) return true ; 
    103     else return false ; 
     98    return (pending || count > 0); 
    10499  } 
    105  
    106  
    107  
    108100} 
    109  
  • XIOS/trunk/src/buffer_client.hpp

    r591 r732  
    99namespace xios 
    1010{ 
    11   extern size_t maxRequestSize ; 
    12  
    1311  class CClientBuffer 
    1412  { 
     13    public: 
     14      static size_t maxRequestSize; 
    1515 
    16     public: 
     16      CClientBuffer(MPI_Comm intercomm,int serverRank, StdSize bfSize = 0); 
     17      ~CClientBuffer(); 
    1718 
    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); 
    2424 
    25     char* buffer[2] ; 
    26     int remain(void) ; 
     25    private: 
     26      char* buffer[2]; 
    2727 
    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; 
    3333 
    34     size_t bufferSizeByServer ; 
     34      MPI_Request request; 
    3535 
    36     MPI_Request request ; 
    37  
    38     CBufferOut* retBuffer; 
    39     MPI_Comm interComm ; 
    40   } ; 
    41  
     36      CBufferOut* retBuffer; 
     37      MPI_Comm interComm; 
     38  }; 
    4239} 
    4340 
    4441#endif 
    45  
  • XIOS/trunk/src/client.cpp

    r697 r732  
    252252      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 ; 
    253253//      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 ; 
    255255      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 ; 
    256256   } 
Note: See TracChangeset for help on using the changeset viewer.