Ignore:
Timestamp:
11/19/18 15:52:54 (5 years ago)
Author:
yushan
Message:

branch_openmp merged with trunk r1597

File:
1 edited

Legend:

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

    r1519 r1601  
    1111#include "memtrack.hpp" 
    1212#include "registry.hpp" 
     13using namespace ep_lib; 
    1314 
    1415namespace xios 
    1516{ 
    16   string CXios::rootFile="./iodef.xml" ; 
    17   string CXios::xiosCodeId="xios.x" ; 
    18   string CXios::clientFile="./xios_client"; 
    19   string CXios::serverFile="./xios_server"; 
    20   string CXios::serverPrmFile="./xios_server1"; 
    21   string CXios::serverSndFile="./xios_server2"; 
     17  const string CXios::rootFile="./iodef.xml" ; 
     18  const string CXios::xiosCodeId="xios.x" ; 
     19  const string CXios::clientFile="./xios_client"; 
     20  const string CXios::serverFile="./xios_server"; 
     21  const string CXios::serverPrmFile="./xios_server1"; 
     22  const string CXios::serverSndFile="./xios_server2"; 
    2223 
    2324  bool CXios::isClient ; 
     
    4344  { 
    4445    set_new_handler(noMemory); 
    45     parseFile(rootFile); 
     46    int tmp_rank; 
     47    MPI_Comm_rank(MPI_COMM_WORLD, &tmp_rank); 
     48    #pragma omp critical 
     49    { 
     50      std::cout<<"thread "<<tmp_rank<<"("<<omp_get_thread_num()<<")"<<" parsing rootfile"<<std::endl; 
     51      parseFile(rootFile); 
     52      std::cout<<"thread "<<tmp_rank<<"("<<omp_get_thread_num()<<")"<<" parsed rootfile"<<std::endl; 
     53    } 
     54    #pragma omp barrier 
    4655    parseXiosConfig(); 
    4756  } 
     
    8190    checkEventSync = getin<bool>("check_event_sync", checkEventSync); 
    8291 
    83     globalComm=MPI_COMM_WORLD ; 
     92    //globalComm=MPI_COMM_WORLD ; 
     93    int num_ep; 
     94    if(isClient)   
     95    {  
     96      num_ep = omp_get_num_threads(); 
     97    } 
     98         
     99    if(isServer)  
     100    {  
     101      num_ep = 1; 
     102    } 
     103         
     104    MPI_Info info; 
     105    #pragma omp master 
     106    { 
     107      MPI_Comm *ep_comm; 
     108      MPI_Comm_create_endpoints(MPI_COMM_WORLD->mpi_comm, num_ep, info, ep_comm);  // servers should reach here too. 
     109      passage = ep_comm;  
     110    } 
     111         
     112    #pragma omp barrier 
     113     
     114           
     115    CXios::globalComm = passage[omp_get_thread_num()]; 
    84116  } 
    85117 
     
    92124  void CXios::initClientSide(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm) 
    93125  { 
     126    isClient = true; 
     127    isServer = false; 
     128 
    94129    initialize() ; 
    95  
    96     isClient = true; 
    97130 
    98131    CClient::initialize(codeId,localComm,returnComm) ; 
     
    105138    if (printLogs2Files) 
    106139    { 
     140      #pragma omp critical 
    107141      CClient::openInfoStream(clientFile); 
    108142      CClient::openErrorStream(clientFile); 
     
    120154     if (CClient::getRank()==0) 
    121155     { 
     156       #pragma omp critical (_output) 
    122157       info(80)<<"Write data base Registry"<<endl<<globalRegistry->toString()<<endl ; 
    123158       globalRegistry->toFile("xios_registry.bin") ; 
     
    155190  void CXios::initServerSide(void) 
    156191  { 
    157     initServer(); 
     192 
    158193    isClient = false; 
    159194    isServer = true; 
     195 
     196    initServer(); 
    160197 
    161198    // Initialize all aspects MPI 
Note: See TracChangeset for help on using the changeset viewer.