annotate fft/fftw/fftw-3.3.4/libbench2/bench-user.h @ 40:223f770b5341 kissfft-double tip

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