ftimings_value.F90 2.32 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
#ifdef HAVE_CONFIG_H
#include "config-f90.h"
#endif

module ftimings_value
  use ftimings_type
  implicit none
  public

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

15
    integer(kind=C_LONG) :: rsssize = 0           ! newly used resident memory
16

17
18
    integer(kind=C_LONG_LONG) :: flop_count = 0   ! floating point operations done in this node
    integer(kind=C_LONG_LONG) :: ldst = 0         ! number of loads and stores
19
20
21
22
23
24
25
26
27
28
29
  end type

  interface operator(+)
    module procedure value_add
  end interface

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

30
31
  type(value_t), parameter :: null_value = value_t(micros = 0, &
                                                   rsssize = 0, &
32
                                                   virtualmem = 0, &
33
                                                   maxrsssize = 0, &
34
                                                   flop_count = 0)
35
36
37
38
39
40
41

  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
42
    c%rsssize = a%rsssize + b%rsssize
43
    c%virtualmem = a%virtualmem + b%virtualmem
44
    c%maxrsssize = a%maxrsssize + b%maxrsssize
45
46
#ifdef HAVE_LIBPAPI
    c%flop_count = a%flop_count + b%flop_count
47
    c%ldst = a%ldst + b%ldst
48
49
50
51
52
53
54
#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
55
    c%rsssize = a%rsssize - b%rsssize
56
    c%virtualmem = a%virtualmem - b%virtualmem
57
    c%maxrsssize = a%maxrsssize - b%maxrsssize
58
59
#ifdef HAVE_LIBPAPI
    c%flop_count = a%flop_count - b%flop_count
60
    c%ldst = a%ldst - b%ldst
61
62
63
64
65
66
67
#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
68
    neg_a%rsssize = - a%rsssize
69
    neg_a%virtualmem = - a%virtualmem
70
    neg_a%maxrsssize = - a%maxrsssize
71
72
#ifdef HAVE_LIBPAPI
    neg_a%flop_count = - a%flop_count
73
    neg_a%ldst = - a%ldst
74
75
76
#endif
  end function
end module