-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfourier-bench1-fftw.cpp
145 lines (128 loc) · 2.83 KB
/
fourier-bench1-fftw.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#include "fourier-bench1.h"
#ifdef HAVE_FFTW_FFT
namespace fftw {
#include <fftw.h>
#include <rfftw.h>
namespace r2r {
rfftw_plan p;
double *in, *out;
struct otest : bench::Test {
otest(int n)
{
bench::init(in, n, out, n);
p = rfftw_create_plan(n, FFTW_FORWARD, FFTW_MEASURE | FFTW_OUT_OF_PLACE);
bench::header("FFTW2", "r2r", "o", "f", n);
}
~otest()
{
rfftw_destroy_plan(p);
bench::free(in, out);
}
void op()
{
rfftw_one(p, reinterpret_cast<fftw_real*>(in), reinterpret_cast<fftw_real*>(out));
};
string opName() const
{
return "rfftw_one()";
}
};
struct itest : bench::Test {
itest(int n)
{
bench::init(in, n);
p = rfftw_create_plan(n, FFTW_FORWARD, FFTW_MEASURE | FFTW_IN_PLACE);
bench::header("FFTW2", "r2r", "i", "f", n);
}
~itest()
{
rfftw_destroy_plan(p);
bench::free(in);
}
void op()
{
rfftw_one(p, reinterpret_cast<fftw_real*>(in), 0);
};
string opName() const
{
return "rfftw_one()";
}
};
}
namespace c2c {
fftw_plan p;
complex<double> *in, *out;
struct otest : bench::Test {
otest(int n)
{
bench::init(in, n, out, n);
p = fftw_create_plan(n, FFTW_FORWARD, FFTW_MEASURE | FFTW_OUT_OF_PLACE);
bench::header("FFTW2", "c2c", "o", "f", n);
}
~otest()
{
fftw_destroy_plan(p);
bench::free(in, out);
}
void op()
{
fftw_one(p, reinterpret_cast<fftw_complex*>(in), reinterpret_cast<fftw_complex*>(out));
};
string opName() const
{
return "fftw_one()";
}
};
struct itest : bench::Test {
itest(int n)
{
bench::init(in, n);
p = fftw_create_plan(n, FFTW_FORWARD, FFTW_MEASURE | FFTW_IN_PLACE);
bench::header("FFTW2", "c2c", "i", "f",n);
}
~itest()
{
fftw_destroy_plan(p);
bench::free(in);
}
void op()
{
fftw_one(p, reinterpret_cast<fftw_complex*>(in), 0);
};
string opName() const
{
return "fftw_one()";
}
};
}
void run(int n, bool verbose)
{
// bench namespace verbose locally scoped
//bench::verbose = true;
{
r2r::otest test(n);
bench::bench(test, n, 0.5, verbose);
}
{
r2r::itest test(n);
bench::bench(test, n, 0.5, verbose);
}
{
c2c::otest test(n);
bench::bench(test, n, 1.0, verbose);
}
{
c2c::itest test(n);
bench::bench(test, n, 1.0, verbose);
}
cout << endl;
}
}
#else
namespace fftw {
void run(int n, bool verbose)
{
cout << "FFTW2 port not available." << endl << endl;
}
}
#endif // HAVE_FFTW_FFT