Mercurial > hg > sv-dependency-builds
comparison src/fftw-3.3.3/mpi/rdft2-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-rdft2.h" | |
22 | |
23 static void destroy(problem *ego_) | |
24 { | |
25 problem_mpi_rdft2 *ego = (problem_mpi_rdft2 *) 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_rdft2 *p = (const problem_mpi_rdft2 *) p_; | |
34 int i; | |
35 X(md5puts)(m, "mpi-rdft2"); | |
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->kind); | |
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_rdft2 *ego = (const problem_mpi_rdft2 *) ego_; | |
53 int i; | |
54 p->print(p, "(mpi-rdft2 %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, (int) ego->kind, 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_rdft2 *ego = (const problem_mpi_rdft2 *) ego_; | |
66 R *I = ego->I; | |
67 dtensor *sz; | |
68 INT i, N; | |
69 int my_pe; | |
70 | |
71 sz = XM(dtensor_copy)(ego->sz); | |
72 sz->dims[sz->rnk - 1].n = sz->dims[sz->rnk - 1].n / 2 + 1; | |
73 MPI_Comm_rank(ego->comm, &my_pe); | |
74 N = 2 * ego->vn * XM(total_block)(sz, IB, my_pe); | |
75 XM(dtensor_destroy)(sz); | |
76 for (i = 0; i < N; ++i) I[i] = K(0.0); | |
77 } | |
78 | |
79 static const problem_adt padt = | |
80 { | |
81 PROBLEM_MPI_RDFT2, | |
82 hash, | |
83 zero, | |
84 print, | |
85 destroy | |
86 }; | |
87 | |
88 problem *XM(mkproblem_rdft2)(const dtensor *sz, INT vn, | |
89 R *I, R *O, | |
90 MPI_Comm comm, | |
91 rdft_kind kind, | |
92 unsigned flags) | |
93 { | |
94 problem_mpi_rdft2 *ego = | |
95 (problem_mpi_rdft2 *)X(mkproblem)(sizeof(problem_mpi_rdft2), &padt); | |
96 int n_pes; | |
97 | |
98 A(XM(dtensor_validp)(sz) && FINITE_RNK(sz->rnk) && sz->rnk > 1); | |
99 MPI_Comm_size(comm, &n_pes); | |
100 A(vn >= 0); | |
101 A(kind == R2HC || kind == HC2R); | |
102 | |
103 /* enforce pointer equality if untainted pointers are equal */ | |
104 if (UNTAINT(I) == UNTAINT(O)) | |
105 I = O = JOIN_TAINT(I, O); | |
106 | |
107 ego->sz = XM(dtensor_canonical)(sz, 0); | |
108 #ifdef FFTW_DEBUG | |
109 ego->sz->dims[sz->rnk - 1].n = sz->dims[sz->rnk - 1].n / 2 + 1; | |
110 A(n_pes >= XM(num_blocks_total)(ego->sz, IB) | |
111 && n_pes >= XM(num_blocks_total)(ego->sz, OB)); | |
112 ego->sz->dims[sz->rnk - 1].n = sz->dims[sz->rnk - 1].n; | |
113 #endif | |
114 | |
115 ego->vn = vn; | |
116 ego->I = I; | |
117 ego->O = O; | |
118 ego->kind = kind; | |
119 | |
120 /* We only support TRANSPOSED_OUT for r2c and TRANSPOSED_IN for | |
121 c2r transforms. */ | |
122 | |
123 ego->flags = flags; | |
124 | |
125 MPI_Comm_dup(comm, &ego->comm); | |
126 | |
127 return &(ego->super); | |
128 } | |
129 | |
130 problem *XM(mkproblem_rdft2_d)(dtensor *sz, INT vn, | |
131 R *I, R *O, | |
132 MPI_Comm comm, | |
133 rdft_kind kind, | |
134 unsigned flags) | |
135 { | |
136 problem *p = XM(mkproblem_rdft2)(sz, vn, I, O, comm, kind, flags); | |
137 XM(dtensor_destroy)(sz); | |
138 return p; | |
139 } |