Changeset 2209


Ignore:
Timestamp:
08/25/21 19:31:05 (3 months ago)
Author:
ymipsl
Message:

Revisiting registry management and make it working.
YM

Location:
XIOS/dev/dev_ym/XIOS_COUPLING/src
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/client.cpp

    r2146 r2209  
    174174      else CXios::setNotUsingServer() ; 
    175175 
    176  
    177       CXios::setGlobalRegistry(new CRegistry(clientsComm_)) ; 
    178176      ///////////////////////////////////////// 
    179177      ///////////// PART 3 //////////////////// 
     
    476474      if (commRank==0) CXios::getRessourcesManager()->finalize() ; 
    477475       
    478       auto globalRegistry=CXios::getGlobalRegistry() ; 
    479       globalRegistry->hierarchicalGatherRegistry() ; 
    480  
    481       if (commRank==0) 
    482       { 
    483         info(80)<<"Write data base Registry"<<endl<<globalRegistry->toString()<<endl ; 
    484         globalRegistry->toFile("xios_registry.bin") ; 
    485       } 
    486       delete globalRegistry ; 
    487  
    488476      CTimer::get("XIOS init/finalize",false).suspend() ; 
    489477      CTimer::get("XIOS").suspend() ; 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/cxios.cpp

    r2176 r2209  
    5656  CContextsManager*   CXios::contextsManager_=nullptr ; 
    5757  CCouplerManager*    CXios::couplerManager_=nullptr ; 
     58  CRegistryManager*   CXios::registryManager_=nullptr ; 
    5859 
    5960  //! Parse configuration file and create some objects from it 
     
    217218  } 
    218219 
     220  void CXios::launchRegistryManager(bool isXiosServer) 
     221  { 
     222    registryManager_ = new CRegistryManager(isXiosServer) ; 
     223  } 
     224 
    219225  void CXios::launchRessourcesManager(bool isXiosServer) 
    220226  { 
     
    243249 
    244250   
     251  void CXios::finalizeRegistryManager() 
     252  { 
     253    delete registryManager_; 
     254  } 
     255 
    245256  void CXios::finalizeRessourcesManager() 
    246257  { 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/cxios.hpp

    r1878 r2209  
    1010#include "daemons_manager.hpp" 
    1111#include "coupler_manager.hpp" 
     12#include "registry_manager.hpp" 
    1213 
    1314namespace xios 
     
    6869 
    6970 
     71     static CRegistryManager* registryManager_ ; 
    7072     static CRessourcesManager* ressourcesManager_ ; 
    7173     static CCouplerManager* couplerManager_ ; 
     
    9395     static void launchRessourcesManager(bool isXiosServer) ; 
    9496     static void launchCouplerManager(bool isXiosServer) ; 
     97     static void launchRegistryManager(bool isXiosServer) ; 
    9598     
    9699     static void finalizeServicesManager() ; 
     
    99102     static void finalizeRessourcesManager() ; 
    100103     static void finalizeCouplerManager() ; 
     104     static void finalizeRegistryManager() ; 
    101105 
     106     static CRegistryManager*   getRegistryManager(void) { return registryManager_ ;} 
    102107     static CRessourcesManager* getRessourcesManager(void) { return ressourcesManager_ ;} 
    103108     static CCouplerManager*    getCouplerManager(void) { return couplerManager_ ;} 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/manager/daemons_manager.cpp

    r1878 r2209  
    1919    MPI_Comm_split(xiosComm,isXiosServer,commRank,&splitComm) ; 
    2020     
     21    CXios::launchRegistryManager(isXiosServer) ; 
    2122    CXios::launchRessourcesManager(isXiosServer) ; 
    2223    CXios::launchServicesManager(isXiosServer) ; 
    2324    CXios::launchContextsManager(isXiosServer) ; 
    2425    CXios::launchCouplerManager(isXiosServer) ; 
    25  
     26  
    2627    if (isXiosServer) CServer::launchServersRessource(splitComm) ; 
     28    MPI_Barrier(xiosComm) ; 
    2729    MPI_Comm_free(&splitComm) ; 
    2830  } 
     
    3436    CXios::finalizeServicesManager() ; 
    3537    CXios::finalizeRessourcesManager() ; 
     38    CXios::finalizeRegistryManager() ; 
    3639  } 
    3740 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/context.cpp

    r2199 r2209  
    428428 
    429429      string contextRegistryId=getId() ; 
    430       registryIn=new CRegistry(intraComm); 
     430      registryIn=new CRegistry(CXios::getRegistryManager()->getRegistryIn()); 
    431431      registryIn->setPath(contextRegistryId) ; 
    432432       
    433       int commRank ; 
    434       MPI_Comm_rank(intraComm_,&commRank) ; 
    435       if (commRank==0) registryIn->fromFile("xios_registry.bin") ; 
    436       registryIn->bcastRegistry() ; 
    437433      registryOut=new CRegistry(intraComm_) ; 
    438434      registryOut->setPath(contextRegistryId) ; 
     
    465461     CXios::getContextsManager()->getContextId(getId(), contextId_, intraComm) ; 
    466462      
    467      registryIn=new CRegistry(intraComm); 
    468      registryIn->setPath(contextId_) ; 
    469       
    470      int commRank ; 
    471      MPI_Comm_rank(intraComm_,&commRank) ; 
    472      if (commRank==0) registryIn->fromFile("xios_registry.bin") ; 
    473      
    474      registryIn->bcastRegistry() ; 
    475      registryOut=new CRegistry(intraComm) ; 
    476      registryOut->setPath(contextId_) ; 
     463     string contextRegistryId=getId() ; 
     464     registryIn=new CRegistry(CXios::getRegistryManager()->getRegistryIn()); 
     465     registryIn->setPath(contextRegistryId) ; 
     466       
     467     registryOut=new CRegistry(intraComm_) ; 
     468     registryOut->setPath(contextRegistryId) ; 
    477469 
    478470   } 
     
    715707   { 
    716708      registryOut->hierarchicalGatherRegistry() ; 
    717       if (server->intraCommRank==0) CXios::globalRegistry->mergeRegistry(*registryOut) ; 
     709      if (server->intraCommRank==0) CXios::getRegistryManager()->merge(*registryOut) ; 
    718710 
    719711      if (serviceType_==CServicesManager::CLIENT) 
     
    15741566             return true; 
    15751567             break; 
    1576            case EVENT_ID_SEND_REGISTRY: 
    1577              recvRegistry(event); 
    1578              return true; 
    1579              break; 
    15801568           case EVENT_ID_COUPLER_IN_READY: 
    15811569             recvCouplerInReady(event); 
     
    21062094  CATCH 
    21072095 
    2108      //! Server side: Receive a message to do some post processing 
    2109   void CContext::recvRegistry(CEventServer& event) 
    2110   TRY 
    2111   { 
    2112     CBufferIn* buffer=event.subEvents.begin()->buffer; 
    2113     getCurrent()->recvRegistry(*buffer); 
    2114   } 
    2115   CATCH 
    2116  
    2117   void CContext::recvRegistry(CBufferIn& buffer) 
    2118   TRY 
    2119   { 
    2120     if (server->intraCommRank==0) 
    2121     { 
    2122       CRegistry registry(server->intraComm) ; 
    2123       registry.fromBuffer(buffer) ; 
    2124       registryOut->mergeRegistry(registry) ; 
    2125     } 
    2126   } 
    2127   CATCH_DUMP_ATTR 
    2128  
    2129   void CContext::sendRegistry(void) 
    2130   TRY 
    2131   { 
    2132     registryOut->hierarchicalGatherRegistry() ; 
    2133  
    2134     int nbSrvPools ; 
    2135     if (serviceType_==CServicesManager::CLIENT) nbSrvPools = 1 ; 
    2136     else if (serviceType_==CServicesManager::GATHERER) nbSrvPools = this->clientPrimServer.size() ; 
    2137     else nbSrvPools = 0 ; 
    2138     CContextClient* contextClientTmp ; 
    2139  
    2140     for (int i = 0; i < nbSrvPools; ++i) 
    2141     { 
    2142       if (serviceType_==CServicesManager::CLIENT) contextClientTmp = client ; 
    2143       else if (serviceType_==CServicesManager::GATHERER ) contextClientTmp = clientPrimServer[i] ; 
    2144  
    2145       CEventClient event(CContext::GetType(), CContext::EVENT_ID_SEND_REGISTRY); 
    2146       if (contextClientTmp->isServerLeader()) 
    2147       { 
    2148         CMessage msg ; 
    2149         if (contextClientTmp->clientRank==0) msg<<*registryOut ; 
    2150         const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 
    2151         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    2152              event.push(*itRank,1,msg); 
    2153         contextClientTmp->sendEvent(event); 
    2154       } 
    2155       else contextClientTmp->sendEvent(event); 
    2156     } 
    2157   } 
    2158   CATCH_DUMP_ATTR 
    2159  
    21602096   
    21612097  void CContext::sendFinalizeClient(CContextClient* contextClient, const string& contextClientId) 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/context.hpp

    r2204 r2209  
    5555           EVENT_ID_CLOSE_DEFINITION,EVENT_ID_UPDATE_CALENDAR, 
    5656           EVENT_ID_CREATE_FILE_HEADER,EVENT_ID_CONTEXT_FINALIZE, 
    57            EVENT_ID_SEND_REGISTRY, 
    5857           EVENT_ID_CONTEXT_FINALIZE_CLIENT, 
    5958           EVENT_ID_COUPLER_IN_READY, 
     
    170169         void sendRefDomainsAxisScalars(const std::vector<CFile*>& activeFiles); 
    171170         //!< after be gathered to the root process of the context, merged registry is sent to the root process of the servers 
    172          void sendRegistry(void) ; 
    173171         void sendFinalizeClient(CContextClient* contextClient, const string& contextClientId); 
    174172          
     
    189187         static void recvSolveInheritanceContext(CEventServer& event); 
    190188         void recvSolveInheritanceContext(CBufferIn& buffer); 
    191          static void recvRegistry(CEventServer& event) ; 
    192          void recvRegistry(CBufferIn& buffer) ; //!< registry is received by the servers 
    193189         static void recvFinalizeClient(CEventServer& event) ; 
    194190         void recvFinalizeClient(CBufferIn& buffer); 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/registry.cpp

    r1639 r2209  
    5151  } 
    5252 
    53   void CRegistry::getKey_(const string& key_, CBaseType& value) 
     53  void CRegistry::getKey_(const string& key_, CBaseType& value) const 
    5454  { 
    5555    const string key=path+key_ ; 
    5656    size_t size=value.size(); 
    5757       
    58     map<string,pair<size_t,char*> >::iterator it=registry.find(key) ; 
     58    map<string,pair<size_t,char*> >::const_iterator it=registry.find(key) ; 
    5959 
    6060    if (it!=registry.end()) 
     
    258258  void CRegistry::hierarchicalGatherRegistry(void) 
    259259  { 
    260     hierarchicalGatherRegistry(communicator) ; 
     260    int color; 
     261    if (isEmpty()) color=0 ; 
     262    else color=1 ; 
     263    int rank ; 
     264    MPI_Comm_rank(communicator,&rank); 
     265    if (rank==0) color=1 ; 
     266    MPI_Comm newComm ; 
     267    MPI_Comm_split(communicator,color,rank,&newComm) ; 
     268    if (color==1) hierarchicalGatherRegistry(newComm) ; 
     269    MPI_Comm_free(&newComm) ;     
    261270  } 
    262271 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/registry.hpp

    r1639 r2209  
    3838 
    3939/** retrieve a value from a key */ 
    40       void getKey(const std::string& key, CBaseType& value) { this->getKey_(key,value); } 
     40      void getKey(const std::string& key, CBaseType& value) const { this->getKey_(key,value); } 
    4141 
    4242/** retrieve a value from a key */ 
    4343      template<typename T> typename boost::enable_if_c<!boost::is_convertible<T&, CBaseType&>::value>::type 
    44       getKey(const std::string& key, T& value) { CType_ref<T> valRef(value); this->getKey_(key,valRef); } 
     44      getKey(const std::string& key, T& value) const { CType_ref<T> valRef(value); this->getKey_(key,valRef); } 
    4545 
    4646 
     
    103103 
    104104/** retrieve a value from a key (internal use)*/ 
    105       void getKey_(const std::string& key, CBaseType& value) ; 
     105      void getKey_(const std::string& key, CBaseType& value) const ; 
    106106 
    107107/** use internally for recursivity */ 
Note: See TracChangeset for help on using the changeset viewer.