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