-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfourier-bench1.h
79 lines (65 loc) · 1.65 KB
/
fourier-bench1.h
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
#include <cstdlib>
#include <complex>
#include <fstream>
#include <iostream>
#include <memory>
#include <bench.h>
using std::complex;
using std::cout;
using std::endl;
using std::setw;
using std::string;
namespace bench {
template <class Test>
double bench(Test & test, int & n, double weight, bool verbose)
{
double t = benchClassOp(test, 4.0);
if (verbose) {
cout << " (" << timeutils::smartTime(t/n) << "/point)\n"
<< "\"mflops\" = 5 (n log2 n) / (t in microseconds) = "
<< setw(10) << weight*5.0*n*log2(static_cast<double>(n))/(1e6*t)
<< '\n' << endl;
}
else {
cout << setw(10) << weight*5.0*n*log2(static_cast<double>(n))/(1e6*t)
<< " mflops" << endl;
}
return t;
}
template <class T1>
void init(T1 * & in, int ni)
{
in = new T1[ni];
for (int i=0; i<ni; ++i) in[i] = T1(0.0);
}
template <class T1>
void free(T1 *in)
{
delete[] in;
}
template <class T1, class T2>
void init(T1 * & in, int ni, T2 * & out, int no)
{
in = new T1[ni];
out = new T2[no];
for (int i=0; i<ni; ++i) in[i] = T1(0.0);
for (int i=0; i<no; ++i) out[i] = T2(0.0);
}
template <class T1, class T2>
void free(T1 *in, T2 *out)
{
delete[] in;
delete[] out;
}
void inline header(const string &source,
const string &type,
const string &inplace,
const string &direction,
int n)
{
if (verbose)
cout << source << ": " << type << inplace << direction << n << endl;
else
cout << source << ": " << type << inplace << direction << n << ":";
}
}