annotate src/fftw-3.3.5/kernel/buffered.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 /* routines shared by the various buffered solvers */
Chris@42 22
Chris@42 23 #include "ifftw.h"
Chris@42 24
Chris@42 25 #define DEFAULT_MAXNBUF ((INT)256)
Chris@42 26
Chris@42 27 /* approx. 512KB of buffers for complex data */
Chris@42 28 #define MAXBUFSZ (256 * 1024 / (INT)(sizeof(R)))
Chris@42 29
Chris@42 30 INT X(nbuf)(INT n, INT vl, INT maxnbuf)
Chris@42 31 {
Chris@42 32 INT i, nbuf, lb;
Chris@42 33
Chris@42 34 if (!maxnbuf)
Chris@42 35 maxnbuf = DEFAULT_MAXNBUF;
Chris@42 36
Chris@42 37 nbuf = X(imin)(maxnbuf,
Chris@42 38 X(imin)(vl, X(imax)((INT)1, MAXBUFSZ / n)));
Chris@42 39
Chris@42 40 /*
Chris@42 41 * Look for a buffer number (not too small) that divides the
Chris@42 42 * vector length, in order that we only need one child plan:
Chris@42 43 */
Chris@42 44 lb = X(imax)(1, nbuf / 4);
Chris@42 45 for (i = nbuf; i >= lb; --i)
Chris@42 46 if (vl % i == 0)
Chris@42 47 return i;
Chris@42 48
Chris@42 49 /* whatever... */
Chris@42 50 return nbuf;
Chris@42 51 }
Chris@42 52
Chris@42 53 #define SKEW 6 /* need to be even for SIMD */
Chris@42 54 #define SKEWMOD 8
Chris@42 55
Chris@42 56 INT X(bufdist)(INT n, INT vl)
Chris@42 57 {
Chris@42 58 if (vl == 1)
Chris@42 59 return n;
Chris@42 60 else
Chris@42 61 /* return smallest X such that X >= N and X == SKEW (mod SKEWMOD) */
Chris@42 62 return n + X(modulo)(SKEW - n, SKEWMOD);
Chris@42 63 }
Chris@42 64
Chris@42 65 int X(toobig)(INT n)
Chris@42 66 {
Chris@42 67 return n > MAXBUFSZ;
Chris@42 68 }
Chris@42 69
Chris@42 70 /* TRUE if there exists i < which such that maxnbuf[i] and
Chris@42 71 maxnbuf[which] yield the same value, in which case we canonicalize
Chris@42 72 on the minimum value */
Chris@42 73 int X(nbuf_redundant)(INT n, INT vl, size_t which,
Chris@42 74 const INT *maxnbuf, size_t nmaxnbuf)
Chris@42 75 {
Chris@42 76 size_t i;
Chris@42 77 (void)nmaxnbuf; /* UNUSED */
Chris@42 78 for (i = 0; i < which; ++i)
Chris@42 79 if (X(nbuf)(n, vl, maxnbuf[i]) == X(nbuf)(n, vl, maxnbuf[which]))
Chris@42 80 return 1;
Chris@42 81 return 0;
Chris@42 82 }