MallocGauge.F90 Source File


This file depends on

sourcefile~~mallocgauge.f90~~EfferentGraph sourcefile~mallocgauge.f90 MallocGauge.F90 sourcefile~abstractgauge.f90 AbstractGauge.F90 sourcefile~mallocgauge.f90->sourcefile~abstractgauge.f90 sourcefile~abstractmeter.f90 AbstractMeter.F90 sourcefile~abstractgauge.f90->sourcefile~abstractmeter.f90 sourcefile~errorhandling.f90 ErrorHandling.F90 sourcefile~abstractmeter.f90->sourcefile~errorhandling.f90 sourcefile~mapl_throw.f90 MAPL_Throw.F90 sourcefile~errorhandling.f90->sourcefile~mapl_throw.f90

Files dependent on this one

sourcefile~~mallocgauge.f90~~AfferentGraph sourcefile~mallocgauge.f90 MallocGauge.F90 sourcefile~globalprofilers.f90 GlobalProfilers.F90 sourcefile~globalprofilers.f90->sourcefile~mallocgauge.f90 sourcefile~memoryprofiler.f90 MemoryProfiler.F90 sourcefile~memoryprofiler.f90->sourcefile~mallocgauge.f90 sourcefile~mapl_profiler.f90~2 MAPL_Profiler.F90 sourcefile~mapl_profiler.f90~2->sourcefile~globalprofilers.f90 sourcefile~mapl_profiler.f90~2->sourcefile~memoryprofiler.f90 sourcefile~abstractserver.f90 AbstractServer.F90 sourcefile~abstractserver.f90->sourcefile~mapl_profiler.f90~2 sourcefile~applicationsupport.f90 ApplicationSupport.F90 sourcefile~applicationsupport.f90->sourcefile~mapl_profiler.f90~2 sourcefile~base_base_implementation.f90 Base_Base_implementation.F90 sourcefile~base_base_implementation.f90->sourcefile~mapl_profiler.f90~2 sourcefile~demo.f90 demo.F90 sourcefile~demo.f90->sourcefile~mapl_profiler.f90~2 sourcefile~extdatadrivergridcomp.f90 ExtDataDriverGridComp.F90 sourcefile~extdatadrivergridcomp.f90->sourcefile~mapl_profiler.f90~2 sourcefile~mapl.f90 MAPL.F90 sourcefile~mapl.f90->sourcefile~mapl_profiler.f90~2 sourcefile~mapl_bundleio_test.f90 mapl_bundleio_test.F90 sourcefile~mapl_bundleio_test.f90->sourcefile~mapl_profiler.f90~2 sourcefile~mapl_capgridcomp.f90 MAPL_CapGridComp.F90 sourcefile~mapl_capgridcomp.f90->sourcefile~mapl_profiler.f90~2 sourcefile~mapl_generic.f90~2 MAPL_Generic.F90 sourcefile~mapl_generic.f90~2->sourcefile~mapl_profiler.f90~2 sourcefile~mapl_nuopcwrappermod.f90 MAPL_NUOPCWrapperMod.F90 sourcefile~mapl_nuopcwrappermod.f90->sourcefile~mapl_profiler.f90~2 sourcefile~mapl_verticalmethods.f90 MAPL_VerticalMethods.F90 sourcefile~mapl_verticalmethods.f90->sourcefile~mapl_profiler.f90~2 sourcefile~maplframework.f90 MaplFramework.F90 sourcefile~maplframework.f90->sourcefile~mapl_profiler.f90~2 sourcefile~mpi_demo.f90 mpi_demo.F90 sourcefile~mpi_demo.f90->sourcefile~mapl_profiler.f90~2 sourcefile~mpiserver.f90 MpiServer.F90 sourcefile~mpiserver.f90->sourcefile~mapl_profiler.f90~2 sourcefile~multigroupserver.f90 MultiGroupServer.F90 sourcefile~multigroupserver.f90->sourcefile~mapl_profiler.f90~2 sourcefile~regrid_util.f90 Regrid_Util.F90 sourcefile~regrid_util.f90->sourcefile~mapl_profiler.f90~2 sourcefile~serverthread.f90 ServerThread.F90 sourcefile~serverthread.f90->sourcefile~mapl_profiler.f90~2 sourcefile~test_advancedmeter.pf test_AdvancedMeter.pf sourcefile~test_advancedmeter.pf->sourcefile~mapl_profiler.f90~2 sourcefile~test_column.pf test_Column.pf sourcefile~test_column.pf->sourcefile~mapl_profiler.f90~2 sourcefile~test_distributedmeter.pf test_DistributedMeter.pf sourcefile~test_distributedmeter.pf->sourcefile~mapl_profiler.f90~2 sourcefile~test_exclusivecolumn.pf test_ExclusiveColumn.pf sourcefile~test_exclusivecolumn.pf->sourcefile~mapl_profiler.f90~2 sourcefile~test_meternode.pf test_MeterNode.pf sourcefile~test_meternode.pf->sourcefile~mapl_profiler.f90~2 sourcefile~test_meternodeiterator.pf test_MeterNodeIterator.pf sourcefile~test_meternodeiterator.pf->sourcefile~mapl_profiler.f90~2 sourcefile~test_namecolumn.pf test_NameColumn.pf sourcefile~test_namecolumn.pf->sourcefile~mapl_profiler.f90~2 sourcefile~test_percentagecolumn.pf test_PercentageColumn.pf sourcefile~test_percentagecolumn.pf->sourcefile~mapl_profiler.f90~2 sourcefile~test_profilereporter.pf test_ProfileReporter.pf sourcefile~test_profilereporter.pf->sourcefile~mapl_profiler.f90~2 sourcefile~test_timeprofiler.pf test_TimeProfiler.pf sourcefile~test_timeprofiler.pf->sourcefile~mapl_profiler.f90~2

Source Code

#include "unused_dummy.H"

module MAPL_MallocGauge
   use, intrinsic :: iso_fortran_env, only: REAL64, INT64
   use, intrinsic :: iso_c_binding, only : C_INT
   use MAPL_AbstractGauge
   implicit none
   private

   public :: MallocGauge

   type, extends(AbstractGauge) :: MallocGauge
      private
      integer(kind=INT64) :: baseline = 0
   contains
      procedure :: get_measurement
   end type MallocGauge

   interface MallocGauge
      module procedure :: new_MallocGauge
   end interface MallocGauge

   type, bind(C) :: mallinfo_t
      integer(C_INT) :: arena     ! Non-mmapped space allocated (bytes)
      integer(C_INT) :: ordblks   ! Number of free chunks
      integer(C_INT) :: smblks    ! Number of free fastbin blocks
      integer(C_INT) :: hblks     ! Number of mmapped regions
      integer(C_INT) :: hblkhd    ! Space allocated in mmapped regions (bytes)
      integer(C_INT) :: usmblks   ! See below
      integer(C_INT) :: fsmblks   ! Space in freed fastbin blocks (bytes)
      integer(C_INT) :: uordblks  ! Total allocated space (bytes)
      integer(C_INT) :: fordblks  ! Total free space (bytes)
      integer(C_INT) :: keepcost  ! Top-most, releasable space (bytes)
   end type mallinfo_t

#if  (!defined(sysDarwin) && (defined(__INTEL_COMPILER) || defined(__GFORTRAN)))
   interface
      function mallinfo() result(info) bind(C,name="mallinfo")
         import mallinfo_t
         type(mallinfo_t) :: info
      end function mallinfo
   end interface
#endif

contains


   function new_MallocGauge() result(gauge)
      type (MallocGauge) :: gauge

      gauge%baseline = 0

   end function new_MallocGauge


   function get_measurement(this) result(mem_use)
      class (MallocGauge), intent(inout) :: this
      real(kind=REAL64) :: mem_use

      type(Mallinfo_t) :: info

      info = mallinfo()
      mem_use = info%uordblks

   end function get_measurement

#if !(!defined(sysDarwin) && (defined(__INTEL_COMPILER) || defined(__GFORTRAN)))
   function mallinfo() result(info)
      type(mallinfo_t) :: info
      info %uordblks = 0
   end function mallinfo
#endif
end module MAPL_MallocGauge