Changeset 1180


Ignore:
Timestamp:
06/22/17 17:03:07 (7 years ago)
Author:
oabramkina
Message:

Two server levels:
(1) oasis works now with two server levels
(2) corrected assignment of processes between two server levels in case of non-contiguous processes
(3) corrected a bug during context finalization.

Location:
XIOS/dev/dev_olga/src
Files:
4 edited

Legend:

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

    r1158 r1180  
    100100          MPI_Comm_split(CXios::globalComm,myColor,rank_,&intraComm) ; 
    101101 
    102           if (CXios::usingServer2) 
    103             MPI_Allgather(&hashClient, 1, MPI_LONG, hashAll, 1, MPI_LONG, CXios::globalComm) ; 
    104  
    105102          if (CXios::usingServer) 
    106103          { 
  • XIOS/dev/dev_olga/src/node/context.cpp

    r1158 r1180  
    491491     info(20)<<"Context <"<<getId()<<"> is finalized."<<endl; 
    492492 
    493      //     if (hasServer && !hasClient) 
     493     if (hasServer && !hasClient) 
    494494     { 
    495495       closeAllFile(); 
  • XIOS/dev/dev_olga/src/server.cpp

    r1168 r1180  
    1818{ 
    1919    MPI_Comm CServer::intraComm ; 
    20     list<MPI_Comm> CServer::interCommLeft ; 
    21     list<MPI_Comm> CServer::interCommRight ; 
     20    std::list<MPI_Comm> CServer::interCommLeft ; 
     21    std::list<MPI_Comm> CServer::interCommRight ; 
    2222    std::list<MPI_Comm> CServer::contextInterComms; 
    2323    std::list<MPI_Comm> CServer::contextIntraComms; 
     
    8484        map<unsigned long, int>::iterator it ; 
    8585 
    86         int srvNodeSize = 1, srvNodeLeader = 0; 
    87  
    8886        // (1) Establish client leaders, distribute processes between two server levels 
     87        vector<int> srvRanks; 
    8988        for(i=0,c=0;i<size;i++) 
    9089        { 
     
    9695          } 
    9796          if (CXios::usingServer2) 
    98           { 
    9997            if (hashAll[i] == hashServer) 
    100             { 
    101               if (hashAll[i-1] != hashServer || i == 0) 
    102               { 
    103                 srvNodeLeader = i; 
    104               } 
    105               if (hashAll[i+1] == hashServer) 
    106               { 
    107                 ++srvNodeSize; 
    108               } 
    109               else 
    110               { 
    111                 if ( (rank_-srvNodeLeader) >= 0 && 
    112                      (rank_-srvNodeLeader) < (1.- CXios::ratioServer2/100.)*srvNodeSize ) 
    113                 { 
    114                   serverLevel = 1; 
    115                 } 
    116                 if ( (rank_-srvNodeLeader) >= (1.- CXios::ratioServer2/100.)*srvNodeSize && 
    117                      (rank_ - srvNodeLeader) < srvNodeSize ) 
    118                 { 
    119                   serverLevel = 2; 
    120                 } 
    121                 srvNodeSize = 1; 
    122               } 
    123             } 
     98              srvRanks.push_back(i); 
     99        } 
     100        for (i=0; i<srvRanks.size(); i++) 
     101        { 
     102          if (i >= srvRanks.size()*CXios::ratioServer2/100) 
     103          { 
     104            sndServerGlobalRanks.push_back(srvRanks[i]); 
     105            if (rank_ == srvRanks[i]) serverLevel=2; 
     106          } 
     107          else 
     108          { 
     109            if (rank_ == srvRanks[i]) serverLevel=1; 
    124110          } 
    125111        } 
     
    130116 
    131117        // (3) Create interComm 
    132         if (CXios::usingServer2) 
    133         { 
    134           MPI_Allgather(&serverLevel, 1, MPI_LONG, hashAll, 1, MPI_LONG, CXios::globalComm) ; 
    135  
    136           for (i=0; i<size; i++) 
    137             if (hashAll[i] == 2) 
    138               sndServerGlobalRanks.push_back(i); 
    139         } 
    140  
    141118        if (serverLevel == 0) 
    142119        { 
     
    154131 
    155132              MPI_Intercomm_create(intraComm, 0, CXios::globalComm, clientLeader, 0, &newComm) ; 
    156                interCommLeft.push_back(newComm) ; 
     133              interCommLeft.push_back(newComm) ; 
    157134            } 
    158135          } 
     
    211188        int size; 
    212189        int myColor; 
     190        unsigned long* srvGlobalRanks; 
    213191        if (!is_MPI_Initialized) oasis_init(CXios::xiosCodeId); 
    214192 
     
    225203        else 
    226204        { 
     205          int globalRank; 
    227206          MPI_Comm_rank(localComm,&rank_) ; 
    228207          MPI_Comm_size(localComm,&size) ; 
     208          MPI_Comm_rank(CXios::globalComm,&globalRank) ; 
     209          srvGlobalRanks = new unsigned long[size] ; 
     210          MPI_Allgather(&globalRank, 1, MPI_LONG, srvGlobalRanks, 1, MPI_LONG, localComm) ; 
    229211 
    230212          for (int i=size*CXios::ratioServer2/100; i<size; i++) 
    231             sndServerGlobalRanks.push_back(i); 
     213            sndServerGlobalRanks.push_back(srvGlobalRanks[i]); 
    232214 
    233215          if ( rank_ < (size - sndServerGlobalRanks.size()) ) 
     
    255237        MPI_Comm_rank(CXios::globalComm,&globalRank); 
    256238 
     239//      (1) Create interComms with models 
    257240        for(it=splitted.begin();it!=splitted.end();it++) 
    258241        { 
    259242          oasis_get_intercomm(newComm,*it) ; 
    260 //        interComm.push_back(newComm) ; 
    261           if ( !CXios::usingServer2) 
     243          if ( !CXios::usingServer2 || serverLevel == 1) 
    262244          { 
    263245            interCommLeft.push_back(newComm) ; 
    264246            if (rank_==0) MPI_Send(&globalRank,1,MPI_INT,0,0,newComm) ; 
    265247          } 
    266           else 
    267           { 
    268             if (serverLevel == 1) 
    269             { 
    270               interCommLeft.push_back(newComm) ; 
    271               if (rank_==0) MPI_Send(&globalRank,1,MPI_INT,0,0,newComm) ; 
    272               for (int i = 0; i < sndServerGlobalRanks.size(); ++i) 
    273               { 
    274                 int srvSndLeader = sndServerGlobalRanks[i]; 
    275                 info(50)<<"intercommCreate::client (server level 1) "<<globalRank<<" intraCommSize : "<<size 
    276                     <<" intraCommRank :"<<rank_<<"  clientLeader "<< srvSndLeader<<endl ; 
    277                 MPI_Intercomm_create(intraComm, 0, CXios::globalComm, srvSndLeader, 0, &newComm) ; 
    278                 interCommRight.push_back(newComm) ; 
    279               } 
    280             } 
    281             else if (serverLevel == 2) 
    282             { 
    283               info(50)<<"intercommCreate::server "<<rank_<<" intraCommSize : "<<size 
    284                        <<" intraCommRank :"<<rank_<<"  clientLeader "<< 0<<endl ; 
    285               MPI_Intercomm_create(intraComm, 0, localComm, 0, 0, &newComm) ; 
    286               interCommLeft.push_back(newComm) ; 
    287             } 
    288           } 
    289 //          MPI_Comm_remote_size(newComm,&size); 
    290         } 
     248        } 
     249 
     250//      (2) Create interComms between primary and secondary servers 
     251        if (serverLevel == 1) 
     252        { 
     253          for (int i = 0; i < sndServerGlobalRanks.size(); ++i) 
     254          { 
     255            int srvSndLeader = sndServerGlobalRanks[i]; 
     256            info(50)<<"intercommCreate::client (server level 1) "<<globalRank<<" intraCommSize : "<<size 
     257                <<" intraCommRank :"<<rank_<<"  clientLeader "<< srvSndLeader<<endl ; 
     258            MPI_Intercomm_create(intraComm, 0, CXios::globalComm, srvSndLeader, 0, &newComm) ; 
     259            interCommRight.push_back(newComm) ; 
     260          } 
     261        } 
     262        else if (serverLevel == 2) 
     263        { 
     264          info(50)<<"intercommCreate::server "<<rank_<<" intraCommSize : "<<size 
     265                   <<" intraCommRank :"<<rank_<<"  clientLeader "<< srvGlobalRanks[0] <<endl ; 
     266          MPI_Intercomm_create(intraComm, 0, CXios::globalComm, srvGlobalRanks[0], 0, &newComm) ; 
     267          interCommLeft.push_back(newComm) ; 
     268        } 
     269        delete [] srvGlobalRanks ; 
     270 
    291271              oasis_enddef() ; 
    292272      } 
  • XIOS/dev/dev_olga/src/server.hpp

    r1168 r1180  
    2525 
    2626        static MPI_Comm intraComm; 
    27         static list<MPI_Comm> interCommLeft;           // interComm between server (primary, classical or secondary) and its client (client or primary server) 
    28         static list<MPI_Comm> interCommRight;          // interComm between primary server and secondary server (non-empty only for primary server pool) 
     27        static std::list<MPI_Comm> interCommLeft;           // interComm between server (primary, classical or secondary) and its client (client or primary server) 
     28        static std::list<MPI_Comm> interCommRight;          // interComm between primary server and secondary server (non-empty only for primary server pool) 
    2929        static std::list<MPI_Comm> contextInterComms;  // list of context intercomms 
    3030        static std::list<MPI_Comm> contextIntraComms;  // list of context intercomms (needed only in case of secondary servers) 
     
    4949        static int getRank(); 
    5050 
    51         //!< Get global ranks of processes dedicated to the secondary server 
     51        //!< Get global ranks of secondary server processes 
    5252        static vector<int>& getSecondaryServerGlobalRanks(); 
    5353 
     
    6868      private: 
    6969        static vector<int> sndServerGlobalRanks;  //!< Global ranks of secondary server processes 
    70         static int rank_;             //!< If (!oasis) global rank, else rank in the intraComm returned by oasis 
    71         static int nbContexts;        //!< Number of contexts registered by server 
     70        static int rank_;                   //!< If (!oasis) global rank, else rank in the intraComm returned by oasis 
     71        static int nbContexts;              //!< Number of contexts registered by server 
    7272        static StdOFStream m_infoStream; 
    7373        static StdOFStream m_errorStream; 
Note: See TracChangeset for help on using the changeset viewer.