Ignore:
Timestamp:
01/25/17 16:25:17 (7 years ago)
Author:
yushan
Message:

initialize the branch

File:
1 edited

Legend:

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

    r1029 r1037  
    3030  bool CXios::isOptPerformance = true; 
    3131  CRegistry* CXios::globalRegistry = 0; 
    32   double CXios::recvFieldTimeout = 10.0; 
    3332 
    3433  //! Parse configuration file and create some objects from it 
    3534  void CXios::initialize() 
    3635  { 
     36     
     37     
    3738    set_new_handler(noMemory); 
    3839    parseFile(rootFile); 
     
    6465    bufferSizeFactor = getin<double>("buffer_size_factor", defaultBufferSizeFactor); 
    6566    minBufferSize = getin<int>("min_buffer_size", 1024 * sizeof(double)); 
    66     recvFieldTimeout = getin<double>("recv_field_timeout", 10.0); 
    67     if (recvFieldTimeout < 0.0) 
    68       ERROR("CXios::parseXiosConfig()", "recv_field_timeout cannot be negative."); 
    69  
    70     globalComm=MPI_COMM_WORLD ; 
     67 
     68    int num_ep; 
     69    if(isClient)  
     70    {  
     71      num_ep = 1; 
     72    } 
     73     
     74    if(isServer)  
     75    {  
     76      num_ep = 1;  
     77    } 
     78     
     79    MPI_Info info; 
     80    MPI_Comm *ep_comm; 
     81    MPI_Comm_create_endpoints(MPI_COMM_WORLD, num_ep, info, ep_comm);  
     82       
     83    globalComm = ep_comm[0]; 
     84     
     85    int tmp_size; 
     86    MPI_Comm_size(globalComm, &tmp_size); 
     87    printf("globalcomm size = %d\n", tmp_size); 
     88 
     89     
    7190  } 
    7291 
     
    7998  void CXios::initClientSide(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm) 
    8099  { 
     100    isClient = true; 
     101     
    81102    initialize() ; 
    82103 
    83     isClient = true; 
    84  
     104    
    85105    CClient::initialize(codeId,localComm,returnComm) ; 
    86106    if (CClient::getRank()==0) globalRegistry = new CRegistry(returnComm) ; 
     
    89109    // and the clients are also servers 
    90110    isServer = !usingServer; 
    91  
     111     
     112     
    92113    if (printLogs2Files) 
    93114    { 
     
    100121      CClient::openErrorStream(); 
    101122    } 
     123     
     124    
    102125  } 
    103126 
     
    123146  void CXios::initServer() 
    124147  { 
     148    int initialized; 
     149    MPI_Initialized(&initialized); 
     150    if (initialized) CServer::is_MPI_Initialized=true ; 
     151    else CServer::is_MPI_Initialized=false ; 
     152       
     153  
     154    if(!CServer::is_MPI_Initialized) 
     155    { 
     156      MPI_Init(NULL, NULL); 
     157    } 
     158       
    125159    set_new_handler(noMemory); 
    126160    std::set<StdString> parseList; 
     
    133167  void CXios::initServerSide(void) 
    134168  { 
    135     initServer(); 
     169     
    136170    isClient = false; 
    137171    isServer = true; 
    138  
     172     
     173    initServer(); 
     174     
     175     
    139176    // Initialize all aspects MPI 
    140177    CServer::initialize(); 
    141178    if (CServer::getRank()==0) globalRegistry = new CRegistry(CServer::intraComm) ; 
    142179     
     180       
    143181    if (printLogs2Files) 
    144182    { 
     
    151189      CServer::openErrorStream(); 
    152190    } 
    153  
     191     
    154192    // Enter the loop to listen message from Client 
    155193    CServer::eventLoop(); 
     194     
     195    printf("server eventloop OK\n"); 
    156196 
    157197    // Finalize 
     
    162202       delete globalRegistry ; 
    163203     } 
     204      
     205     printf("server globalRegistry OK\n"); 
     206      
    164207    CServer::finalize(); 
     208     
     209    printf("server finalize OK\n"); 
     210     
    165211    CServer::closeInfoStream(); 
    166212  } 
Note: See TracChangeset for help on using the changeset viewer.