-
Notifications
You must be signed in to change notification settings - Fork 0
/
testfftspeed.c
160 lines (133 loc) · 3.91 KB
/
testfftspeed.c
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/** @file testfftspeed.c
*/
#include <fftw3.h>
#include "CommandLineInterface/CLIcore.h"
#include "COREMOD_memory/COREMOD_memory.h"
#include "dofft.h"
// ==========================================
// Forward declaration(s)
// ==========================================
int test_fftspeed(int nmax);
// ==========================================
// Command line interface wrapper function(s)
// ==========================================
errno_t test_fftspeed_cli()
{
if(CLI_checkarg(1, CLIARG_INT64) == 0)
{
test_fftspeed((int) data.cmdargtoken[1].val.numl);
return CLICMD_SUCCESS;
}
else
{
return CLICMD_INVALID_ARG;
}
}
// ==========================================
// Register CLI command(s)
// ==========================================
errno_t testfftspeed_addCLIcmd()
{
RegisterCLIcommand("testfftspeed",
__FILE__,
test_fftspeed_cli,
"test FFTW speed",
"no argument",
"testfftspeed",
"int test_fftwspeed(int nmax)");
return RETURN_SUCCESS;
}
/** @brief Test FFT speed (fftw)
*
*/
int test_fftspeed(int nmax)
{
int n;
long size;
int nbiter, iter;
struct timespec tS0;
struct timespec tS1;
struct timespec tS2;
double ti0, ti1, ti2;
double dt1;
//struct timeval tv;
//int nb_threads=1;
//int nb_threads_max = 8;
/* printf("%ld ticks per second\n",CLOCKS_PER_SEC);*/
nbiter = 10000;
size = 2;
printf("Testing complex FFT, nxn pix\n");
printf("size(pix)");
#ifdef FFTWMT
for(nb_threads = 1; nb_threads < nb_threads_max; nb_threads++)
{
printf("%13d", nb_threads);
}
#endif
printf("\n");
size = 2;
for(n = 0; n < nmax; n++)
{
printf("%9ld", size);
#ifdef FFTWMT
for(nb_threads = 1; nb_threads < nb_threads_max; nb_threads++)
{
fft_setNthreads(nb_threads);
#endif
#if _POSIX_TIMERS > 0
clock_gettime(CLOCK_REALTIME, &tS0);
#else
gettimeofday(&tv, NULL);
tS0.tv_sec = tv.tv_sec;
tS0.tv_nsec = tv.tv_usec * 1000;
#endif
// clock_gettime(CLOCK_REALTIME, &tS0);
for(iter = 0; iter < nbiter; iter++)
{
create_2DCimage_ID("tmp", size, size, NULL);
do2dfft("tmp", "tmpf");
delete_image_ID("tmp", DELETE_IMAGE_ERRMODE_WARNING);
delete_image_ID("tmpf", DELETE_IMAGE_ERRMODE_WARNING);
}
#if _POSIX_TIMERS > 0
clock_gettime(CLOCK_REALTIME, &tS1);
#else
gettimeofday(&tv, NULL);
tS1.tv_sec = tv.tv_sec;
tS1.tv_nsec = tv.tv_usec * 1000;
#endif
// clock_gettime(CLOCK_REALTIME, &tS1);
for(iter = 0; iter < nbiter; iter++)
{
create_2DCimage_ID("tmp", size, size, NULL);
delete_image_ID("tmp", DELETE_IMAGE_ERRMODE_WARNING);
}
#if _POSIX_TIMERS > 0
clock_gettime(CLOCK_REALTIME, &tS2);
#else
gettimeofday(&tv, NULL);
tS2.tv_sec = tv.tv_sec;
tS2.tv_nsec = tv.tv_usec * 1000;
#endif
//clock_gettime(CLOCK_REALTIME, &tS2);
ti0 = 1.0 * tS0.tv_sec + 0.000000001 * tS0.tv_nsec;
ti1 = 1.0 * tS1.tv_sec + 0.000000001 * tS1.tv_nsec;
ti2 = 1.0 * tS2.tv_sec + 0.000000001 * tS2.tv_nsec;
dt1 = 1.0 * (ti1 - ti0) - 1.0 * (ti2 - ti1);
dt1 /= nbiter;
printf("%10.3f ms", dt1 * 1000.0);
//printf("Complex FFT %ldx%ld [%d threads] : %f ms [%ld]\n",size,size,nb_threads,dt1*1000.0,nbiter);
fflush(stdout);
#ifdef FFTWMT
}
#endif
printf("\n");
nbiter = 0.1 / dt1;
if(nbiter < 2)
{
nbiter = 2;
}
size = size * 2;
}
return (0);
}