ftimings_value.F90 1.75 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
12
13
14
    integer(kind=C_INT64_T) :: micros = 0         ! microseconds spent in this node
    integer(kind=C_LONG) :: rsssize = 0           ! newly used resident memory
    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
15
16
17
18
19
20
21
22
23
24
25
  end type

  interface operator(+)
    module procedure value_add
  end interface

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

26
27
28
  type(value_t), parameter :: null_value = value_t(micros = 0, &
                                                   rsssize = 0, &
                                                   flop_count = 0)
29
30
31
32
33
34
35

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