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