~ubuntu-branches/ubuntu/raring/fftw3/raring-proposed

« back to all changes in this revision

Viewing changes to rdft/hc2hc-dit.c

  • Committer: Bazaar Package Importer
  • Author(s): Paul Brossier
  • Date: 2006-05-31 13:44:05 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060531134405-ol9hrbg6bh81sg0c
Tags: 3.1.1-1
* New upstream release (closes: #350327, #338487, #338501)
* Add --enable-portable-binary to use -mtune instead of -march
* Use --with-gcc-arch=G5 / pentium4 on powerpc / i386
* Updated Standards-Version

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (c) 2003 Matteo Frigo
3
 
 * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
 
 *
19
 
 */
20
 
 
21
 
/* $Id: hc2hc-dit.c,v 1.16 2003/03/15 20:29:43 stevenj Exp $ */
22
 
 
23
 
/* decimation in time Cooley-Tukey */
24
 
#include "rdft.h"
25
 
#include "hc2hc.h"
26
 
 
27
 
static void apply(const plan *ego_, R *I, R *O)
28
 
{
29
 
     const plan_hc2hc *ego = (const plan_hc2hc *) ego_;
30
 
 
31
 
     /* two-dimensional r x vl sub-transform: */
32
 
     {
33
 
          plan_rdft *cld = (plan_rdft *) ego->cld;
34
 
          cld->apply((plan *) cld, I, O);
35
 
     }
36
 
 
37
 
     {
38
 
          plan_rdft *cld0 = (plan_rdft *) ego->cld0;
39
 
          plan_rdft *cldm = (plan_rdft *) ego->cldm;
40
 
          int i, r = ego->r, m = ego->m, vl = ego->vl;
41
 
          int os = ego->os, ovs = ego->ovs;
42
 
 
43
 
          for (i = 0; i < vl; ++i, O += ovs) {
44
 
               cld0->apply((plan *) cld0, O, O);
45
 
               ego->k(O + os, O + (r * m - 1) * os, ego->W, ego->ios, m, os);
46
 
               cldm->apply((plan *) cldm, O + os*(m/2), O + os*(m/2));
47
 
          }
48
 
     }
49
 
}
50
 
 
51
 
static int applicable0(const solver_hc2hc *ego, const problem *p_,
52
 
                       const planner *plnr)
53
 
{
54
 
     UNUSED(plnr);
55
 
     if (X(rdft_hc2hc_applicable)(ego, p_)) {
56
 
          int ivs, ovs;
57
 
          int vl;
58
 
          const hc2hc_desc *e = ego->desc;
59
 
          const problem_rdft *p = (const problem_rdft *) p_;
60
 
          iodim *d = p->sz->dims;
61
 
          int m = d[0].n / e->radix;
62
 
          X(tensor_tornk1)(p->vecsz, &vl, &ivs, &ovs);
63
 
          return (1
64
 
                  && (e->genus->okp(e, p->O + d[0].os,
65
 
                                    p->O + (e->radix * m - 1) * d[0].os, 
66
 
                                    (int)m * d[0].os, 0, m, d[0].os))
67
 
                  && (e->genus->okp(e, p->O + ovs + d[0].os,
68
 
                                    p->O + ovs + (e->radix * m - 1) * d[0].os, 
69
 
                                    (int)m * d[0].os, 0, m, d[0].os))
70
 
               );
71
 
     }
72
 
     return 0;
73
 
}
74
 
 
75
 
static int applicable(const solver_hc2hc *ego, const problem *p_,
76
 
                      const planner *plnr)
77
 
{
78
 
     const problem_rdft *p;
79
 
 
80
 
     if (!applicable0(ego, p_, plnr)) return 0;
81
 
 
82
 
     p = (const problem_rdft *) p_;
83
 
 
84
 
     /* emulate fftw2 behavior */
85
 
     if (NO_VRECURSEP(plnr) && (p->vecsz->rnk > 0)) return 0;
86
 
 
87
 
     if (NO_UGLYP(plnr)) {
88
 
          if (X(ct_uglyp)(16, p->sz->dims[0].n, ego->desc->radix)) return 0;
89
 
          if (NONTHREADED_ICKYP(plnr))
90
 
               return 0; /* prefer threaded version */
91
 
     }
92
 
 
93
 
     return 1;
94
 
}
95
 
 
96
 
static void finish(plan_hc2hc *ego)
97
 
{
98
 
     const hc2hc_desc *d = ego->slv->desc;
99
 
     opcnt t;
100
 
 
101
 
     ego->ios = X(mkstride)(ego->r, ego->m * ego->os);
102
 
 
103
 
     X(ops_add)(&ego->cld0->ops, &ego->cldm->ops, &t);
104
 
     X(ops_madd)(ego->vl, &t, &ego->cld->ops, &ego->super.super.ops);
105
 
     X(ops_madd2)(ego->vl * ((ego->m - 1)/2) / d->genus->vl, &d->ops,
106
 
                  &ego->super.super.ops);
107
 
}
108
 
 
109
 
 
110
 
static plan *mkplan(const solver *ego, const problem *p, planner *plnr)
111
 
{
112
 
     static const hc2hcadt adt = {
113
 
          sizeof(plan_hc2hc), 
114
 
          X(rdft_mkcldrn_dit), finish, applicable, apply
115
 
     };
116
 
     return X(mkplan_rdft_hc2hc)((const solver_hc2hc *) ego, p, plnr, &adt);
117
 
}
118
 
 
119
 
 
120
 
solver *X(mksolver_rdft_hc2hc_dit)(khc2hc codelet, const hc2hc_desc *desc)
121
 
{
122
 
     static const solver_adt sadt = { mkplan };
123
 
     static const char name[] = "rdft-dit";
124
 
 
125
 
     return X(mksolver_rdft_hc2hc)(codelet, desc, name, &sadt);
126
 
}