Skip to content

Commit 46cc3a5

Browse files
authored
Merge pull request #19 from certik/bench2
Add initial benchmark for fftpack
2 parents 505fdcd + f4c551f commit 46cc3a5

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

example/bench1.f90

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
program bench1
2+
use fftpack, only: zffti, zfftf, zfftb
3+
implicit none
4+
integer, parameter :: dp = kind(0.d0)
5+
complex(dp), allocatable :: z(:)
6+
real(dp), allocatable :: w(:), x(:)
7+
real(dp) :: err, time_init, time_forward, time_backward, t1, t2
8+
integer :: N
9+
10+
N = 1024*1014*16
11+
12+
allocate(x(N), z(N), w(4*N+15))
13+
call random_number(x)
14+
z = x
15+
16+
print *, "Initializing"
17+
call cpu_time(t1)
18+
call zffti(N, w)
19+
call cpu_time(t2)
20+
time_init = t2-t1
21+
22+
print *, "Forward"
23+
call cpu_time(t1)
24+
call zfftf(N, z, w)
25+
call cpu_time(t2)
26+
time_forward = t2-t1
27+
28+
print *, "Backward"
29+
call cpu_time(t1)
30+
call zfftb(N, z, w)
31+
call cpu_time(t2)
32+
time_backward = t2-t1
33+
print *, "Done"
34+
35+
err = maxval(abs(x-real(z/N,dp)))
36+
print *
37+
print *, "Error: ", err
38+
print *, "Init time: ", time_init
39+
print *, "Forward time: ", time_forward
40+
print *, "Backward time: ", time_backward
41+
end program

fpm.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ keywords = ["netlib", "fftpack", "fft"]
1313
[build]
1414
auto-executables = false
1515
auto-tests = false
16-
auto-examples = false
16+
auto-examples = true
1717

1818
# Original test
1919
[[test]]

0 commit comments

Comments
 (0)