Changeset 1137


Ignore:
Timestamp:
05/18/17 17:26:56 (3 years ago)
Author:
ymipsl
Message:

Add "light" memory tracking which must be activated at compile time : make_xios --memtrack light

  • report at info level 10 : max memory consumption and the current memory consumption at the end of exection
  • info at info level 50 : at each timestep, the current memory consumption is printed

YM

Location:
XIOS/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/make_xios

    r984 r1137  
    4747         "--job")   job=$2              ; shift ; shift ;; 
    4848         "--netcdf_lib")   netcdf_lib=$2 ; shift ; shift ;; 
    49          "--memtrack")   use_memtrack="true" ; shift ;; 
     49         "--memtrack")  use_memtrack="true" memtrack=$2  ; shift ; shift ;; 
    5050         *)         code="$1"           ; shift ;; 
    5151      esac 
     
    172172if [[ "$use_memtrack" == "true" ]] 
    173173   then 
    174    XIOS_LIB="$ADDR2LINE_LIBDIR $ADDR2LINE_LIB $XIOS_LIB" 
    175174   XIOS_CPPKEY="$XIOS_CPPKEY XIOS_MEMTRACK" 
     175 
     176    if [[ "$memtrack" == "light" ]] 
     177    then 
     178        XIOS_CPPKEY="$XIOS_CPPKEY XIOS_MEMTRACK_LIGHT" 
     179    elif [[ "$memtrack" == "FULL"  ]] 
     180    then 
     181      XIOS_LIB="$ADDR2LINE_LIBDIR $ADDR2LINE_LIB $XIOS_LIB" 
     182      XIOS_CPPKEY="$XIOS_CPPKEY XIOS_MEMTRACK_FULL" 
     183    else 
     184        echo "Bad choice for --memtrack argument : choose between 'light','full'" 
     185        exit 
     186    fi 
    176187fi  
    177188 
  • XIOS/trunk/src/cxios.cpp

    r1029 r1137  
    111111       delete globalRegistry ; 
    112112     } 
    113      CClient::closeInfoStream(); 
    114    
    115113 
    116114#ifdef XIOS_MEMTRACK 
     115 
     116#ifdef XIOS_MEMTRACK_LIGHT 
     117       report(10) << " Memory report : current memory used by XIOS : "<<  MemTrack::getCurrentMemorySize()*1.0/(1024*1024)<<" Mbyte" << endl ; 
     118       report(10) << " Memory report : maximum memory used by XIOS : "<<  MemTrack::getMaxMemorySize()*1.0/(1024*1024)<<" Mbyte" << endl ; 
     119#endif 
     120 
     121#ifdef XIOS_MEMTRACK_FULL 
    117122     MemTrack::TrackListMemoryUsage() ; 
    118123     MemTrack::TrackDumpBlocks(); 
     124#endif 
     125 
     126     CClient::closeInfoStream(); 
     127 
    119128#endif 
    120129  } 
     
    163172     } 
    164173    CServer::finalize(); 
     174 
     175#ifdef XIOS_MEMTRACK 
     176 
     177#ifdef XIOS_MEMTRACK_LIGHT 
     178       report(10) << " Memory report : current memory used by XIOS : "<<  MemTrack::getCurrentMemorySize()*1.0/(1024*1024)<<" Mbyte" << endl ; 
     179       report(10) << " Memory report : maximum memory used by XIOS : "<<  MemTrack::getMaxMemorySize()*1.0/(1024*1024)<<" Mbyte" << endl ; 
     180#endif 
     181 
     182#ifdef XIOS_MEMTRACK_FULL 
     183     MemTrack::TrackListMemoryUsage() ; 
     184     MemTrack::TrackDumpBlocks(); 
     185#endif 
     186#endif 
    165187    CServer::closeInfoStream(); 
    166188  } 
  • XIOS/trunk/src/memtrack.cpp

    r501 r1137  
    4444#include <sstream> 
    4545#include <string> 
     46 
    4647#include <execinfo.h> 
    4748 
     
    5253{ 
    5354  void addr2line(const char *file_name, char** addr, int naddr) ; 
     55#ifdef XIOS_MEMTRACK_LIGHT 
     56  void addr2line(const char *file_name, char** addr, int naddr) {}  
     57#endif 
    5458} 
    5559/* ------------------------------------------------------------ */ 
     
    5963namespace MemTrack 
    6064{ 
     65    size_t currentMemorySize=0 ; 
     66    size_t maxMemorySize=0 ;  
     67 
     68    size_t getCurrentMemorySize(void) {return currentMemorySize; } 
     69    size_t getMaxMemorySize(void) {return maxMemorySize ; } 
    6170 
    6271    /* ------------------------------------------------------------ */ 
     
    375384        // Get the offset to the user chunk and return it. 
    376385        UserChunk *pUser = GetUserAddress(pProlog); 
     386 
     387        currentMemorySize += size ; 
     388        if (currentMemorySize>maxMemorySize) maxMemorySize=currentMemorySize ; 
    377389         
    378390        return pUser; 
     
    400412        // Unlink the block header from the list and destroy it. 
    401413        BlockHeader *pBlockHeader = GetHeaderAddress(pProlog); 
     414        currentMemorySize-=pBlockHeader->GetRequestedSize(); 
    402415        BlockHeader::RemoveNode(pBlockHeader); 
    403416        pBlockHeader->~BlockHeader(); 
  • XIOS/trunk/src/memtrack.hpp

    r501 r1137  
    6161    void TrackDumpBlocks(); 
    6262    void TrackListMemoryUsage(); 
    63  
     63    size_t getCurrentMemorySize(void) ; 
     64    size_t getMaxMemorySize(void) ; 
    6465    /* ---------------------------------------- operator * (MemStamp, ptr) */ 
    6566 
  • XIOS/trunk/src/node/context.cpp

    r1135 r1137  
    1515#include "xios_spl.hpp" 
    1616#include "timer.hpp" 
     17#include "memtrack.hpp" 
    1718 
    1819 
     
    11971198      calendar->update(step); 
    11981199      info(50) << "updateCalendar : after : " << calendar->getCurrentDate() << endl; 
    1199  
     1200#ifdef XIOS_MEMTRACK_LIGHT 
     1201      info(50) << " Current memory used by XIOS : "<<  MemTrack::getCurrentMemorySize()*1.0/(1024*1024)<<" Mbyte, at timestep "<<step<<" of context "<<this->getId()<<endl ; 
     1202#endif 
    12001203      if (hasClient) 
    12011204      { 
Note: See TracChangeset for help on using the changeset viewer.