2
* Copyright (c) 2003, 2007-11 Matteo Frigo
3
* Copyright (c) 2003, 2007-11 Massachusetts Institute of Technology
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
/* "MPI" RDFTs where all of the data is on one processor...just
22
call through to serial API. */
31
static void apply(const plan *ego_, R *I, R *O)
33
const P *ego = (const P *) ego_;
34
plan_rdft *cld = (plan_rdft *) ego->cld;
35
cld->apply(ego->cld, I, O);
38
static void awake(plan *ego_, enum wakefulness wakefulness)
41
X(plan_awake)(ego->cld, wakefulness);
44
static void destroy(plan *ego_)
47
X(plan_destroy_internal)(ego->cld);
50
static void print(const plan *ego_, printer *p)
52
const P *ego = (const P *) ego_;
53
p->print(p, "(mpi-rdft-serial %(%p%))", ego->cld);
56
int XM(rdft_serial_applicable)(const problem_mpi_rdft *p)
59
&& p->flags == 0 /* TRANSPOSED/SCRAMBLED_IN/OUT not supported */
60
&& ((XM(is_local)(p->sz, IB) && XM(is_local)(p->sz, OB))
64
static plan *mkplan(const solver *ego, const problem *p_, planner *plnr)
66
const problem_mpi_rdft *p = (const problem_mpi_rdft *) p_;
70
static const plan_adt padt = {
71
XM(rdft_solve), awake, print, destroy
76
/* check whether applicable: */
77
if (!XM(rdft_serial_applicable)(p))
80
MPI_Comm_rank(p->comm, &my_pe);
81
if (my_pe == 0 && p->vn > 0) {
82
int i, rnk = p->sz->rnk;
83
tensor *sz = X(mktensor)(rnk);
85
= (rdft_kind *) MALLOC(sizeof(rdft_kind) * rnk, PROBLEMS);
86
sz->dims[rnk - 1].is = sz->dims[rnk - 1].os = p->vn;
87
sz->dims[rnk - 1].n = p->sz->dims[rnk - 1].n;
88
for (i = rnk - 1; i > 0; --i) {
89
sz->dims[i - 1].is = sz->dims[i - 1].os =
90
sz->dims[i].is * sz->dims[i].n;
91
sz->dims[i - 1].n = p->sz->dims[i - 1].n;
93
for (i = 0; i < rnk; ++i)
96
cld = X(mkplan_d)(plnr,
97
X(mkproblem_rdft_d)(sz,
98
X(mktensor_1d)(p->vn, 1, 1),
102
else { /* idle process: make nop plan */
103
cld = X(mkplan_d)(plnr,
104
X(mkproblem_rdft_0_d)(X(mktensor_1d)(0,0,0),
107
if (XM(any_true)(!cld, p->comm)) return (plan *) 0;
109
pln = MKPLAN_MPI_RDFT(P, &padt, apply);
111
X(ops_cpy)(&cld->ops, &pln->super.super.ops);
112
return &(pln->super.super);
115
static solver *mksolver(void)
117
static const solver_adt sadt = { PROBLEM_MPI_RDFT, mkplan, 0 };
118
return MKSOLVER(solver, &sadt);
121
void XM(rdft_serial_register)(planner *p)
123
REGISTER_SOLVER(p, mksolver());