Ignore:
Timestamp:
03/13/17 17:21:04 (7 years ago)
Author:
oabramkina
Message:

dev: test for secondary servers added.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_olga/src/node/context.cpp

    r1054 r1071  
    2828      , isPostProcessed(false), finalized(false) 
    2929      , idServer_(), client(0), server(0) 
    30 //        , clientPrimServer(0), serverPrimServer(0) 
    3130      , allProcessed(false) 
    3231   { /* Ne rien faire de plus */ } 
     
    3736      , isPostProcessed(false), finalized(false) 
    3837      , idServer_(), client(0), server(0) 
    39 //        , clientPrimServer(0), serverPrimServer(0) 
    4038      , allProcessed(false) 
    4139   { /* Ne rien faire de plus */ } 
     
    4543     delete client; 
    4644     delete server; 
    47 //     delete clientPrimServer; 
    48 //     delete serverPrimServer; 
     45     for (std::vector<CContextClient*>::iterator it = clientPrimServer.begin(); it != clientPrimServer.end(); it++)  delete *it; 
     46     for (std::vector<CContextServer*>::iterator it = serverPrimServer.begin(); it != serverPrimServer.end(); it++)  delete *it; 
    4947   } 
    5048 
     
    249247 
    250248     hasClient = true; 
     249     MPI_Comm intraCommServer, interCommServer; 
    251250 
    252251     if (CServer::serverLevel != 1) 
    253      // initClient is called by client 
     252      // initClient is called by client 
    254253     { 
    255254       client = new CContextClient(this, intraComm, interComm, cxtServer); 
    256        server = new CContextServer(this, intraComm, interComm); 
    257        MPI_Comm intraCommServer, interCommServer; 
    258255       if (cxtServer) // Attached mode 
    259256       { 
     
    263260       else 
    264261       { 
    265 //         MPI_Comm_dup(intraComm, &intraCommServer); 
    266 //         comms.push_back(intraCommServer); 
    267 //         MPI_Comm_dup(interComm, &interCommServer); 
    268 //         comms.push_back(interCommServer); 
    269        } 
    270      } 
    271  
     262         MPI_Comm_dup(intraComm, &intraCommServer); 
     263         comms.push_back(intraCommServer); 
     264         MPI_Comm_dup(interComm, &interCommServer); 
     265         comms.push_back(interCommServer); 
     266       } 
     267       registryIn=new CRegistry(intraComm); 
     268       registryIn->setPath(getId()) ; 
     269       if (client->clientRank==0) registryIn->fromFile("xios_registry.bin") ; 
     270       registryIn->bcastRegistry() ; 
     271       registryOut=new CRegistry(intraComm) ; 
     272       registryOut->setPath(getId()) ; 
     273 
     274       server = new CContextServer(this, intraCommServer, interCommServer); 
     275     } 
    272276     else 
    273277     // initClient is called by primary server 
    274278     { 
    275279       clientPrimServer.push_back(new CContextClient(this, intraComm, interComm)); 
    276        serverPrimServer.push_back(new CContextServer(this, intraComm, interComm)); 
    277      } 
    278  
    279  
    280  
    281 //     registryIn=new CRegistry(intraComm); 
    282 //     registryIn->setPath(getId()) ; 
    283 //     if (client->clientRank==0) registryIn->fromFile("xios_registry.bin") ; 
    284 //     registryIn->bcastRegistry() ; 
    285 // 
    286 //     registryOut=new CRegistry(intraComm) ; 
    287 //     registryOut->setPath(getId()) ; 
    288  
    289  
     280       MPI_Comm_dup(intraComm, &intraCommServer); 
     281       comms.push_back(intraCommServer); 
     282       MPI_Comm_dup(interComm, &interCommServer); 
     283       comms.push_back(interCommServer); 
     284       serverPrimServer.push_back(new CContextServer(this, intraCommServer, interCommServer)); 
     285     } 
    290286   } 
    291287 
     
    354350     hasServer=true; 
    355351     server = new CContextServer(this,intraComm,interComm); 
    356      client = new CContextClient(this,intraComm,interComm); 
    357352//     client = new CContextClient(this,intraComm,interComm, cxtClient); 
    358353 
    359 //     registryIn=new CRegistry(intraComm); 
    360 //     registryIn->setPath(getId()) ; 
    361 //     if (server->intraCommRank==0) registryIn->fromFile("xios_registry.bin") ; 
    362 //     registryIn->bcastRegistry() ; 
    363 //     registryOut=new CRegistry(intraComm) ; 
    364 //     registryOut->setPath(getId()) ; 
     354     registryIn=new CRegistry(intraComm); 
     355     registryIn->setPath(getId()) ; 
     356     if (server->intraCommRank==0) registryIn->fromFile("xios_registry.bin") ; 
     357     registryIn->bcastRegistry() ; 
     358     registryOut=new CRegistry(intraComm) ; 
     359     registryOut->setPath(getId()) ; 
    365360 
    366361     MPI_Comm intraCommClient, interCommClient; 
     
    372367     else 
    373368     { 
    374 //       MPI_Comm_dup(intraComm, &intraCommClient); 
    375 //       comms.push_back(intraCommClient); 
    376 //       MPI_Comm_dup(interComm, &interCommClient); 
    377 //       comms.push_back(interCommClient); 
    378      } 
    379  
    380    } 
    381  
    382    //! Server side: Put server into a loop in order to listen message from client 
    383 //   bool CContext::eventLoop(void) 
    384 //   { 
    385 //     if (CServer::serverLevel == 0) 
    386 //     { 
    387 //       return server->eventLoop(); 
    388 //     } 
    389 //     else if (CServer::serverLevel == 1) 
    390 //     { 
    391 //       bool serverFinished = server->eventLoop(); 
    392 //       bool serverPrimFinished = true; 
    393 //       for (int i = 0; i < serverPrimServer.size(); ++i) 
    394 //       { 
    395 //         serverPrimFinished *= serverPrimServer[i]->eventLoop(); 
    396 //       } 
    397 //       return ( serverFinished && serverPrimFinished); 
    398 //     } 
    399 //     else 
    400 //     { 
    401 //       return server->eventLoop(); 
    402 //     } 
    403 //   } 
     369       MPI_Comm_dup(intraComm, &intraCommClient); 
     370       comms.push_back(intraCommClient); 
     371       MPI_Comm_dup(interComm, &interCommClient); 
     372       comms.push_back(interCommClient); 
     373     } 
     374     client = new CContextClient(this,intraCommClient,interCommClient); 
     375 
     376   } 
    404377 
    405378   //! Try to send the buffers and receive possible answers 
     
    412385       if (hasTmpBufferedEvent) 
    413386         hasTmpBufferedEvent = !client->sendTemporarilyBufferedEvent(); 
    414  
    415387       // Don't process events if there is a temporarily buffered event 
    416388       return server->eventLoop(!hasTmpBufferedEvent); 
     
    432404         if (hasTmpBufferedEventPrim) 
    433405           hasTmpBufferedEventPrim = !clientPrimServer[i]->sendTemporarilyBufferedEvent(); 
    434          serverPrimFinished *= serverPrimServer[i]->eventLoop(hasTmpBufferedEventPrim); 
     406//         serverPrimFinished *= serverPrimServer[i]->eventLoop(!hasTmpBufferedEventPrim); 
     407         serverPrimFinished *= serverPrimServer[i]->eventLoop(); 
    435408       } 
    436409       return ( serverFinished && serverPrimFinished); 
     
    441414       client->checkBuffers(); 
    442415       bool hasTmpBufferedEvent = client->hasTemporarilyBufferedEvent(); 
    443        if (hasTmpBufferedEvent) 
    444          hasTmpBufferedEvent = !client->sendTemporarilyBufferedEvent(); 
    445        return server->eventLoop(!hasTmpBufferedEvent); 
    446      } 
     416//       if (hasTmpBufferedEvent) 
     417//         hasTmpBufferedEvent = !client->sendTemporarilyBufferedEvent(); 
     418//       return server->eventLoop(!hasTmpBufferedEvent); 
     419       return server->eventLoop(); 
     420      } 
    447421   } 
    448422 
     
    453427     { 
    454428       finalized = true; 
    455 //       if (hasClient) sendRegistry() ; 
    456  
    457        client->finalize(); 
    458        while (!server->hasFinished()) 
    459        { 
    460          server->eventLoop(); 
    461        } 
     429 
     430       if (hasClient) sendRegistry() ; 
    462431 
    463432       if ((hasClient) && (hasServer)) 
     
    475444         } 
    476445       } 
    477  
     446       client->finalize(); 
     447       while (!server->hasFinished()) 
     448       { 
     449         server->eventLoop(); 
     450       } 
     451 
     452       info(20)<<"Server Side context <"<<getId()<<"> finalized"<<endl; 
    478453       report(0)<< " Memory report : Context <"<<getId()<<"> : server side : total memory used for buffers "<<CContextServer::getTotalBuf()<<" bytes"<<endl; 
    479454 
     
    482457       { 
    483458         closeAllFile(); 
    484 //         registryOut->hierarchicalGatherRegistry() ; 
    485 //         if (server->intraCommRank==0) CXios::globalRegistry->mergeRegistry(*registryOut) ; 
    486        } 
    487  
    488        for (std::vector<CContextClient*>::iterator it = clientPrimServer.begin(); it != clientPrimServer.end(); it++) 
    489          delete *it; 
    490  
    491        for (std::vector<CContextServer*>::iterator it = serverPrimServer.begin(); it != serverPrimServer.end(); it++) 
    492          delete *it; 
    493  
    494        for (std::list<MPI_Comm>::iterator it = comms.begin(); it != comms.end(); ++it) 
    495          MPI_Comm_free(&(*it)); 
    496        comms.clear(); 
     459         registryOut->hierarchicalGatherRegistry() ; 
     460         if (server->intraCommRank==0) CXios::globalRegistry->mergeRegistry(*registryOut) ; 
     461       } 
     462 
     463//       for (std::list<MPI_Comm>::iterator it = comms.begin(); it != comms.end(); ++it) 
     464//         MPI_Comm_free(&(*it)); 
     465//       comms.clear(); 
    497466 
    498467      } 
    499468   } 
    500  
     469   //! Free internally allocated communicators 
     470   void CContext::freeComms(void) 
     471   { 
     472     for (std::list<MPI_Comm>::iterator it = comms.begin(); it != comms.end(); ++it) 
     473       MPI_Comm_free(&(*it)); 
     474     comms.clear(); 
     475   } 
    501476 
    502477   void CContext::postProcessingGlobalAttributes() 
     
    15971572 
    15981573    // Use correct context client to send message 
    1599     // int nbSrvPools = (hasServer) ? clientPrimServer.size() : 1; 
    16001574    int nbSrvPools = (this->hasServer) ? (this->hasClient ? this->clientPrimServer.size() : 0) : 1; 
    16011575    for (int i = 0; i < nbSrvPools; ++i) 
     
    16181592         else contextClientTmp->sendEvent(event); 
    16191593    } 
    1620  
    1621     // if (!hasServer) 
    1622     // { 
    1623     //   if (client->isServerLeader()) 
    1624     //   { 
    1625     //      CMessage msg ; 
    1626     //      msg<<this->getIdServer(); 
    1627     //      if (client->clientRank==0) msg<<*registryOut ; 
    1628     //      const std::list<int>& ranks = client->getRanksServerLeader(); 
    1629     //      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    1630     //        event.push(*itRank,1,msg); 
    1631     //      client->sendEvent(event); 
    1632     //    } 
    1633     //    else client->sendEvent(event); 
    1634     // } 
    1635     // else 
    1636     // { 
    1637     //   if (clientPrimServer->isServerLeader()) 
    1638     //   { 
    1639     //      CMessage msg ; 
    1640     //      msg<<this->getIdServer(); 
    1641     //      if (clientPrimServer->clientRank==0) msg<<*registryOut ; 
    1642     //      const std::list<int>& ranks = clientPrimServer->getRanksServerLeader(); 
    1643     //      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    1644     //        event.push(*itRank,1,msg); 
    1645     //      clientPrimServer->sendEvent(event); 
    1646     //    } 
    1647     //    else clientPrimServer->sendEvent(event); 
    1648     // } 
    16491594  } 
    16501595 
Note: See TracChangeset for help on using the changeset viewer.