annotate src/fftw-3.3.8/dft/dftw-directsq.c @ 83:ae30d91d2ffe

Replace these with versions built using an older toolset (so as to avoid ABI compatibilities when linking on Ubuntu 14.04 for packaging purposes)
author Chris Cannam
date Fri, 07 Feb 2020 11:51:13 +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
Chris@82 22 #include "dft/ct.h"
Chris@82 23
Chris@82 24 typedef struct {
Chris@82 25 ct_solver super;
Chris@82 26 const ct_desc *desc;
Chris@82 27 kdftwsq k;
Chris@82 28 } S;
Chris@82 29
Chris@82 30 typedef struct {
Chris@82 31 plan_dftw super;
Chris@82 32 kdftwsq k;
Chris@82 33 INT r;
Chris@82 34 stride rs, vs;
Chris@82 35 INT m, ms, v, mb, me;
Chris@82 36 twid *td;
Chris@82 37 const S *slv;
Chris@82 38 } P;
Chris@82 39
Chris@82 40
Chris@82 41 static void apply(const plan *ego_, R *rio, R *iio)
Chris@82 42 {
Chris@82 43 const P *ego = (const P *) ego_;
Chris@82 44 INT mb = ego->mb, ms = ego->ms;
Chris@82 45 ego->k(rio + mb*ms, iio + mb*ms, ego->td->W, ego->rs, ego->vs,
Chris@82 46 mb, ego->me, ms);
Chris@82 47 }
Chris@82 48
Chris@82 49 static void awake(plan *ego_, enum wakefulness wakefulness)
Chris@82 50 {
Chris@82 51 P *ego = (P *) ego_;
Chris@82 52
Chris@82 53 X(twiddle_awake)(wakefulness, &ego->td, ego->slv->desc->tw,
Chris@82 54 ego->r * ego->m, ego->r, ego->m);
Chris@82 55 }
Chris@82 56
Chris@82 57 static void destroy(plan *ego_)
Chris@82 58 {
Chris@82 59 P *ego = (P *) ego_;
Chris@82 60 X(stride_destroy)(ego->rs);
Chris@82 61 X(stride_destroy)(ego->vs);
Chris@82 62 }
Chris@82 63
Chris@82 64 static void print(const plan *ego_, printer *p)
Chris@82 65 {
Chris@82 66 const P *ego = (const P *) ego_;
Chris@82 67 const S *slv = ego->slv;
Chris@82 68 const ct_desc *e = slv->desc;
Chris@82 69
Chris@82 70 p->print(p, "(dftw-directsq-%D/%D%v \"%s\")",
Chris@82 71 ego->r, X(twiddle_length)(ego->r, e->tw), ego->v, e->nam);
Chris@82 72 }
Chris@82 73
Chris@82 74 static int applicable(const S *ego,
Chris@82 75 INT r, INT irs, INT ors,
Chris@82 76 INT m, INT ms,
Chris@82 77 INT v, INT ivs, INT ovs,
Chris@82 78 INT mb, INT me,
Chris@82 79 R *rio, R *iio,
Chris@82 80 const planner *plnr)
Chris@82 81 {
Chris@82 82 const ct_desc *e = ego->desc;
Chris@82 83 UNUSED(v);
Chris@82 84
Chris@82 85 return (
Chris@82 86 1
Chris@82 87 && r == e->radix
Chris@82 88
Chris@82 89 /* transpose r, v */
Chris@82 90 && r == v
Chris@82 91 && irs == ovs
Chris@82 92 && ivs == ors
Chris@82 93
Chris@82 94 /* check for alignment/vector length restrictions */
Chris@82 95 && e->genus->okp(e, rio, iio, irs, ivs, m, mb, me, ms, plnr)
Chris@82 96
Chris@82 97 );
Chris@82 98 }
Chris@82 99
Chris@82 100 static plan *mkcldw(const ct_solver *ego_,
Chris@82 101 INT r, INT irs, INT ors,
Chris@82 102 INT m, INT ms,
Chris@82 103 INT v, INT ivs, INT ovs,
Chris@82 104 INT mstart, INT mcount,
Chris@82 105 R *rio, R *iio,
Chris@82 106 planner *plnr)
Chris@82 107 {
Chris@82 108 const S *ego = (const S *) ego_;
Chris@82 109 P *pln;
Chris@82 110 const ct_desc *e = ego->desc;
Chris@82 111
Chris@82 112 static const plan_adt padt = {
Chris@82 113 0, awake, print, destroy
Chris@82 114 };
Chris@82 115
Chris@82 116 A(mstart >= 0 && mstart + mcount <= m);
Chris@82 117 if (!applicable(ego,
Chris@82 118 r, irs, ors, m, ms, v, ivs, ovs, mstart, mstart + mcount,
Chris@82 119 rio, iio, plnr))
Chris@82 120 return (plan *)0;
Chris@82 121
Chris@82 122 pln = MKPLAN_DFTW(P, &padt, apply);
Chris@82 123
Chris@82 124 pln->k = ego->k;
Chris@82 125 pln->rs = X(mkstride)(r, irs);
Chris@82 126 pln->vs = X(mkstride)(v, ivs);
Chris@82 127 pln->td = 0;
Chris@82 128 pln->r = r;
Chris@82 129 pln->m = m;
Chris@82 130 pln->ms = ms;
Chris@82 131 pln->v = v;
Chris@82 132 pln->mb = mstart;
Chris@82 133 pln->me = mstart + mcount;
Chris@82 134 pln->slv = ego;
Chris@82 135
Chris@82 136 X(ops_zero)(&pln->super.super.ops);
Chris@82 137 X(ops_madd2)(mcount/e->genus->vl, &e->ops, &pln->super.super.ops);
Chris@82 138
Chris@82 139 return &(pln->super.super);
Chris@82 140 }
Chris@82 141
Chris@82 142 static void regone(planner *plnr, kdftwsq codelet,
Chris@82 143 const ct_desc *desc, int dec)
Chris@82 144 {
Chris@82 145 S *slv = (S *)X(mksolver_ct)(sizeof(S), desc->radix, dec, mkcldw, 0);
Chris@82 146 slv->k = codelet;
Chris@82 147 slv->desc = desc;
Chris@82 148 REGISTER_SOLVER(plnr, &(slv->super.super));
Chris@82 149 if (X(mksolver_ct_hook)) {
Chris@82 150 slv = (S *)X(mksolver_ct_hook)(sizeof(S), desc->radix, dec,
Chris@82 151 mkcldw, 0);
Chris@82 152 slv->k = codelet;
Chris@82 153 slv->desc = desc;
Chris@82 154 REGISTER_SOLVER(plnr, &(slv->super.super));
Chris@82 155 }
Chris@82 156 }
Chris@82 157
Chris@82 158 void X(regsolver_ct_directwsq)(planner *plnr, kdftwsq codelet,
Chris@82 159 const ct_desc *desc, int dec)
Chris@82 160 {
Chris@82 161 regone(plnr, codelet, desc, dec+TRANSPOSE);
Chris@82 162 }