cannam@167: /* cannam@167: * Copyright (c) 2003, 2007-14 Matteo Frigo cannam@167: * Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology cannam@167: * cannam@167: * This program is free software; you can redistribute it and/or modify cannam@167: * it under the terms of the GNU General Public License as published by cannam@167: * the Free Software Foundation; either version 2 of the License, or cannam@167: * (at your option) any later version. cannam@167: * cannam@167: * This program is distributed in the hope that it will be useful, cannam@167: * but WITHOUT ANY WARRANTY; without even the implied warranty of cannam@167: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the cannam@167: * GNU General Public License for more details. cannam@167: * cannam@167: * You should have received a copy of the GNU General Public License cannam@167: * along with this program; if not, write to the Free Software cannam@167: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA cannam@167: * cannam@167: */ cannam@167: cannam@167: #include "libbench2/bench.h" cannam@167: cannam@167: typedef bench_real R; cannam@167: typedef bench_complex C; cannam@167: cannam@167: typedef struct dofft_closure_s { cannam@167: void (*apply)(struct dofft_closure_s *k, cannam@167: bench_complex *in, bench_complex *out); cannam@167: int recopy_input; cannam@167: } dofft_closure; cannam@167: cannam@167: double dmax(double x, double y); cannam@167: cannam@167: typedef void (*aconstrain)(C *a, int n); cannam@167: cannam@167: void arand(C *a, int n); cannam@167: void mkreal(C *A, int n); cannam@167: void mkhermitian(C *A, int rank, const bench_iodim *dim, int stride); cannam@167: void mkhermitian1(C *a, int n); cannam@167: void aadd(C *c, C *a, C *b, int n); cannam@167: void asub(C *c, C *a, C *b, int n); cannam@167: void arol(C *b, C *a, int n, int nb, int na); cannam@167: void aphase_shift(C *b, C *a, int n, int nb, int na, double sign); cannam@167: void ascale(C *a, C alpha, int n); cannam@167: double acmp(C *a, C *b, int n, const char *test, double tol); cannam@167: double mydrand(void); cannam@167: double impulse(dofft_closure *k, cannam@167: int n, int vecn, cannam@167: C *inA, C *inB, C *inC, cannam@167: C *outA, C *outB, C *outC, cannam@167: C *tmp, int rounds, double tol); cannam@167: double linear(dofft_closure *k, int realp, cannam@167: int n, C *inA, C *inB, C *inC, C *outA, cannam@167: C *outB, C *outC, C *tmp, int rounds, double tol); cannam@167: void preserves_input(dofft_closure *k, aconstrain constrain, cannam@167: int n, C *inA, C *inB, C *outB, int rounds); cannam@167: cannam@167: enum { TIME_SHIFT, FREQ_SHIFT }; cannam@167: double tf_shift(dofft_closure *k, int realp, const bench_tensor *sz, cannam@167: int n, int vecn, double sign, cannam@167: C *inA, C *inB, C *outA, C *outB, C *tmp, cannam@167: int rounds, double tol, int which_shift); cannam@167: cannam@167: typedef struct dotens2_closure_s { cannam@167: void (*apply)(struct dotens2_closure_s *k, cannam@167: int indx0, int ondx0, int indx1, int ondx1); cannam@167: } dotens2_closure; cannam@167: cannam@167: void bench_dotens2(const bench_tensor *sz0, cannam@167: const bench_tensor *sz1, dotens2_closure *k); cannam@167: cannam@167: void accuracy_test(dofft_closure *k, aconstrain constrain, cannam@167: int sign, int n, C *a, C *b, int rounds, int impulse_rounds, cannam@167: double t[6]); cannam@167: cannam@167: void accuracy_dft(bench_problem *p, int rounds, int impulse_rounds, cannam@167: double t[6]); cannam@167: void accuracy_rdft2(bench_problem *p, int rounds, int impulse_rounds, cannam@167: double t[6]); cannam@167: void accuracy_r2r(bench_problem *p, int rounds, int impulse_rounds, cannam@167: double t[6]); cannam@167: cannam@167: #if defined(BENCHFFT_LDOUBLE) && HAVE_COSL cannam@167: typedef long double trigreal; cannam@167: # define COS cosl cannam@167: # define SIN sinl cannam@167: # define TAN tanl cannam@167: # define KTRIG(x) (x##L) cannam@167: #elif defined(BENCHFFT_QUAD) && HAVE_LIBQUADMATH cannam@167: typedef __float128 trigreal; cannam@167: # define COS cosq cannam@167: # define SIN sinq cannam@167: # define TAN tanq cannam@167: # define KTRIG(x) (x##Q) cannam@167: extern trigreal cosq(trigreal); cannam@167: extern trigreal sinq(trigreal); cannam@167: extern trigreal tanq(trigreal); cannam@167: #else cannam@167: typedef double trigreal; cannam@167: # define COS cos cannam@167: # define SIN sin cannam@167: # define TAN tan cannam@167: # define KTRIG(x) (x) cannam@167: #endif cannam@167: #define K2PI KTRIG(6.2831853071795864769252867665590057683943388)