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

    r1587 r1601  
    1212#include "buffer_client.hpp" 
    1313#include "string_tools.hpp" 
     14using namespace ep_lib; 
    1415 
    1516namespace xios 
     
    1819    MPI_Comm CClient::intraComm ; 
    1920    MPI_Comm CClient::interComm ; 
    20     std::list<MPI_Comm> CClient::contextInterComms; 
     21    std::list<MPI_Comm> *CClient::contextInterComms_ptr = 0; 
    2122    int CClient::serverLeader ; 
    2223    bool CClient::is_MPI_Initialized ; 
     
    2425    StdOFStream CClient::m_infoStream; 
    2526    StdOFStream CClient::m_errorStream; 
     27 
     28    StdOFStream CClient::array_infoStream[16]; 
     29 
    2630    MPI_Comm& CClient::getInterComm(void)   { return (interComm); } 
    27       
     31 
    2832///--------------------------------------------------------------- 
    2933/*! 
     
    106110            MPI_Comm_size(intraComm,&intraCommSize) ; 
    107111            MPI_Comm_rank(intraComm,&intraCommRank) ; 
    108             info(50)<<"intercommCreate::client "<<rank_<<" intraCommSize : "<<intraCommSize 
     112 
     113            MPI_Intercomm_create(intraComm, 0, CXios::globalComm, serverLeader, 0, &interComm) ; 
     114            #pragma omp critical (_output) 
     115            { 
     116              info(50)<<"intercommCreate::client "<<rank_<<" intraCommSize : "<<intraCommSize 
    109117                   <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< serverLeader<<endl ; 
    110              MPI_Intercomm_create(intraComm, 0, CXios::globalComm, serverLeader, 0, &interComm) ; 
    111              //rank_ = intraCommRank; 
     118            } 
    112119          } 
    113120          else 
     
    191198        CContext::setCurrent(id); 
    192199 
    193         contextInterComms.push_back(contextInterComm); 
     200        if(contextInterComms_ptr == NULL) contextInterComms_ptr = new std::list<MPI_Comm>; 
     201        contextInterComms_ptr->push_back(contextInterComm); 
    194202      } 
    195203      else 
     
    217225 
    218226        MPI_Intercomm_create(contextComm,0,CXios::globalComm,serverLeader,10+globalRank,&contextInterComm) ; 
     227        #pragma omp critical (_output) 
    219228        info(10)<<"Register new Context : "<<id<<endl ; 
    220229        MPI_Comm inter ; 
     
    224233        context->initClient(contextComm,contextInterComm) ; 
    225234 
    226         contextInterComms.push_back(contextInterComm); 
     235        if(contextInterComms_ptr == NULL) contextInterComms_ptr = new std::list<MPI_Comm>; 
     236        contextInterComms_ptr->push_back(contextInterComm); 
     237 
    227238        MPI_Comm_free(&inter); 
    228239        delete [] buff ; 
     
    277288      } 
    278289 
    279       for (std::list<MPI_Comm>::iterator it = contextInterComms.begin(); it != contextInterComms.end(); it++) 
     290      for (std::list<MPI_Comm>::iterator it = contextInterComms_ptr->begin(); it != contextInterComms_ptr->end(); it++) 
    280291        MPI_Comm_free(&(*it)); 
    281292      MPI_Comm_free(&interComm); 
     
    287298      if (!is_MPI_Initialized) 
    288299      { 
    289         if (CXios::usingOasis) oasis_finalize(); 
    290         else MPI_Finalize() ; 
    291       } 
    292        
     300        //if (CXios::usingOasis) oasis_finalize(); 
     301        //else 
     302        MPI_Finalize() ; 
     303      } 
     304      #pragma omp critical (_output) 
    293305      info(20) << "Client side context is finalized"<<endl ; 
    294       report(0) <<" Performance report : Whole time from XIOS init and finalize: "<< CTimer::get("XIOS init/finalize").getCumulatedTime()<<" s"<<endl ; 
    295       report(0) <<" Performance report : total time spent for XIOS : "<< CTimer::get("XIOS").getCumulatedTime()<<" s"<<endl ; 
    296       report(0)<< " Performance report : time spent for waiting free buffer : "<< CTimer::get("Blocking time").getCumulatedTime()<<" s"<<endl ; 
    297       report(0)<< " Performance report : Ratio : "<< CTimer::get("Blocking time").getCumulatedTime()/CTimer::get("XIOS init/finalize").getCumulatedTime()*100.<<" %"<<endl ; 
    298       report(0)<< " Performance report : This ratio must be close to zero. Otherwise it may be usefull to increase buffer size or numbers of server"<<endl ; 
     306 
     307      #pragma omp critical (_output) 
     308      { 
     309        report(0) <<" Performance report : Whole time from XIOS init and finalize: "<< CTimer::get("XIOS init/finalize").getCumulatedTime()<<" s"<<endl ; 
     310        report(0) <<" Performance report : total time spent for XIOS : "<< CTimer::get("XIOS").getCumulatedTime()<<" s"<<endl ; 
     311        report(0)<< " Performance report : time spent for waiting free buffer : "<< CTimer::get("Blocking time").getCumulatedTime()<<" s"<<endl ; 
     312        report(0)<< " Performance report : Ratio : "<< CTimer::get("Blocking time").getCumulatedTime()/CTimer::get("XIOS init/finalize").getCumulatedTime()*100.<<" %"<<endl ; 
     313        report(0)<< " Performance report : This ratio must be close to zero. Otherwise it may be usefull to increase buffer size or numbers of server"<<endl ; 
    299314//      report(0)<< " Memory report : Current buffer_size : "<<CXios::bufferSize<<endl ; 
    300       report(0)<< " Memory report : Minimum buffer size required : " << CClientBuffer::maxRequestSize << " bytes" << endl ; 
    301       report(0)<< " Memory report : increasing it by a factor will increase performance, depending of the volume of data wrote in file at each time step of the file"<<endl ; 
    302       report(100)<<CTimer::getAllCumulatedTime()<<endl ; 
     315        report(0)<< " Memory report : Minimum buffer size required : " << CClientBuffer::maxRequestSize << " bytes" << endl ; 
     316        report(0)<< " Memory report : increasing it by a factor will increase performance, depending of the volume of data wrote in file at each time step of the file"<<endl ; 
     317        report(100)<<CTimer::getAllCumulatedTime()<<endl ; 
     318      } 
    303319   } 
    304320 
     
    355371    void CClient::openInfoStream(const StdString& fileName) 
    356372    { 
    357       std::filebuf* fb = m_infoStream.rdbuf(); 
    358       openStream(fileName, ".out", fb); 
    359  
    360       info.write2File(fb); 
    361       report.write2File(fb); 
     373      info_FB[omp_get_thread_num()] = array_infoStream[omp_get_thread_num()].rdbuf(); 
     374           
     375      openStream(fileName, ".out", info_FB[omp_get_thread_num()]); 
     376 
     377      info.write2File(info_FB[omp_get_thread_num()]); 
     378      report.write2File(info_FB[omp_get_thread_num()]); 
    362379    } 
    363380 
Note: See TracChangeset for help on using the changeset viewer.