Ignore:
Timestamp:
11/07/16 17:55:55 (8 years ago)
Author:
oabramkina
Message:

My branch

Location:
XIOS/dev/dev_olga
Files:
1 edited
1 copied

Legend:

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

    r925 r983  
    1818    MPI_Comm CClient::interComm ; 
    1919    std::list<MPI_Comm> CClient::contextInterComms; 
    20     int CClient::serverLeader ; 
     20    int CClient::serverLeader; 
    2121    bool CClient::is_MPI_Initialized ; 
    2222    int CClient::rank = INVALID_RANK; 
     
    2424    StdOFStream CClient::m_errorStream; 
    2525 
    26     void CClient::initialize(const string& codeId,MPI_Comm& localComm,MPI_Comm& returnComm) 
     26///--------------------------------------------------------------- 
     27/*! 
     28 * \fn void CClient::initialize(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm) 
     29 * Function creates intraComm (CClient::intraComm) for client group with id=codeId and interComm (CClient::interComm) between client and server groups. 
     30 * \param [in] codeId identity of context. 
     31 * \param [in/out] localComm local communicator. 
     32 * \param [in/out] returnComm (intra)communicator of client group. 
     33 */ 
     34 
     35    void CClient::initialize(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm) 
    2736    { 
    2837      int initialized ; 
     
    3443      if (!CXios::usingOasis) 
    3544      { 
    36 // localComm doesn't given 
     45// localComm isn't given 
    3746        if (localComm == MPI_COMM_NULL) 
    3847        { 
     
    4554          boost::hash<string> hashString ; 
    4655 
    47           unsigned long hashClient=hashString(codeId) ; 
    48           unsigned long hashServer=hashString(CXios::xiosCodeId) ; 
     56          unsigned long hashClient = hashString(codeId) ; 
     57          unsigned long hashServer = hashString(CXios::xiosCodeIdPrm); 
    4958          unsigned long* hashAll ; 
    5059          int size ; 
     
    5867          hashAll=new unsigned long[size] ; 
    5968 
    60           MPI_Allgather(&hashClient,1,MPI_LONG,hashAll,1,MPI_LONG,CXios::globalComm) ; 
     69          MPI_Allgather(&hashClient, 1, MPI_LONG, hashAll, 1, MPI_LONG, CXios::globalComm) ; 
    6170 
    6271          map<unsigned long, int> colors ; 
     
    7786          for (i=0; i < size; ++i) 
    7887          { 
    79             if (hashServer == hashAll[i]) 
     88            if ((hashAll[i] == hashString(CXios::xiosCodeId)) 
     89                || (hashAll[i] == hashString(CXios::xiosCodeIdPrm)) 
     90                || (hashAll[i] == hashString(CXios::xiosCodeIdSnd))) 
    8091            { 
    8192              CXios::setUsingServer(); 
     
    8596 
    8697          myColor=colors[hashClient] ; 
    87  
    8898          MPI_Comm_split(CXios::globalComm,myColor,rank,&intraComm) ; 
    8999 
     
    92102            int clientLeader=leaders[hashClient] ; 
    93103            serverLeader=leaders[hashServer] ; 
    94  
    95104            int intraCommSize, intraCommRank ; 
    96105            MPI_Comm_size(intraComm,&intraCommSize) ; 
    97106            MPI_Comm_rank(intraComm,&intraCommRank) ; 
    98107            info(50)<<"intercommCreate::client "<<rank<<" intraCommSize : "<<intraCommSize 
    99                  <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< serverLeader<<endl ; 
    100             MPI_Intercomm_create(intraComm,0,CXios::globalComm,serverLeader,0,&interComm) ; 
     108                   <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< serverLeader<<endl ; 
     109             MPI_Intercomm_create(intraComm,0,CXios::globalComm,serverLeader,0,&interComm) ; 
    101110          } 
    102111          else 
     
    123132      else 
    124133      { 
    125         // localComm doesn't given 
     134        // localComm isn't given 
    126135        if (localComm == MPI_COMM_NULL) 
    127136        { 
     
    150159    } 
    151160 
    152  
    153     void CClient::registerContext(const string& id,MPI_Comm contextComm) 
     161    void CClient::initializeClientOnServer(const int rank, MPI_Comm& intraCommPrmSrv, const int srvSndLeader) 
     162    { 
     163      MPI_Comm_dup(intraCommPrmSrv, &intraComm) ; 
     164      serverLeader = srvSndLeader; 
     165      int intraCommSize, intraCommRank ; 
     166      MPI_Comm_size(intraComm,&intraCommSize) ; 
     167      MPI_Comm_rank(intraComm,&intraCommRank) ; 
     168      info(50)<<"intercommCreate::client "<<rank<<" intraCommSize : "<<intraCommSize 
     169          <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< serverLeader<<endl ; 
     170      MPI_Intercomm_create(intraComm, 0, CXios::globalComm, serverLeader, 0, &interComm) ; 
     171    } 
     172 
     173///--------------------------------------------------------------- 
     174/*! 
     175 * \fn void CClient::registerContext(const string& id, MPI_Comm contextComm) 
     176 * Function creates intraComm (CClient::intraComm) for client group with id=codeId and interComm (CClient::interComm) between client and server groups. 
     177 * \param [in] id id of context. 
     178 * \param [in] contextComm. 
     179 */ 
     180    void CClient::registerContext(const string& id, MPI_Comm contextComm) 
    154181    { 
    155182      CContext::setCurrent(id) ; 
     
    158185      idServer += "_server"; 
    159186 
    160       if (!CXios::isServer) 
     187      if (CXios::isServer && !context->hasServer) 
     188      // Attached mode 
     189      { 
     190        MPI_Comm contextInterComm ; 
     191        MPI_Comm_dup(contextComm,&contextInterComm) ; 
     192        CContext* contextServer = CContext::create(idServer); 
     193 
     194        // Firstly, initialize context on client side 
     195        context->initClient(contextComm,contextInterComm, contextServer); 
     196 
     197        // Secondly, initialize context on server side 
     198        contextServer->initServer(contextComm,contextInterComm, context); 
     199 
     200        // Finally, we should return current context to context client 
     201        CContext::setCurrent(id); 
     202 
     203        contextInterComms.push_back(contextInterComm); 
     204      } 
     205      else 
    161206      { 
    162207        int size,rank,globalRank ; 
     
    170215        if (rank!=0) globalRank=0 ; 
    171216 
    172  
    173217        CMessage msg ; 
    174218        msg<<idServer<<size<<globalRank ; 
     
    180224        buffer<<msg ; 
    181225 
    182         MPI_Send(buff,buffer.count(),MPI_CHAR,serverLeader,1,CXios::globalComm) ; 
     226        MPI_Send(buff, buffer.count(), MPI_CHAR, serverLeader, 1, CXios::globalComm) ; 
    183227        delete [] buff ; 
    184228 
    185         MPI_Intercomm_create(contextComm,0,CXios::globalComm,serverLeader,10+globalRank,&contextInterComm) ; 
     229        MPI_Intercomm_create(contextComm, 0, CXios::globalComm, serverLeader, 10+globalRank, &contextInterComm) ; 
    186230        info(10)<<"Register new Context : "<<id<<endl ; 
    187231 
     
    195239        MPI_Comm_free(&inter); 
    196240      } 
    197       else 
    198       { 
    199         MPI_Comm contextInterComm ; 
    200         MPI_Comm_dup(contextComm,&contextInterComm) ; 
    201         CContext* contextServer = CContext::create(idServer); 
    202  
    203         // Firstly, initialize context on client side 
    204         context->initClient(contextComm,contextInterComm, contextServer); 
    205  
    206         // Secondly, initialize context on server side 
    207         contextServer->initServer(contextComm,contextInterComm, context); 
    208  
    209         // Finally, we should return current context to context client 
    210         CContext::setCurrent(id); 
    211  
    212         contextInterComms.push_back(contextInterComm); 
    213       } 
    214241    } 
    215242 
     
    221248      MPI_Comm_rank(intraComm,&rank) ; 
    222249  
    223       if (!CXios::isServer) 
     250      if ((!CXios::isServer) || (CXios::serverLevel == 1)) 
    224251      { 
    225252        MPI_Comm_rank(intraComm,&rank) ; 
     
    252279      report(0)<< " Memory report : Minimum buffer size required : " << CClientBuffer::maxRequestSize << " bytes" << endl ; 
    253280      report(0)<< " Memory report : increasing it by a factor will increase performance, depending of the volume of data wrote in file at each time step of the file"<<endl ; 
     281 
    254282   } 
    255283 
Note: See TracChangeset for help on using the changeset viewer.