1
1
program benchmark_dot
2
2
3
3
use kinds
4
- use fordot
4
+ use fordot, only: fdot_product = > dot_product ! to avoid overloading
5
5
use fast_math, only: fprod, fprod_kahan
6
6
use forbenchmark
7
7
@@ -19,7 +19,7 @@ program benchmark_dot
19
19
allocate (seed_array(seed_size))
20
20
seed_array = 123456789
21
21
22
- call bench% init(7 ,' Benchmark dot_product' ,' benchmarks/dot/results/dot' , 10000 )
22
+ call bench% init(8 ,' Benchmark dot_product' ,' benchmarks/dot/results/dot' , 10000 )
23
23
24
24
num_elements = [1000_ik , 10000_ik , 100000_ik , 1000000_ik ]
25
25
@@ -48,47 +48,57 @@ program benchmark_dot
48
48
49
49
50
50
! ===============================================================================
51
- call bench% start_benchmark(2 ,' m1 ' , " a = dot_product(u,v,'m1 ')" ,[p])
51
+ call bench% start_benchmark(2 ,' blas ' , " a = dot_product(u,v,'m2 ')" ,[p])
52
52
do nl = 1 ,bench% nloops
53
- a = dot_product (u,v,' m1 ' )
53
+ a = fdot_product (u,v,' m2 ' )
54
54
call prevent_optimization(a,nl) ! loop-invariant
55
55
end do
56
56
call bench% stop_benchmark(cmp_gflops)
57
57
! ===============================================================================
58
58
59
59
60
60
! ===============================================================================
61
- call bench% start_benchmark(3 ,' m2 ' , " a = dot_product (u,v,'m2' )" ,[p])
61
+ call bench% start_benchmark(3 ,' m1_b16 ' , " a = f (u,v,'m1',16 )" ,[p])
62
62
do nl = 1 ,bench% nloops
63
- a = dot_product (u,v,' m2 ' )
63
+ a = fdot_product (u,v,' m1 ' , 16 )
64
64
call prevent_optimization(a,nl) ! loop-invariant
65
65
end do
66
66
call bench% stop_benchmark(cmp_gflops)
67
67
! ===============================================================================
68
68
69
69
70
70
! ===============================================================================
71
- call bench% start_benchmark(4 ,' m3 ' , " a = dot_product(u,v,'m3' )" ,[p])
71
+ call bench% start_benchmark(4 ,' blas_b16 ' , " a = dot_product(u,v,'m2',16 )" ,[p])
72
72
do nl = 1 ,bench% nloops
73
- a = dot_product (u,v,' m3 ' )
73
+ a = fdot_product (u,v,' m2 ' , 16 )
74
74
call prevent_optimization(a,nl) ! loop-invariant
75
75
end do
76
76
call bench% stop_benchmark(cmp_gflops)
77
77
! ===============================================================================
78
78
79
79
80
80
! ===============================================================================
81
- call bench% start_benchmark(5 ,' m4 ' , " a = dot_product(u,v,'m4' )" ,[p])
81
+ call bench% start_benchmark(5 ,' m3_b16 ' , " a = dot_product(u,v,'m3',16 )" ,[p])
82
82
do nl = 1 ,bench% nloops
83
- a = dot_product (u,v,' m4 ' )
83
+ a = fdot_product (u,v,' m3 ' , 16 )
84
84
call prevent_optimization(a,nl) ! loop-invariant
85
85
end do
86
86
call bench% stop_benchmark(cmp_gflops)
87
87
! ===============================================================================
88
88
89
89
90
90
! ===============================================================================
91
- call bench% start_benchmark(6 ,' chunks' , " a = fprod(u,v)" ,[p])
91
+ call bench% start_benchmark(6 ,' m4_b16' , " a = dot_product(u,v,'m4',16)" ,[p])
92
+ do nl = 1 ,bench% nloops
93
+ a = fdot_product(u,v,' m4' ,16 )
94
+ call prevent_optimization(a,nl) ! loop-invariant
95
+ end do
96
+ call bench% stop_benchmark(cmp_gflops)
97
+ ! ===============================================================================
98
+
99
+
100
+ ! ===============================================================================
101
+ call bench% start_benchmark(7 ,' chunks' , " a = fprod(u,v)" ,[p])
92
102
do nl = 1 ,bench% nloops
93
103
a = fprod(u,v)
94
104
call prevent_optimization(a,nl) ! loop-invariant
@@ -98,7 +108,7 @@ program benchmark_dot
98
108
99
109
100
110
! ===============================================================================
101
- call bench% start_benchmark(7 ,' kahan' , " a = fprod_kahan(u,v)" ,[p])
111
+ call bench% start_benchmark(8 ,' kahan' , " a = fprod_kahan(u,v)" ,[p])
102
112
do nl = 1 ,bench% nloops
103
113
a = fprod_kahan(u,v)
104
114
call prevent_optimization(a,nl) ! loop-invariant
@@ -128,7 +138,7 @@ end function cmp_gflops
128
138
subroutine prevent_optimization (a , nl )
129
139
real (rk), intent (in ) :: a
130
140
integer , intent (in ) :: nl
131
- if (a == 0.0_rk ) print * , nl, ' a = 0.0'
141
+ if (abs (a)< tiny ( 0.0_rk ) ) print * , nl, ' a = 0.0'
132
142
end subroutine prevent_optimization
133
143
! ===============================================================================
134
144
0 commit comments