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