ftimings_value.F90 3.33 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
! Copyright 2014 Lorenz Hüdepohl
!
! This file is part of ftimings.
!
! ftimings is free software: you can redistribute it and/or modify
! it under the terms of the GNU Lesser General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
!
! ftimings is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
! GNU Lesser General Public License for more details.
!
! You should have received a copy of the GNU Lesser General Public License
! along with ftimings.  If not, see <http://www.gnu.org/licenses/>.

18
19
20
21
22
23
24
25
26
27
#ifdef HAVE_CONFIG_H
#include "config-f90.h"
#endif

module ftimings_value
  use ftimings_type
  implicit none
  public

  type value_t
28
    integer(kind=C_INT64_T) :: micros = 0         ! microseconds spent in this node
29
    integer(kind=C_LONG) :: virtualmem = 0        ! newly created virtual memory
30
31
    integer(kind=C_LONG) :: maxrsssize = 0            ! newly used max. resident mem ("high water mark")

32
    integer(kind=C_LONG) :: rsssize = 0           ! newly used resident memory
33

34
    integer(kind=C_LONG_LONG) :: flop_count = 0   ! floating point operations done in this node
35
36
    integer(kind=C_INT64_T) :: mem_reads = 0          ! bytes read from DRAM
    integer(kind=C_INT64_T) :: mem_writes = 0         ! bytes written to DRAM
37
38
39
40
41
42
43
44
45
46
47
  end type

  interface operator(+)
    module procedure value_add
  end interface

  interface operator(-)
    module procedure value_minus
    module procedure value_inverse
  end interface

48
49
  type(value_t), parameter :: null_value = value_t(micros = 0, &
                                                   rsssize = 0, &
50
                                                   virtualmem = 0, &
51
                                                   maxrsssize = 0, &
52
                                                   flop_count = 0)
53
54
55
56
57
58
59

  contains

  pure elemental function value_add(a,b) result(c)
    class(value_t), intent(in) :: a, b
    type(value_t) :: c
    c%micros = a%micros + b%micros
60
    c%rsssize = a%rsssize + b%rsssize
61
    c%virtualmem = a%virtualmem + b%virtualmem
62
    c%maxrsssize = a%maxrsssize + b%maxrsssize
63
64
#ifdef HAVE_LIBPAPI
    c%flop_count = a%flop_count + b%flop_count
65
66
67
68
#endif
#ifdef HAVE_PERF
    c%mem_reads = a%mem_reads + b%mem_reads
    c%mem_writes = a%mem_writes + b%mem_writes
69
70
71
72
73
74
75
#endif
  end function

  pure elemental function value_minus(a,b) result(c)
    class(value_t), intent(in) :: a, b
    type(value_t) :: c
    c%micros = a%micros - b%micros
76
    c%rsssize = a%rsssize - b%rsssize
77
    c%virtualmem = a%virtualmem - b%virtualmem
78
    c%maxrsssize = a%maxrsssize - b%maxrsssize
79
80
#ifdef HAVE_LIBPAPI
    c%flop_count = a%flop_count - b%flop_count
81
82
83
84
#endif
#ifdef HAVE_PERF
    c%mem_reads = a%mem_reads - b%mem_reads
    c%mem_writes = a%mem_writes - b%mem_writes
85
86
87
88
89
90
91
#endif
  end function

  pure elemental function value_inverse(a) result(neg_a)
    class(value_t), intent(in) :: a
    type(value_t) :: neg_a
    neg_a%micros = - a%micros
92
    neg_a%rsssize = - a%rsssize
93
    neg_a%virtualmem = - a%virtualmem
94
    neg_a%maxrsssize = - a%maxrsssize
95
96
#ifdef HAVE_LIBPAPI
    neg_a%flop_count = - a%flop_count
97
98
99
100
#endif
#ifdef HAVE_PERF
    neg_a%mem_reads = - a%mem_reads
    neg_a%mem_writes = - a%mem_writes
101
102
103
#endif
  end function
end module