Ignore:
Timestamp:
03/22/18 10:43:20 (6 years ago)
Author:
yushan
Message:

branch_openmp merged with XIOS_DEV_CMIP6@1459

File:
1 edited

Legend:

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

    r1355 r1460  
    1919  const string CXios::clientFile="./xios_client"; 
    2020  const string CXios::serverFile="./xios_server"; 
     21  const string CXios::serverPrmFile="./xios_server1"; 
     22  const string CXios::serverSndFile="./xios_server2"; 
    2123 
    2224  bool CXios::isClient ; 
     
    2527  bool CXios::usingOasis ; 
    2628  bool CXios::usingServer = false; 
     29  bool CXios::usingServer2 = false; 
     30  int CXios::ratioServer2 = 50; 
     31  int CXios::nbPoolsServer2 = 1; 
    2732  double CXios::bufferSizeFactor = 1.0; 
    2833  const double CXios::defaultBufferSizeFactor = 1.0; 
    2934  StdSize CXios::minBufferSize = 1024 * sizeof(double); 
     35  StdSize CXios::maxBufferSize = std::numeric_limits<int>::max() ; 
    3036  bool CXios::printLogs2Files; 
    3137  bool CXios::isOptPerformance = true; 
    3238  CRegistry* CXios::globalRegistry = 0; 
    33   double CXios::recvFieldTimeout = 10.0; 
    34  
     39  double CXios::recvFieldTimeout = 300.0; 
     40  bool CXios::checkEventSync=false ; 
     41  
    3542  //! Parse configuration file and create some objects from it 
    3643  void CXios::initialize() 
     
    5764    usingOasis=getin<bool>("using_oasis",false) ; 
    5865    usingServer=getin<bool>("using_server",false) ; 
     66    usingServer2=getin<bool>("using_server2",false) ; 
     67    ratioServer2=getin<int>("ratio_server2",50); 
     68    nbPoolsServer2=getin<int>("number_pools_server2",1); 
    5969    info.setLevel(getin<int>("info_level",0)) ; 
    6070    report.setLevel(getin<int>("info_level",50)); 
     
    7383    bufferSizeFactor = getin<double>("buffer_size_factor", defaultBufferSizeFactor); 
    7484    minBufferSize = getin<int>("min_buffer_size", 1024 * sizeof(double)); 
    75     recvFieldTimeout = getin<double>("recv_field_timeout", 10.0); 
     85    maxBufferSize = getin<int>("max_buffer_size", std::numeric_limits<int>::max()); 
     86    recvFieldTimeout = getin<double>("recv_field_timeout", recvFieldTimeout); 
    7687    if (recvFieldTimeout < 0.0) 
    7788      ERROR("CXios::parseXiosConfig()", "recv_field_timeout cannot be negative."); 
     89 
     90    checkEventSync = getin<bool>("check_event_sync", checkEventSync); 
    7891 
    7992    //globalComm=MPI_COMM_WORLD ; 
     
    112125  { 
    113126    isClient = true; 
    114      
     127 
    115128    initialize() ; 
    116129 
     
    179192    isClient = false; 
    180193    isServer = true; 
    181      
     194 
    182195    initServer(); 
    183196 
    184197    // Initialize all aspects MPI 
    185198    CServer::initialize(); 
    186     if (CServer::getRank()==0) globalRegistry = new CRegistry(CServer::intraComm) ; 
     199    if (CServer::getRank()==0 && CServer::serverLevel != 1) globalRegistry = new CRegistry(CServer::intraComm) ; 
    187200     
    188201    if (printLogs2Files) 
    189202    { 
    190       CServer::openInfoStream(serverFile); 
    191       CServer::openErrorStream(serverFile); 
     203      if (CServer::serverLevel == 0) 
     204      { 
     205        CServer::openInfoStream(serverFile); 
     206        CServer::openErrorStream(serverFile); 
     207      } 
     208      else if (CServer::serverLevel == 1) 
     209      { 
     210        CServer::openInfoStream(serverPrmFile); 
     211        CServer::openErrorStream(serverPrmFile); 
     212      } 
     213      else 
     214      { 
     215        CServer::openInfoStream(serverSndFile); 
     216        CServer::openErrorStream(serverSndFile); 
     217      } 
    192218    } 
    193219    else 
     
    201227 
    202228    // Finalize 
    203      if (CServer::getRank()==0) 
    204      { 
    205        info(80)<<"Write data base Registry"<<endl<<globalRegistry->toString()<<endl ; 
    206        globalRegistry->toFile("xios_registry.bin") ; 
    207        delete globalRegistry ; 
    208      } 
     229    if (CServer::serverLevel == 0) 
     230    { 
     231      if (CServer::getRank()==0) 
     232      { 
     233        info(80)<<"Write data base Registry"<<endl<<globalRegistry->toString()<<endl ; 
     234        globalRegistry->toFile("xios_registry.bin") ; 
     235        delete globalRegistry ; 
     236      } 
     237    } 
     238    else 
     239    { 
     240      // If using two server levels: 
     241      // (1) merge registries on each pool 
     242      // (2) send merged registries to the first pool 
     243      // (3) merge received registries on the first pool 
     244      if (CServer::serverLevel == 2) 
     245      { 
     246        vector<int>& secondaryServerGlobalRanks = CServer::getSecondaryServerGlobalRanks(); 
     247        int firstPoolGlobalRank = secondaryServerGlobalRanks[0]; 
     248        int rankGlobal; 
     249        MPI_Comm_rank(globalComm, &rankGlobal); 
     250 
     251        // Merge registries defined on each pools 
     252        CRegistry globalRegistrySndServers (CServer::intraComm); 
     253 
     254        // All pools (except the first): send globalRegistry to the first pool 
     255        for (int i=1; i<secondaryServerGlobalRanks.size(); i++) 
     256        { 
     257          if (rankGlobal == secondaryServerGlobalRanks[i]) 
     258          { 
     259            globalRegistrySndServers.mergeRegistry(*globalRegistry) ; 
     260            int registrySize = globalRegistrySndServers.size(); 
     261            MPI_Send(&registrySize,1,MPI_LONG,firstPoolGlobalRank,15,CXios::globalComm) ; 
     262            CBufferOut buffer(registrySize) ; 
     263            globalRegistrySndServers.toBuffer(buffer) ; 
     264            MPI_Send(buffer.start(),registrySize,MPI_CHAR,firstPoolGlobalRank,15,CXios::globalComm) ; 
     265          } 
     266        } 
     267 
     268        // First pool: receive globalRegistry of all secondary server pools, merge and write the resultant registry 
     269        if (rankGlobal == firstPoolGlobalRank) 
     270        { 
     271          MPI_Status status; 
     272          char* recvBuff; 
     273 
     274          globalRegistrySndServers.mergeRegistry(*globalRegistry) ; 
     275 
     276          for (int i=1; i< secondaryServerGlobalRanks.size(); i++) 
     277          { 
     278            int rank = secondaryServerGlobalRanks[i]; 
     279            int registrySize = 0; 
     280            MPI_Recv(&registrySize, 1, MPI_LONG, rank, 15, CXios::globalComm, &status); 
     281            recvBuff = new char[registrySize]; 
     282            MPI_Recv(recvBuff, registrySize, MPI_CHAR, rank, 15, CXios::globalComm, &status); 
     283            CBufferIn buffer(recvBuff, registrySize) ; 
     284            CRegistry recvRegistry; 
     285            recvRegistry.fromBuffer(buffer) ; 
     286            globalRegistrySndServers.mergeRegistry(recvRegistry) ; 
     287            delete[] recvBuff; 
     288          } 
     289 
     290          info(80)<<"Write data base Registry"<<endl<<globalRegistrySndServers.toString()<<endl ; 
     291          globalRegistrySndServers.toFile("xios_registry.bin") ; 
     292 
     293        } 
     294      } 
     295      delete globalRegistry; 
     296    } 
    209297    CServer::finalize(); 
    210298 
Note: See TracChangeset for help on using the changeset viewer.