Mercurial > hg > sv-dependency-builds
comparison src/fftw-3.3.3/libbench2/bench-user.h @ 10:37bf6b4a2645
Add FFTW3
author | Chris Cannam |
---|---|
date | Wed, 20 Mar 2013 15:35:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
9:c0fb53affa76 | 10:37bf6b4a2645 |
---|---|
1 /* | |
2 * Copyright (c) 2001 Matteo Frigo | |
3 * Copyright (c) 2001 Massachusetts Institute of Technology | |
4 * | |
5 * This program is free software; you can redistribute it and/or modify | |
6 * it under the terms of the GNU General Public License as published by | |
7 * the Free Software Foundation; either version 2 of the License, or | |
8 * (at your option) any later version. | |
9 * | |
10 * This program is distributed in the hope that it will be useful, | |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 * GNU General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU General Public License | |
16 * along with this program; if not, write to the Free Software | |
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
18 * | |
19 */ | |
20 | |
21 #ifndef __BENCH_USER_H__ | |
22 #define __BENCH_USER_H__ | |
23 | |
24 #ifdef __cplusplus | |
25 extern "C" { | |
26 #endif /* __cplusplus */ | |
27 | |
28 /* benchmark program definitions for user code */ | |
29 #include "config.h" | |
30 | |
31 #if HAVE_STDDEF_H | |
32 #include <stddef.h> | |
33 #endif | |
34 | |
35 #if HAVE_STDLIB_H | |
36 #include <stdlib.h> | |
37 #endif | |
38 | |
39 #if defined(BENCHFFT_SINGLE) | |
40 typedef float bench_real; | |
41 #elif defined(BENCHFFT_LDOUBLE) | |
42 typedef long double bench_real; | |
43 #elif defined(BENCHFFT_QUAD) | |
44 typedef __float128 bench_real; | |
45 #else | |
46 typedef double bench_real; | |
47 #endif | |
48 | |
49 typedef bench_real bench_complex[2]; | |
50 | |
51 #define c_re(c) ((c)[0]) | |
52 #define c_im(c) ((c)[1]) | |
53 | |
54 #undef DOUBLE_PRECISION | |
55 #define DOUBLE_PRECISION (sizeof(bench_real) == sizeof(double)) | |
56 #undef SINGLE_PRECISION | |
57 #define SINGLE_PRECISION (!DOUBLE_PRECISION && sizeof(bench_real) == sizeof(float)) | |
58 #undef LDOUBLE_PRECISION | |
59 #define LDOUBLE_PRECISION (!DOUBLE_PRECISION && sizeof(bench_real) == sizeof(long double)) | |
60 | |
61 #undef QUAD_PRECISION | |
62 #ifdef BENCHFFT_QUAD | |
63 #define QUAD_PRECISION (!LDOUBLE_PRECISION && sizeof(bench_real) == sizeof(__float128)) | |
64 #else | |
65 #define QUAD_PRECISION 0 | |
66 #endif | |
67 | |
68 typedef enum { PROBLEM_COMPLEX, PROBLEM_REAL, PROBLEM_R2R } problem_kind_t; | |
69 | |
70 typedef enum { | |
71 R2R_R2HC, R2R_HC2R, R2R_DHT, | |
72 R2R_REDFT00, R2R_REDFT01, R2R_REDFT10, R2R_REDFT11, | |
73 R2R_RODFT00, R2R_RODFT01, R2R_RODFT10, R2R_RODFT11 | |
74 } r2r_kind_t; | |
75 | |
76 typedef struct { | |
77 int n; | |
78 int is; /* input stride */ | |
79 int os; /* output stride */ | |
80 } bench_iodim; | |
81 | |
82 typedef struct { | |
83 int rnk; | |
84 bench_iodim *dims; | |
85 } bench_tensor; | |
86 | |
87 bench_tensor *mktensor(int rnk); | |
88 void tensor_destroy(bench_tensor *sz); | |
89 int tensor_sz(const bench_tensor *sz); | |
90 bench_tensor *tensor_compress(const bench_tensor *sz); | |
91 int tensor_unitstridep(bench_tensor *t); | |
92 int tensor_rowmajorp(bench_tensor *t); | |
93 int tensor_real_rowmajorp(bench_tensor *t, int sign, int in_place); | |
94 bench_tensor *tensor_append(const bench_tensor *a, const bench_tensor *b); | |
95 bench_tensor *tensor_copy(const bench_tensor *sz); | |
96 bench_tensor *tensor_copy_sub(const bench_tensor *sz, int start_dim, int rnk); | |
97 bench_tensor *tensor_copy_swapio(const bench_tensor *sz); | |
98 void tensor_ibounds(bench_tensor *t, int *lbp, int *ubp); | |
99 void tensor_obounds(bench_tensor *t, int *lbp, int *ubp); | |
100 | |
101 /* | |
102 Definition of rank -infinity. | |
103 This definition has the property that if you want rank 0 or 1, | |
104 you can simply test for rank <= 1. This is a common case. | |
105 | |
106 A tensor of rank -infinity has size 0. | |
107 */ | |
108 #define RNK_MINFTY ((int)(((unsigned) -1) >> 1)) | |
109 #define FINITE_RNK(rnk) ((rnk) != RNK_MINFTY) | |
110 | |
111 typedef struct { | |
112 problem_kind_t kind; | |
113 r2r_kind_t *k; | |
114 bench_tensor *sz; | |
115 bench_tensor *vecsz; | |
116 int sign; | |
117 int in_place; | |
118 int destroy_input; | |
119 int split; | |
120 void *in, *out; | |
121 void *inphys, *outphys; | |
122 int iphyssz, ophyssz; | |
123 char *pstring; | |
124 void *userinfo; /* user can store whatever */ | |
125 int scrambled_in, scrambled_out; /* hack for MPI */ | |
126 | |
127 /* internal hack so that we can use verifier in FFTW test program */ | |
128 void *ini, *outi; /* if nonzero, point to imag. parts for dft */ | |
129 | |
130 /* another internal hack to avoid passing around too many parameters */ | |
131 double setup_time; | |
132 } bench_problem; | |
133 | |
134 extern int verbose; | |
135 | |
136 extern int no_speed_allocation; | |
137 | |
138 extern int always_pad_real; | |
139 | |
140 #define LIBBENCH_TIMER 0 | |
141 #define USER_TIMER 1 | |
142 #define BENCH_NTIMERS 2 | |
143 extern void timer_start(int which_timer); | |
144 extern double timer_stop(int which_timer); | |
145 | |
146 extern int can_do(bench_problem *p); | |
147 extern void setup(bench_problem *p); | |
148 extern void doit(int iter, bench_problem *p); | |
149 extern void done(bench_problem *p); | |
150 extern void main_init(int *argc, char ***argv); | |
151 extern void cleanup(void); | |
152 extern void verify(const char *param, int rounds, double tol); | |
153 extern void useropt(const char *arg); | |
154 | |
155 extern void verify_problem(bench_problem *p, int rounds, double tol); | |
156 | |
157 extern void problem_alloc(bench_problem *p); | |
158 extern void problem_free(bench_problem *p); | |
159 extern void problem_zero(bench_problem *p); | |
160 extern void problem_destroy(bench_problem *p); | |
161 | |
162 extern int power_of_two(int n); | |
163 extern int log_2(int n); | |
164 | |
165 | |
166 #define CASSIGN(out, in) (c_re(out) = c_re(in), c_im(out) = c_im(in)) | |
167 | |
168 bench_tensor *verify_pack(const bench_tensor *sz, int s); | |
169 | |
170 typedef struct { | |
171 double l; | |
172 double i; | |
173 double s; | |
174 } errors; | |
175 | |
176 void verify_dft(bench_problem *p, int rounds, double tol, errors *e); | |
177 void verify_rdft2(bench_problem *p, int rounds, double tol, errors *e); | |
178 void verify_r2r(bench_problem *p, int rounds, double tol, errors *e); | |
179 | |
180 /**************************************************************/ | |
181 /* routines to override */ | |
182 | |
183 extern void after_problem_ccopy_from(bench_problem *p, bench_real *ri, bench_real *ii); | |
184 extern void after_problem_ccopy_to(bench_problem *p, bench_real *ro, bench_real *io); | |
185 extern void after_problem_hccopy_from(bench_problem *p, bench_real *ri, bench_real *ii); | |
186 extern void after_problem_hccopy_to(bench_problem *p, bench_real *ro, bench_real *io); | |
187 extern void after_problem_rcopy_from(bench_problem *p, bench_real *ri); | |
188 extern void after_problem_rcopy_to(bench_problem *p, bench_real *ro); | |
189 extern void bench_exit(int status); | |
190 extern double bench_cost_postprocess(double cost); | |
191 | |
192 /************************************************************** | |
193 * malloc | |
194 **************************************************************/ | |
195 extern void *bench_malloc(size_t size); | |
196 extern void bench_free(void *ptr); | |
197 extern void bench_free0(void *ptr); | |
198 | |
199 /************************************************************** | |
200 * alloca | |
201 **************************************************************/ | |
202 #ifdef HAVE_ALLOCA_H | |
203 #include <alloca.h> | |
204 #endif | |
205 | |
206 /************************************************************** | |
207 * assert | |
208 **************************************************************/ | |
209 extern void bench_assertion_failed(const char *s, int line, const char *file); | |
210 #define BENCH_ASSERT(ex) \ | |
211 (void)((ex) || (bench_assertion_failed(#ex, __LINE__, __FILE__), 0)) | |
212 | |
213 #define UNUSED(x) (void)x | |
214 | |
215 /*************************************** | |
216 * Documentation strings | |
217 ***************************************/ | |
218 struct bench_doc { | |
219 const char *key; | |
220 const char *val; | |
221 const char *(*f)(void); | |
222 }; | |
223 | |
224 extern struct bench_doc bench_doc[]; | |
225 | |
226 #ifdef CC | |
227 #define CC_DOC BENCH_DOC("cc", CC) | |
228 #elif defined(BENCH_CC) | |
229 #define CC_DOC BENCH_DOC("cc", BENCH_CC) | |
230 #else | |
231 #define CC_DOC /* none */ | |
232 #endif | |
233 | |
234 #ifdef CXX | |
235 #define CXX_DOC BENCH_DOC("cxx", CXX) | |
236 #elif defined(BENCH_CXX) | |
237 #define CXX_DOC BENCH_DOC("cxx", BENCH_CXX) | |
238 #else | |
239 #define CXX_DOC /* none */ | |
240 #endif | |
241 | |
242 #ifdef F77 | |
243 #define F77_DOC BENCH_DOC("f77", F77) | |
244 #elif defined(BENCH_F77) | |
245 #define F77_DOC BENCH_DOC("f77", BENCH_F77) | |
246 #else | |
247 #define F77_DOC /* none */ | |
248 #endif | |
249 | |
250 #ifdef F90 | |
251 #define F90_DOC BENCH_DOC("f90", F90) | |
252 #elif defined(BENCH_F90) | |
253 #define F90_DOC BENCH_DOC("f90", BENCH_F90) | |
254 #else | |
255 #define F90_DOC /* none */ | |
256 #endif | |
257 | |
258 #define BEGIN_BENCH_DOC \ | |
259 struct bench_doc bench_doc[] = { \ | |
260 CC_DOC \ | |
261 CXX_DOC \ | |
262 F77_DOC \ | |
263 F90_DOC | |
264 | |
265 #define BENCH_DOC(key, val) { key, val, 0 }, | |
266 #define BENCH_DOCF(key, f) { key, 0, f }, | |
267 | |
268 #define END_BENCH_DOC \ | |
269 {0, 0, 0}}; | |
270 | |
271 #ifdef __cplusplus | |
272 } /* extern "C" */ | |
273 #endif /* __cplusplus */ | |
274 | |
275 #endif /* __BENCH_USER_H__ */ |