Ignore:
Timestamp:
01/23/19 10:31:44 (5 years ago)
Author:
yushan
Message:

dev on ADA. add flag switch _usingEP/_usingMPI

File:
1 edited

Legend:

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

    r1556 r1642  
    1111#include "memtrack.hpp" 
    1212#include "registry.hpp" 
    13 using namespace ep_lib; 
    1413 
    1514namespace xios 
    1615{ 
    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"; 
     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"; 
     22 
     23  bool CXios::xiosStack = true; 
     24  bool CXios::systemStack = false; 
    2325 
    2426  bool CXios::isClient ; 
    2527  bool CXios::isServer ; 
    26   MPI_Comm CXios::globalComm ; 
     28  ep_lib::MPI_Comm CXios::globalComm ; 
    2729  bool CXios::usingOasis ; 
    2830  bool CXios::usingServer = false; 
     
    4446  { 
    4547    set_new_handler(noMemory); 
    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 
     48    parseFile(rootFile); 
    5549    parseXiosConfig(); 
    5650  } 
     
    7165    printLogs2Files=getin<bool>("print_file",false); 
    7266 
     67    xiosStack=getin<bool>("xios_stack",true) ; 
     68    systemStack=getin<bool>("system_stack",false) ; 
     69    if (xiosStack && systemStack) 
     70    { 
     71      xiosStack = false; 
     72    } 
     73 
    7374    StdString bufMemory("memory"); 
    7475    StdString bufPerformance("performance"); 
     
    8990 
    9091    checkEventSync = getin<bool>("check_event_sync", checkEventSync); 
    91  
    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()]; 
     92    #ifdef _usingMPI 
     93    globalComm=MPI_COMM_WORLD ; 
     94    #elif _usingEP 
     95    ep_lib::MPI_Comm *ep_comm; 
     96    ep_lib::MPI_Info info; 
     97    ep_lib::MPI_Comm_create_endpoints(EP_COMM_WORLD->mpi_comm, 1, info, ep_comm); 
     98    ep_lib::passage = ep_comm; 
     99    globalComm=ep_lib::passage[0] ; 
     100    #endif 
    116101  } 
    117102 
     
    122107  \param [in/out] returnComm communicator corresponding to group of client with same codeId 
    123108  */ 
    124   void CXios::initClientSide(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm) 
     109  void CXios::initClientSide(const string& codeId, ep_lib::MPI_Comm& localComm, ep_lib::MPI_Comm& returnComm) 
     110  TRY 
    125111  { 
    126112    isClient = true; 
     
    129115    initialize() ; 
    130116 
     117 
    131118    CClient::initialize(codeId,localComm,returnComm) ; 
    132119    if (CClient::getRank()==0) globalRegistry = new CRegistry(returnComm) ; 
     120 
    133121 
    134122    // If there are no server processes then we are in attached mode 
     
    138126    if (printLogs2Files) 
    139127    { 
    140       #pragma omp critical 
    141128      CClient::openInfoStream(clientFile); 
    142129      CClient::openErrorStream(clientFile); 
     
    148135    } 
    149136  } 
     137  CATCH 
    150138 
    151139  void CXios::clientFinalize(void) 
     
    154142     if (CClient::getRank()==0) 
    155143     { 
    156        #pragma omp critical (_output) 
    157144       info(80)<<"Write data base Registry"<<endl<<globalRegistry->toString()<<endl ; 
    158145       globalRegistry->toFile("xios_registry.bin") ; 
     
    190177  void CXios::initServerSide(void) 
    191178  { 
    192      
    193179    isClient = false; 
    194180    isServer = true; 
    195181 
    196182    initServer(); 
    197  
     183    isClient = false; 
     184    isServer = true; 
    198185    // Initialize all aspects MPI 
    199186    CServer::initialize(); 
     
    248235        int firstPoolGlobalRank = secondaryServerGlobalRanks[0]; 
    249236        int rankGlobal; 
    250         MPI_Comm_rank(globalComm, &rankGlobal); 
     237        ep_lib::MPI_Comm_rank(globalComm, &rankGlobal); 
    251238 
    252239        // Merge registries defined on each pools 
     
    260247            globalRegistrySndServers.mergeRegistry(*globalRegistry) ; 
    261248            int registrySize = globalRegistrySndServers.size(); 
    262             MPI_Send(&registrySize,1,MPI_LONG,firstPoolGlobalRank,15,CXios::globalComm) ; 
     249            ep_lib::MPI_Send(&registrySize,1,EP_LONG,firstPoolGlobalRank,15,CXios::globalComm) ; 
    263250            CBufferOut buffer(registrySize) ; 
    264251            globalRegistrySndServers.toBuffer(buffer) ; 
    265             MPI_Send(buffer.start(),registrySize,MPI_CHAR,firstPoolGlobalRank,15,CXios::globalComm) ; 
     252            ep_lib::MPI_Send(buffer.start(),registrySize,EP_CHAR,firstPoolGlobalRank,15,CXios::globalComm) ; 
    266253          } 
    267254        } 
     
    270257        if (rankGlobal == firstPoolGlobalRank) 
    271258        { 
    272           MPI_Status status; 
     259          ep_lib::MPI_Status status; 
    273260          char* recvBuff; 
    274261 
     
    279266            int rank = secondaryServerGlobalRanks[i]; 
    280267            int registrySize = 0; 
    281             MPI_Recv(&registrySize, 1, MPI_LONG, rank, 15, CXios::globalComm, &status); 
     268            ep_lib::MPI_Recv(&registrySize, 1, EP_LONG, rank, 15, CXios::globalComm, &status); 
    282269            recvBuff = new char[registrySize]; 
    283             MPI_Recv(recvBuff, registrySize, MPI_CHAR, rank, 15, CXios::globalComm, &status); 
     270            ep_lib::MPI_Recv(recvBuff, registrySize, EP_CHAR, rank, 15, CXios::globalComm, &status); 
    284271            CBufferIn buffer(recvBuff, registrySize) ; 
    285272            CRegistry recvRegistry; 
Note: See TracChangeset for help on using the changeset viewer.