annotate fft/fftw/fftw-3.3.4/mpi/rearrange.c @ 40:223f770b5341 kissfft-double tip

Try a double-precision kissfft
author Chris Cannam
date Wed, 07 Sep 2016 10:40:32 +0100
parents 26056e866c29
children
rev   line source
Chris@19 1 /*
Chris@19 2 * Copyright (c) 2003, 2007-14 Matteo Frigo
Chris@19 3 * Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
Chris@19 4 *
Chris@19 5 * This program is free software; you can redistribute it and/or modify
Chris@19 6 * it under the terms of the GNU General Public License as published by
Chris@19 7 * the Free Software Foundation; either version 2 of the License, or
Chris@19 8 * (at your option) any later version.
Chris@19 9 *
Chris@19 10 * This program is distributed in the hope that it will be useful,
Chris@19 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@19 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@19 13 * GNU General Public License for more details.
Chris@19 14 *
Chris@19 15 * You should have received a copy of the GNU General Public License
Chris@19 16 * along with this program; if not, write to the Free Software
Chris@19 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Chris@19 18 *
Chris@19 19 */
Chris@19 20
Chris@19 21 #include "ifftw-mpi.h"
Chris@19 22
Chris@19 23 /* common functions for rearrangements of the data for the *-rank1-bigvec
Chris@19 24 solvers */
Chris@19 25
Chris@19 26 static int div_mult(INT b, INT a) {
Chris@19 27 return (a > b && a % b == 0);
Chris@19 28 }
Chris@19 29 static int div_mult2(INT b, INT a, INT n) {
Chris@19 30 return (div_mult(b, a) && div_mult(n, b));
Chris@19 31 }
Chris@19 32
Chris@19 33 int XM(rearrange_applicable)(rearrangement rearrange,
Chris@19 34 ddim dim0, INT vn, int n_pes)
Chris@19 35 {
Chris@19 36 /* note: it is important that cases other than CONTIG be
Chris@19 37 applicable only when the resulting transpose dimension
Chris@19 38 is divisible by n_pes; otherwise, the allocation size
Chris@19 39 returned by the API will be incorrect */
Chris@19 40 return ((rearrange != DISCONTIG || div_mult(n_pes, vn))
Chris@19 41 && (rearrange != SQUARE_BEFORE
Chris@19 42 || div_mult2(dim0.b[IB], vn, n_pes))
Chris@19 43 && (rearrange != SQUARE_AFTER
Chris@19 44 || (dim0.b[IB] != dim0.b[OB]
Chris@19 45 && div_mult2(dim0.b[OB], vn, n_pes)))
Chris@19 46 && (rearrange != SQUARE_MIDDLE
Chris@19 47 || div_mult(dim0.n * n_pes, vn)));
Chris@19 48 }
Chris@19 49
Chris@19 50 INT XM(rearrange_ny)(rearrangement rearrange, ddim dim0, INT vn, int n_pes)
Chris@19 51 {
Chris@19 52 switch (rearrange) {
Chris@19 53 case CONTIG:
Chris@19 54 return vn;
Chris@19 55 case DISCONTIG:
Chris@19 56 return n_pes;
Chris@19 57 case SQUARE_BEFORE:
Chris@19 58 return dim0.b[IB];
Chris@19 59 case SQUARE_AFTER:
Chris@19 60 return dim0.b[OB];
Chris@19 61 case SQUARE_MIDDLE:
Chris@19 62 return dim0.n * n_pes;
Chris@19 63 }
Chris@19 64 return 0;
Chris@19 65 }