Mercurial > hg > sv-dependency-builds
comparison src/fftw-3.3.3/mpi/dft-problem.c @ 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 #include "mpi-dft.h" | |
22 | |
23 static void destroy(problem *ego_) | |
24 { | |
25 problem_mpi_dft *ego = (problem_mpi_dft *) ego_; | |
26 XM(dtensor_destroy)(ego->sz); | |
27 MPI_Comm_free(&ego->comm); | |
28 X(ifree)(ego_); | |
29 } | |
30 | |
31 static void hash(const problem *p_, md5 *m) | |
32 { | |
33 const problem_mpi_dft *p = (const problem_mpi_dft *) p_; | |
34 int i; | |
35 X(md5puts)(m, "mpi-dft"); | |
36 X(md5int)(m, p->I == p->O); | |
37 /* don't include alignment -- may differ between processes | |
38 X(md5int)(m, X(alignment_of)(p->I)); | |
39 X(md5int)(m, X(alignment_of)(p->O)); | |
40 ... note that applicability of MPI plans does not depend | |
41 on alignment (although optimality may, in principle). */ | |
42 XM(dtensor_md5)(m, p->sz); | |
43 X(md5INT)(m, p->vn); | |
44 X(md5int)(m, p->sign); | |
45 X(md5int)(m, p->flags); | |
46 MPI_Comm_size(p->comm, &i); X(md5int)(m, i); | |
47 A(XM(md5_equal)(*m, p->comm)); | |
48 } | |
49 | |
50 static void print(const problem *ego_, printer *p) | |
51 { | |
52 const problem_mpi_dft *ego = (const problem_mpi_dft *) ego_; | |
53 int i; | |
54 p->print(p, "(mpi-dft %d %d %d ", | |
55 ego->I == ego->O, | |
56 X(alignment_of)(ego->I), | |
57 X(alignment_of)(ego->O)); | |
58 XM(dtensor_print)(ego->sz, p); | |
59 p->print(p, " %D %d %d", ego->vn, ego->sign, ego->flags); | |
60 MPI_Comm_size(ego->comm, &i); p->print(p, " %d)", i); | |
61 } | |
62 | |
63 static void zero(const problem *ego_) | |
64 { | |
65 const problem_mpi_dft *ego = (const problem_mpi_dft *) ego_; | |
66 R *I = ego->I; | |
67 INT i, N; | |
68 int my_pe; | |
69 | |
70 MPI_Comm_rank(ego->comm, &my_pe); | |
71 N = 2 * ego->vn * XM(total_block)(ego->sz, IB, my_pe); | |
72 for (i = 0; i < N; ++i) I[i] = K(0.0); | |
73 } | |
74 | |
75 static const problem_adt padt = | |
76 { | |
77 PROBLEM_MPI_DFT, | |
78 hash, | |
79 zero, | |
80 print, | |
81 destroy | |
82 }; | |
83 | |
84 problem *XM(mkproblem_dft)(const dtensor *sz, INT vn, | |
85 R *I, R *O, | |
86 MPI_Comm comm, | |
87 int sign, | |
88 unsigned flags) | |
89 { | |
90 problem_mpi_dft *ego = | |
91 (problem_mpi_dft *)X(mkproblem)(sizeof(problem_mpi_dft), &padt); | |
92 int n_pes; | |
93 | |
94 A(XM(dtensor_validp)(sz) && FINITE_RNK(sz->rnk)); | |
95 MPI_Comm_size(comm, &n_pes); | |
96 A(n_pes >= XM(num_blocks_total)(sz, IB) | |
97 && n_pes >= XM(num_blocks_total)(sz, OB)); | |
98 A(vn >= 0); | |
99 A(sign == -1 || sign == 1); | |
100 | |
101 /* enforce pointer equality if untainted pointers are equal */ | |
102 if (UNTAINT(I) == UNTAINT(O)) | |
103 I = O = JOIN_TAINT(I, O); | |
104 | |
105 ego->sz = XM(dtensor_canonical)(sz, 1); | |
106 ego->vn = vn; | |
107 ego->I = I; | |
108 ego->O = O; | |
109 ego->sign = sign; | |
110 | |
111 /* canonicalize: replace TRANSPOSED_IN with TRANSPOSED_OUT by | |
112 swapping the first two dimensions (for rnk > 1) */ | |
113 if ((flags & TRANSPOSED_IN) && ego->sz->rnk > 1) { | |
114 ddim dim0 = ego->sz->dims[0]; | |
115 ego->sz->dims[0] = ego->sz->dims[1]; | |
116 ego->sz->dims[1] = dim0; | |
117 flags &= ~TRANSPOSED_IN; | |
118 flags ^= TRANSPOSED_OUT; | |
119 } | |
120 ego->flags = flags; | |
121 | |
122 MPI_Comm_dup(comm, &ego->comm); | |
123 | |
124 return &(ego->super); | |
125 } | |
126 | |
127 problem *XM(mkproblem_dft_d)(dtensor *sz, INT vn, | |
128 R *I, R *O, | |
129 MPI_Comm comm, | |
130 int sign, | |
131 unsigned flags) | |
132 { | |
133 problem *p = XM(mkproblem_dft)(sz, vn, I, O, comm, sign, flags); | |
134 XM(dtensor_destroy)(sz); | |
135 return p; | |
136 } |