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