Changeset 1234 for XIOS


Ignore:
Timestamp:
08/03/17 15:16:56 (7 years ago)
Author:
oabramkina
Message:

Minor modifications for secondary server:

  • adding a check of the number of processes requested for the secondary server
  • making process distribution between two server levels in case of oasis similar to that wihtout oasis.
Location:
XIOS/dev/XIOS_DEV_CMIP6/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/XIOS_DEV_CMIP6/src/cxios.cpp

    r1227 r1234  
    186186 
    187187    // Finalize 
    188     if (!usingServer2) 
     188    if (CServer::serverLevel == 0) 
    189189    { 
    190190      if (CServer::getRank()==0) 
  • XIOS/dev/XIOS_DEV_CMIP6/src/cxios.hpp

    r1227 r1234  
    4242     static bool usingOasis ; //!< Using Oasis 
    4343     static bool usingServer ; //!< Using server (server mode) 
    44      static bool usingServer2 ; //!< Using secondary server (server mode) 
     44     static bool usingServer2 ; //!< Using secondary server (server mode). IMPORTANT: Use this variable ONLY in CServer::initialize(). 
    4545     static int ratioServer2 ;  //!< Percentage of server processors dedicated to secondary server 
    4646     static double bufferSizeFactor; //!< Factor used to tune the buffer size 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/file.cpp

    r1232 r1234  
    1717#include "mpi.hpp" 
    1818#include "timer.hpp" 
     19#include "server.hpp" 
    1920 
    2021namespace xios { 
     
    302303      // Done by classical server or secondary server 
    303304      // This condition should be changed soon 
    304       if (!CXios::usingServer2 || (CXios::usingServer2 && !context->hasClient))           
     305      if (CServer::serverLevel == 0 || CServer::serverLevel == 2) 
    305306      { 
    306307        if (mode.isEmpty() || mode.getValue() == mode_attr::write) 
     
    326327      // Done by classical server or secondary server 
    327328      // TODO: This condition should be changed soon. It only works with maximum number of level as 2 
    328       if (!CXios::usingServer2 || (CXios::usingServer2 && context->hasClient)) 
     329      if (CServer::serverLevel == 0 || CServer::serverLevel == 2) 
    329330      { 
    330331        if (!mode.isEmpty() && mode.getValue() == mode_attr::read) 
  • XIOS/dev/XIOS_DEV_CMIP6/src/server.cpp

    r1226 r1234  
    3838 * \fn void CServer::initialize(void) 
    3939 * Creates intraComm for each possible type of servers (classical, primary or secondary). 
    40  * In case of secondary servers intraComm is created for each secondary server pool. 
    41  * (For now the assumption is that there is one proc per pool.) 
     40 * (For now the assumption is that there is one proc per secondary server pool.) 
    4241 * Creates interComm and stores them into the following lists: 
    4342 *   classical server -- interCommLeft 
    4443 *   primary server -- interCommLeft and interCommRight 
    4544 *   secondary server -- interCommLeft for each pool. 
     45 *   IMPORTANT: CXios::usingServer2 should NOT be used beyond this function. Use CServer::serverLevel instead. 
    4646 */ 
    4747    void CServer::initialize(void) 
     
    8585 
    8686        // (1) Establish client leaders, distribute processes between two server levels 
    87         vector<int> srvRanks; 
     87        std::vector<int> srvRanks; 
    8888        for(i=0,c=0;i<size;i++) 
    8989        { 
     
    9898              srvRanks.push_back(i); 
    9999        } 
    100         for (i=0; i<srvRanks.size(); i++) 
    101         { 
    102           if (i >= srvRanks.size()*(100.-CXios::ratioServer2)/100.) 
    103           { 
    104             sndServerGlobalRanks.push_back(srvRanks[i]); 
    105             if (rank_ == srvRanks[i]) serverLevel=2; 
     100 
     101        if (CXios::usingServer2) 
     102        { 
     103          int reqNbProc = srvRanks.size()*CXios::ratioServer2/100.; 
     104          if (reqNbProc<1 || reqNbProc==srvRanks.size()) 
     105          { 
     106            error(0)<<"WARNING: void CServer::initialize(void)"<<endl 
     107                << "It is impossible to dedicate the requested number of processes = "<<reqNbProc 
     108                <<" to secondary server. XIOS will run in the classical server mode."<<endl; 
    106109          } 
    107110          else 
    108111          { 
    109             if (rank_ == srvRanks[i]) serverLevel=1; 
    110           } 
    111         } 
    112  
     112            for (i=0; i<srvRanks.size(); i++) 
     113            { 
     114              if (i >= srvRanks.size()*(100.-CXios::ratioServer2)/100.) 
     115              { 
     116                sndServerGlobalRanks.push_back(srvRanks[i]); 
     117                if (rank_ == srvRanks[i]) serverLevel=2; 
     118              } 
     119              else 
     120              { 
     121                if (rank_ == srvRanks[i]) serverLevel=1; 
     122              } 
     123            } 
     124          } 
     125        } 
    113126        // (2) Create intraComm 
    114127        myColor = (serverLevel == 2) ? rank_ : colors[hashServer]; 
     
    188201        int size; 
    189202        int myColor; 
    190         unsigned long* srvGlobalRanks; 
     203        int* srvGlobalRanks; 
    191204        if (!is_MPI_Initialized) oasis_init(CXios::xiosCodeId); 
    192205 
     
    194207        MPI_Comm localComm; 
    195208        oasis_get_localcomm(localComm); 
    196  
    197         // Create server intraComm 
     209        MPI_Comm_rank(localComm,&rank_) ; 
     210 
     211//      (1) Create server intraComm 
    198212        if (!CXios::usingServer2) 
    199213        { 
    200214          MPI_Comm_dup(localComm, &intraComm); 
    201           MPI_Comm_rank(localComm,&rank_) ; 
    202215        } 
    203216        else 
    204217        { 
    205218          int globalRank; 
    206           MPI_Comm_rank(localComm,&rank_) ; 
    207219          MPI_Comm_size(localComm,&size) ; 
    208220          MPI_Comm_rank(CXios::globalComm,&globalRank) ; 
    209           srvGlobalRanks = new unsigned long[size] ; 
    210           MPI_Allgather(&globalRank, 1, MPI_LONG, srvGlobalRanks, 1, MPI_LONG, localComm) ; 
    211  
    212           for (int i=size*(100.-CXios::ratioServer2)/100.; i<size; i++) 
    213             sndServerGlobalRanks.push_back(srvGlobalRanks[i]); 
    214  
    215           if ( rank_ < (size - sndServerGlobalRanks.size()) ) 
    216           { 
    217             serverLevel = 1; 
    218             myColor = 0; 
     221          srvGlobalRanks = new int[size] ; 
     222          MPI_Allgather(&globalRank, 1, MPI_INT, srvGlobalRanks, 1, MPI_INT, localComm) ; 
     223 
     224          int reqNbProc = size*CXios::ratioServer2/100.; 
     225          if (reqNbProc < 1 || reqNbProc == size) 
     226          { 
     227            error(0)<<"WARNING: void CServer::initialize(void)"<<endl 
     228                << "It is impossible to dedicate the requested number of processes = "<<reqNbProc 
     229                <<" to secondary server. XIOS will run in the classical server mode."<<endl; 
     230            MPI_Comm_dup(localComm, &intraComm); 
    219231          } 
    220232          else 
    221233          { 
    222             serverLevel = 2; 
    223             myColor = rank_; 
    224           } 
    225           MPI_Comm_split(localComm, myColor, rank_, &intraComm) ; 
    226  
    227         } 
    228         MPI_Comm_size(intraComm,&size) ; 
     234            for (int i=0; i<size; i++) 
     235            { 
     236              if (i >= size*(100.-CXios::ratioServer2)/100.) 
     237              { 
     238                sndServerGlobalRanks.push_back(srvGlobalRanks[i]); 
     239                if (globalRank == srvGlobalRanks[i]) serverLevel=2; 
     240              } 
     241              else 
     242              { 
     243                if (globalRank == srvGlobalRanks[i]) serverLevel=1; 
     244              } 
     245            } 
     246            myColor = (serverLevel == 2) ? globalRank : 0; 
     247            MPI_Comm_split(localComm, myColor, rank_, &intraComm) ; 
     248          } 
     249        } 
     250 
    229251        string codesId=CXios::getin<string>("oasis_codes_id") ; 
    230  
    231252        vector<string> splitted ; 
    232253        boost::split( splitted, codesId, boost::is_any_of(","), boost::token_compress_on ) ; 
     
    237258        MPI_Comm_rank(CXios::globalComm,&globalRank); 
    238259 
    239 //      (1) Create interComms with models 
     260//      (2) Create interComms with models 
    240261        for(it=splitted.begin();it!=splitted.end();it++) 
    241262        { 
    242263          oasis_get_intercomm(newComm,*it) ; 
    243           if ( !CXios::usingServer2 || serverLevel == 1) 
     264          if ( serverLevel == 0 || serverLevel == 1) 
    244265          { 
    245266            interCommLeft.push_back(newComm) ; 
     
    248269        } 
    249270 
    250 //      (2) Create interComms between primary and secondary servers 
     271//      (3) Create interComms between primary and secondary servers 
     272        MPI_Comm_size(intraComm,&size) ; 
    251273        if (serverLevel == 1) 
    252274        { 
Note: See TracChangeset for help on using the changeset viewer.