annotate src/fftw-3.3.5/libbench2/speed.c @ 127:7867fa7e1b6b

Current fftw source
author Chris Cannam <cannam@all-day-breakfast.com>
date Tue, 18 Oct 2016 13:40:26 +0100
parents
children
rev   line source
cannam@127 1 /*
cannam@127 2 * Copyright (c) 2001 Matteo Frigo
cannam@127 3 * Copyright (c) 2001 Massachusetts Institute of Technology
cannam@127 4 *
cannam@127 5 * This program is free software; you can redistribute it and/or modify
cannam@127 6 * it under the terms of the GNU General Public License as published by
cannam@127 7 * the Free Software Foundation; either version 2 of the License, or
cannam@127 8 * (at your option) any later version.
cannam@127 9 *
cannam@127 10 * This program is distributed in the hope that it will be useful,
cannam@127 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cannam@127 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cannam@127 13 * GNU General Public License for more details.
cannam@127 14 *
cannam@127 15 * You should have received a copy of the GNU General Public License
cannam@127 16 * along with this program; if not, write to the Free Software
cannam@127 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
cannam@127 18 *
cannam@127 19 */
cannam@127 20
cannam@127 21
cannam@127 22 #include "bench.h"
cannam@127 23
cannam@127 24 int no_speed_allocation = 0; /* 1 to not allocate array data in speed() */
cannam@127 25
cannam@127 26 void speed(const char *param, int setup_only)
cannam@127 27 {
cannam@127 28 double *t;
cannam@127 29 int iter = 0, k;
cannam@127 30 bench_problem *p;
cannam@127 31 double tmin, y;
cannam@127 32
cannam@127 33 t = (double *) bench_malloc(time_repeat * sizeof(double));
cannam@127 34
cannam@127 35 for (k = 0; k < time_repeat; ++k)
cannam@127 36 t[k] = 0;
cannam@127 37
cannam@127 38 p = problem_parse(param);
cannam@127 39 BENCH_ASSERT(can_do(p));
cannam@127 40 if (!no_speed_allocation) {
cannam@127 41 problem_alloc(p);
cannam@127 42 problem_zero(p);
cannam@127 43 }
cannam@127 44
cannam@127 45 timer_start(LIBBENCH_TIMER);
cannam@127 46 setup(p);
cannam@127 47 p->setup_time = bench_cost_postprocess(timer_stop(LIBBENCH_TIMER));
cannam@127 48
cannam@127 49 /* reset the input to zero again, because the planner in paranoid
cannam@127 50 mode sets it to random values, thus making the benchmark
cannam@127 51 diverge. */
cannam@127 52 if (!no_speed_allocation)
cannam@127 53 problem_zero(p);
cannam@127 54
cannam@127 55 if (setup_only)
cannam@127 56 goto done;
cannam@127 57
cannam@127 58 start_over:
cannam@127 59 for (iter = 1; iter < (1<<30); iter *= 2) {
cannam@127 60 tmin = 1.0e20;
cannam@127 61 for (k = 0; k < time_repeat; ++k) {
cannam@127 62 timer_start(LIBBENCH_TIMER);
cannam@127 63 doit(iter, p);
cannam@127 64 y = bench_cost_postprocess(timer_stop(LIBBENCH_TIMER));
cannam@127 65 if (y < 0) /* yes, it happens */
cannam@127 66 goto start_over;
cannam@127 67 t[k] = y;
cannam@127 68 if (y < tmin)
cannam@127 69 tmin = y;
cannam@127 70 }
cannam@127 71
cannam@127 72 if (tmin >= time_min)
cannam@127 73 goto done;
cannam@127 74 }
cannam@127 75
cannam@127 76 goto start_over; /* this also happens */
cannam@127 77
cannam@127 78 done:
cannam@127 79 done(p);
cannam@127 80
cannam@127 81 if (iter)
cannam@127 82 for (k = 0; k < time_repeat; ++k)
cannam@127 83 t[k] /= iter;
cannam@127 84 else
cannam@127 85 for (k = 0; k < time_repeat; ++k)
cannam@127 86 t[k] = 0;
cannam@127 87
cannam@127 88 report(p, t, time_repeat);
cannam@127 89
cannam@127 90 if (!no_speed_allocation)
cannam@127 91 problem_destroy(p);
cannam@127 92 bench_free(t);
cannam@127 93 return;
cannam@127 94 }