annotate src/fftw-3.3.8/mpi/rdft-serial.c @ 169:223a55898ab9 tip default

Add null config files
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 02 Mar 2020 14:03:47 +0000
parents bd3cc4d1df30
children
rev   line source
cannam@167 1 /*
cannam@167 2 * Copyright (c) 2003, 2007-14 Matteo Frigo
cannam@167 3 * Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
cannam@167 4 *
cannam@167 5 * This program is free software; you can redistribute it and/or modify
cannam@167 6 * it under the terms of the GNU General Public License as published by
cannam@167 7 * the Free Software Foundation; either version 2 of the License, or
cannam@167 8 * (at your option) any later version.
cannam@167 9 *
cannam@167 10 * This program is distributed in the hope that it will be useful,
cannam@167 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cannam@167 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cannam@167 13 * GNU General Public License for more details.
cannam@167 14 *
cannam@167 15 * You should have received a copy of the GNU General Public License
cannam@167 16 * along with this program; if not, write to the Free Software
cannam@167 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
cannam@167 18 *
cannam@167 19 */
cannam@167 20
cannam@167 21 /* "MPI" RDFTs where all of the data is on one processor...just
cannam@167 22 call through to serial API. */
cannam@167 23
cannam@167 24 #include "mpi-rdft.h"
cannam@167 25
cannam@167 26 typedef struct {
cannam@167 27 plan_mpi_rdft super;
cannam@167 28 plan *cld;
cannam@167 29 } P;
cannam@167 30
cannam@167 31 static void apply(const plan *ego_, R *I, R *O)
cannam@167 32 {
cannam@167 33 const P *ego = (const P *) ego_;
cannam@167 34 plan_rdft *cld = (plan_rdft *) ego->cld;
cannam@167 35 cld->apply(ego->cld, I, O);
cannam@167 36 }
cannam@167 37
cannam@167 38 static void awake(plan *ego_, enum wakefulness wakefulness)
cannam@167 39 {
cannam@167 40 P *ego = (P *) ego_;
cannam@167 41 X(plan_awake)(ego->cld, wakefulness);
cannam@167 42 }
cannam@167 43
cannam@167 44 static void destroy(plan *ego_)
cannam@167 45 {
cannam@167 46 P *ego = (P *) ego_;
cannam@167 47 X(plan_destroy_internal)(ego->cld);
cannam@167 48 }
cannam@167 49
cannam@167 50 static void print(const plan *ego_, printer *p)
cannam@167 51 {
cannam@167 52 const P *ego = (const P *) ego_;
cannam@167 53 p->print(p, "(mpi-rdft-serial %(%p%))", ego->cld);
cannam@167 54 }
cannam@167 55
cannam@167 56 int XM(rdft_serial_applicable)(const problem_mpi_rdft *p)
cannam@167 57 {
cannam@167 58 return (1
cannam@167 59 && p->flags == 0 /* TRANSPOSED/SCRAMBLED_IN/OUT not supported */
cannam@167 60 && ((XM(is_local)(p->sz, IB) && XM(is_local)(p->sz, OB))
cannam@167 61 || p->vn == 0));
cannam@167 62 }
cannam@167 63
cannam@167 64 static plan *mkplan(const solver *ego, const problem *p_, planner *plnr)
cannam@167 65 {
cannam@167 66 const problem_mpi_rdft *p = (const problem_mpi_rdft *) p_;
cannam@167 67 P *pln;
cannam@167 68 plan *cld;
cannam@167 69 int my_pe;
cannam@167 70 static const plan_adt padt = {
cannam@167 71 XM(rdft_solve), awake, print, destroy
cannam@167 72 };
cannam@167 73
cannam@167 74 UNUSED(ego);
cannam@167 75
cannam@167 76 /* check whether applicable: */
cannam@167 77 if (!XM(rdft_serial_applicable)(p))
cannam@167 78 return (plan *) 0;
cannam@167 79
cannam@167 80 MPI_Comm_rank(p->comm, &my_pe);
cannam@167 81 if (my_pe == 0 && p->vn > 0) {
cannam@167 82 int i, rnk = p->sz->rnk;
cannam@167 83 tensor *sz = X(mktensor)(rnk);
cannam@167 84 rdft_kind *kind
cannam@167 85 = (rdft_kind *) MALLOC(sizeof(rdft_kind) * rnk, PROBLEMS);
cannam@167 86 sz->dims[rnk - 1].is = sz->dims[rnk - 1].os = p->vn;
cannam@167 87 sz->dims[rnk - 1].n = p->sz->dims[rnk - 1].n;
cannam@167 88 for (i = rnk - 1; i > 0; --i) {
cannam@167 89 sz->dims[i - 1].is = sz->dims[i - 1].os =
cannam@167 90 sz->dims[i].is * sz->dims[i].n;
cannam@167 91 sz->dims[i - 1].n = p->sz->dims[i - 1].n;
cannam@167 92 }
cannam@167 93 for (i = 0; i < rnk; ++i)
cannam@167 94 kind[i] = p->kind[i];
cannam@167 95
cannam@167 96 cld = X(mkplan_d)(plnr,
cannam@167 97 X(mkproblem_rdft_d)(sz,
cannam@167 98 X(mktensor_1d)(p->vn, 1, 1),
cannam@167 99 p->I, p->O, kind));
cannam@167 100 X(ifree0)(kind);
cannam@167 101 }
cannam@167 102 else { /* idle process: make nop plan */
cannam@167 103 cld = X(mkplan_d)(plnr,
cannam@167 104 X(mkproblem_rdft_0_d)(X(mktensor_1d)(0,0,0),
cannam@167 105 p->I, p->O));
cannam@167 106 }
cannam@167 107 if (XM(any_true)(!cld, p->comm)) return (plan *) 0;
cannam@167 108
cannam@167 109 pln = MKPLAN_MPI_RDFT(P, &padt, apply);
cannam@167 110 pln->cld = cld;
cannam@167 111 X(ops_cpy)(&cld->ops, &pln->super.super.ops);
cannam@167 112 return &(pln->super.super);
cannam@167 113 }
cannam@167 114
cannam@167 115 static solver *mksolver(void)
cannam@167 116 {
cannam@167 117 static const solver_adt sadt = { PROBLEM_MPI_RDFT, mkplan, 0 };
cannam@167 118 return MKSOLVER(solver, &sadt);
cannam@167 119 }
cannam@167 120
cannam@167 121 void XM(rdft_serial_register)(planner *p)
cannam@167 122 {
cannam@167 123 REGISTER_SOLVER(p, mksolver());
cannam@167 124 }