source: XIOS/trunk/src/buffer_client.cpp @ 509

Last change on this file since 509 was 509, checked in by mhnguyen, 10 years ago

Implementing buffer size auto-detection for mode client -server

+) Process xml tree in client side then send all the information to server
+) Only information enabled fields in enabled files are sent to server
+) Some important change in structure of code which must be refactored

Test
+) On Curie
+) Only mode client-server
+) Passed for all tests

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
  • Property svn:eol-style set to native
File size: 2.4 KB
RevLine 
[300]1#include "xmlioserver_spl.hpp"
2#include "exception.hpp"
[380]3#include "log.hpp"
[300]4#include "buffer_out.hpp"
5#include "buffer_client.hpp"
[317]6#include "cxios.hpp"
[382]7#include "mpi.hpp"
[347]8#include "tracer.hpp"
[300]9
[335]10namespace xios
[300]11{
[509]12
[400]13  size_t maxRequestSize=0 ;
[509]14
15  CClientBuffer::CClientBuffer(MPI_Comm interComm_,int serverRank_, StdSize bfSize)
[300]16  {
[509]17    bufferSizeByServer=bfSize; //CXios::bufferSize ;
[380]18    info(10)<<"bufferSizeByServer "<<bufferSizeByServer<<endl ;
[300]19    interComm=interComm_ ;
20    serverRank=serverRank_ ;
[509]21    bufferSize=bufferSizeByServer/2; //2 ;
[300]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) ;
28  }
[509]29
[300]30  CClientBuffer::~CClientBuffer()
31  {
32   delete [] buffer[0] ;
33   delete [] buffer[1] ;
34   delete retBuffer ;
35  }
[509]36
[300]37  int CClientBuffer::remain(void)
38  {
39    return bufferSize-count ;
40  }
[509]41
[300]42  bool CClientBuffer::isBufferFree(int size)
43  {
[400]44    if (size>maxRequestSize) maxRequestSize=size ;
[509]45
[300]46    if (size>bufferSize) ERROR("CClientBuffer::hasSpace(int size)",
[400]47                               <<"request size is too big for buffer, increase buffer client size"<<endl
48                               <<"Current buffer_size : "<<CXios::bufferSize<<endl
49                               <<"buffer_size must be > "<<size*2<<endl)
[509]50
[300]51    if (size<=remain()) return true ;
52    else return false ;
53  }
[509]54
55
[300]56  CBufferOut*  CClientBuffer::getBuffer(int size)
57  {
58    if (size<=remain())
59    {
60      retBuffer->realloc(buffer[current]+count,size) ;
61      count+=size ;
62      return retBuffer ;
63    }
64    else
65    {
66       ERROR("CBufferOut*  CClientBuffer::getSpace(int size) ;",
67               <<"No ennough space in buffer, that may not happen...");
68       return NULL ;
69    }
[509]70
71  }
72
[300]73  bool CClientBuffer::checkBuffer(void)
74  {
75    MPI_Status status ;
76    int flag ;
[509]77
[300]78    if (pending)
79    {
[347]80      traceOff() ;
[300]81      MPI_Test(&request,&flag,&status) ;
[347]82      traceOn() ;
[300]83      if (flag==true) pending=false ;
84    }
85
86    if (!pending)
87    {
88      if (count>0)
89      {
90        MPI_Issend(buffer[current],count,MPI_CHAR,serverRank,20,interComm,&request) ;
91        pending=true ;
92        if (current==1) current=0 ;
93        else current=1 ;
94        count=0 ;
95      }
96    }
97    return pending ;
98  }
[509]99
[300]100  bool CClientBuffer::hasPendingRequest(void)
101  {
102    if (pending) return true ;
103    else if (count>0) return true ;
104    else return false ;
105  }
[509]106
107
108
109}
110
Note: See TracBrowser for help on using the repository browser.