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