Ignore:
Timestamp:
06/02/17 16:56:46 (7 years ago)
Author:
oabramkina
Message:

Two servel levels: correcting initialization in case of non-contiguous server ranks.
Tests on Curie: test_complete.

File:
1 edited

Legend:

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

    r1150 r1152  
    2020    list<MPI_Comm> CServer::interCommLeft ; 
    2121    list<MPI_Comm> CServer::interCommRight ; 
    22 //    list<MPI_Comm> CServer::interComm ; 
    2322    std::list<MPI_Comm> CServer::contextInterComms; 
    2423    std::list<MPI_Comm> CServer::contextIntraComms; 
    2524    int CServer::serverLevel = 0 ; 
    26     int CServer::serverLeader_ = 0; 
    27     int CServer::serverSize_ = 0; 
    28     int CServer::nbPools = 0; 
    29     int CServer::poolId = 0; 
    3025    int CServer::nbContexts = 0; 
    3126    bool CServer::isRoot = false ; 
     
    3429    StdOFStream CServer::m_errorStream; 
    3530    map<string,CContext*> CServer::contextList ; 
     31    vector<int> CServer::sndServerGlobalRanks; 
    3632    bool CServer::finished=false ; 
    3733    bool CServer::is_MPI_Initialized ; 
     
    5551      if (initialized) is_MPI_Initialized=true ; 
    5652      else is_MPI_Initialized=false ; 
     53      int rank ; 
    5754 
    5855      // Not using OASIS 
     
    7067 
    7168        unsigned long* hashAll ; 
    72  
    73 //        int rank ; 
     69        unsigned long* srvLevelAll ; 
     70 
    7471        int size ; 
    7572        int myColor ; 
    7673        int i,c ; 
    77         MPI_Comm newComm, serversComm; 
     74        MPI_Comm newComm; 
    7875 
    7976        MPI_Comm_size(CXios::globalComm, &size) ; 
     
    8885 
    8986        int nbSrv = 0; 
     87        int srvNodeSize = 1, srvNodeLeader = 0; 
     88 
     89        // (1) Establish client leaders, distribute processes between two server levels 
    9090        for(i=0,c=0;i<size;i++) 
    9191        { 
     
    9696            c++ ; 
    9797          } 
    98           if (hashAll[i] == hashServer) ++serverSize_; 
     98          if (CXios::usingServer2) 
     99          { 
     100            if (hashAll[i] == hashServer) 
     101            { 
     102              if (hashAll[i-1] != hashServer || i == 0) 
     103              { 
     104                srvNodeLeader = i; 
     105              } 
     106              if (hashAll[i+1] == hashServer) 
     107              { 
     108                ++srvNodeSize; 
     109              } 
     110              else 
     111              { 
     112                if ( (rank_-srvNodeLeader) >= 0 && 
     113                     (rank_-srvNodeLeader) < (1.- CXios::ratioServer2/100.)*srvNodeSize ) 
     114                { 
     115                  serverLevel = 1; 
     116                } 
     117                if ( (rank_-srvNodeLeader) >= (1.- CXios::ratioServer2/100.)*srvNodeSize && 
     118                     (rank_ - srvNodeLeader) < srvNodeSize ) 
     119                { 
     120                  serverLevel = 2; 
     121                } 
     122                srvNodeSize = 1; 
     123              } 
     124            } 
     125          } 
    99126        } 
    100127 
    101         // Setting the number of secondary pools 
    102         myColor = colors[hashServer]; 
     128        // (2) Create intraComm 
     129        myColor = (serverLevel == 2) ? rank_ : colors[hashServer]; 
     130        MPI_Comm_split(CXios::globalComm, myColor, rank_, &intraComm) ; 
     131 
     132        // (3) Create interComm 
    103133        if (CXios::usingServer2) 
    104134        { 
    105           int serverRank = rank_ - leaders[hashServer]; // server proc rank starting 0 
    106           nbPools = serverSize_ * CXios::ratioServer2 / 100; 
    107           if ( serverRank < (serverSize_ - nbPools) ) 
    108           { 
    109             serverLevel = 1; 
    110           } 
    111           else 
    112           { 
    113             serverLevel = 2; 
    114             poolId = serverRank - serverSize_ + nbPools; 
    115             myColor = rank_ + size; // + size to make sure that myColor is unique among not only servers but also clients. It's only a temporary solution 
    116           } 
     135          MPI_Allgather(&serverLevel, 1, MPI_LONG, hashAll, 1, MPI_LONG, CXios::globalComm) ; 
     136          for (i=0; i<size; i++) 
     137            if (hashAll[i] == 2) 
     138              sndServerGlobalRanks.push_back(i); 
    117139        } 
    118  
    119         MPI_Comm_split(CXios::globalComm, myColor, rank_, &intraComm) ; 
    120140 
    121141        if (serverLevel == 0) 
     
    142162          int clientLeader, srvSndLeader; 
    143163          int srvPrmLeader ; 
     164 
    144165          for (it=leaders.begin();it!=leaders.end();it++) 
    145166          { 
     
    155176              interCommLeft.push_back(newComm) ; 
    156177            } 
    157             else 
    158               serverLeader_ = it->second; 
    159           } 
    160  
    161           for (int i = 0; i < nbPools; ++i) 
    162           { 
    163             srvSndLeader = serverLeader_ + serverSize_ - nbPools + i; 
     178          } 
     179 
     180          for (int i = 0; i < sndServerGlobalRanks.size(); ++i) 
     181          { 
    164182            int intraCommSize, intraCommRank ; 
    165183            MPI_Comm_size(intraComm, &intraCommSize) ; 
    166184            MPI_Comm_rank(intraComm, &intraCommRank) ; 
    167185            info(50)<<"intercommCreate::client (server level 1) "<<rank_<<" intraCommSize : "<<intraCommSize 
    168                 <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< srvSndLeader<<endl ; 
    169             MPI_Intercomm_create(intraComm, 0, CXios::globalComm, srvSndLeader, 1, &newComm) ; 
     186                <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< sndServerGlobalRanks[i]<<endl ; 
     187            MPI_Intercomm_create(intraComm, 0, CXios::globalComm, sndServerGlobalRanks[i], 1, &newComm) ; 
    170188            interCommRight.push_back(newComm) ; 
    171189          } 
     
    191209      else 
    192210      { 
    193         int size, rank; 
     211        int size; 
    194212        int myColor; 
    195213        if (!is_MPI_Initialized) oasis_init(CXios::xiosCodeId); 
     
    204222        else 
    205223        { 
    206           MPI_Comm_rank(localComm,&rank) ; 
    207           MPI_Comm_size(localComm,&serverSize_) ; 
    208           nbPools = serverSize_ * CXios::ratioServer2 / 100; 
    209           if ( rank < (serverSize_ - nbPools) ) 
     224          MPI_Comm_rank(localComm,&rank_) ; 
     225          MPI_Comm_size(localComm,&size) ; 
     226 
     227          for (int i=size*CXios::ratioServer2/100; i<size; i++) 
     228            sndServerGlobalRanks.push_back(i); 
     229 
     230          if ( rank_ < (size - sndServerGlobalRanks.size()) ) 
    210231          { 
    211232            serverLevel = 1; 
     
    215236          { 
    216237            serverLevel = 2; 
    217             poolId = rank - serverSize_ + nbPools; 
    218             myColor = rank; 
    219           } 
    220           MPI_Comm_split(localComm, myColor, rank, &intraComm) ; 
     238            myColor = rank_; 
     239          } 
     240          MPI_Comm_split(localComm, myColor, rank_, &intraComm) ; 
    221241 
    222242        } 
    223         MPI_Comm_rank(intraComm,&rank_) ; 
    224243        MPI_Comm_size(intraComm,&size) ; 
    225  
    226244        string codesId=CXios::getin<string>("oasis_codes_id") ; 
    227245 
     
    233251        int globalRank ; 
    234252        MPI_Comm_rank(CXios::globalComm,&globalRank); 
    235         if (rank_ == 0) 
    236           serverLeader_ = globalRank; 
    237253 
    238254        for(it=splitted.begin();it!=splitted.end();it++) 
     
    251267              interCommLeft.push_back(newComm) ; 
    252268              if (rank_==0) MPI_Send(&globalRank,1,MPI_INT,0,0,newComm) ; 
    253               for (int i = 0; i < nbPools; ++i) 
     269              for (int i = 0; i < sndServerGlobalRanks.size(); ++i) 
    254270              { 
    255                 int srvSndLeader = serverLeader_ + serverSize_ - nbPools + i; 
     271                int srvSndLeader = sndServerGlobalRanks[i]; 
    256272                info(50)<<"intercommCreate::client (server level 1) "<<globalRank<<" intraCommSize : "<<size 
    257273                    <<" intraCommRank :"<<rank_<<"  clientLeader "<< srvSndLeader<<endl ; 
     
    273289      } 
    274290 
    275       MPI_Comm_rank(intraComm, &rank_) ; 
    276       if (rank_==0) isRoot=true; 
     291      MPI_Comm_rank(intraComm, &rank) ; 
     292      if (rank==0) isRoot=true; 
    277293      else isRoot=false; 
    278294       
     
    612628           CBufferOut buffer(buff,messageSize) ; 
    613629           buffer<<msg ; 
    614            int sndServerGloRanks = serverSize_-nbPools+serverLeader_ +i;  // the assumption is that there is only one proc per secondary server pool 
    615            MPI_Send(buff, buffer.count(), MPI_CHAR, sndServerGloRanks, 1, CXios::globalComm) ; 
     630           MPI_Send(buff, buffer.count(), MPI_CHAR, sndServerGlobalRanks[i], 1, CXios::globalComm) ; 
    616631           MPI_Comm_dup(*it, &inter); 
    617632           contextInterComms.push_back(inter); 
     
    668683        ++numDigit; 
    669684      } 
    670  
    671       if (!CXios::usingServer2) 
    672         id = getRank(); 
    673       else 
    674       { 
    675         if (serverLevel == 1) 
    676           id = rank_; 
    677         else 
    678           id = poolId; 
    679       } 
     685      id = getRank(); 
     686 
     687//      if (!CXios::usingServer2) 
     688//        id = getRank(); 
     689//      else 
     690//      { 
     691//        if (serverLevel == 1) 
     692//          id = rank_; 
     693//        else 
     694//          id = poolId; 
     695//      } 
    680696      fileNameClient << fileName << "_" << std::setfill('0') << std::setw(numDigit) << id << ext; 
    681697      fb->open(fileNameClient.str().c_str(), std::ios::out); 
Note: See TracChangeset for help on using the changeset viewer.