annotate src/fftw-3.3.8/mpi/rdft-rank1-bigvec.c @ 84:08ae793730bd

Add null config files
author Chris Cannam
date Mon, 02 Mar 2020 14:03:47 +0000
parents d0c2a83c1364
children
rev   line source
Chris@82 1 /*
Chris@82 2 * Copyright (c) 2003, 2007-14 Matteo Frigo
Chris@82 3 * Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
Chris@82 4 *
Chris@82 5 * This program is free software; you can redistribute it and/or modify
Chris@82 6 * it under the terms of the GNU General Public License as published by
Chris@82 7 * the Free Software Foundation; either version 2 of the License, or
Chris@82 8 * (at your option) any later version.
Chris@82 9 *
Chris@82 10 * This program is distributed in the hope that it will be useful,
Chris@82 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@82 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@82 13 * GNU General Public License for more details.
Chris@82 14 *
Chris@82 15 * You should have received a copy of the GNU General Public License
Chris@82 16 * along with this program; if not, write to the Free Software
Chris@82 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Chris@82 18 *
Chris@82 19 */
Chris@82 20
Chris@82 21 /* Complex RDFTs of rank == 1 when the vector length vn is >= # processes.
Chris@82 22 In this case, we don't need to use a six-step type algorithm, and can
Chris@82 23 instead transpose the RDFT dimension with the vector dimension to
Chris@82 24 make the RDFT local. */
Chris@82 25
Chris@82 26 #include "mpi-rdft.h"
Chris@82 27 #include "mpi-transpose.h"
Chris@82 28
Chris@82 29 typedef struct {
Chris@82 30 solver super;
Chris@82 31 int preserve_input; /* preserve input even if DESTROY_INPUT was passed */
Chris@82 32 rearrangement rearrange;
Chris@82 33 } S;
Chris@82 34
Chris@82 35 typedef struct {
Chris@82 36 plan_mpi_rdft super;
Chris@82 37
Chris@82 38 plan *cldt_before, *cld, *cldt_after;
Chris@82 39 int preserve_input;
Chris@82 40 rearrangement rearrange;
Chris@82 41 } P;
Chris@82 42
Chris@82 43 static void apply(const plan *ego_, R *I, R *O)
Chris@82 44 {
Chris@82 45 const P *ego = (const P *) ego_;
Chris@82 46 plan_rdft *cld, *cldt_before, *cldt_after;
Chris@82 47
Chris@82 48 /* global transpose */
Chris@82 49 cldt_before = (plan_rdft *) ego->cldt_before;
Chris@82 50 cldt_before->apply(ego->cldt_before, I, O);
Chris@82 51
Chris@82 52 if (ego->preserve_input) I = O;
Chris@82 53
Chris@82 54 /* 1d RDFT(s) */
Chris@82 55 cld = (plan_rdft *) ego->cld;
Chris@82 56 cld->apply(ego->cld, O, I);
Chris@82 57
Chris@82 58 /* global transpose */
Chris@82 59 cldt_after = (plan_rdft *) ego->cldt_after;
Chris@82 60 cldt_after->apply(ego->cldt_after, I, O);
Chris@82 61 }
Chris@82 62
Chris@82 63 static int applicable(const S *ego, const problem *p_,
Chris@82 64 const planner *plnr)
Chris@82 65 {
Chris@82 66 const problem_mpi_rdft *p = (const problem_mpi_rdft *) p_;
Chris@82 67 int n_pes;
Chris@82 68 MPI_Comm_size(p->comm, &n_pes);
Chris@82 69 return (1
Chris@82 70 && p->sz->rnk == 1
Chris@82 71 && !(p->flags & ~RANK1_BIGVEC_ONLY)
Chris@82 72 && (!ego->preserve_input || (!NO_DESTROY_INPUTP(plnr)
Chris@82 73 && p->I != p->O))
Chris@82 74
Chris@82 75 #if 0 /* don't need this check since no other rank-1 rdft solver */
Chris@82 76 && (p->vn >= n_pes /* TODO: relax this, using more memory? */
Chris@82 77 || (p->flags & RANK1_BIGVEC_ONLY))
Chris@82 78 #endif
Chris@82 79
Chris@82 80 && XM(rearrange_applicable)(ego->rearrange,
Chris@82 81 p->sz->dims[0], p->vn, n_pes)
Chris@82 82
Chris@82 83 && (!NO_SLOWP(plnr) /* slow if rdft-serial is applicable */
Chris@82 84 || !XM(rdft_serial_applicable)(p))
Chris@82 85 );
Chris@82 86 }
Chris@82 87
Chris@82 88 static void awake(plan *ego_, enum wakefulness wakefulness)
Chris@82 89 {
Chris@82 90 P *ego = (P *) ego_;
Chris@82 91 X(plan_awake)(ego->cldt_before, wakefulness);
Chris@82 92 X(plan_awake)(ego->cld, wakefulness);
Chris@82 93 X(plan_awake)(ego->cldt_after, wakefulness);
Chris@82 94 }
Chris@82 95
Chris@82 96 static void destroy(plan *ego_)
Chris@82 97 {
Chris@82 98 P *ego = (P *) ego_;
Chris@82 99 X(plan_destroy_internal)(ego->cldt_after);
Chris@82 100 X(plan_destroy_internal)(ego->cld);
Chris@82 101 X(plan_destroy_internal)(ego->cldt_before);
Chris@82 102 }
Chris@82 103
Chris@82 104 static void print(const plan *ego_, printer *p)
Chris@82 105 {
Chris@82 106 const P *ego = (const P *) ego_;
Chris@82 107 const char descrip[][16] = { "contig", "discontig", "square-after",
Chris@82 108 "square-middle", "square-before" };
Chris@82 109 p->print(p, "(mpi-rdft-rank1-bigvec/%s%s %(%p%) %(%p%) %(%p%))",
Chris@82 110 descrip[ego->rearrange], ego->preserve_input==2 ?"/p":"",
Chris@82 111 ego->cldt_before, ego->cld, ego->cldt_after);
Chris@82 112 }
Chris@82 113
Chris@82 114 static plan *mkplan(const solver *ego_, const problem *p_, planner *plnr)
Chris@82 115 {
Chris@82 116 const S *ego = (const S *) ego_;
Chris@82 117 const problem_mpi_rdft *p;
Chris@82 118 P *pln;
Chris@82 119 plan *cld = 0, *cldt_before = 0, *cldt_after = 0;
Chris@82 120 R *I, *O;
Chris@82 121 INT yblock, yb, nx, ny, vn;
Chris@82 122 int my_pe, n_pes;
Chris@82 123 static const plan_adt padt = {
Chris@82 124 XM(rdft_solve), awake, print, destroy
Chris@82 125 };
Chris@82 126
Chris@82 127 UNUSED(ego);
Chris@82 128
Chris@82 129 if (!applicable(ego, p_, plnr))
Chris@82 130 return (plan *) 0;
Chris@82 131
Chris@82 132 p = (const problem_mpi_rdft *) p_;
Chris@82 133
Chris@82 134 MPI_Comm_rank(p->comm, &my_pe);
Chris@82 135 MPI_Comm_size(p->comm, &n_pes);
Chris@82 136
Chris@82 137 nx = p->sz->dims[0].n;
Chris@82 138 if (!(ny = XM(rearrange_ny)(ego->rearrange, p->sz->dims[0],p->vn,n_pes)))
Chris@82 139 return (plan *) 0;
Chris@82 140 vn = p->vn / ny;
Chris@82 141 A(ny * vn == p->vn);
Chris@82 142
Chris@82 143 yblock = XM(default_block)(ny, n_pes);
Chris@82 144 cldt_before = X(mkplan_d)(plnr,
Chris@82 145 XM(mkproblem_transpose)(
Chris@82 146 nx, ny, vn,
Chris@82 147 I = p->I, O = p->O,
Chris@82 148 p->sz->dims[0].b[IB], yblock,
Chris@82 149 p->comm, 0));
Chris@82 150 if (XM(any_true)(!cldt_before, p->comm)) goto nada;
Chris@82 151 if (ego->preserve_input || NO_DESTROY_INPUTP(plnr)) { I = O; }
Chris@82 152
Chris@82 153 yb = XM(block)(ny, yblock, my_pe);
Chris@82 154 cld = X(mkplan_d)(plnr,
Chris@82 155 X(mkproblem_rdft_1_d)(X(mktensor_1d)(nx, vn, vn),
Chris@82 156 X(mktensor_2d)(yb, vn*nx, vn*nx,
Chris@82 157 vn, 1, 1),
Chris@82 158 O, I, p->kind[0]));
Chris@82 159 if (XM(any_true)(!cld, p->comm)) goto nada;
Chris@82 160
Chris@82 161 cldt_after = X(mkplan_d)(plnr,
Chris@82 162 XM(mkproblem_transpose)(
Chris@82 163 ny, nx, vn,
Chris@82 164 I, O,
Chris@82 165 yblock, p->sz->dims[0].b[OB],
Chris@82 166 p->comm, 0));
Chris@82 167 if (XM(any_true)(!cldt_after, p->comm)) goto nada;
Chris@82 168
Chris@82 169 pln = MKPLAN_MPI_RDFT(P, &padt, apply);
Chris@82 170
Chris@82 171 pln->cldt_before = cldt_before;
Chris@82 172 pln->cld = cld;
Chris@82 173 pln->cldt_after = cldt_after;
Chris@82 174 pln->preserve_input = ego->preserve_input ? 2 : NO_DESTROY_INPUTP(plnr);
Chris@82 175 pln->rearrange = ego->rearrange;
Chris@82 176
Chris@82 177 X(ops_add)(&cldt_before->ops, &cld->ops, &pln->super.super.ops);
Chris@82 178 X(ops_add2)(&cldt_after->ops, &pln->super.super.ops);
Chris@82 179
Chris@82 180 return &(pln->super.super);
Chris@82 181
Chris@82 182 nada:
Chris@82 183 X(plan_destroy_internal)(cldt_after);
Chris@82 184 X(plan_destroy_internal)(cld);
Chris@82 185 X(plan_destroy_internal)(cldt_before);
Chris@82 186 return (plan *) 0;
Chris@82 187 }
Chris@82 188
Chris@82 189 static solver *mksolver(rearrangement rearrange, int preserve_input)
Chris@82 190 {
Chris@82 191 static const solver_adt sadt = { PROBLEM_MPI_RDFT, mkplan, 0 };
Chris@82 192 S *slv = MKSOLVER(S, &sadt);
Chris@82 193 slv->rearrange = rearrange;
Chris@82 194 slv->preserve_input = preserve_input;
Chris@82 195 return &(slv->super);
Chris@82 196 }
Chris@82 197
Chris@82 198 void XM(rdft_rank1_bigvec_register)(planner *p)
Chris@82 199 {
Chris@82 200 rearrangement rearrange;
Chris@82 201 int preserve_input;
Chris@82 202 FORALL_REARRANGE(rearrange)
Chris@82 203 for (preserve_input = 0; preserve_input <= 1; ++preserve_input)
Chris@82 204 REGISTER_SOLVER(p, mksolver(rearrange, preserve_input));
Chris@82 205 }