ftimings_value.F90 2.02 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
    integer(kind=C_LONG) :: rsssize = 0           ! newly used resident memory
14

15
16
    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
17
18
19
20
21
22
23
24
25
26
27
  end type

  interface operator(+)
    module procedure value_add
  end interface

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

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

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