Changeset 1071


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

dev: test for secondary servers added.

Location:
XIOS/dev/dev_olga
Files:
5 added
13 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_olga/src/buffer_client.cpp

    r992 r1071  
    7474    int flag; 
    7575 
     76    int error, errclass, len; 
     77    char errstring[MPI_MAX_ERROR_STRING]; 
     78 
    7679    if (pending) 
    7780    { 
     
    8689      if (count > 0) 
    8790      { 
    88         MPI_Comm_test_inter(interComm, &flag); 
    89         MPI_Issend(buffer[current], count, MPI_CHAR, serverRank, 20, interComm, &request); 
     91        MPI_Errhandler_set(interComm,MPI_ERRORS_RETURN); 
     92        error = MPI_Issend(buffer[current], count, MPI_CHAR, serverRank, 20, interComm, &request); 
     93        if (error != MPI_SUCCESS) 
     94        { 
     95          MPI_Error_class(error, &errclass); 
     96          MPI_Error_string(error, errstring, &len); 
     97          ERROR("MPI error class: ", <<errclass<<" MPI error "<<errstring ); 
     98        } 
    9099        pending = true; 
    91100        if (current == 1) current = 0; 
  • XIOS/dev/dev_olga/src/context_client.cpp

    r1054 r1071  
    9191        // We force the getBuffers call to be non-blocking on the servers 
    9292        list<CBufferOut*> buffList; 
    93         bool couldBuffer = getBuffers(ranks, sizes, buffList, !CXios::isClient); 
    9493//        bool couldBuffer = getBuffers(ranks, sizes, buffList, CXios::isServer); 
     94        bool couldBuffer = getBuffers(ranks, sizes, buffList, false); 
    9595 
    9696        if (couldBuffer) 
     
    182182     * \return whether the already allocated buffers could be used 
    183183    */ 
    184     bool CContextClient::getBuffers(const list<int>& serverList, const list<int>& sizeList, list<CBufferOut*>& retBuffers, bool nonBlocking /*= false*/) 
     184    bool CContextClient::getBuffers(const list<int>& serverList, const list<int>& sizeList, list<CBufferOut*>& retBuffers, 
     185                                    bool nonBlocking /*= false*/) 
    185186    { 
    186187      list<int>::const_iterator itServer, itSize; 
     
    211212        { 
    212213          checkBuffers(); 
    213 //          if (?) 
    214 //          { 
     214 
     215         // WHY DO WE PUT HERE SERVER INTO LISTENING LOOP AT ALL???? 
     216//            context->server->listen(); 
    215217//            for (int i = 0; i < context->serverPrimServer.size(); ++i) 
    216218//              context->serverPrimServer[i]->listen(); 
    217 //          } 
    218 //          else 
    219             context->server->listen(); 
    220219        } 
    221220      } while (!areBuffersFree && !nonBlocking); 
     
    237236   void CContextClient::newBuffer(int rank) 
    238237   { 
    239       if (!mapBufferSize_.count(rank)) 
    240       { 
    241         error(0) << "WARNING: Unexpected request for buffer to communicate with server " << rank << std::endl; 
    242         mapBufferSize_[rank] = CXios::minBufferSize; 
    243       } 
    244       CClientBuffer* buffer = buffers[rank] = new CClientBuffer(interComm, rank, mapBufferSize_[rank], maxBufferedEvents); 
    245       // Notify the server 
    246       CBufferOut* bufOut = buffer->getBuffer(sizeof(StdSize)); 
    247       bufOut->put(mapBufferSize_[rank]); // Stupid C++ 
    248       buffer->checkBuffer(); 
     238     if (!mapBufferSize_.count(rank)) 
     239     { 
     240       error(0) << "WARNING: Unexpected request for buffer to communicate with server " << rank << std::endl; 
     241       mapBufferSize_[rank] = CXios::minBufferSize; 
     242     } 
     243     CClientBuffer* buffer = buffers[rank] = new CClientBuffer(interComm, rank, mapBufferSize_[rank], maxBufferedEvents); 
     244     // Notify the server 
     245     CBufferOut* bufOut = buffer->getBuffer(sizeof(StdSize)); 
     246     bufOut->put(mapBufferSize_[rank]); // Stupid C++ 
     247     buffer->checkBuffer(); 
    249248   } 
    250249 
     
    262261 
    263262   //! Release all buffers 
    264    void CContextClient::releaseBuffers(void) 
     263   void CContextClient::releaseBuffers() 
    265264   { 
    266265      map<int,CClientBuffer*>::iterator itBuff; 
    267266      for (itBuff = buffers.begin(); itBuff != buffers.end(); itBuff++) delete itBuff->second; 
     267//        buffersReleased_ = true; 
    268268   } 
    269269 
     
    273273   \return state of buffers, pending(true), ready(false) 
    274274   */ 
     275//   bool CContextClient::checkBuffers(list<int>& ranks) 
    275276   bool CContextClient::checkBuffers(list<int>& ranks) 
    276277   { 
     
    358359   Finalize context client and do some reports 
    359360   */ 
    360   void CContextClient::finalize(void) 
     361//  void CContextClient::finalize(void) 
     362  void CContextClient::finalize() 
    361363  { 
    362364    map<int,CClientBuffer*>::iterator itBuff; 
     
    396398    std::map<int,StdSize>::const_iterator itbMap = mapBufferSize_.begin(), 
    397399                                          iteMap = mapBufferSize_.end(), itMap; 
     400 
    398401    StdSize totalBuf = 0; 
    399402    for (itMap = itbMap; itMap != iteMap; ++itMap) 
  • XIOS/dev/dev_olga/src/context_client.hpp

    r1054 r1071  
    7070      MPI_Comm intraComm; //!< Communicator of client group 
    7171 
    72       map<int,CClientBuffer*> buffers;     //!< Buffers for connection to servers 
     72      map<int,CClientBuffer*> buffers;         //!< Buffers for connection to servers 
     73//      map<int,CClientBuffer*> buffersPrim;     //!< Buffers for connection to secondary servers 
    7374 
    7475    private: 
     
    7778      //! Maximum number of events that can be buffered 
    7879      StdSize maxBufferedEvents; 
     80 
     81//      bool buffersReleased_; 
    7982 
    8083      struct { 
  • XIOS/dev/dev_olga/src/context_server.cpp

    r1054 r1071  
    225225    { 
    226226      finished=true; 
    227       info(20)<<"Server Side context <"<<context->getId()<<"> finalized"<<endl; 
     227//      info(20)<<"Server Side context <"<<context->getId()<<"> finalized"<<endl;            // moved to CContext::finalize() 
    228228      std::map<int, StdSize>::const_iterator itbMap = mapBufferSize_.begin(), 
    229229                           iteMap = mapBufferSize_.end(), itMap; 
     
    231231      { 
    232232        rank = itMap->first; 
    233         report(10)<< " Memory report : Context <"<<ctxId<<"> : server side : memory used for buffer of each connection to client" << endl 
    234             << "  +) With client of rank " << rank << " : " << itMap->second << " bytes " << endl; 
     233//        report(10)<< " Memory report : Context <"<<ctxId<<"> : server side : memory used for buffer of each connection to client" << endl 
     234//            << "  +) With client of rank " << rank << " : " << itMap->second << " bytes " << endl; 
    235235        totalBuf_ += itMap->second; 
    236236      } 
    237237      context->finalize(); 
    238238 
    239 //      report(0)<< " Memory report : Context <"<<ctxId<<"> : server side : total memory used for buffer "<<totalBuf<<" bytes"<<endl; 
     239//      report(0)<< " Memory report : Context <"<<ctxId<<"> : server side : total memory used for buffer "<<totalBuf<<" bytes"<<endl; // moved to CContext::finalize() 
    240240    } 
    241241    else if (event.classId==CContext::GetType()) CContext::dispatchEvent(event); 
  • 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 
  • XIOS/dev/dev_olga/src/node/context.hpp

    r1054 r1071  
    100100         void finalize(void); 
    101101         void closeDefinition(void); 
     102         bool isFinalized(void); 
    102103 
    103104         // Some functions to process context 
     
    165166         void recvRegistry(CBufferIn& buffer) ; //!< registry is received by the servers 
    166167 
    167          bool isFinalized(void); 
     168         void freeComms(void); //!< Free internally allcoated communicators 
    168169 
    169170         // dispatch event 
     
    231232         bool hasServer; 
    232233 
    233          // Concrete contex client 
    234          CContextClient* client; 
     234         CContextServer* server;  //!< Concrete context server 
     235         CContextClient* client;  //!< Concrete contex client 
     236         std::vector<CContextServer*> serverPrimServer; 
     237         std::vector<CContextClient*> clientPrimServer; 
     238 
    235239         CRegistry* registryIn ;  //!< input registry which is read from file 
    236240         CRegistry* registryOut ; //!< output registry which will be wrote on file at the finalize 
    237  
    238          // Concrete context server 
    239          CContextServer* server; 
    240  
    241 //         CContextClient* clientPrimServer; 
    242 //         CContextServer* serverPrimServer; 
    243          std::vector<CContextClient*> clientPrimServer; 
    244          std::vector<CContextServer*> serverPrimServer; 
    245241 
    246242      private: 
     
    250246         StdString idServer_; 
    251247         CGarbageCollector garbageCollector; 
    252          std::list<MPI_Comm> comms; //!< Communicators allocated internally  --- significance?? 
     248         std::list<MPI_Comm> comms; //!< Communicators allocated internally 
    253249 
    254250      public: // Some function maybe removed in the near future 
  • XIOS/dev/dev_olga/src/node/field.cpp

    r1054 r1071  
    398398  { 
    399399    CContext* context = CContext::getCurrent(); 
    400     CContextClient* client = context->client; 
     400//    CContextClient* client = context->client; 
     401    CContextClient* client = (!context->hasServer) ? context->client : this->file->getContextClient(); 
     402 
    401403 
    402404    lastDataRequestedFromServer = tsDataRequested; 
  • XIOS/dev/dev_olga/src/node/file.cpp

    r1054 r1071  
    857857   } 
    858858 
     859 
    859860   /*! 
    860861   \brief Send a message to create a field on server side 
     
    10811082   void CFile::sendAddVariable(const string& id, CContextClient* client) 
    10821083   { 
    1083       sendAddItem(id, (int)EVENT_ID_ADD_VARIABLE, client); 
     1084      sendAddItem(id, (int)EVENT_ID_ADD_VARIABLE); 
    10841085    // CContext* context = CContext::getCurrent(); 
    10851086 
  • XIOS/dev/dev_olga/src/node/file.hpp

    r1054 r1071  
    122122 
    123123         // Send info to server 
    124 //         void sendEnabledFields(); 
     124         void sendEnabledFields(); 
    125125         void sendEnabledFields(CContextClient* client); 
    126126         void sendAddField(const string& id = ""); 
  • XIOS/dev/dev_olga/src/node/variable.cpp

    r1030 r1071  
    128128   } 
    129129 
    130    void CVariable::sendValue(CContextClient* client) 
     130   void CVariable::sendValue(CContextClient* client, bool clientPrim /*= false*/) 
    131131   { 
    132132     CEventClient event(this->getType(),EVENT_ID_VARIABLE_VALUE) ; 
  • XIOS/dev/dev_olga/src/node/variable.hpp

    r1021 r1071  
    7979            //! Sending a request to set up variable data 
    8080            void sendValue(); 
    81             void sendValue(CContextClient* client); 
     81            void sendValue(CContextClient* client, bool clientPrim = false); 
    8282 
    8383            static void recvValue(CEventServer& event) ; 
  • XIOS/dev/dev_olga/src/server.cpp

    r1054 r1071  
    2222//    list<MPI_Comm> CServer::interComm ; 
    2323    std::list<MPI_Comm> CServer::contextInterComms; 
     24    std::list<MPI_Comm> CServer::contextIntraComms; 
    2425    int CServer::serverLevel = 0 ; 
    25     int CServer::serverLeader = 0; 
    26     int CServer::serverSize = 0; 
     26    int CServer::serverLeader_ = 0; 
     27    int CServer::serverSize_ = 0; 
    2728    int CServer::nbPools = 0; 
    2829    int CServer::poolId = 0; 
     30    int CServer::nbContexts_ = 0; 
    2931    bool CServer::isRoot = false ; 
    3032    int CServer::rank = INVALID_RANK; 
     
    103105        { 
    104106          int serverRank = rank - leaders[hashServer]; // server proc rank starting 0 
    105           serverSize = size - leaders[hashServer]; 
    106           nbPools = serverSize * CXios::ratioServer2 / 100; 
    107           if ( serverRank < (serverSize - nbPools) ) 
     107          serverSize_ = size - leaders[hashServer]; 
     108          nbPools = serverSize_ * CXios::ratioServer2 / 100; 
     109          if ( serverRank < (serverSize_ - nbPools) ) 
    108110          { 
    109111            serverLevel = 1; 
     
    112114          { 
    113115            serverLevel = 2; 
    114             poolId = serverRank - serverSize + nbPools; 
     116            poolId = serverRank - serverSize_ + nbPools; 
    115117            myColor = rank; 
    116118          } 
     
    156158            } 
    157159            else 
    158               serverLeader = it->second; 
     160              serverLeader_ = it->second; 
    159161          } 
    160162 
    161163          for (int i = 0; i < nbPools; ++i) 
    162164          { 
    163             srvSndLeader = serverLeader + serverSize - nbPools + i; 
     165            srvSndLeader = serverLeader_ + serverSize_ - nbPools + i; 
    164166            int intraCommSize, intraCommRank ; 
    165167            MPI_Comm_size(intraComm, &intraCommSize) ; 
     
    239241 
    240242      for (std::list<MPI_Comm>::iterator it = contextInterComms.begin(); it != contextInterComms.end(); it++) 
     243        MPI_Comm_free(&(*it)); 
     244 
     245      for (std::list<MPI_Comm>::iterator it = contextIntraComms.begin(); it != contextIntraComms.end(); it++) 
    241246        MPI_Comm_free(&(*it)); 
    242247 
     
    310315              { 
    311316                MPI_Send(&msg,1,MPI_INT,0,0,*itr) ; 
    312 //                itr = interCommRight.erase(itr) ; 
    313317              } 
    314318              MPI_Comm_free(&(*it)); 
     
    488492       contextList[contextId]=context; 
    489493 
    490        // All type of servers initialize its own server (CContextServer) 
     494       // Primary or classical server: initialize its own server (CContextServer) 
     495       MPI_Comm inter; 
    491496       if (serverLevel < 2) 
    492497       { 
    493498         MPI_Comm contextInterComm; 
    494499         MPI_Intercomm_create(intraComm, 0, CXios::globalComm, leaderRank, 10+leaderRank, &contextInterComm); 
    495          MPI_Comm inter; 
    496500         MPI_Intercomm_merge(contextInterComm,1,&inter); 
    497501         MPI_Barrier(inter); 
     
    499503         context->initServer(intraComm,contextInterComm); 
    500504         contextInterComms.push_back(contextInterComm); 
    501        } 
     505 
     506       } 
     507       // Secondary server: initialize its own server (CContextServer) 
    502508       else if (serverLevel == 2) 
    503509       { 
    504          context->initServer(intraComm, interCommLeft.front()); 
     510         MPI_Comm_dup(interCommLeft.front(), &inter); 
     511         contextInterComms.push_back(inter); 
     512         context->initServer(intraComm, contextInterComms.back()); 
     513//         context->initServer(intraComm, interCommLeft.front()); 
    505514       } 
    506515 
     
    520529           CBufferOut buffer(buff,messageSize) ; 
    521530           buffer<<msg ; 
    522            int sndServerGloRanks = serverSize-nbPools+serverLeader +i;  // the assumption is that there is only one proc per secondary server pool 
     531           int sndServerGloRanks = serverSize_-nbPools+serverLeader_ +i;  // the assumption is that there is only one proc per secondary server pool 
    523532           MPI_Send(buff, buffer.count(), MPI_CHAR, sndServerGloRanks, 1, CXios::globalComm) ; 
    524            context->initClient(intraComm, *it) ; 
     533           MPI_Comm_dup(*it, &inter); 
     534           contextInterComms.push_back(inter); 
     535           MPI_Comm_dup(intraComm, &inter); 
     536           contextIntraComms.push_back(inter); 
     537           context->initClient(contextIntraComms.back(), contextInterComms.back()) ; 
     538//           context->initClient(intraComm, contextPrimInterComms.back()) ; 
     539//           context->initClient(intraComm, *it) ; 
    525540           delete [] buff ; 
    526541         } 
     542         ++nbContexts_; 
    527543       } 
    528544     } 
     
    539555         if (finished) 
    540556         { 
     557//           it->second->freeComms();  // deallocate internally allcoated context communicators 
    541558           contextList.erase(it) ; 
    542559           break ; 
    543560         } 
    544561         else 
     562         { 
    545563           finished=it->second->checkBuffersAndListen(); 
     564         } 
    546565       } 
    547566     } 
     
    579598      { 
    580599        if (serverLevel == 1) 
    581           id = rank-serverLeader; 
     600          id = rank-serverLeader_; 
    582601        else 
    583602          id = poolId; 
  • XIOS/dev/dev_olga/src/server.hpp

    r1054 r1071  
    2727        static list<MPI_Comm> interCommLeft;           // interComm between server (primary, classical or secondary) and its client (client or primary server) 
    2828        static list<MPI_Comm> interCommRight;          // interComm between primary server and secondary server (non-empty only for primary server pool) 
    29         static std::list<MPI_Comm> contextInterComms;  // significance ?? 
     29        static std::list<MPI_Comm> contextInterComms;  // list of context intercomms 
     30        static std::list<MPI_Comm> contextIntraComms;  // list of context intercomms (needed only in case of secondary servers) 
    3031        static CEventScheduler* eventScheduler; 
    3132 
     
    6465      private: 
    6566        static int rank; 
    66         static int serverLeader;  //!< Leader of the classical or primary server (needed in case of secondary servers) 
    67         static int serverSize;    //!< Number of procs dedicated to servers (primary and seconday (if any) combined) 
     67        static int serverLeader_;  //!< Leader of the classical or primary server (needed in case of secondary servers) 
     68        static int serverSize_;    //!< Number of procs dedicated to servers (primary and seconday (if any) combined) 
    6869        static int nbPools;       //!< Number of secondary server pools 
    6970        static int poolId;        //!< id of a secondary server pool starting from 1 
     71        static int nbContexts_; 
    7072        static StdOFStream m_infoStream; 
    7173        static StdOFStream m_errorStream; 
Note: See TracChangeset for help on using the changeset viewer.