Coverage Report

Created: 2025-06-22 06:45

/src/fftw3/dft/dftw-directsq.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (c) 2003, 2007-14 Matteo Frigo
3
 * Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
4
 *
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.
9
 *
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.
14
 *
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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18
 *
19
 */
20
21
22
#include "dft/ct.h"
23
24
typedef struct {
25
     ct_solver super;
26
     const ct_desc *desc;
27
     kdftwsq k;
28
} S;
29
30
typedef struct {
31
     plan_dftw super;
32
     kdftwsq k;
33
     INT r;
34
     stride rs, vs;
35
     INT m, ms, v, mb, me;
36
     twid *td;
37
     const S *slv;
38
} P;
39
40
41
static void apply(const plan *ego_, R *rio, R *iio)
42
14
{
43
14
     const P *ego = (const P *) ego_;
44
14
     INT mb = ego->mb, ms = ego->ms;
45
14
     ego->k(rio + mb*ms, iio + mb*ms, ego->td->W, ego->rs, ego->vs,
46
14
      mb, ego->me, ms);
47
14
}
48
49
static void awake(plan *ego_, enum wakefulness wakefulness)
50
8
{
51
8
     P *ego = (P *) ego_;
52
53
8
     X(twiddle_awake)(wakefulness, &ego->td, ego->slv->desc->tw,
54
8
          ego->r * ego->m, ego->r, ego->m);
55
8
}
56
57
static void destroy(plan *ego_)
58
22
{
59
22
     P *ego = (P *) ego_;
60
22
     X(stride_destroy)(ego->rs);
61
22
     X(stride_destroy)(ego->vs);
62
22
}
63
64
static void print(const plan *ego_, printer *p)
65
0
{
66
0
     const P *ego = (const P *) ego_;
67
0
     const S *slv = ego->slv;
68
0
     const ct_desc *e = slv->desc;
69
70
0
     p->print(p, "(dftw-directsq-%D/%D%v \"%s\")",
71
0
        ego->r, X(twiddle_length)(ego->r, e->tw), ego->v, e->nam);
72
0
}
73
74
static int applicable(const S *ego,
75
          INT r, INT irs, INT ors,
76
          INT m, INT ms,
77
          INT v, INT ivs, INT ovs,
78
          INT mb, INT me,
79
          R *rio, R *iio,
80
          const planner *plnr)
81
22
{
82
22
     const ct_desc *e = ego->desc;
83
22
     UNUSED(v);
84
85
22
     return (
86
22
    1
87
22
    && r == e->radix
88
89
    /* transpose r, v */
90
22
    && r == v
91
22
    && irs == ovs
92
22
    && ivs == ors
93
94
    /* check for alignment/vector length restrictions */
95
22
    && e->genus->okp(e, rio, iio, irs, ivs, m, mb, me, ms, plnr)
96
97
22
    );
98
22
}
99
100
static plan *mkcldw(const ct_solver *ego_,
101
        INT r, INT irs, INT ors,
102
        INT m, INT ms,
103
        INT v, INT ivs, INT ovs,
104
        INT mstart, INT mcount,
105
        R *rio, R *iio,
106
        planner *plnr)
107
22
{
108
22
     const S *ego = (const S *) ego_;
109
22
     P *pln;
110
22
     const ct_desc *e = ego->desc;
111
112
22
     static const plan_adt padt = {
113
22
    0, awake, print, destroy
114
22
     };
115
116
22
     A(mstart >= 0 && mstart + mcount <= m);
117
22
     if (!applicable(ego,
118
22
         r, irs, ors, m, ms, v, ivs, ovs, mstart, mstart + mcount,
119
22
         rio, iio, plnr))
120
0
          return (plan *)0;
121
122
22
     pln = MKPLAN_DFTW(P, &padt, apply);
123
124
22
     pln->k = ego->k;
125
22
     pln->rs = X(mkstride)(r, irs);
126
22
     pln->vs = X(mkstride)(v, ivs);
127
22
     pln->td = 0;
128
22
     pln->r = r;
129
22
     pln->m = m;
130
22
     pln->ms = ms;
131
22
     pln->v = v;
132
22
     pln->mb = mstart;
133
22
     pln->me = mstart + mcount;
134
22
     pln->slv = ego;
135
136
22
     X(ops_zero)(&pln->super.super.ops);
137
22
     X(ops_madd2)(mcount/e->genus->vl, &e->ops, &pln->super.super.ops);
138
139
22
     return &(pln->super.super);
140
22
}
141
142
static void regone(planner *plnr, kdftwsq codelet,
143
       const ct_desc *desc, int dec)
144
6
{
145
6
     S *slv = (S *)X(mksolver_ct)(sizeof(S), desc->radix, dec, mkcldw, 0);
146
6
     slv->k = codelet;
147
6
     slv->desc = desc;
148
6
     REGISTER_SOLVER(plnr, &(slv->super.super));
149
6
     if (X(mksolver_ct_hook)) {
150
0
    slv = (S *)X(mksolver_ct_hook)(sizeof(S), desc->radix, dec,
151
0
           mkcldw, 0);
152
0
    slv->k = codelet;
153
0
    slv->desc = desc;
154
0
    REGISTER_SOLVER(plnr, &(slv->super.super));
155
0
     }
156
6
}
157
158
void X(regsolver_ct_directwsq)(planner *plnr, kdftwsq codelet,
159
             const ct_desc *desc, int dec)
160
6
{
161
6
     regone(plnr, codelet, desc, dec+TRANSPOSE);
162
6
}