Changeset 2420 for XIOS3


Ignore:
Timestamp:
10/13/22 15:45:43 (19 months ago)
Author:
jderouillat
Message:

Add an option (log_memory : set to false by default), to activate memory monitoring. Logs are now buffered.

Location:
XIOS3/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • XIOS3/trunk/bld.cfg

    r2409 r2420  
    5353bld::target xios_server.exe  
    5454bld::target generic_testcase.exe  
    55 bld::target test_ugrid.exe  
     55#bld::target test_ugrid.exe  
    5656#bld::target test_regular.exe 
    5757#bld::target test_xios2_cmip6.exe 
  • XIOS3/trunk/scripts/plotly_memory.js

    r2419 r2420  
    7272        title: "Memory consumption", 
    7373        xaxis: { 
    74             title: "Time (ms)", 
     74            title: "Time (s)", 
    7575        }, 
    7676        yaxis: { 
  • XIOS3/trunk/src/cxios.cpp

    r2419 r2420  
    5656  bool CXios::checkSumRecv=false ; 
    5757  bool CXios::checkSumSend=false ; 
     58  bool CXios::logMemory=false ; 
    5859 
    5960  CDaemonsManager*    CXios::daemonsManager_=nullptr ; 
     
    117118    checkSumSend = getin<bool>("checksum_send_fields", false); 
    118119    checkSumRecv = getin<bool>("checksum_recv_fields", false); 
     120     
     121    logMemory = getin<bool>("log_memory", false); 
    119122 
    120123    globalComm=MPI_COMM_WORLD ; 
     
    157160  void CXios::clientFinalize(void) 
    158161  { 
    159      CMemChecker::logMem("CXios::clientFinalize"); 
     162     CMemChecker::logMem("CXios::clientFinalize", true); 
    160163 
    161164     CClient::finalize() ; 
  • XIOS3/trunk/src/cxios.hpp

    r2407 r2420  
    6868     static bool checkSumRecv; //!< For debugging, compute a checksum of fields received by the model through the XIOS client 
    6969 
     70     static bool logMemory; //!< Activate memory monitoring for all XIOS process 
     71     
    7072     static const string defaultPoolId ; 
    7173     static const string defaultServerId ; 
  • XIOS3/trunk/src/mem_checker.cpp

    r2419 r2420  
    11#include "mem_checker.hpp" 
     2#include "cxios.hpp" 
    23#include "mpi.hpp" 
    34#include <string> 
     
    56#include <iostream> 
    67#include <sstream> 
    7 #include <fstream> 
    88 
    99#include <fcntl.h> 
     
    2020  double CMemChecker::vsize_init_=0; 
    2121  double CMemChecker::time_init_=0; 
    22  
     22  std::ofstream CMemChecker::fout_; 
     23  int CMemChecker::flush_counter_=1; 
     24   
    2325  CMemChecker::CMemChecker(const std::string& name) : name_(name)  
    2426  {  
     
    6466  void CMemChecker::logMem( std::string id, bool finalizeLog ) 
    6567  { 
    66     // function get_xios_mem_data() { 
    67     //   return [ 
    68     //        ... 
    69     //        [ "2000-01-01 01:00:10.XXX", "XIOS close context def", 1000], 
    70     //        [ "2000-01-01 01:00:11.XXX", "update timestep"       , 1000], 
    71     //        [ "2000-01-01 01:00:15.XXX", "send field"            , 2000], 
    72     //        ... 
    73     //   ]; 
    74     // } 
    75      
    76     std::ofstream fout; 
     68    if ( !CXios::logMemory ) return ; 
     69 
    7770    int rk = 0; 
    7871    MPI_Comm_rank( MPI_COMM_WORLD, &rk ); 
     
    8073    double mem = getMemRSS(); 
    8174    if (!mem) { 
    82       fout.open( logName ); 
    83       fout << "time,event,memory" << std::endl; 
    84     } 
    85     else 
    86     { 
    87       fout.open( logName, std::ios_base::app ); 
     75      fout_.open( logName ); 
     76      fout_ << "time,event,memory" << std::endl; 
    8877    } 
    8978 
     79    fout_.precision(4); 
    9080    // Time format : YYYY-MM-DD HH:MM:SS.XXX -> seconds * 1000. 
    91     fout << (MPI_Wtime()-time_init_)*1000. << "," << id << "," << mem/1000000. << std::endl; 
     81    fout_ << (MPI_Wtime()-time_init_) << "," << id << "," << mem/1000000. << std::endl; 
    9282 
    93     fout.close(); 
     83    if ((MPI_Wtime()-time_init_)>flush_counter_*600.) 
     84    { 
     85      fout_.flush(); 
     86      flush_counter_++; 
     87    } 
     88     
     89    if (finalizeLog) 
     90    { 
     91      fout_.close(); 
     92    } 
    9493  } 
    9594 
  • XIOS3/trunk/src/mem_checker.hpp

    r2418 r2420  
    44#include <string> 
    55#include <map> 
     6#include <fstream> 
    67 
    78namespace xios 
     
    3940      static double vsize_init_; 
    4041      static double time_init_; 
     42      static std::ofstream fout_; 
     43      static int flush_counter_; 
    4144  }; 
    4245} 
  • XIOS3/trunk/src/server.cpp

    r2419 r2420  
    434434      CXios::getMpiGarbageCollector().release() ; // release unfree MPI ressources 
    435435 
    436       CMemChecker::logMem( "CServer::finalize" ); 
     436      CMemChecker::logMem( "CServer::finalize", true ); 
    437437      if (!is_MPI_Initialized) 
    438438      { 
Note: See TracChangeset for help on using the changeset viewer.