annotate src/fftw-3.3.8/libbench2/speed.c @ 168:ceec0dd9ec9c

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