annotate src/fftw-3.3.8/libbench2/bench-user.h @ 83:ae30d91d2ffe

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