Ignore:
Timestamp:
05/16/17 17:54:30 (7 years ago)
Author:
yushan
Message:

branch merged with trunk r1130

File:
1 edited

Legend:

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

    r1029 r1134  
    1414namespace xios 
    1515{ 
    16   string CXios::rootFile="./iodef.xml" ; 
    17   string CXios::xiosCodeId="xios.x" ; 
    18   string CXios::clientFile="./xios_client"; 
    19   string CXios::serverFile="./xios_server"; 
     16 
     17  extern int test_omp_rank; 
     18  #pragma omp threadprivate(test_omp_rank) 
     19 
     20  const string CXios::rootFile="./iodef.xml" ; 
     21  const string CXios::xiosCodeId="xios.x" ; 
     22  const string CXios::clientFile="./xios_client"; 
     23  const string CXios::serverFile="./xios_server"; 
     24 
    2025 
    2126  bool CXios::isClient ; 
    2227  bool CXios::isServer ; 
     28 
     29 
    2330  MPI_Comm CXios::globalComm ; 
     31 
     32   
    2433  bool CXios::usingOasis ; 
    2534  bool CXios::usingServer = false; 
     35 
     36 
    2637  double CXios::bufferSizeFactor = 1.0; 
    2738  const double CXios::defaultBufferSizeFactor = 1.0; 
    2839  StdSize CXios::minBufferSize = 1024 * sizeof(double); 
     40 
     41 
    2942  bool CXios::printLogs2Files; 
    3043  bool CXios::isOptPerformance = true; 
     
    3649  { 
    3750    set_new_handler(noMemory); 
    38     parseFile(rootFile); 
     51     
     52     
     53    #pragma omp critical 
     54    { 
     55      parseFile(rootFile);   
     56    } 
     57    #pragma omp barrier 
    3958    parseXiosConfig(); 
    4059  } 
     
    6887      ERROR("CXios::parseXiosConfig()", "recv_field_timeout cannot be negative."); 
    6988 
    70     globalComm=MPI_COMM_WORLD ; 
     89  
     90    int num_ep; 
     91    if(isClient)   
     92    {  
     93      num_ep = omp_get_num_threads(); 
     94    } 
     95     
     96    if(isServer)  
     97    {  
     98      num_ep = omp_get_num_threads(); 
     99    } 
     100     
     101    MPI_Info info; 
     102    #pragma omp master 
     103    { 
     104      MPI_Comm *ep_comm; 
     105      MPI_Comm_create_endpoints(MPI_COMM_WORLD, num_ep, info, ep_comm);  // servers should reach here too. 
     106      passage = ep_comm;   
     107    } 
     108     
     109    #pragma omp barrier 
     110 
     111       
     112    CXios::globalComm = passage[omp_get_thread_num()]; 
     113 
     114    int tmp_rank; 
     115    MPI_Comm_rank(CXios::globalComm, &tmp_rank); 
     116 
     117     
     118    test_omp_rank = tmp_rank; 
     119     
    71120  } 
    72121 
     
    79128  void CXios::initClientSide(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm) 
    80129  { 
     130    isClient = true; 
     131     
    81132    initialize() ; 
    82133 
    83     isClient = true; 
    84  
    85134    CClient::initialize(codeId,localComm,returnComm) ; 
     135 
    86136    if (CClient::getRank()==0) globalRegistry = new CRegistry(returnComm) ; 
    87137 
     
    92142    if (printLogs2Files) 
    93143    { 
     144      #pragma omp critical 
    94145      CClient::openInfoStream(clientFile); 
    95146      CClient::openErrorStream(clientFile); 
     
    107158     if (CClient::getRank()==0) 
    108159     { 
     160       #pragma omp critical (_output) 
    109161       info(80)<<"Write data base Registry"<<endl<<globalRegistry->toString()<<endl ; 
    110162       globalRegistry->toFile("xios_registry.bin") ; 
     
    123175  void CXios::initServer() 
    124176  { 
     177    int initialized; 
     178    MPI_Initialized(&initialized); 
     179    if (initialized) CServer::is_MPI_Initialized=true ; 
     180    else CServer::is_MPI_Initialized=false ; 
     181       
     182  
     183    if(!CServer::is_MPI_Initialized) 
     184    { 
     185      MPI_Init(NULL, NULL); 
     186    } 
     187       
    125188    set_new_handler(noMemory); 
    126189    std::set<StdString> parseList; 
     
    133196  void CXios::initServerSide(void) 
    134197  { 
    135     initServer(); 
     198     
    136199    isClient = false; 
    137200    isServer = true; 
    138  
     201     
     202    initServer(); 
     203     
     204     
    139205    // Initialize all aspects MPI 
    140206    CServer::initialize(); 
     
    162228       delete globalRegistry ; 
    163229     } 
     230 
    164231    CServer::finalize(); 
     232         
    165233    CServer::closeInfoStream(); 
    166234  } 
Note: See TracChangeset for help on using the changeset viewer.