Skip to content

Commit

Permalink
Add new methods to the dot benchmark
Browse files Browse the repository at this point in the history
- Update the results
- Update the export script
- Update the fpm.rsp
  • Loading branch information
gha3mi committed Jan 30, 2024
1 parent ac66fc4 commit 9ead68a
Show file tree
Hide file tree
Showing 37 changed files with 734 additions and 550 deletions.
36 changes: 23 additions & 13 deletions benchmarks/dot/dot.f90
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
program benchmark_dot

use kinds
use fordot
use fordot, only: fdot_product => dot_product ! to avoid overloading
use fast_math, only: fprod, fprod_kahan
use forbenchmark

Expand All @@ -19,7 +19,7 @@ program benchmark_dot
allocate(seed_array(seed_size))
seed_array = 123456789

call bench%init(7,'Benchmark dot_product','benchmarks/dot/results/dot', 10000)
call bench%init(8,'Benchmark dot_product','benchmarks/dot/results/dot', 10000)

num_elements = [1000_ik, 10000_ik, 100000_ik, 1000000_ik]

Expand Down Expand Up @@ -48,47 +48,57 @@ program benchmark_dot


!===============================================================================
call bench%start_benchmark(2,'m1', "a = dot_product(u,v,'m1')",[p])
call bench%start_benchmark(2,'blas', "a = dot_product(u,v,'m2')",[p])
do nl = 1,bench%nloops
a = dot_product(u,v,'m1')
a = fdot_product(u,v,'m2')
call prevent_optimization(a,nl) ! loop-invariant
end do
call bench%stop_benchmark(cmp_gflops)
!===============================================================================


!===============================================================================
call bench%start_benchmark(3,'m2', "a = dot_product(u,v,'m2')",[p])
call bench%start_benchmark(3,'m1_b16', "a = f(u,v,'m1',16)",[p])
do nl = 1,bench%nloops
a = dot_product(u,v,'m2')
a = fdot_product(u,v,'m1',16)
call prevent_optimization(a,nl) ! loop-invariant
end do
call bench%stop_benchmark(cmp_gflops)
!===============================================================================


!===============================================================================
call bench%start_benchmark(4,'m3', "a = dot_product(u,v,'m3')",[p])
call bench%start_benchmark(4,'blas_b16', "a = dot_product(u,v,'m2',16)",[p])
do nl = 1,bench%nloops
a = dot_product(u,v,'m3')
a = fdot_product(u,v,'m2',16)
call prevent_optimization(a,nl) ! loop-invariant
end do
call bench%stop_benchmark(cmp_gflops)
!===============================================================================


!===============================================================================
call bench%start_benchmark(5,'m4', "a = dot_product(u,v,'m4')",[p])
call bench%start_benchmark(5,'m3_b16', "a = dot_product(u,v,'m3',16)",[p])
do nl = 1,bench%nloops
a = dot_product(u,v,'m4')
a = fdot_product(u,v,'m3',16)
call prevent_optimization(a,nl) ! loop-invariant
end do
call bench%stop_benchmark(cmp_gflops)
!===============================================================================


!===============================================================================
call bench%start_benchmark(6,'chunks', "a = fprod(u,v)",[p])
call bench%start_benchmark(6,'m4_b16', "a = dot_product(u,v,'m4',16)",[p])
do nl = 1,bench%nloops
a = fdot_product(u,v,'m4',16)
call prevent_optimization(a,nl) ! loop-invariant
end do
call bench%stop_benchmark(cmp_gflops)
!===============================================================================


!===============================================================================
call bench%start_benchmark(7,'chunks', "a = fprod(u,v)",[p])
do nl = 1,bench%nloops
a = fprod(u,v)
call prevent_optimization(a,nl) ! loop-invariant
Expand All @@ -98,7 +108,7 @@ program benchmark_dot


!===============================================================================
call bench%start_benchmark(7,'kahan', "a = fprod_kahan(u,v)",[p])
call bench%start_benchmark(8,'kahan', "a = fprod_kahan(u,v)",[p])
do nl = 1,bench%nloops
a = fprod_kahan(u,v)
call prevent_optimization(a,nl) ! loop-invariant
Expand Down Expand Up @@ -128,7 +138,7 @@ end function cmp_gflops
subroutine prevent_optimization(a, nl)
real(rk), intent(in) :: a
integer, intent(in) :: nl
if (a == 0.0_rk) print*, nl, 'a = 0.0'
if (abs(a)<tiny(0.0_rk)) print*, nl, 'a = 0.0'
end subroutine prevent_optimization
!===============================================================================

Expand Down
10 changes: 5 additions & 5 deletions benchmarks/dot/dot_co.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ program benchmark_dot_coarray
#if defined(USE_COARRAY)

use kinds
use fordot
use fordot, only: fdot_product => dot_product ! to avoid overloading
use forbenchmark

implicit none
Expand All @@ -21,7 +21,7 @@ program benchmark_dot_coarray
allocate(seed_array(seed_size))
seed_array = 123456789

call bench%init(4, 'Fordot_product','benchmarks/dot/results/dot', 1000)
call bench%init(6, 'Fordot_product','benchmarks/dot/results/dot', 1000)

num_elements = [1000_ik, 10000_ik, 100000_ik, 1000000_ik]

Expand Down Expand Up @@ -52,7 +52,7 @@ program benchmark_dot_coarray
!===============================================================================
call bench%start_benchmark(2,'m1_co', "a = dot_product(u,v,'m1',coarray=.true.)",[p])
do nl = 1,bench%nloops
a = dot_product(u,v,'m1',coarray=.true.)
a = fdot_product(u,v,'m1',coarray=.true.)
call prevent_optimization(a,nl) ! loop-invariant
end do
call bench%stop_benchmark(cmp_gflops)
Expand All @@ -62,7 +62,7 @@ program benchmark_dot_coarray
!===============================================================================
call bench%start_benchmark(3,'m2_co', "a = dot_product(u,v,'m2',coarray=.true.)",[p])
do nl = 1,bench%nloops
a = dot_product(u,v,'m2',coarray=.true.)
a = fdot_product(u,v,'m2',coarray=.true.)
call prevent_optimization(a,nl) ! loop-invariant
end do
call bench%stop_benchmark(cmp_gflops)
Expand All @@ -72,7 +72,7 @@ program benchmark_dot_coarray
!===============================================================================
call bench%start_benchmark(4,'m3_co', "a = dot_product(u,v,'m3',coarray=.true.)",[p])
do nl = 1,bench%nloops
a = dot_product(u,v,'m3',coarray=.true.)
a = fdot_product(u,v,'m3',coarray=.true.)
call prevent_optimization(a,nl) ! loop-invariant
end do
call bench%stop_benchmark(cmp_gflops)
Expand Down
Loading

0 comments on commit 9ead68a

Please sign in to comment.