annotate src/fftw-3.3.3/libbench2/verify.c @ 10:37bf6b4a2645

Add FFTW3
author Chris Cannam
date Wed, 20 Mar 2013 15:35:50 +0000
parents
children
rev   line source
Chris@10 1 /*
Chris@10 2 * Copyright (c) 2000 Matteo Frigo
Chris@10 3 * Copyright (c) 2000 Massachusetts Institute of Technology
Chris@10 4 *
Chris@10 5 * This program is free software; you can redistribute it and/or modify
Chris@10 6 * it under the terms of the GNU General Public License as published by
Chris@10 7 * the Free Software Foundation; either version 2 of the License, or
Chris@10 8 * (at your option) any later version.
Chris@10 9 *
Chris@10 10 * This program is distributed in the hope that it will be useful,
Chris@10 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@10 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@10 13 * GNU General Public License for more details.
Chris@10 14 *
Chris@10 15 * You should have received a copy of the GNU General Public License
Chris@10 16 * along with this program; if not, write to the Free Software
Chris@10 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Chris@10 18 *
Chris@10 19 */
Chris@10 20
Chris@10 21
Chris@10 22 #include <stdio.h>
Chris@10 23 #include <stdlib.h>
Chris@10 24
Chris@10 25 #include "verify.h"
Chris@10 26
Chris@10 27 void verify_problem(bench_problem *p, int rounds, double tol)
Chris@10 28 {
Chris@10 29 errors e;
Chris@10 30 const char *pstring = p->pstring ? p->pstring : "<unknown problem>";
Chris@10 31
Chris@10 32 switch (p->kind) {
Chris@10 33 case PROBLEM_COMPLEX: verify_dft(p, rounds, tol, &e); break;
Chris@10 34 case PROBLEM_REAL: verify_rdft2(p, rounds, tol, &e); break;
Chris@10 35 case PROBLEM_R2R: verify_r2r(p, rounds, tol, &e); break;
Chris@10 36 }
Chris@10 37
Chris@10 38 if (verbose)
Chris@10 39 ovtpvt("%s %g %g %g\n", pstring, e.l, e.i, e.s);
Chris@10 40 }
Chris@10 41
Chris@10 42 void verify(const char *param, int rounds, double tol)
Chris@10 43 {
Chris@10 44 bench_problem *p;
Chris@10 45
Chris@10 46 p = problem_parse(param);
Chris@10 47 problem_alloc(p);
Chris@10 48
Chris@10 49 if (!can_do(p)) {
Chris@10 50 ovtpvt_err("No can_do for %s\n", p->pstring);
Chris@10 51 BENCH_ASSERT(0);
Chris@10 52 }
Chris@10 53
Chris@10 54 problem_zero(p);
Chris@10 55 setup(p);
Chris@10 56
Chris@10 57 verify_problem(p, rounds, tol);
Chris@10 58
Chris@10 59 done(p);
Chris@10 60 problem_destroy(p);
Chris@10 61 }
Chris@10 62
Chris@10 63
Chris@10 64 static void do_accuracy(bench_problem *p, int rounds, int impulse_rounds)
Chris@10 65 {
Chris@10 66 double t[6];
Chris@10 67
Chris@10 68 switch (p->kind) {
Chris@10 69 case PROBLEM_COMPLEX:
Chris@10 70 accuracy_dft(p, rounds, impulse_rounds, t); break;
Chris@10 71 case PROBLEM_REAL:
Chris@10 72 accuracy_rdft2(p, rounds, impulse_rounds, t); break;
Chris@10 73 case PROBLEM_R2R:
Chris@10 74 accuracy_r2r(p, rounds, impulse_rounds, t); break;
Chris@10 75 }
Chris@10 76
Chris@10 77 /* t[0] : L1 error
Chris@10 78 t[1] : L2 error
Chris@10 79 t[2] : Linf error
Chris@10 80 t[3..5]: L1, L2, Linf backward error */
Chris@10 81 ovtpvt("%6.2e %6.2e %6.2e %6.2e %6.2e %6.2e\n",
Chris@10 82 t[0], t[1], t[2], t[3], t[4], t[5]);
Chris@10 83 }
Chris@10 84
Chris@10 85 void accuracy(const char *param, int rounds, int impulse_rounds)
Chris@10 86 {
Chris@10 87 bench_problem *p;
Chris@10 88 p = problem_parse(param);
Chris@10 89 BENCH_ASSERT(can_do(p));
Chris@10 90 problem_alloc(p);
Chris@10 91 problem_zero(p);
Chris@10 92 setup(p);
Chris@10 93 do_accuracy(p, rounds, impulse_rounds);
Chris@10 94 done(p);
Chris@10 95 problem_destroy(p);
Chris@10 96 }