annotate src/fftw-3.3.5/libbench2/verify-dft.c @ 84:08ae793730bd

Add null config files
author Chris Cannam
date Mon, 02 Mar 2020 14:03:47 +0000
parents 2cd0e3b3e1fd
children
rev   line source
Chris@42 1 /*
Chris@42 2 * Copyright (c) 2003, 2007-14 Matteo Frigo
Chris@42 3 * Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
Chris@42 4 *
Chris@42 5 * This program is free software; you can redistribute it and/or modify
Chris@42 6 * it under the terms of the GNU General Public License as published by
Chris@42 7 * the Free Software Foundation; either version 2 of the License, or
Chris@42 8 * (at your option) any later version.
Chris@42 9 *
Chris@42 10 * This program is distributed in the hope that it will be useful,
Chris@42 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@42 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@42 13 * GNU General Public License for more details.
Chris@42 14 *
Chris@42 15 * You should have received a copy of the GNU General Public License
Chris@42 16 * along with this program; if not, write to the Free Software
Chris@42 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Chris@42 18 *
Chris@42 19 */
Chris@42 20
Chris@42 21
Chris@42 22 #include "verify.h"
Chris@42 23
Chris@42 24 /* copy A into B, using output stride of A and input stride of B */
Chris@42 25 typedef struct {
Chris@42 26 dotens2_closure k;
Chris@42 27 R *ra; R *ia;
Chris@42 28 R *rb; R *ib;
Chris@42 29 int scalea, scaleb;
Chris@42 30 } cpy_closure;
Chris@42 31
Chris@42 32 static void cpy0(dotens2_closure *k_,
Chris@42 33 int indxa, int ondxa, int indxb, int ondxb)
Chris@42 34 {
Chris@42 35 cpy_closure *k = (cpy_closure *)k_;
Chris@42 36 k->rb[indxb * k->scaleb] = k->ra[ondxa * k->scalea];
Chris@42 37 k->ib[indxb * k->scaleb] = k->ia[ondxa * k->scalea];
Chris@42 38 UNUSED(indxa); UNUSED(ondxb);
Chris@42 39 }
Chris@42 40
Chris@42 41 static void cpy(R *ra, R *ia, const bench_tensor *sza, int scalea,
Chris@42 42 R *rb, R *ib, const bench_tensor *szb, int scaleb)
Chris@42 43 {
Chris@42 44 cpy_closure k;
Chris@42 45 k.k.apply = cpy0;
Chris@42 46 k.ra = ra; k.ia = ia; k.rb = rb; k.ib = ib;
Chris@42 47 k.scalea = scalea; k.scaleb = scaleb;
Chris@42 48 bench_dotens2(sza, szb, &k.k);
Chris@42 49 }
Chris@42 50
Chris@42 51 typedef struct {
Chris@42 52 dofft_closure k;
Chris@42 53 bench_problem *p;
Chris@42 54 } dofft_dft_closure;
Chris@42 55
Chris@42 56 static void dft_apply(dofft_closure *k_, bench_complex *in, bench_complex *out)
Chris@42 57 {
Chris@42 58 dofft_dft_closure *k = (dofft_dft_closure *)k_;
Chris@42 59 bench_problem *p = k->p;
Chris@42 60 bench_tensor *totalsz, *pckdsz;
Chris@42 61 bench_tensor *totalsz_swap, *pckdsz_swap;
Chris@42 62 bench_real *ri, *ii, *ro, *io;
Chris@42 63 int totalscale;
Chris@42 64
Chris@42 65 totalsz = tensor_append(p->vecsz, p->sz);
Chris@42 66 pckdsz = verify_pack(totalsz, 2);
Chris@42 67 ri = (bench_real *) p->in;
Chris@42 68 ro = (bench_real *) p->out;
Chris@42 69
Chris@42 70 totalsz_swap = tensor_copy_swapio(totalsz);
Chris@42 71 pckdsz_swap = tensor_copy_swapio(pckdsz);
Chris@42 72
Chris@42 73 /* confusion: the stride is the distance between complex elements
Chris@42 74 when using interleaved format, but it is the distance between
Chris@42 75 real elements when using split format */
Chris@42 76 if (p->split) {
Chris@42 77 ii = p->ini ? (bench_real *) p->ini : ri + p->iphyssz;
Chris@42 78 io = p->outi ? (bench_real *) p->outi : ro + p->ophyssz;
Chris@42 79 totalscale = 1;
Chris@42 80 } else {
Chris@42 81 ii = p->ini ? (bench_real *) p->ini : ri + 1;
Chris@42 82 io = p->outi ? (bench_real *) p->outi : ro + 1;
Chris@42 83 totalscale = 2;
Chris@42 84 }
Chris@42 85
Chris@42 86 cpy(&c_re(in[0]), &c_im(in[0]), pckdsz, 1,
Chris@42 87 ri, ii, totalsz, totalscale);
Chris@42 88 after_problem_ccopy_from(p, ri, ii);
Chris@42 89 doit(1, p);
Chris@42 90 after_problem_ccopy_to(p, ro, io);
Chris@42 91 if (k->k.recopy_input)
Chris@42 92 cpy(ri, ii, totalsz_swap, totalscale,
Chris@42 93 &c_re(in[0]), &c_im(in[0]), pckdsz_swap, 1);
Chris@42 94 cpy(ro, io, totalsz, totalscale,
Chris@42 95 &c_re(out[0]), &c_im(out[0]), pckdsz, 1);
Chris@42 96
Chris@42 97 tensor_destroy(totalsz);
Chris@42 98 tensor_destroy(pckdsz);
Chris@42 99 tensor_destroy(totalsz_swap);
Chris@42 100 tensor_destroy(pckdsz_swap);
Chris@42 101 }
Chris@42 102
Chris@42 103 void verify_dft(bench_problem *p, int rounds, double tol, errors *e)
Chris@42 104 {
Chris@42 105 C *inA, *inB, *inC, *outA, *outB, *outC, *tmp;
Chris@42 106 int n, vecn, N;
Chris@42 107 dofft_dft_closure k;
Chris@42 108
Chris@42 109 BENCH_ASSERT(p->kind == PROBLEM_COMPLEX);
Chris@42 110
Chris@42 111 k.k.apply = dft_apply;
Chris@42 112 k.k.recopy_input = 0;
Chris@42 113 k.p = p;
Chris@42 114
Chris@42 115 if (rounds == 0)
Chris@42 116 rounds = 20; /* default value */
Chris@42 117
Chris@42 118 n = tensor_sz(p->sz);
Chris@42 119 vecn = tensor_sz(p->vecsz);
Chris@42 120 N = n * vecn;
Chris@42 121
Chris@42 122 inA = (C *) bench_malloc(N * sizeof(C));
Chris@42 123 inB = (C *) bench_malloc(N * sizeof(C));
Chris@42 124 inC = (C *) bench_malloc(N * sizeof(C));
Chris@42 125 outA = (C *) bench_malloc(N * sizeof(C));
Chris@42 126 outB = (C *) bench_malloc(N * sizeof(C));
Chris@42 127 outC = (C *) bench_malloc(N * sizeof(C));
Chris@42 128 tmp = (C *) bench_malloc(N * sizeof(C));
Chris@42 129
Chris@42 130 e->i = impulse(&k.k, n, vecn, inA, inB, inC, outA, outB, outC,
Chris@42 131 tmp, rounds, tol);
Chris@42 132 e->l = linear(&k.k, 0, N, inA, inB, inC, outA, outB, outC,
Chris@42 133 tmp, rounds, tol);
Chris@42 134
Chris@42 135 e->s = 0.0;
Chris@42 136 e->s = dmax(e->s, tf_shift(&k.k, 0, p->sz, n, vecn, p->sign,
Chris@42 137 inA, inB, outA, outB,
Chris@42 138 tmp, rounds, tol, TIME_SHIFT));
Chris@42 139 e->s = dmax(e->s, tf_shift(&k.k, 0, p->sz, n, vecn, p->sign,
Chris@42 140 inA, inB, outA, outB,
Chris@42 141 tmp, rounds, tol, FREQ_SHIFT));
Chris@42 142
Chris@42 143 if (!p->in_place && !p->destroy_input)
Chris@42 144 preserves_input(&k.k, 0, N, inA, inB, outB, rounds);
Chris@42 145
Chris@42 146 bench_free(tmp);
Chris@42 147 bench_free(outC);
Chris@42 148 bench_free(outB);
Chris@42 149 bench_free(outA);
Chris@42 150 bench_free(inC);
Chris@42 151 bench_free(inB);
Chris@42 152 bench_free(inA);
Chris@42 153 }
Chris@42 154
Chris@42 155
Chris@42 156 void accuracy_dft(bench_problem *p, int rounds, int impulse_rounds,
Chris@42 157 double t[6])
Chris@42 158 {
Chris@42 159 dofft_dft_closure k;
Chris@42 160 int n;
Chris@42 161 C *a, *b;
Chris@42 162
Chris@42 163 BENCH_ASSERT(p->kind == PROBLEM_COMPLEX);
Chris@42 164 BENCH_ASSERT(p->sz->rnk == 1);
Chris@42 165 BENCH_ASSERT(p->vecsz->rnk == 0);
Chris@42 166
Chris@42 167 k.k.apply = dft_apply;
Chris@42 168 k.k.recopy_input = 0;
Chris@42 169 k.p = p;
Chris@42 170 n = tensor_sz(p->sz);
Chris@42 171
Chris@42 172 a = (C *) bench_malloc(n * sizeof(C));
Chris@42 173 b = (C *) bench_malloc(n * sizeof(C));
Chris@42 174 accuracy_test(&k.k, 0, p->sign, n, a, b, rounds, impulse_rounds, t);
Chris@42 175 bench_free(b);
Chris@42 176 bench_free(a);
Chris@42 177 }