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