Changeset 512


Ignore:
Timestamp:
11/14/14 17:56:37 (7 years ago)
Author:
mhnguyen
Message:

Correct bug causing infinite run on multiple server and do some code clean

+) Correct a stupid typo which causes the bug
+) Add comments for class Contextclient
+) Remove some redundant codes

Test
+) On Curie
+) Connection mode: Attached: One and Multiple; Seperated: One and Multiple server
+) File mode: One and multiple file
+) All tests passed (Will it make the trusting board become red :)? )

Location:
XIOS/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/inputs/COMPLETE/context_surface.xml

    r509 r512  
    77    <field id="field_A_srf_K" name="field_A_srf_K" field_ref="field_A_srf" long_name="Champ en degK" unit="degK"> field_A_srf + 273.15 </field> 
    88    <field id="field_A_srf_max" name="field_A_srf_max" field_ref="field_A_srf" long_name="maximum field_A_srf" operation="maximum" /> 
    9     <field id="field_D_srf" name="field_D_srf" long_name="Somme champ A et C" > field_A_srf + field_A_srf_K </field> 
     9    <field id="field_D_srf" name="field_D_srf" long_name="Somme champ A et C" > field_A_srf + field_C_srf </field> 
    1010     
    1111  </field_definition> 
     
    1717        <variable id="my_attribute2" type="integer" > 10 </variable> 
    1818        <variable id="my_attribute3" type="float" >6.8</variable> 
    19         <variable id="my_attribute4" type="double" >100.201</variable> 
     19        <variable id="my_attribute5" type="double" >100.201</variable> 
    2020      </field> 
    2121      <field field_ref="field_A_srf_K" /> 
     
    3131        <variable id="my_attribute1" type="string" >surf_att</variable> 
    3232        <variable id="my_attribute2" type="integer" >10</variable> 
    33         <variable id="my_attribute3" type="float" >7.8</variable> 
     33        <variable id="my_attribute3" type="float" >6.8</variable> 
    3434        <variable id="my_attribute4" type="double" >100.201</variable> 
    3535      </field> 
    36       <field field_ref="field_D_srf" /> 
    3736      <field field_ref="field_A_srf_K" /> 
    3837      <field field_ref="field_A_srf" name="field_A_srf_min" operation="minimum" /> 
  • XIOS/trunk/inputs/COMPLETE/iodef.xml

    r491 r512  
    99      <variable_definition> 
    1010        <variable_group id="buffer"> 
    11             buffer_size = 80000000 
    12             buffer_server_factor_size = 2 
     11            <variable id="optimal_buffer_size" type="string">memory</variable> 
     12            <variable id="buffer_factor_size" type="double">1.0</variable>  
    1313         </variable_group> 
    1414 
  • XIOS/trunk/inputs/iodef.xml

    r511 r512  
    1010     
    1111     
    12    <file_definition type="one_file" par_access="collective" output_freq="6h" output_level="10" enabled=".TRUE."> 
     12   <file_definition type="multiple_file" par_access="collective" output_freq="6h" output_level="10" enabled=".TRUE."> 
    1313     <file id="output" name="output">  
    1414        <field field_ref="field_A" /> 
     
    4747        <variable_group id="parameters" > 
    4848          <variable id="using_server" type="boolean">false</variable> 
    49           <variable id="info_level" type="int">10</variable> 
     49          <variable id="info_level" type="int">50</variable> 
    5050          <variable id="print_file" type="boolean">true</variable> 
    5151        </variable_group> 
  • XIOS/trunk/src/buffer_client.cpp

    r509 r512  
    4646    if (size>bufferSize) ERROR("CClientBuffer::hasSpace(int size)", 
    4747                               <<"request size is too big for buffer, increase buffer client size"<<endl 
    48                                <<"Current buffer_size : "<<CXios::bufferSize<<endl 
    4948                               <<"buffer_size must be > "<<size*2<<endl) 
    5049 
  • XIOS/trunk/src/buffer_client.hpp

    r509 r512  
    1616    public: 
    1717 
    18     CClientBuffer(MPI_Comm intercomm,int serverRank, StdSize bfSize = CXios::bufferSize) ; 
     18    CClientBuffer(MPI_Comm intercomm,int serverRank, StdSize bfSize = 0) ; 
    1919    ~CClientBuffer() ; 
    2020    bool isBufferFree(int size) ; 
  • XIOS/trunk/src/buffer_server.hpp

    r509 r512  
    1515    public: 
    1616 
    17     CServerBuffer(StdSize bufSize = CXios::bufferSize) ; 
     17    CServerBuffer(StdSize bufSize) ; 
    1818    ~CServerBuffer() ; 
    1919    char* buffer ; 
  • XIOS/trunk/src/context_client.cpp

    r511 r512  
    1515namespace xios 
    1616{ 
    17  
    18  
     17    /*! 
     18    \param [in] parent Pointer to context on client side 
     19    \param [in] intraComm_ communicator of group client 
     20    \param [in] interComm_ communicator of group server 
     21    \cxtSer [in] cxtSer Pointer to context of server side. (It is only used on case of attached mode) 
     22    */ 
    1923    CContextClient::CContextClient(CContext* parent,MPI_Comm intraComm_, MPI_Comm interComm_, CContext* cxtSer) 
    2024     : mapBufferSize_(), parentServer(cxtSer) 
     
    3539    } 
    3640 
    37  
     41    /*! 
     42    In case of attached mode, the current context must be reset to context for client 
     43    \param [in] event Event sent to server 
     44    */ 
    3845    void CContextClient::sendEvent(CEventClient& event) 
    3946    { 
     
    7279    } 
    7380 
     81    /*! 
     82    Special function to setup size of buffer not only on client side but also on server side 
     83    corresponding to the connection 
     84    */ 
    7485    void CContextClient::sendBufferSizeEvent() 
    7586    { 
     
    8192              <<"No information about server buffer, that should not happen..."); 
    8293 
    83       for (; itMap != iteMap; ++iteMap) 
     94      for (; itMap != iteMap; ++itMap) 
    8495      { 
    8596        if (buffers.end() == buffers.find(itMap->first)) 
     
    97108    } 
    98109 
     110    /*! 
     111    If client is also server (attached mode), after sending event, it should process right away 
     112    the incoming event. 
     113    \param [in] ranks list rank of server connected this client 
     114    */ 
    99115    void CContextClient::waitEvent(list<int>& ranks) 
    100116    { 
     
    122138       parentServer->server->eventLoop() ; 
    123139      } 
    124  
    125140    } 
    126141 
     142    /*! 
     143    Setup buffer for each connection to server and verify their state to put content into them 
     144    \param [in] serverList list of rank of connected server 
     145    \param [in] sizeList size of message corresponding to each connection 
     146    \return List of buffer input which event can be placed 
     147    */ 
    127148    list<CBufferOut*> CContextClient::getBuffers(list<int>& serverList, list<int>& sizeList) 
    128149    { 
     
    166187   } 
    167188 
     189   /*! 
     190   Make a new buffer for a certain connection to server with specific rank 
     191   \param [in] rank rank of connected server 
     192   */ 
    168193   void CContextClient::newBuffer(int rank) 
    169194   { 
    170 //     buffers[rank]=new CClientBuffer(interComm,rank); 
    171195      buffers[rank]=new CClientBuffer(interComm,rank, mapBufferSize_[rank]) ; 
    172196   } 
    173197 
     198   /*! 
     199   Verify state of buffers. Buffer is under pending state if there is no message on it 
     200   \return state of buffers, pending(true), ready(false) 
     201   */ 
    174202   bool CContextClient::checkBuffers(void) 
    175203   { 
     
    180208   } 
    181209 
     210   //! Release all buffers 
    182211   void CContextClient::releaseBuffers(void) 
    183212   { 
     
    186215   } 
    187216 
     217   /*! 
     218   Verify state of buffers corresponding to a connection 
     219   \param [in] ranks list rank of server to which client connects to 
     220   \return state of buffers, pending(true), ready(false) 
     221   */ 
    188222   bool CContextClient::checkBuffers(list<int>& ranks) 
    189223   { 
     
    194228   } 
    195229 
     230   /*! 
     231   Set buffer size for each connection 
     232   \param [in] mapSize mapping rank of connected server to size of allocated buffer 
     233   */ 
    196234   void CContextClient::setBufferSize(const std::map<int, StdSize>& mapSize) 
    197235   { 
     
    200238   } 
    201239 
     240   /*! 
     241   Get leading server in the group of connected server 
     242   \return rank of leading server 
     243   */ 
    202244   int CContextClient::getServerLeader(void) 
    203245   { 
     
    217259   } 
    218260 
     261   /*! 
     262   Check if client connects to leading server 
     263   \return connected(true), not connected (false) 
     264   */ 
    219265   bool CContextClient::isServerLeader(void) 
    220266   { 
     
    236282   } 
    237283 
     284   /*! 
     285   Finalize context client and do some reports 
     286   */ 
    238287   void CContextClient::finalize(void) 
    239288   { 
    240  
    241289     map<int,CClientBuffer*>::iterator itBuff ; 
    242290     bool stop=true ; 
     
    259307     } 
    260308     CTimer::get("Blocking time").suspend(); 
    261 //     report(0)<< " Memory report : Context <"<<context->getId()<<"> : client side : total memory used for buffer "<<buffers.size()*CXios::bufferSize<<" bytes"<<endl ; 
    262309 
    263310     std::map<int, StdSize>::const_iterator itbMap = mapBufferSize_.begin(), 
     
    267314     { 
    268315       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; 
     316                 << "  +) To server with rank " << itMap->first << " : " << itMap->second << " bytes " << endl; 
    270317       totalBuf += itMap->second; 
    271318     } 
  • XIOS/trunk/src/context_client.hpp

    r511 r512  
    1212  class CContext ; 
    1313 
     14  /*! 
     15  \class CContextClient 
     16  A context can be both on client and on server side. In order to differenciate the role of 
     17  context on each side, e.x client sending events, server receiving and processing events, there is a need of 
     18  concrete "context" classes for both sides. 
     19  CContextClient processes and sends events from client to server where CContextServer receives these events 
     20  and processes them. 
     21  */ 
    1422  class CContextClient 
    1523  { 
     24    public: 
     25    // Contructor 
     26    CContextClient(CContext* parent,MPI_Comm intraComm, MPI_Comm interComm, CContext* parentServer = 0) ; 
    1627 
    17     public: 
    18     CContextClient(CContext* parent,MPI_Comm intraComm, MPI_Comm interComm, CContext* parentServer = 0) ; 
    19 //    void registerEvent(CEventClient& event) ; 
     28    // Send event to server 
     29    void sendEvent(CEventClient& event) ; 
     30    void waitEvent(list<int>& ranks) ; 
    2031 
    21 //    list<CBufferOut*> newEvent(CEventClient& event,list<int>& sizes) ; 
    22     void sendEvent(CEventClient& event) ; 
    23  
     32    // Functions relates to set/get buffers 
    2433    list<CBufferOut*> getBuffers(list<int>& serverlist, list<int>& sizeList) ; 
    2534    void newBuffer(int rank) ; 
    26     size_t timeLine ; 
    27     int clientRank ; 
    28     int clientSize ; 
    29     int serverSize ; 
    30 //    set<int> connectedServer ; 
    31     MPI_Comm interComm ; 
    32     MPI_Comm intraComm ; 
    33     map<int,CClientBuffer*> buffers ; 
    3435    bool checkBuffers(list<int>& ranks) ; 
    3536    bool checkBuffers(void); 
    3637    void releaseBuffers(void); 
    37     void closeContext(void) ; 
     38 
    3839    bool isServerLeader(void) ; 
    3940    int getServerLeader(void) ; 
     41 
     42    // Close and finalize context client 
     43    void closeContext(void) ; 
    4044    void finalize(void) ; 
    41     void waitEvent(list<int>& ranks) ; 
    4245 
    4346    void setBufferSize(const std::map<int, StdSize>& mapSize); 
    4447    void sendBufferSizeEvent(); 
    4548 
    46     CContext* context ; 
     49    public: 
     50      CContext* context ; //!< Context for client 
     51 
     52      size_t timeLine ; //!< Timeline of each event 
     53 
     54      int clientRank ; //!< Rank of current client 
     55 
     56      int clientSize ; //!< Size of client group 
     57 
     58      int serverSize ; //!< Size of server group 
     59 
     60      MPI_Comm interComm ; //!< Communicator of server group 
     61 
     62      MPI_Comm intraComm ; //!< Communicator of client group 
     63 
     64      map<int,CClientBuffer*> buffers ; //!< Buffers for connection to servers 
    4765 
    4866    private: 
    49     std::map<int, StdSize> mapBufferSize_; 
    50     CContext* parentServer; 
     67      //! Mapping of server and buffer size for each connection to server 
     68      std::map<int, StdSize> mapBufferSize_; 
     69 
     70      //! Context for server (Only used in attached mode) 
     71      CContext* parentServer; 
     72 
     73    public: // Some function should be removed in the future 
     74      //    void registerEvent(CEventClient& event) ; 
     75//    list<CBufferOut*> newEvent(CEventClient& event,list<int>& sizes) ; 
    5176//    bool locked ; 
     77//    set<int> connectedServer ; 
    5278 
    5379  } ; 
    54  
    55  
    56  
    57  
    5880} 
    5981 
    60  
    61  
    62 #endif 
     82#endif // __CONTEXT_CLIENT_HPP__ 
  • XIOS/trunk/src/cxios.cpp

    r511 r512  
    2323  bool CXios::usingOasis ; 
    2424  bool CXios::usingServer = false; 
    25   size_t CXios::bufferSize ; 
    26   double CXios::bufferServerFactorSize=2 ; 
    27   size_t CXios::defaultBufferSize=1024*1024*100 ; // 100Mo 
    28   double CXios::defaultBufferServerFactorSize=2 ; 
     25  double CXios::bufferServerFactorSize=1.0 ; 
     26  double CXios::defaultBufferServerFactorSize=1.0 ; 
    2927  bool CXios::printInfo2File; 
    3028  bool CXios::isServerSide; 
    3129  bool CXios::isOptPerformance = true; 
    3230 
     31  //! Parse configuration file and create some objects from it 
    3332  void CXios::initialize() 
    3433  { 
     
    3837  } 
    3938 
     39  /*! 
     40  \brief Parse xios part of configuration file (.iodef.xml) 
     41   Both client and server need information returned from this function 
     42  */ 
    4043  void CXios::parseXiosConfig() 
    4144  { 
     
    4346    usingServer=getin<bool>("using_server",false) ; 
    4447    info.setLevel(getin<int>("info_level",0)) ; 
    45     report.setLevel(getin<int>("info_level",0)); 
     48    report.setLevel(getin<int>("info_level",50)); 
    4649    printInfo2File=getin<bool>("print_file",false); 
    47     bufferSize=getin<size_t>("buffer_size",defaultBufferSize) ; 
     50 
    4851    StdString bufMemory("memory"); 
    4952    StdString bufPerformance("performance"); 
     
    5659    } 
    5760 
    58 //    bufferServerFactorSize=getin<double>("buffer_server_factor_size",defaultBufferServerFactorSize) ; 
    5961    bufferServerFactorSize=getin<double>("buffer_factor_size",defaultBufferServerFactorSize) ; 
    6062    globalComm=MPI_COMM_WORLD ; 
    6163  } 
    6264 
     65  /*! 
     66  Initialize client 
     67  \param [in] codeId identity of context 
     68  \param [in] localComm local communicator 
     69  \param [in/out] returnComm communicator corresponding to group of client with same codeId 
     70  */ 
    6371  void CXios::initClientSide(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm) 
    6472  { 
     
    8997  } 
    9098 
     99  //! Init server by parsing only xios part of config file 
    91100  void CXios::initServer() 
    92101  { 
     
    98107  } 
    99108 
     109  //! Initialize server then put it into listening state 
    100110  void CXios::initServerSide(void) 
    101111  { 
    102 //    initialize(); 
    103112    initServer(); 
    104113    isClient=true; 
     
    123132  } 
    124133 
     134  //! Parse configuration file 
    125135  void CXios::parseFile(const string& filename) 
    126136  { 
     
    128138  } 
    129139 
     140  //! Set using server 
    130141  void CXios::setUsingServer() 
    131142  { 
     
    133144  } 
    134145 
     146  //! Unset using server 
    135147  void CXios::setNotUsingServer() 
    136148  { 
  • XIOS/trunk/src/cxios.hpp

    r511 r512  
    77namespace xios 
    88{ 
     9  /*! 
     10  \class CXios 
     11  */ 
    912  class CXios 
    1013  { 
    11      public: 
    12  
    13      static string rootFile ; 
    14      static string xiosCodeId ; 
    15      static string clientFile; 
    16      static string serverFile; 
    17  
     14    public: 
    1815     static void initialize(void) ; 
    19  
    20  
    2116     static void initClientSide(const string & codeId, MPI_Comm& localComm, MPI_Comm& returnComm) ; 
    2217     static void initServerSide(void) ; 
     
    3025     static T getin(const string& id) ; 
    3126 
    32      static bool isClient ; 
    33      static bool isServer ; 
     27    public: 
     28     static string rootFile ; //!< Configuration filename 
     29     static string xiosCodeId ; //!< Identity for XIOS 
     30     static string clientFile; //!< Filename template for client 
     31     static string serverFile; //!< Filename template for server 
    3432 
    35      static MPI_Comm globalComm ; 
     33     static bool isClient ; //!< Check if xios is client 
     34     static bool isServer ; //!< Check if xios is server 
    3635 
    37      static bool printInfo2File; 
    38      static bool usingOasis ; 
    39      static bool usingServer ; 
    40      static size_t bufferSize ; 
    41      static size_t defaultBufferSize ; 
    42      static double bufferServerFactorSize ; 
    43      static double defaultBufferServerFactorSize ; 
    44      static bool isOptPerformance; 
     36     static MPI_Comm globalComm ; //!< Global communicator 
    4537 
    46      public: 
     38     static bool printInfo2File; //!< Printing out information into file 
     39     static bool usingOasis ; //!< Using Oasis 
     40     static bool usingServer ; //!< Using server (server mode) 
     41     static double bufferServerFactorSize ; //!< Factor helps tune buffer size 
     42     static double defaultBufferServerFactorSize ; //!< Default factor value 
     43     static bool isOptPerformance; //!< Check if buffer size is for performance (as large as possible) 
     44 
     45    public: 
    4746     //! Setting xios to use server mode 
    4847     static void setUsingServer(); 
     
    5453     static bool isServerSide; 
    5554 
     55     //! Initialize server (if any) 
    5656     static  void initServer(); 
    5757 
    58      private: 
     58    private: 
     59      //! Parse only Xios part of configuration file 
    5960      static void parseXiosConfig(); 
    60  
    6161  } ; 
    62  
    6362} 
    6463 
    6564//#include "cxios_impl.hpp" 
    66  
    67  
    68  
    69  
    70  
    71  
    72  
    73  
    74  
    75 #endif 
     65#endif // __XIOS_HPP__ 
Note: See TracChangeset for help on using the changeset viewer.