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