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