Ignore:
Timestamp:
05/11/17 16:12:23 (7 years ago)
Author:
yushan
Message:

log OK with threads

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/branch_yushan/src/client.cpp

    r1126 r1128  
    1111#include "timer.hpp" 
    1212#include "buffer_client.hpp" 
     13#include "log.hpp" 
     14 
    1315 
    1416namespace xios 
    1517{ 
     18    extern int test_omp_rank; 
     19    #pragma omp threadprivate(test_omp_rank) 
    1620 
    1721    MPI_Comm CClient::intraComm ; 
     
    2428    StdOFStream CClient::m_errorStream; 
    2529 
     30    StdOFStream CClient::array_infoStream[10]; 
     31 
    2632    void CClient::initialize(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm) 
    2733    { 
     
    103109            MPI_Comm_size(intraComm,&intraCommSize) ; 
    104110            MPI_Comm_rank(intraComm,&intraCommRank) ; 
     111             
    105112            #pragma omp critical(_output) 
    106113            { 
    107               info(50)<<"intercommCreate::client "<<rank<<" intraCommSize : "<<intraCommSize 
     114              info(10)<<"intercommCreate::client "<<test_omp_rank<< " "<< &test_omp_rank <<" intraCommSize : "<<intraCommSize 
    108115                 <<" intraCommRank :"<<intraCommRank<<"  serverLeader "<< serverLeader 
    109116                 <<" globalComm : "<< &(CXios::globalComm) << endl ;   
    110117            } 
     118 
     119             
    111120             
    112121            MPI_Intercomm_create(intraComm,0,CXios::globalComm,serverLeader,0,&interComm) ; 
     
    162171      MPI_Comm_dup(intraComm,&returnComm) ; 
    163172 
     173       
     174 
    164175    } 
    165176 
     
    167178    void CClient::registerContext(const string& id,MPI_Comm contextComm) 
    168179    { 
    169       //#pragma omp critical(_output) 
    170       //info(50) << "Client "<<getRank() << " start registerContext using info output" << endl; 
    171180 
    172181      CContext::setCurrent(id) ; 
     
    175184      int tmp_rank; 
    176185      MPI_Comm_rank(contextComm,&tmp_rank) ; 
    177        
    178       // #pragma omp critical (_output) 
    179       //printf("Client %d : client.cpp Client::registerContext %s context add = %p\n", tmp_rank, id, &(*context)); 
    180        
    181186       
    182187      StdString idServer(id); 
     
    214219        MPI_Intercomm_create(contextComm,0,CXios::globalComm,serverLeader,10+globalRank,&contextInterComm) ; 
    215220         
    216         //#pragma omp critical (_output) 
    217         //info(10)<<"Register new Context : "<<id<<endl ; 
    218                        
     221        #pragma omp critical(_output) 
     222        info(10)<<" RANK "<< tmp_rank<<" Register new Context : "<<id<<endl ; 
     223 
    219224 
    220225        MPI_Comm inter ; 
     
    224229         
    225230        context->initClient(contextComm,contextInterComm) ; 
    226          
    227         // #pragma omp critical (_output) 
    228         // printf("Client %d : context->initClient(contextComm,contextInterComm) OK \n", getRank()) ; 
    229          
    230         //contextInterComms->push_back(contextInterComm); 
     231 
     232         
    231233        if(contextInterComms_ptr == NULL) contextInterComms_ptr = new std::list<MPI_Comm>; 
    232234        contextInterComms_ptr->push_back(contextInterComm); 
     
    251253        if(contextInterComms_ptr == NULL) contextInterComms_ptr = new std::list<MPI_Comm>; 
    252254        contextInterComms_ptr->push_back(contextInterComm); 
    253         //contextInterComms->push_back(contextInterComm); 
     255 
    254256      } 
    255257    } 
     
    286288      } 
    287289       
    288        
    289         //info(20) << "Client "<<rank<<" : Client side context is finalized "<< endl ; 
    290 //         report(0) <<"     Performance report : total time spent for XIOS : "<< CTimer::get("XIOS").getCumulatedTime()<<" s"<<endl ; 
    291 //         report(0)<< "     Performance report : time spent for waiting free buffer : "<< CTimer::get("Blocking time").getCumulatedTime()<<" s"<<endl ; 
    292 //         report(0)<< "     Performance report : Ratio : "<< CTimer::get("Blocking time").getCumulatedTime()/CTimer::get("XIOS").getCumulatedTime()*100.<<" %"<<endl ; 
    293 //         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 ; 
    294 // //      report(0)<< "     Memory report : Current buffer_size : "<<CXios::bufferSize<<endl ; 
    295 //         report(0)<< "     Memory report : Minimum buffer size required : " << CClientBuffer::maxRequestSize << " bytes" << endl ; 
    296 //         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 ; 
    297        
    298  
     290      #pragma omp critical (_output) 
     291      info(20) << "Client "<<rank<<" : Client side context is finalized "<< endl ; 
     292 
     293  /*    #pragma omp critical (_output) 
     294      { 
     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").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 ; 
     299         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       }       
     303*/ 
    299304   } 
    300305 
     
    325330 
    326331      fileNameClient << fileName << "_" << std::setfill('0') << std::setw(numDigit) << getRank() << ext; 
    327       //printf("getrank() = %d, file name = %s\n", getRank(), fileNameClient.str().c_str()); 
    328        
    329         fb->open(fileNameClient.str().c_str(), std::ios::out); 
    330         if (!fb->is_open()) 
    331           ERROR("void CClient::openStream(const StdString& fileName, const StdString& ext, std::filebuf* fb)", 
    332               << std::endl << "Can not open <" << fileNameClient << "> file to write the client log(s).");   
     332       
     333      fb->open(fileNameClient.str().c_str(), std::ios::out); 
     334      if (!fb->is_open()) 
     335        ERROR("void CClient::openStream(const StdString& fileName, const StdString& ext, std::filebuf* fb)", 
     336            << std::endl << "Can not open <" << fileNameClient << "> file to write the client log(s).");   
    333337       
    334338       
     
    343347    void CClient::openInfoStream(const StdString& fileName) 
    344348    { 
    345       std::filebuf* fb = m_infoStream.rdbuf(); 
    346       openStream(fileName, ".out", fb); 
    347  
    348       info.write2File(fb); 
    349       report.write2File(fb); 
     349      //std::filebuf* fb = m_infoStream.rdbuf(); 
     350 
     351      info_FB[omp_get_thread_num()] = array_infoStream[omp_get_thread_num()].rdbuf(); 
     352           
     353      openStream(fileName, ".out", info_FB[omp_get_thread_num()]); 
     354 
     355      info.write2File(info_FB[omp_get_thread_num()]); 
     356      report.write2File(info_FB[omp_get_thread_num()]); 
     357       
    350358    } 
    351359 
Note: See TracChangeset for help on using the changeset viewer.