Changeset 2405
- Timestamp:
- 09/20/22 11:12:53 (21 months ago)
- Location:
- XIOS3/trunk/src/node
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS3/trunk/src/node/context.cpp
r2397 r2405 49 49 , allProcessed(false), countChildContextFinalized_(0), isProcessingEvent_(false) 50 50 51 { /* Ne rien faire de plus */ }51 { /* Ne rien faire de plus */ } 52 52 53 53 CContext::CContext(const StdString & id) … … 542 542 CATCH_DUMP_ATTR 543 543 544 545 void CContext::createServerInterComm(const string& poolId, const string& serverId, vector<pair<string, pair<CContextClient*,CContextServer*>>>& clientServers ) 546 TRY 547 { 548 MPI_Comm interCommClient, interCommServer ; 549 int commRank ; 550 MPI_Comm_rank(intraComm_,&commRank) ; 551 552 int nbPartitions ; 553 if (commRank==0) 554 { 555 CXios::getServicesManager()->getServiceNbPartitions(poolId, serverId, 0, nbPartitions) ; 556 for(int i=0 ; i<nbPartitions; i++) CXios::getContextsManager()->createServerContext(poolId, serverId, i, getContextId()) ; 557 } 558 setCurrent(getId()) ; // getCurrent/setCurrent may be supress, it can cause a lot of trouble (attached ???) 559 MPI_Bcast(&nbPartitions, 1, MPI_INT, 0, intraComm_) ; 560 561 MPI_Comm interComm ; 562 for(int i=0 ; i<nbPartitions; i++) 563 { 564 parentServerContext_->createIntercomm(poolId, serverId, i, getContextId(), intraComm_, interCommClient, interCommServer) ; 565 int type ; 566 if (commRank==0) CXios::getServicesManager()->getServiceType(poolId, serverId, 0, type) ; 567 MPI_Bcast(&type,1,MPI_INT,0,intraComm_) ; 568 string fullServerId=CXios::getContextsManager()->getServerContextName(poolId, serverId, i, type, getContextId()) ; 569 570 MPI_Comm intraCommClient, intraCommServer ; 571 572 intraCommClient=intraComm_ ; 573 MPI_Comm_dup(intraComm_, &intraCommServer) ; 574 575 CContextClient* client = CContextClient::getNew(this, intraCommClient, interCommClient) ; 576 CContextServer* server = CContextServer::getNew(this, intraCommServer, interCommServer) ; 577 client->setAssociatedServer(server) ; 578 server->setAssociatedClient(client) ; 579 580 clientServers.push_back({fullServerId,{client,server}}) ; 581 } 582 } 583 CATCH_DUMP_ATTR 584 544 585 void CContext::createServerInterComm(void) 586 TRY 587 { 588 vector<pair<string, pair<CContextClient*,CContextServer*>>> clientServers ; 589 590 if (serviceType_ == CServicesManager::CLIENT) 591 { 592 if (attached_mode) createServerInterComm(CClient::getPoolRessource()->getId(), getContextId()+"_"+CXios::defaultServerId, clientServers) ; 593 else if (CXios::usingServer2) createServerInterComm(CXios::defaultPoolId, CXios::defaultGathererId, clientServers) ; 594 else createServerInterComm(CXios::defaultPoolId, CXios::defaultServerId, clientServers) ; 595 596 client = clientServers[0].second.first ; 597 server = clientServers[0].second.second ; 598 } 599 else if (serviceType_ == CServicesManager::GATHERER) 600 { 601 createServerInterComm(CXios::defaultPoolId, CXios::defaultServerId, clientServers) ; 602 for(auto& clientServer : clientServers) 603 { 604 primServerId_.push_back(clientServer.first) ; 605 clientPrimServer.push_back(clientServer.second.first); 606 serverPrimServer.push_back(clientServer.second.second); 607 } 608 } 609 610 } 611 CATCH_DUMP_ATTR 612 613 void CContext::createServerInterComm_old(void) 545 614 TRY 546 615 { … … 582 651 else 583 652 { 653 584 654 //CXios::getContextsManager()->createServerContextIntercomm(CXios::defaultPoolId, CXios::defaultServerId, 0, getContextId(), intraComm_, interComm) ; 585 655 parentServerContext_->createIntercomm(CXios::defaultPoolId, CXios::defaultServerId, 0, getContextId(), intraComm_, … … 1638 1708 return true; 1639 1709 break; 1640 case EVENT_ID_CREATE_FILE_HEADER :1641 recvCreateFileHeader(event);1642 return true;1643 break;1644 1710 case EVENT_ID_COUPLER_IN_READY: 1645 1711 recvCouplerInReady(event); … … 1761 1827 CATCH_DUMP_ATTR 1762 1828 1763 //! Client side: Send a message to create header part of netcdf file1764 void CContext::sendCreateFileHeader(void)1765 TRY1766 {1767 int nbSrvPools ;1768 if (serviceType_==CServicesManager::CLIENT) nbSrvPools = 1 ;1769 else if (serviceType_==CServicesManager::GATHERER) nbSrvPools = this->clientPrimServer.size() ;1770 else nbSrvPools = 0 ;1771 CContextClient* contextClientTmp ;1772 1773 for (int i = 0; i < nbSrvPools; ++i)1774 {1775 if (serviceType_==CServicesManager::CLIENT) contextClientTmp = client ;1776 else if (serviceType_==CServicesManager::GATHERER ) contextClientTmp = clientPrimServer[i] ;1777 CEventClient event(getType(),EVENT_ID_CREATE_FILE_HEADER);1778 1779 if (contextClientTmp->isServerLeader())1780 {1781 CMessage msg;1782 const std::list<int>& ranks = contextClientTmp->getRanksServerLeader();1783 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)1784 event.push(*itRank,1,msg) ;1785 contextClientTmp->sendEvent(event);1786 }1787 else contextClientTmp->sendEvent(event);1788 }1789 }1790 CATCH_DUMP_ATTR1791 1792 //! Server side: Receive a message of client annoucing the creation of header part of netcdf file1793 void CContext::recvCreateFileHeader(CEventServer& event)1794 TRY1795 {1796 CBufferIn* buffer=event.subEvents.begin()->buffer;1797 getCurrent()->recvCreateFileHeader(*buffer);1798 }1799 CATCH1800 1801 //! Server side: Receive a message of client annoucing the creation of header part of netcdf file1802 void CContext::recvCreateFileHeader(CBufferIn& buffer)1803 TRY1804 {1805 if (serviceType_==CServicesManager::IO_SERVER || serviceType_==CServicesManager::OUT_SERVER)1806 createFileHeader();1807 }1808 CATCH_DUMP_ATTR1809 1829 1810 1830 void CContext::createCouplerInterCommunicator(void) -
XIOS3/trunk/src/node/context.hpp
r2404 r2405 55 55 EVENT_ID_COLLECTIVE=100, 56 56 EVENT_ID_CLOSE_DEFINITION,EVENT_ID_UPDATE_CALENDAR, 57 EVENT_ID_C REATE_FILE_HEADER,EVENT_ID_CONTEXT_FINALIZE,57 EVENT_ID_CONTEXT_FINALIZE, 58 58 EVENT_ID_CONTEXT_FINALIZE_CLIENT, 59 59 EVENT_ID_COUPLER_IN_READY, … … 104 104 void initServer(MPI_Comm intraComm, int serviceType ); 105 105 void createClientInterComm(MPI_Comm interCommClient, MPI_Comm interCommServer) ; 106 106 107 void createServerInterComm(void) ; 108 void createServerInterComm_old(void) ; 109 void createServerInterComm(const string& poolId, const string& serverId, vector<pair<string, pair<CContextClient*,CContextServer*>>>& clientServers ) ; 110 107 111 108 112 bool isInitialized(void); … … 168 172 // There are something to send on closing context defintion 169 173 void sendUpdateCalendar(int step); 170 void sendCreateFileHeader(void);171 174 void sendEnabledFiles(const std::vector<CFile*>& activeFiles); 172 175 void sendEnabledFieldsInFiles(const std::vector<CFile*>& activeFiles); … … 187 190 void recvUpdateCalendar(CBufferIn& buffer); 188 191 static void recvCloseDefinition(CEventServer& event); 189 static void recvCreateFileHeader(CEventServer& event);190 void recvCreateFileHeader(CBufferIn& buffer);191 192 static void recvSolveInheritanceContext(CEventServer& event); 192 193 void recvSolveInheritanceContext(CBufferIn& buffer); … … 315 316 // list of slave servers (IO server or others) 316 317 set<CContextClient*> slaveServers_ ; 318 319 private: 320 std::string defaultReaderId ; 321 std::string defaultWriterId ; 322 std::string defaultGathererId ; 323 324 std::map<std::string, CContextClient*> clients_ ; 325 std::map<std::string, CContextClient*> servers_ ; 326 317 327 private: 318 328 // the map containing context client associated to it string id for coupling out ;
Note: See TracChangeset
for help on using the changeset viewer.