Changeset 511 for XIOS


Ignore:
Timestamp:
11/13/14 15:09:28 (9 years ago)
Author:
mhnguyen
Message:

Seperating database of context on "client" side and "server" side

+) Add one more context in contex client in case of attached mode
+) Do some minor changements to make sure everything fine in case of attached mode
+) Replace buffer group with the new options

Test
+) On Curie
+) Connection mode: Attached and seperated
+) File mode: one and multiple
+) All tests passed

Location:
XIOS/trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/inputs/iodef.xml

    r481 r511  
    1010     
    1111     
    12    <file_definition type="multiple_file" par_access="collective" output_freq="6h" output_level="10" enabled=".TRUE."> 
     12   <file_definition type="one_file" par_access="collective" output_freq="6h" output_level="10" enabled=".TRUE."> 
    1313     <file id="output" name="output">  
    1414        <field field_ref="field_A" /> 
     
    4141      <variable_definition> 
    4242        <variable_group id="buffer"> 
    43             buffer_size = 80000000 
    44             buffer_server_factor_size = 2  
     43            <variable id="optimal_buffer_size" type="string">performance</variable> 
     44            <variable id="buffer_factor_size" type="double">1.0</variable>  
    4545         </variable_group> 
    4646 
    4747        <variable_group id="parameters" > 
    4848          <variable id="using_server" type="boolean">false</variable> 
    49           <variable id="info_level" type="int">50</variable> 
     49          <variable id="info_level" type="int">10</variable> 
     50          <variable id="print_file" type="boolean">true</variable> 
    5051        </variable_group> 
    5152      </variable_definition> 
  • XIOS/trunk/src/client.cpp

    r506 r511  
    132132        CTimer::get("XIOS").resume() ; 
    133133        CTimer::get("XIOS init").resume() ; 
    134    
    135         if (CXios::usingServer)  
     134 
     135        if (CXios::usingServer) 
    136136        { 
    137137          MPI_Status status ; 
     
    153153    { 
    154154      CContext::setCurrent(id) ; 
    155       CContext* context=CContext::create(id) ; 
     155      CContext* context=CContext::create(id); 
     156      StdString idServer(id); 
     157      idServer += "_server"; 
    156158 
    157159      if (!CXios::isServer) 
     
    169171 
    170172        CMessage msg ; 
    171         msg<<id<<size<<globalRank ; 
     173        msg<<idServer<<size<<globalRank ; 
     174//        msg<<id<<size<<globalRank ; 
    172175 
    173176        int messageSize=msg.size() ; 
     
    192195        MPI_Comm contextInterComm ; 
    193196        MPI_Comm_dup(contextComm,&contextInterComm) ; 
    194         context->initClient(contextComm,contextInterComm) ; 
    195         context->initServer(contextComm,contextInterComm) ; 
     197        CContext* contextServer = CContext::create(idServer); 
     198 
     199        // Firstly, initialize context on client side 
     200        context->initClient(contextComm,contextInterComm, contextServer); 
     201 
     202 
     203        // Secondly, initialize context on server side 
     204        contextServer->initServer(contextComm,contextInterComm); 
     205 
     206        // Finally, we should return current context to context client 
     207        CContext::setCurrent(id); 
     208//        context->initServer(contextComm,contextInterComm) ; 
    196209      } 
    197210    } 
     
    223236      report(0)<< " Performance report : Ratio : "<< CTimer::get("Blocking time").getCumulatedTime()/CTimer::get("XIOS").getCumulatedTime()*100.<<" %"<<endl ; 
    224237      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 ; 
    225       report(0)<< " Memory report : Current buffer_size : "<<CXios::bufferSize<<endl ; 
    226       report(0)<< " Memory report : Minimum buffer size required : "<<maxRequestSize*2<<endl ; 
     238//      report(0)<< " Memory report : Current buffer_size : "<<CXios::bufferSize<<endl ; 
     239      report(0)<< " Memory report : Minimum buffer size required : "<<maxRequestSize*2<< " bytes" << endl ; 
    227240      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 ; 
    228241   } 
  • XIOS/trunk/src/context_client.cpp

    r509 r511  
    1717 
    1818 
    19     CContextClient::CContextClient(CContext* parent,MPI_Comm intraComm_, MPI_Comm interComm_) : mapBufferSize_() 
     19    CContextClient::CContextClient(CContext* parent,MPI_Comm intraComm_, MPI_Comm interComm_, CContext* cxtSer) 
     20     : mapBufferSize_(), parentServer(cxtSer) 
    2021    { 
    2122      context=parent ; 
     
    6162      } 
    6263 
    63       if (context->hasServer) waitEvent(ranks) ; 
     64//      if (context->hasServer) 
     65      if (0 != parentServer) 
     66      { 
     67        waitEvent(ranks); 
     68        CContext::setCurrent(context->getId()); 
     69      } 
     70 
    6471      timeLine++ ; 
    6572    } 
     
    9299    void CContextClient::waitEvent(list<int>& ranks) 
    93100    { 
    94       context->server->setPendingEvent() ; 
     101//      context->server->setPendingEvent() ; 
     102//      while(checkBuffers(ranks)) 
     103//      { 
     104//        context->server->listen() ; 
     105//        context->server->checkPendingRequest() ; 
     106//      } 
     107// 
     108//      while(context->server->hasPendingEvent()) 
     109//      { 
     110//       context->server->eventLoop() ; 
     111//      } 
     112 
     113      parentServer->server->setPendingEvent() ; 
    95114      while(checkBuffers(ranks)) 
    96115      { 
    97         context->server->listen() ; 
    98         context->server->checkPendingRequest() ; 
    99       } 
    100  
    101       while(context->server->hasPendingEvent()) 
    102       { 
    103        context->server->eventLoop() ; 
     116        parentServer->server->listen() ; 
     117        parentServer->server->checkPendingRequest() ; 
     118      } 
     119 
     120      while(parentServer->server->hasPendingEvent()) 
     121      { 
     122       parentServer->server->eventLoop() ; 
    104123      } 
    105124 
     
    240259     } 
    241260     CTimer::get("Blocking time").suspend(); 
    242      report(0)<< " Memory report : Context <"<<context->getId()<<"> : client side : total memory used for buffer "<<buffers.size()*CXios::bufferSize<<" bytes"<<endl ; 
     261//     report(0)<< " Memory report : Context <"<<context->getId()<<"> : client side : total memory used for buffer "<<buffers.size()*CXios::bufferSize<<" bytes"<<endl ; 
     262 
     263     std::map<int, StdSize>::const_iterator itbMap = mapBufferSize_.begin(), 
     264                                            iteMap = mapBufferSize_.end(), itMap; 
     265     StdSize totalBuf = 0; 
     266     for (itMap = itbMap; itMap != iteMap; ++itMap) 
     267     { 
     268       report(10)<< " Memory report : Context <"<<context->getId()<<"> : client side : memory used for buffer of each connection to server" << endl 
     269                 << "  +)To server with rank " << itMap->first << " : " << itMap->second << " bytes " << endl; 
     270       totalBuf += itMap->second; 
     271     } 
     272     report(0)<< " Memory report : Context <"<<context->getId()<<"> : client side : total memory used for buffer "<<totalBuf<<" bytes"<<endl ; 
    243273 
    244274     releaseBuffers() ; 
  • XIOS/trunk/src/context_client.hpp

    r509 r511  
    1616 
    1717    public: 
    18     CContextClient(CContext* parent,MPI_Comm intraComm, MPI_Comm interComm) ; 
     18    CContextClient(CContext* parent,MPI_Comm intraComm, MPI_Comm interComm, CContext* parentServer = 0) ; 
    1919//    void registerEvent(CEventClient& event) ; 
    2020 
     
    4848    private: 
    4949    std::map<int, StdSize> mapBufferSize_; 
     50    CContext* parentServer; 
    5051//    bool locked ; 
    5152 
  • XIOS/trunk/src/context_server.cpp

    r509 r511  
    8383            StdSize buffSize = 0; 
    8484            MPI_Recv(&buffSize, 1, MPI_LONG, rank, 20, interComm, &status); 
     85            mapBufferSize_.insert(std::make_pair(rank, buffSize)); 
    8586            it=(buffers.insert(pair<int,CServerBuffer*>(rank,new CServerBuffer(buffSize)))).first ; 
    8687          } 
     
    207208    { 
    208209      info(20)<<"Server Side context <"<<context->getId()<<"> finalized"<<endl ; 
     210      std::map<int, StdSize>::const_iterator itbMap = mapBufferSize_.begin(), 
     211                                             iteMap = mapBufferSize_.end(), itMap; 
     212      StdSize totalBuf = 0; 
     213      for (itMap = itbMap; itMap != iteMap; ++itMap) 
     214      { 
     215        report(10)<< " Memory report : Context <"<<context->getId()<<"> : server side : memory used for buffer of each connection to client" << endl 
     216                  << "  +) With client of rank " << itMap->first << " : " << itMap->second << " bytes " << endl; 
     217        totalBuf += itMap->second; 
     218      } 
    209219      context->finalize() ; 
    210220      finished=true ; 
    211       report(0)<< " Memory report : Context <"<<context->getId()<<"> : server side : total memory used for buffer "<<buffers.size()*CXios::bufferSize<<" bytes"<<endl ; 
     221      report(0)<< " Memory report : Context <"<<context->getId()<<"> : server side : total memory used for buffer "<<totalBuf<<" bytes"<<endl ; 
    212222    } 
    213223    else if (event.classId==CContext::GetType()) CContext::dispatchEvent(event) ; 
  • XIOS/trunk/src/context_server.hpp

    r501 r511  
    99{ 
    1010  class CContext ; 
    11    
     11 
    1212  class CContextServer 
    1313  { 
    1414    public: 
    15      
     15 
    1616    CContextServer(CContext* parent,MPI_Comm intraComm,MPI_Comm interComm) ; 
    1717    bool eventLoop(void) ; 
     
    2323    void setPendingEvent(void) ; 
    2424    bool hasPendingEvent(void) ; 
    25      
     25 
    2626    MPI_Comm intraComm ; 
    2727    int intraCommSize ; 
    2828    int intraCommRank ; 
    29      
     29 
    3030    MPI_Comm interComm ; 
    3131    int commSize ; 
    32    
     32 
    3333    map<int,CServerBuffer*> buffers ; 
    3434    map<int,MPI_Request> pendingRequest ; 
    3535    map<int,char*> bufferRequest ; 
    36      
     36 
    3737    map<size_t,CEventServer*> events ; 
    3838    size_t currentTimeLine ; 
    3939    CContext* context ; 
    40      
     40 
    4141    bool finished ; 
    4242    bool pendingEvent ; 
    4343    bool scheduled  ;    /*!< event of current timeline is alreading scheduled ? */ 
    4444    size_t hashId ; 
    45     ~CContextServer() ;     
     45    ~CContextServer() ; 
     46 
     47    private: 
     48      std::map<int, StdSize> mapBufferSize_; 
    4649  } ; 
    4750 
  • XIOS/trunk/src/cxios.cpp

    r509 r511  
    2929  bool CXios::printInfo2File; 
    3030  bool CXios::isServerSide; 
    31  
     31  bool CXios::isOptPerformance = true; 
    3232 
    3333  void CXios::initialize() 
     
    3535    set_new_handler(noMemory); 
    3636    parseFile(rootFile); 
     37    parseXiosConfig(); 
     38  } 
     39 
     40  void CXios::parseXiosConfig() 
     41  { 
    3742    usingOasis=getin<bool>("using_oasis",false) ; 
    3843    usingServer=getin<bool>("using_server",false) ; 
    3944    info.setLevel(getin<int>("info_level",0)) ; 
     45    report.setLevel(getin<int>("info_level",0)); 
    4046    printInfo2File=getin<bool>("print_file",false); 
    4147    bufferSize=getin<size_t>("buffer_size",defaultBufferSize) ; 
    42     bufferServerFactorSize=getin<double>("buffer_server_factor_size",defaultBufferServerFactorSize) ; 
     48    StdString bufMemory("memory"); 
     49    StdString bufPerformance("performance"); 
     50    StdString bufOpt = getin<StdString>("optimal_buffer_size", bufPerformance); 
     51    std::transform(bufOpt.begin(), bufOpt.end(), bufOpt.begin(), ::tolower); 
     52    if (0 == bufOpt.compare(bufMemory)) isOptPerformance = false; 
     53    else if (0 != bufOpt.compare(bufPerformance)) 
     54    { 
     55      ERROR("CXios::parseXiosConfig()", << "optimal_buffer_size must be memory or performance "<< endl ); 
     56    } 
     57 
     58//    bufferServerFactorSize=getin<double>("buffer_server_factor_size",defaultBufferServerFactorSize) ; 
     59    bufferServerFactorSize=getin<double>("buffer_factor_size",defaultBufferServerFactorSize) ; 
    4360    globalComm=MPI_COMM_WORLD ; 
    4461  } 
    45  
    4662 
    4763  void CXios::initClientSide(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm) 
     
    7995    parseList.insert("xios"); 
    8096    xml::CXMLParser::ParseFile(rootFile, parseList); 
    81 //    parseFile(rootFile); 
    82     usingOasis=getin<bool>("using_oasis",false) ; 
    83     info.setLevel(getin<int>("info_level",0)) ; 
    84     printInfo2File=getin<bool>("print_file",false); 
    85     bufferSize=getin<size_t>("buffer_size",defaultBufferSize) ; 
    86     bufferServerFactorSize=getin<double>("buffer_server_factor_size",defaultBufferServerFactorSize) ; 
    87     globalComm=MPI_COMM_WORLD ; 
    88  
     97    parseXiosConfig(); 
    8998  } 
    9099 
  • XIOS/trunk/src/cxios.hpp

    r509 r511  
    4242     static double bufferServerFactorSize ; 
    4343     static double defaultBufferServerFactorSize ; 
     44     static bool isOptPerformance; 
    4445 
    4546     public: 
     
    5455 
    5556     static  void initServer(); 
     57 
     58     private: 
     59      static void parseXiosConfig(); 
    5660 
    5761  } ; 
  • XIOS/trunk/src/node/context.cpp

    r510 r511  
    2323   CContext::CContext(void) 
    2424      : CObjectTemplate<CContext>(), CContextAttributes() 
    25       , calendar(),hasClient(false),hasServer(false), isPostProcessed(false), dataSize_() 
     25      , calendar(),hasClient(false),hasServer(false), isPostProcessed(false), dataSize_(), idServer_() 
    2626   { /* Ne rien faire de plus */ } 
    2727 
    2828   CContext::CContext(const StdString & id) 
    2929      : CObjectTemplate<CContext>(id), CContextAttributes() 
    30       , calendar(),hasClient(false),hasServer(false), isPostProcessed(false), dataSize_() 
     30      , calendar(),hasClient(false),hasServer(false), isPostProcessed(false), dataSize_(), idServer_() 
    3131   { /* Ne rien faire de plus */ } 
    3232 
     
    280280 
    281281   //! Initialize client side 
    282    void CContext::initClient(MPI_Comm intraComm, MPI_Comm interComm) 
     282   void CContext::initClient(MPI_Comm intraComm, MPI_Comm interComm, CContext* cxtServer) 
    283283   { 
    284284     hasClient=true ; 
    285      client = new CContextClient(this,intraComm, interComm) ; 
     285     client = new CContextClient(this,intraComm, interComm, cxtServer) ; 
    286286   } 
    287287 
     
    575575     { 
    576576       CMessage msg ; 
    577        msg<<this->getId() ; 
     577       msg<<this->getIdServer() ; 
    578578       event.push(client->getServerLeader(),1,msg) ; 
    579579       client->sendEvent(event) ; 
     
    601601       { 
    602602         CMessage msg ; 
    603          msg<<this->getId()<<step ; 
     603         msg<<this->getIdServer()<<step ; 
    604604         event.push(client->getServerLeader(),1,msg) ; 
    605605         client->sendEvent(event) ; 
     
    634634     { 
    635635       CMessage msg ; 
    636        msg<<this->getId() ; 
     636       msg<<this->getIdServer() ; 
    637637       event.push(client->getServerLeader(),1,msg) ; 
    638638       client->sendEvent(event) ; 
     
    665665       { 
    666666         CMessage msg ; 
    667          msg<<this->getId(); 
     667         msg<<this->getIdServer(); 
    668668         event.push(client->getServerLeader(),1,msg) ; 
    669669         client->sendEvent(event) ; 
     
    686686   { 
    687687      postProcessing(); 
     688   } 
     689 
     690   const StdString& CContext::getIdServer() 
     691   { 
     692      if (hasClient) 
     693      { 
     694        idServer_ = this->getId(); 
     695        idServer_ += "_server"; 
     696        return idServer_; 
     697      } 
     698      if (hasServer) return (this->getId()); 
    688699   } 
    689700 
     
    736747         else 
    737748         { 
     749           std::map<int, StdSize>::const_iterator it = mapSize.begin(), itE = mapSize.end(); 
    738750           if (domainIds.find(prDomAxisId.first) == domainIds.end()) 
    739751           { 
    740              std::map<int, StdSize>::const_iterator it = mapSize.begin(), itE = mapSize.end(); 
    741752             for (; it != itE; ++it) 
    742753             { 
     
    744755               else dataSize_.insert(make_pair(it->first, it->second)); 
    745756             } 
     757           } else 
     758           { 
     759             for (; it != itE; ++it) 
     760             { 
     761               if (0 < dataSize_.count(it->first)) 
     762                if (CXios::isOptPerformance) dataSize_[it->first] += it->second; 
     763                else 
     764                { 
     765                  if (dataSize_[it->first] < it->second) dataSize_[it->first] = it->second; 
     766                } 
     767               else dataSize_.insert(make_pair(it->first, it->second)); 
     768             } 
    746769           } 
    747  
    748770         } 
    749  
    750771       } 
    751772     } 
  • XIOS/trunk/src/node/context.hpp

    r509 r511  
    8888         // Initialize server or client 
    8989         void initServer(MPI_Comm intraComm, MPI_Comm interComm) ; 
    90          void initClient(MPI_Comm intraComm, MPI_Comm interComm) ; 
     90         void initClient(MPI_Comm intraComm, MPI_Comm interComm, CContext* cxtServer=0) ; 
    9191         bool isInitialized(void) ; 
    9292 
     
    129129         void sendPostProcessing(); 
    130130 
     131         const StdString& getIdServer(); 
     132 
    131133         // Client side: Receive and process messages 
    132134         static void recvUpdateCalendar(CEventServer& event) ; 
     
    206208         bool isPostProcessed; 
    207209         std::map<int, StdSize> dataSize_; 
     210         StdString idServer_; 
    208211 
    209212 
  • XIOS/trunk/src/node/grid.cpp

    r510 r511  
    177177       if (this->withAxis) retVal *= this->axis->size.getValue(); 
    178178       retVal *= sizeof(double); 
    179        retVal *= 1.2; // Secure factor 
     179       retVal *= 1.2 * CXios::bufferServerFactorSize; // Secure factor 
    180180       ret.insert(make_pair(it->first, retVal)); 
    181181     } 
  • XIOS/trunk/src/object.cpp

    r501 r511  
    2020   { /* Ne rien faire de plus */ } 
    2121 
    22    const StdString & CObject::getId(void) const  
    23    {  
     22   const StdString & CObject::getId(void) const 
     23   { 
    2424      return (this->id); 
    2525   } 
    2626 
    27    bool CObject::hasId(void) const   
    28    {  
     27   const StdString& CObject::getIdServer() 
     28   { 
     29      return (this->id); 
     30   } 
     31 
     32   bool CObject::hasId(void) const 
     33   { 
    2934      return (this->IdDefined); 
    3035   } 
    3136 
    32    void CObject::resetId(void)  
    33    {  
     37   void CObject::resetId(void) 
     38   { 
    3439      this->IdDefined = false ; 
    3540   } 
    3641 
    3742   void CObject::setId(const StdString & id) 
    38    {  
     43   { 
    3944      this->id = id ; 
    4045      this->IdDefined = true ; 
     
    4954 
    5055   bool CObject::operator!=(const CObject & other) const 
    51    {  
     56   { 
    5257      return (!(*this == other)); 
    5358   } 
    5459*/ 
    5560   StdOStream & operator << (StdOStream & os, const CObject & object) 
    56    {  
     61   { 
    5762      os << object.toString(); 
    5863      return (os); 
  • XIOS/trunk/src/object.hpp

    r501 r511  
    1818         /// Accesseurs /// 
    1919         const StdString & getId(void) const; 
     20 
     21         virtual const StdString& getIdServer(); 
    2022 
    2123         /// Mutateurs /// 
  • XIOS/trunk/src/object_template_impl.hpp

    r509 r511  
    193193       { 
    194194         CMessage msg ; 
    195          msg<<this->getId() ; 
     195//         msg<<this->getId() ; 
     196         msg<<this->getIdServer(); 
    196197         msg<<attr.getName() ; 
    197198         msg<<attr ; 
Note: See TracChangeset for help on using the changeset viewer.