Changeset 697


Ignore:
Timestamp:
09/18/15 12:01:48 (9 years ago)
Author:
ymipsl
Message:

Implement registryIn and registryOut functionnalities.
YM

Location:
XIOS/trunk/src
Files:
10 edited

Legend:

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

    r655 r697  
    220220      int rank ; 
    221221      int msg=0 ; 
     222 
     223      MPI_Comm_rank(intraComm,&rank) ; 
     224  
    222225      if (!CXios::isServer) 
    223226      { 
     
    242245        else MPI_Finalize() ; 
    243246      } 
     247       
    244248      info(20) << "Client side context is finalized"<<endl ; 
    245249      report(0) <<" Performance report : total time spent for XIOS : "<< CTimer::get("XIOS").getCumulatedTime()<<" s"<<endl ; 
  • XIOS/trunk/src/context_client.cpp

    r597 r697  
    66#include "buffer_client.hpp" 
    77#include "type.hpp" 
    8 #include "message.hpp" 
    98#include "event_client.hpp" 
    109#include "context.hpp" 
     
    7170 
    7271      timeLine = 0; 
     72 
    7373    } 
    7474 
     75      
    7576    /*! 
    7677    In case of attached mode, the current context must be reset to context for client 
     
    287288  } 
    288289 
     290  
     291 
    289292   /*! 
    290293   Finalize context client and do some reports 
    291294   */ 
     295     
    292296   void CContextClient::finalize(void) 
    293297   { 
    294298     map<int,CClientBuffer*>::iterator itBuff; 
    295299     bool stop = true; 
    296  
     300       
    297301     CEventClient event(CContext::GetType(), CContext::EVENT_ID_CONTEXT_FINALIZE); 
    298302     if (isServerLeader()) 
     
    327331 
    328332     releaseBuffers(); 
     333      
    329334   } 
    330335} 
  • XIOS/trunk/src/context_client.hpp

    r595 r697  
    44#include "xios_spl.hpp" 
    55#include "buffer_out.hpp" 
     6#include "buffer_in.hpp" 
    67#include "buffer_client.hpp" 
    78#include "event_client.hpp" 
     9#include "event_server.hpp" 
    810#include "mpi.hpp" 
     11#include "registry.hpp" 
    912 
    1013namespace xios 
     
    4649      void setBufferSize(const std::map<int,StdSize>& mapSize); 
    4750      void sendBufferSizeEvent(); 
    48  
    4951    public: 
    5052      CContext* context; //!< Context for client 
  • XIOS/trunk/src/context_server.hpp

    r597 r697  
    3939    size_t currentTimeLine ; 
    4040    CContext* context ; 
    41  
     41       
    4242    bool finished ; 
    4343    bool pendingEvent ; 
  • XIOS/trunk/src/cxios.cpp

    r591 r697  
    1010#include <new> 
    1111#include "memtrack.hpp" 
     12#include "registry.hpp" 
    1213 
    1314namespace xios 
     
    2728  bool CXios::printLogs2Files; 
    2829  bool CXios::isOptPerformance = true; 
     30  CRegistry* CXios::globalRegistry = 0; 
    2931 
    3032  //! Parse configuration file and create some objects from it 
     
    7577 
    7678    CClient::initialize(codeId,localComm,returnComm) ; 
     79    if (CClient::getRank()==0) globalRegistry = new CRegistry(returnComm) ; 
    7780 
    7881    if (usingServer) isServer=false; 
     
    9598     CClient::finalize() ; 
    9699     CClient::closeInfoStream(); 
     100     if (CClient::getRank()==0) 
     101     { 
     102       info(80)<<"Write data base Registry"<<endl<<globalRegistry->toString()<<endl ; 
     103       globalRegistry->toFile("xios_registry.bin") ; 
     104       delete globalRegistry ; 
     105     } 
    97106 
    98107#ifdef XIOS_MEMTRACK 
     
    121130    // Initialize all aspects MPI 
    122131    CServer::initialize(); 
    123  
     132    if (CServer::getRank()==0) globalRegistry = new CRegistry(CServer::intraComm) ; 
     133     
    124134    if (printLogs2Files) 
    125135    { 
     
    137147 
    138148    // Finalize 
     149     if (CServer::getRank()==0) 
     150     { 
     151       info(80)<<"Write data base Registry"<<endl<<globalRegistry->toString()<<endl ; 
     152       globalRegistry->toFile("xios_registry.bin") ; 
     153       delete globalRegistry ; 
     154     } 
    139155    CServer::finalize(); 
    140156    CServer::closeInfoStream(); 
  • XIOS/trunk/src/cxios.hpp

    r591 r697  
    44#include "xios_spl.hpp" 
    55#include "mpi.hpp" 
     6#include "registry.hpp" 
    67 
    78namespace xios 
     
    4243     static double defaultBufferServerFactorSize ; //!< Default factor value 
    4344     static bool isOptPerformance; //!< Check if buffer size is for performance (as large as possible) 
     45     static CRegistry* globalRegistry ; //!< global registry which is wrote by the root process of the servers 
    4446 
    4547    public: 
  • XIOS/trunk/src/node/context.cpp

    r676 r697  
    1414#include "type.hpp" 
    1515#include "xios_spl.hpp" 
     16 
    1617 
    1718namespace xios { 
     
    239240     hasClient=true; 
    240241     client = new CContextClient(this,intraComm, interComm, cxtServer); 
     242     registryIn=new CRegistry(intraComm); 
     243     registryIn->setPath(getId()) ; 
     244     if (client->clientRank==0) registryIn->fromFile("xios_registry.bin") ; 
     245     registryIn->bcastRegistry() ; 
     246 
     247     registryOut=new CRegistry(intraComm) ; 
     248     registryOut->setPath(getId()) ; 
     249 
    241250     MPI_Comm intraCommServer, interCommServer; 
    242251     if (cxtServer) // Attached mode 
     
    296305     hasServer=true; 
    297306     server = new CContextServer(this,intraComm,interComm); 
     307 
     308     registryIn=new CRegistry(intraComm); 
     309     registryIn->setPath(getId()) ; 
     310     if (server->intraCommRank==0) registryIn->fromFile("xios_registry.bin") ; 
     311     registryIn->bcastRegistry() ; 
     312     registryOut=new CRegistry(intraComm) ; 
     313     registryOut->setPath(getId()) ; 
     314  
    298315     MPI_Comm intraCommClient, interCommClient; 
    299316     if (cxtClient) // Attached mode 
     
    331348      { 
    332349        finalized = true; 
    333  
     350        if (hasClient) sendRegistry() ; 
    334351        client->finalize(); 
    335352        while (!server->hasFinished()) 
     
    341358        { 
    342359          closeAllFile(); 
     360          registryOut->hierarchicalGatherRegistry() ; 
     361          if (server->intraCommRank==0) CXios::globalRegistry->mergeRegistry(*registryOut) ; 
    343362        } 
    344  
     363         
    345364        for (std::list<MPI_Comm>::iterator it = comms.begin(); it != comms.end(); ++it) 
    346365          MPI_Comm_free(&(*it)); 
     
    576595             recvPostProcessing(event); 
    577596             return true; 
    578              break; 
     597            case EVENT_ID_SEND_REGISTRY: 
     598             recvRegistry(event); 
     599             return true; 
     600            break; 
    579601 
    580602           default : 
     
    10181040    return (context); 
    10191041  } 
     1042 
     1043 
     1044 
     1045     //! Server side: Receive a message to do some post processing 
     1046  void CContext::recvRegistry(CEventServer& event) 
     1047  { 
     1048    CBufferIn* buffer=event.subEvents.begin()->buffer; 
     1049    string id; 
     1050    *buffer>>id; 
     1051    get(id)->recvRegistry(*buffer); 
     1052  } 
     1053 
     1054  void CContext::recvRegistry(CBufferIn& buffer) 
     1055  { 
     1056    if (server->intraCommRank==0) 
     1057    { 
     1058      CRegistry registry(server->intraComm) ; 
     1059      registry.fromBuffer(buffer) ; 
     1060      registryOut->mergeRegistry(registry) ; 
     1061    } 
     1062  } 
     1063 
     1064  void CContext::sendRegistry(void) 
     1065  { 
     1066    registryOut->hierarchicalGatherRegistry() ; 
     1067 
     1068    CEventClient event(CContext::GetType(), CContext::EVENT_ID_SEND_REGISTRY); 
     1069    if (client->isServerLeader()) 
     1070    { 
     1071       CMessage msg ; 
     1072       msg<<this->getIdServer(); 
     1073       if (client->clientRank==0) msg<<*registryOut ; 
     1074       const std::list<int>& ranks = client->getRanksServerLeader(); 
     1075       for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     1076         event.push(*itRank,1,msg); 
     1077       client->sendEvent(event); 
     1078     } 
     1079     else client->sendEvent(event); 
     1080  } 
     1081 
    10201082} // namespace xios 
  • XIOS/trunk/src/node/context.hpp

    r676 r697  
    1212#include "data_output.hpp" 
    1313#include "garbage_collector.hpp" 
    14  
     14#include "registry.hpp" 
    1515#include "mpi.hpp" 
    1616 
     
    5151           EVENT_ID_CLOSE_DEFINITION,EVENT_ID_UPDATE_CALENDAR, 
    5252           EVENT_ID_CREATE_FILE_HEADER,EVENT_ID_CONTEXT_FINALIZE, 
    53            EVENT_ID_POST_PROCESS 
     53           EVENT_ID_POST_PROCESS, EVENT_ID_SEND_REGISTRY 
    5454         }; 
    5555 
     
    132132         void sendRefGrid(); 
    133133         void sendPostProcessing(); 
    134  
     134         void sendRegistry(void) ; //!< after be gathered to the root process of the context, merged registry is sent to the root process of the servers 
    135135         const StdString& getIdServer(); 
    136136 
     
    145145         static void recvPostProcessing(CEventServer& event); 
    146146         void recvPostProcessing(CBufferIn& buffer); 
     147         static void recvRegistry(CEventServer& event) ; 
     148         void recvRegistry(CBufferIn& buffer) ; //!< registry is received by the root process of the servers 
    147149 
    148150         // dispatch event 
     
    213215         // Concrete contex client 
    214216         CContextClient* client; 
    215  
     217         CRegistry* registryIn ;  //!< input registry which is read from file  
     218         CRegistry* registryOut ; //!< output registry which will be wrote on file at the finalize 
     219          
    216220      private: 
    217221         bool isPostProcessed; 
  • XIOS/trunk/src/server.cpp

    r680 r697  
    2727    bool CServer::is_MPI_Initialized ; 
    2828    CEventScheduler* CServer::eventScheduler = 0; 
    29  
     29    
    3030    void CServer::initialize(void) 
    3131    { 
     
    148148    { 
    149149      CTimer::get("XIOS").suspend() ; 
    150  
     150      
    151151      delete eventScheduler ; 
    152152 
  • XIOS/trunk/src/server.hpp

    r655 r697  
    44#include "xios_spl.hpp" 
    55#include "context.hpp" 
     6#include "context_client.hpp" 
    67#include "mpi.hpp" 
    78#include "event_scheduler.hpp" 
     
    2728        static std::list<MPI_Comm> contextInterComms; 
    2829        static CEventScheduler* eventScheduler; 
    29  
     30         
    3031        struct contextMessage 
    3132        { 
Note: See TracChangeset for help on using the changeset viewer.