comparison src/fftw-3.3.3/mpi/ifftw-mpi.h @ 10:37bf6b4a2645

Add FFTW3
author Chris Cannam
date Wed, 20 Mar 2013 15:35:50 +0000
parents
children
comparison
equal deleted inserted replaced
9:c0fb53affa76 10:37bf6b4a2645
1 /*
2 * Copyright (c) 2003, 2007-11 Matteo Frigo
3 * Copyright (c) 2003, 2007-11 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 /* FFTW-MPI internal header file */
22 #ifndef __IFFTW_MPI_H__
23 #define __IFFTW_MPI_H__
24
25 #include "ifftw.h"
26 #include "rdft.h"
27
28 #include <mpi.h>
29
30 /* mpi problem flags: problem-dependent meaning, but in general
31 SCRAMBLED means some reordering *within* the dimensions, while
32 TRANSPOSED means some reordering *of* the dimensions */
33 #define SCRAMBLED_IN (1 << 0)
34 #define SCRAMBLED_OUT (1 << 1)
35 #define TRANSPOSED_IN (1 << 2)
36 #define TRANSPOSED_OUT (1 << 3)
37 #define RANK1_BIGVEC_ONLY (1 << 4) /* for rank=1, allow only bigvec solver */
38
39 #define ONLY_SCRAMBLEDP(flags) (!((flags) & ~(SCRAMBLED_IN|SCRAMBLED_OUT)))
40 #define ONLY_TRANSPOSEDP(flags) (!((flags) & ~(TRANSPOSED_IN|TRANSPOSED_OUT)))
41
42 #if defined(FFTW_SINGLE)
43 # define FFTW_MPI_TYPE MPI_FLOAT
44 #elif defined(FFTW_LDOUBLE)
45 # define FFTW_MPI_TYPE MPI_LONG_DOUBLE
46 #elif defined(FFTW_QUAD)
47 # error MPI quad-precision type is unknown
48 #else
49 # define FFTW_MPI_TYPE MPI_DOUBLE
50 #endif
51
52 /* all fftw-mpi identifiers start with fftw_mpi (or fftwf_mpi etc.) */
53 #define XM(name) X(CONCAT(mpi_, name))
54
55 /***********************************************************************/
56 /* block distributions */
57
58 /* a distributed dimension of length n with input and output block
59 sizes ib and ob, respectively. */
60 typedef enum { IB = 0, OB } block_kind;
61 typedef struct {
62 INT n;
63 INT b[2]; /* b[IB], b[OB] */
64 } ddim;
65
66 /* Loop over k in {IB, OB}. Note: need explicit casts for C++. */
67 #define FORALL_BLOCK_KIND(k) for (k = IB; k <= OB; k = (block_kind) (((int) k) + 1))
68
69 /* unlike tensors in the serial FFTW, the ordering of the dtensor
70 dimensions matters - both the array and the block layout are
71 row-major order. */
72 typedef struct {
73 int rnk;
74 #if defined(STRUCT_HACK_KR)
75 ddim dims[1];
76 #elif defined(STRUCT_HACK_C99)
77 ddim dims[];
78 #else
79 ddim *dims;
80 #endif
81 } dtensor;
82
83
84 /* dtensor.c: */
85 dtensor *XM(mkdtensor)(int rnk);
86 void XM(dtensor_destroy)(dtensor *sz);
87 dtensor *XM(dtensor_copy)(const dtensor *sz);
88 dtensor *XM(dtensor_canonical)(const dtensor *sz, int compress);
89 int XM(dtensor_validp)(const dtensor *sz);
90 void XM(dtensor_md5)(md5 *p, const dtensor *t);
91 void XM(dtensor_print)(const dtensor *t, printer *p);
92
93 /* block.c: */
94
95 /* for a single distributed dimension: */
96 INT XM(num_blocks)(INT n, INT block);
97 int XM(num_blocks_ok)(INT n, INT block, MPI_Comm comm);
98 INT XM(default_block)(INT n, int n_pes);
99 INT XM(block)(INT n, INT block, int which_block);
100
101 /* for multiple distributed dimensions: */
102 INT XM(num_blocks_total)(const dtensor *sz, block_kind k);
103 int XM(idle_process)(const dtensor *sz, block_kind k, int which_pe);
104 void XM(block_coords)(const dtensor *sz, block_kind k, int which_pe,
105 INT *coords);
106 INT XM(total_block)(const dtensor *sz, block_kind k, int which_pe);
107 int XM(is_local_after)(int dim, const dtensor *sz, block_kind k);
108 int XM(is_local)(const dtensor *sz, block_kind k);
109 int XM(is_block1d)(const dtensor *sz, block_kind k);
110
111 /* choose-radix.c */
112 INT XM(choose_radix)(ddim d, int n_pes, unsigned flags, int sign,
113 INT rblock[2], INT mblock[2]);
114
115 /***********************************************************************/
116 /* any_true.c */
117 int XM(any_true)(int condition, MPI_Comm comm);
118 int XM(md5_equal)(md5 m, MPI_Comm comm);
119
120 /* conf.c */
121 void XM(conf_standard)(planner *p);
122
123 /***********************************************************************/
124 /* rearrange.c */
125
126 /* Different ways to rearrange the vector dimension vn during transposition,
127 reflecting different tradeoffs between ease of transposition and
128 contiguity during the subsequent DFTs.
129
130 TODO: can we pare this down to CONTIG and DISCONTIG, at least
131 in MEASURE mode? SQUARE_MIDDLE is also used for 1d destroy-input DFTs. */
132 typedef enum {
133 CONTIG = 0, /* vn x 1: make subsequent DFTs contiguous */
134 DISCONTIG, /* P x (vn/P) for P processes */
135 SQUARE_BEFORE, /* try to get square transpose at beginning */
136 SQUARE_MIDDLE, /* try to get square transpose in the middle */
137 SQUARE_AFTER /* try to get square transpose at end */
138 } rearrangement;
139
140 /* skipping SQUARE_AFTER since it doesn't seem to offer any advantage
141 over SQUARE_BEFORE */
142 #define FORALL_REARRANGE(rearrange) for (rearrange = CONTIG; rearrange <= SQUARE_MIDDLE; rearrange = (rearrangement) (((int) rearrange) + 1))
143
144 int XM(rearrange_applicable)(rearrangement rearrange,
145 ddim dim0, INT vn, int n_pes);
146 INT XM(rearrange_ny)(rearrangement rearrange, ddim dim0, INT vn, int n_pes);
147
148 /***********************************************************************/
149
150 #endif /* __IFFTW_MPI_H__ */
151