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

    r1587 r1601  
    1515#include "event_scheduler.hpp" 
    1616#include "string_tools.hpp" 
     17using namespace ep_lib; 
    1718 
    1819namespace xios 
     
    4748    void CServer::initialize(void) 
    4849    { 
    49       int initialized ; 
    50       MPI_Initialized(&initialized) ; 
    51       if (initialized) is_MPI_Initialized=true ; 
    52       else is_MPI_Initialized=false ; 
     50      //int initialized ; 
     51      //MPI_Initialized(&initialized) ; 
     52      //if (initialized) is_MPI_Initialized=true ; 
     53      //else is_MPI_Initialized=false ; 
    5354      int rank ; 
    5455 
     
    5758      { 
    5859 
    59         if (!is_MPI_Initialized) 
    60         { 
    61           MPI_Init(NULL, NULL); 
    62         } 
     60        //if (!is_MPI_Initialized) 
     61        //{ 
     62        //  MPI_Init(NULL, NULL); 
     63        //} 
    6364        CTimer::get("XIOS").resume() ; 
    6465 
     
    152153            if (serverLevel==2) 
    153154            { 
     155              #pragma omp critical (_output) 
    154156              info(50)<<"The number of secondary server pools is "<< sndServerGlobalRanks.size() <<endl ; 
    155157              for (i=0; i<sndServerGlobalRanks.size(); i++) 
     
    188190              MPI_Comm_size(intraComm,&intraCommSize) ; 
    189191              MPI_Comm_rank(intraComm,&intraCommRank) ; 
    190               info(50)<<"intercommCreate::server (classical mode) "<<rank_<<" intraCommSize : "<<intraCommSize 
     192 
     193              MPI_Intercomm_create(intraComm, 0, CXios::globalComm, clientLeader, 0, &newComm) ; 
     194              #pragma omp critical (_output) 
     195              { 
     196                info(50)<<"intercommCreate::server (classical mode) "<<rank_<<" intraCommSize : "<<intraCommSize 
    191197                       <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< clientLeader<<endl ; 
    192  
    193               MPI_Intercomm_create(intraComm, 0, CXios::globalComm, clientLeader, 0, &newComm) ; 
     198              } 
     199               
    194200              interCommLeft.push_back(newComm) ; 
    195201            } 
     
    209215              MPI_Comm_size(intraComm, &intraCommSize) ; 
    210216              MPI_Comm_rank(intraComm, &intraCommRank) ; 
    211               info(50)<<"intercommCreate::server (server level 1) "<<rank_<<" intraCommSize : "<<intraCommSize 
     217               
     218              MPI_Intercomm_create(intraComm, 0, CXios::globalComm, clientLeader, 0, &newComm) ; 
     219              #pragma omp critical (_output) 
     220              { 
     221                info(50)<<"intercommCreate::server (server level 1) "<<rank_<<" intraCommSize : "<<intraCommSize 
    212222                       <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< clientLeader<<endl ; 
    213               MPI_Intercomm_create(intraComm, 0, CXios::globalComm, clientLeader, 0, &newComm) ; 
     223              } 
    214224              interCommLeft.push_back(newComm) ; 
    215225            } 
     
    221231            MPI_Comm_size(intraComm, &intraCommSize) ; 
    222232            MPI_Comm_rank(intraComm, &intraCommRank) ; 
    223             info(50)<<"intercommCreate::client (server level 1) "<<rank_<<" intraCommSize : "<<intraCommSize 
     233 
     234            MPI_Intercomm_create(intraComm, 0, CXios::globalComm, sndServerGlobalRanks[i], 1, &newComm) ; 
     235            #pragma omp critical (_output) 
     236            { 
     237              info(50)<<"intercommCreate::client (server level 1) "<<rank_<<" intraCommSize : "<<intraCommSize 
    224238                <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< sndServerGlobalRanks[i]<<endl ; 
    225             MPI_Intercomm_create(intraComm, 0, CXios::globalComm, sndServerGlobalRanks[i], 1, &newComm) ; 
     239            } 
    226240            interCommRight.push_back(newComm) ; 
    227241          } 
     
    234248          MPI_Comm_size(intraComm, &intraCommSize) ; 
    235249          MPI_Comm_rank(intraComm, &intraCommRank) ; 
    236           info(50)<<"intercommCreate::server (server level 2) "<<rank_<<" intraCommSize : "<<intraCommSize 
     250 
     251          MPI_Intercomm_create(intraComm, 0, CXios::globalComm, clientLeader, 1, &newComm) ; 
     252          #pragma omp critical (_output) 
     253          { 
     254            info(50)<<"intercommCreate::server (server level 2) "<<rank_<<" intraCommSize : "<<intraCommSize 
    237255                   <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< clientLeader<<endl ; 
    238  
    239           MPI_Intercomm_create(intraComm, 0, CXios::globalComm, clientLeader, 1, &newComm) ; 
     256          } 
     257 
    240258          interCommLeft.push_back(newComm) ; 
    241259        } 
     
    426444      { 
    427445        if (CXios::usingOasis) oasis_finalize(); 
    428         else MPI_Finalize() ; 
     446        //else MPI_Finalize() ; 
    429447      } 
     448 
    430449      report(0)<<"Performance report : Time spent for XIOS : "<<CTimer::get("XIOS server").getCumulatedTime()<<endl  ; 
    431450      report(0)<<"Performance report : Time spent in processing events : "<<CTimer::get("Process events").getCumulatedTime()<<endl  ; 
     
    637656       { 
    638657         traceOff() ; 
    639          MPI_Iprobe(MPI_ANY_SOURCE,1,CXios::globalComm, &flag, &status) ; 
     658         MPI_Iprobe(-2,1,CXios::globalComm, &flag, &status) ; 
    640659         traceOn() ; 
    641660         if (flag==true) 
    642661         { 
     662           #ifdef _usingMPI 
    643663           rank=status.MPI_SOURCE ; 
     664           #elif _usingEP 
     665           rank=status.ep_src; 
     666           #endif 
    644667           MPI_Get_count(&status,MPI_CHAR,&count) ; 
    645668           buffer=new char[count] ; 
     
    655678         if (flag==true) 
    656679         { 
     680           #ifdef _usingMPI 
    657681           rank=status.MPI_SOURCE ; 
     682           #elif _usingEP 
     683           rank=status.ep_src; 
     684           #endif 
    658685           MPI_Get_count(&status,MPI_CHAR,&count) ; 
    659686           recvContextMessage((void*)buffer,count) ; 
     
    740767         MPI_Get_count(&status,MPI_CHAR,&(counts.back())) ; 
    741768         buffers.push_back(new char[counts.back()]) ; 
     769         MPI_Irecv((void*)(buffers.back()),counts.back(),MPI_CHAR,root,2,intraComm,&request) ; 
    742770         requests.push_back(request); 
    743          MPI_Irecv((void*)(buffers.back()),counts.back(),MPI_CHAR,root,2,intraComm,&(requests.back())) ; 
    744771         isEventRegistered.push_back(false); 
    745772         isEventQueued.push_back(false); 
     
    750777       { 
    751778         // (2) If context id is received, register an event 
    752          MPI_Test(&requests[ctxNb],&flag,&status) ; 
     779         if(!isEventRegistered[ctxNb]) MPI_Test(&requests[ctxNb],&flag,&status) ; 
    753780         if (flag==true && !isEventRegistered[ctxNb]) 
    754781         { 
     
    794821         MPI_Intercomm_merge(contextInterComm,1,&inter); 
    795822         MPI_Barrier(inter); 
    796          MPI_Comm_free(&inter); 
    797823         context->initServer(intraComm,contextInterComm); 
    798824         contextInterComms.push_back(contextInterComm); 
    799825 
     826         MPI_Comm_free(&inter); 
    800827       } 
    801828       // Secondary server: create communication channel with a primary server 
Note: See TracChangeset for help on using the changeset viewer.