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/server.cpp

    r1032 r1134  
    99#include <boost/functional/hash.hpp> 
    1010#include <boost/algorithm/string.hpp> 
    11 #include "mpi.hpp" 
    1211#include "tracer.hpp" 
    1312#include "timer.hpp" 
     
    2625    bool CServer::finished=false ; 
    2726    bool CServer::is_MPI_Initialized ; 
     27 
     28     
    2829    CEventScheduler* CServer::eventScheduler = 0; 
    2930    
    3031    void CServer::initialize(void) 
    3132    { 
    32       int initialized ; 
    33       MPI_Initialized(&initialized) ; 
    34       if (initialized) is_MPI_Initialized=true ; 
    35       else is_MPI_Initialized=false ; 
    36  
    3733      // Not using OASIS 
    3834      if (!CXios::usingOasis) 
    3935      { 
    4036 
    41         if (!is_MPI_Initialized) 
    42         { 
    43           MPI_Init(NULL, NULL); 
    44         } 
    4537        CTimer::get("XIOS").resume() ; 
    4638 
     
    5042        unsigned long* hashAll ; 
    5143 
    52 //        int rank ; 
     44 
    5345        int size ; 
    5446        int myColor ; 
     
    7769 
    7870        myColor=colors[hashServer] ; 
    79         MPI_Comm_split(MPI_COMM_WORLD,myColor,rank,&intraComm) ; 
    80  
     71 
     72 
     73        MPI_Comm_split(CXios::globalComm,myColor,rank,&intraComm) ; 
     74 
     75         
    8176        int serverLeader=leaders[hashServer] ; 
    8277        int clientLeader; 
    8378 
    8479         serverLeader=leaders[hashServer] ; 
    85          for(it=leaders.begin();it!=leaders.end();it++) 
     80         for(it=leaders.begin();it!=leaders.end();++it) 
    8681         { 
    8782           if (it->first!=hashServer) 
     
    10499      else 
    105100      { 
    106 //        int rank ,size; 
    107101        int size; 
    108102        if (!is_MPI_Initialized) oasis_init(CXios::xiosCodeId); 
     
    135129      } 
    136130 
    137 //      int rank; 
    138131      MPI_Comm_rank(intraComm,&rank) ; 
    139132      if (rank==0) isRoot=true; 
     
    149142      delete eventScheduler ; 
    150143 
    151       for (std::list<MPI_Comm>::iterator it = contextInterComms.begin(); it != contextInterComms.end(); it++) 
     144      for (std::list<MPI_Comm>::iterator it = contextInterComms.begin(); it != contextInterComms.end(); ++it) 
    152145        MPI_Comm_free(&(*it)); 
    153       for (std::list<MPI_Comm>::iterator it = interComm.begin(); it != interComm.end(); it++) 
     146      for (std::list<MPI_Comm>::iterator it = interComm.begin(); it != interComm.end(); ++it) 
    154147        MPI_Comm_free(&(*it)); 
     148 
    155149      MPI_Comm_free(&intraComm); 
    156150 
     
    158152      { 
    159153        if (CXios::usingOasis) oasis_finalize(); 
    160         else MPI_Finalize() ; 
     154        //else  {MPI_Finalize() ;} 
    161155      } 
     156 
     157       
    162158      report(0)<<"Performance report : Time spent for XIOS : "<<CTimer::get("XIOS server").getCumulatedTime()<<endl  ; 
    163159      report(0)<<"Performance report : Time spent in processing events : "<<CTimer::get("Process events").getCumulatedTime()<<endl  ; 
     
    180176         { 
    181177           listenRootContext(); 
    182            if (!finished) listenRootFinalize() ; 
     178           if (!finished)  
     179           { 
     180             listenRootFinalize() ; 
     181           } 
    183182         } 
    184183 
    185184         contextEventLoop() ; 
    186185         if (finished && contextList.empty()) stop=true ; 
     186          
    187187         eventScheduler->checkEvent() ; 
    188188       } 
     189        
     190        
    189191       CTimer::get("XIOS server").suspend() ; 
    190192     } 
     
    196198        int flag ; 
    197199 
    198         for(it=interComm.begin();it!=interComm.end();it++) 
     200        for(it=interComm.begin();it!=interComm.end();++it) 
    199201        { 
    200202           MPI_Status status ; 
     
    206208              MPI_Recv(&msg,1,MPI_INT,0,0,*it,&status) ; 
    207209              info(20)<<" CServer : Receive client finalize"<<endl ; 
     210 
    208211              MPI_Comm_free(&(*it)); 
    209212              interComm.erase(it) ; 
     
    259262       { 
    260263         traceOff() ; 
     264         #ifdef _usingEP 
     265         MPI_Iprobe(-1,1,CXios::globalComm, &flag, &status) ; 
     266         #else 
    261267         MPI_Iprobe(MPI_ANY_SOURCE,1,CXios::globalComm, &flag, &status) ; 
     268         #endif 
    262269         traceOn() ; 
     270          
    263271         if (flag==true) 
    264272         { 
     273           #ifdef _usingMPI 
    265274           rank=status.MPI_SOURCE ; 
     275           #elif _usingEP 
     276           rank= status.ep_src ; 
     277           #endif 
    266278           MPI_Get_count(&status,MPI_CHAR,&count) ; 
    267279           buffer=new char[count] ; 
     
    277289         if (flag==true) 
    278290         { 
     291           #ifdef _usingMPI 
    279292           rank=status.MPI_SOURCE ; 
     293           #elif _usingEP 
     294           rank= status.ep_src ; 
     295           #endif 
    280296           MPI_Get_count(&status,MPI_CHAR,&count) ; 
    281297           recvContextMessage((void*)buffer,count) ; 
     
    399415       bool finished ; 
    400416       map<string,CContext*>::iterator it ; 
    401        for(it=contextList.begin();it!=contextList.end();it++) 
     417       for(it=contextList.begin();it!=contextList.end();++it) 
    402418       { 
    403419         finished=it->second->checkBuffersAndListen(); 
Note: See TracChangeset for help on using the changeset viewer.