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

Last change on this file since 509 was 509, checked in by mhnguyen, 7 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
Line 
1#include "xmlioserver_spl.hpp"
2#include "exception.hpp"
3#include "log.hpp"
4#include "buffer_out.hpp"
5#include "buffer_client.hpp"
6#include "cxios.hpp"
7#include "mpi.hpp"
8#include "tracer.hpp"
9
10namespace xios
11{
12
13  size_t maxRequestSize=0 ;
14
15  CClientBuffer::CClientBuffer(MPI_Comm interComm_,int serverRank_, StdSize bfSize)
16  {
17    bufferSizeByServer=bfSize; //CXios::bufferSize ;
18    info(10)<<"bufferSizeByServer "<<bufferSizeByServer<<endl ;
19    interComm=interComm_ ;
20    serverRank=serverRank_ ;
21    bufferSize=bufferSizeByServer/2; //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) ;
28  }
29
30  CClientBuffer::~CClientBuffer()
31  {
32   delete [] buffer[0] ;
33   delete [] buffer[1] ;
34   delete retBuffer ;
35  }
36
37  int CClientBuffer::remain(void)
38  {
39    return bufferSize-count ;
40  }
41
42  bool CClientBuffer::isBufferFree(int size)
43  {
44    if (size>maxRequestSize) maxRequestSize=size ;
45
46    if (size>bufferSize) ERROR("CClientBuffer::hasSpace(int size)",
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)
50
51    if (size<=remain()) return true ;
52    else return false ;
53  }
54
55
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    }
70
71  }
72
73  bool CClientBuffer::checkBuffer(void)
74  {
75    MPI_Status status ;
76    int flag ;
77
78    if (pending)
79    {
80      traceOff() ;
81      MPI_Test(&request,&flag,&status) ;
82      traceOn() ;
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  }
99
100  bool CClientBuffer::hasPendingRequest(void)
101  {
102    if (pending) return true ;
103    else if (count>0) return true ;
104    else return false ;
105  }
106
107
108
109}
110
Note: See TracBrowser for help on using the repository browser.