annotate src/fftw-3.3.3/kernel/buffered.c @ 127:7867fa7e1b6b

Current fftw source
author Chris Cannam <cannam@all-day-breakfast.com>
date Tue, 18 Oct 2016 13:40:26 +0100
parents 89f5e221ed7b
children
rev   line source
cannam@95 1 /*
cannam@95 2 * Copyright (c) 2003, 2007-11 Matteo Frigo
cannam@95 3 * Copyright (c) 2003, 2007-11 Massachusetts Institute of Technology
cannam@95 4 *
cannam@95 5 * This program is free software; you can redistribute it and/or modify
cannam@95 6 * it under the terms of the GNU General Public License as published by
cannam@95 7 * the Free Software Foundation; either version 2 of the License, or
cannam@95 8 * (at your option) any later version.
cannam@95 9 *
cannam@95 10 * This program is distributed in the hope that it will be useful,
cannam@95 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cannam@95 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cannam@95 13 * GNU General Public License for more details.
cannam@95 14 *
cannam@95 15 * You should have received a copy of the GNU General Public License
cannam@95 16 * along with this program; if not, write to the Free Software
cannam@95 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
cannam@95 18 *
cannam@95 19 */
cannam@95 20
cannam@95 21 /* routines shared by the various buffered solvers */
cannam@95 22
cannam@95 23 #include "ifftw.h"
cannam@95 24
cannam@95 25 #define DEFAULT_MAXNBUF ((INT)256)
cannam@95 26
cannam@95 27 /* approx. 512KB of buffers for complex data */
cannam@95 28 #define MAXBUFSZ (256 * 1024 / (INT)(sizeof(R)))
cannam@95 29
cannam@95 30 INT X(nbuf)(INT n, INT vl, INT maxnbuf)
cannam@95 31 {
cannam@95 32 INT i, nbuf, lb;
cannam@95 33
cannam@95 34 if (!maxnbuf)
cannam@95 35 maxnbuf = DEFAULT_MAXNBUF;
cannam@95 36
cannam@95 37 nbuf = X(imin)(maxnbuf,
cannam@95 38 X(imin)(vl, X(imax)((INT)1, MAXBUFSZ / n)));
cannam@95 39
cannam@95 40 /*
cannam@95 41 * Look for a buffer number (not too small) that divides the
cannam@95 42 * vector length, in order that we only need one child plan:
cannam@95 43 */
cannam@95 44 lb = X(imax)(1, nbuf / 4);
cannam@95 45 for (i = nbuf; i >= lb; --i)
cannam@95 46 if (vl % i == 0)
cannam@95 47 return i;
cannam@95 48
cannam@95 49 /* whatever... */
cannam@95 50 return nbuf;
cannam@95 51 }
cannam@95 52
cannam@95 53 #define SKEW 6 /* need to be even for SIMD */
cannam@95 54 #define SKEWMOD 8
cannam@95 55
cannam@95 56 INT X(bufdist)(INT n, INT vl)
cannam@95 57 {
cannam@95 58 if (vl == 1)
cannam@95 59 return n;
cannam@95 60 else
cannam@95 61 /* return smallest X such that X >= N and X == SKEW (mod SKEWMOD) */
cannam@95 62 return n + X(modulo)(SKEW - n, SKEWMOD);
cannam@95 63 }
cannam@95 64
cannam@95 65 int X(toobig)(INT n)
cannam@95 66 {
cannam@95 67 return n > MAXBUFSZ;
cannam@95 68 }
cannam@95 69
cannam@95 70 /* TRUE if there exists i < which such that maxnbuf[i] and
cannam@95 71 maxnbuf[which] yield the same value, in which case we canonicalize
cannam@95 72 on the minimum value */
cannam@95 73 int X(nbuf_redundant)(INT n, INT vl, int which,
cannam@95 74 const INT *maxnbuf, int nmaxnbuf)
cannam@95 75 {
cannam@95 76 int i;
cannam@95 77 (void)nmaxnbuf; /* UNUSED */
cannam@95 78 for (i = 0; i < which; ++i)
cannam@95 79 if (X(nbuf)(n, vl, maxnbuf[i]) == X(nbuf)(n, vl, maxnbuf[which]))
cannam@95 80 return 1;
cannam@95 81 return 0;
cannam@95 82 }