annotate src/fftw-3.3.5/libbench2/bench-user.h @ 56:af97cad61ff0

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