2
* Copyright (c) 1997-1999 Massachusetts Institute of Technology
3
* Copyright (c) 2003, 2006 Matteo Frigo
4
* Copyright (c) 2003, 2006 Massachusetts Institute of Technology
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
(* $Id: gen_notw.ml,v 1.30 2006-02-12 23:34:12 athena Exp $ *)
27
let cvsid = "$Id: gen_notw.ml,v 1.30 2006-02-12 23:34:12 athena Exp $"
29
let usage = "Usage: " ^ Sys.argv.(0) ^ " -n <number>"
31
let uistride = ref Stride_variable
32
let uostride = ref Stride_variable
33
let uivstride = ref Stride_variable
34
let uovstride = ref Stride_variable
38
Arg.String(fun x -> uistride := arg_to_stride x),
39
" specialize for given input stride";
42
Arg.String(fun x -> uostride := arg_to_stride x),
43
" specialize for given output stride";
46
Arg.String(fun x -> uivstride := arg_to_stride x),
47
" specialize for given input vector stride";
50
Arg.String(fun x -> uovstride := arg_to_stride x),
51
" specialize for given output vector stride"
54
let nonstandard_optimizer list_of_buddy_stores dag =
55
let sched = standard_scheduler dag in
56
let annot = Annotate.annotate list_of_buddy_stores sched in
57
let _ = dump_asched annot in
71
let sign = !Genutil.sign
72
and name = !Magic.codelet_name
73
and byvl x = choose_simd x (ctimes (CVar "(2 * VL)", x)) in
74
let ename = expand_name name in
76
let vistride = either_stride (!uistride) (C.SVar istride)
77
and vostride = either_stride (!uostride) (C.SVar ostride)
80
let _ = Simd.ovs := stride_to_string "ovs" !uovstride in
81
let _ = Simd.ivs := stride_to_string "ivs" !uivstride in
83
let locations = unique_array_c n in
86
(C.array_subscript riarray vistride)
87
(C.array_subscript iiarray vistride)
89
let output = Fft.dft sign n (load_array_c n input) in
92
(C.array_subscript roarray vostride)
93
(C.array_subscript ioarray vostride)
95
let list_of_buddy_stores =
96
let k = !Simdmagic.store_multiple in
98
if (n mod k == 0) then
101
(fun i -> List.map (fun j -> (fst (oloc (k * i + j)))) (iota k))
104
(fun i -> List.map (fun j -> (snd (oloc (k * i + j)))) (iota k))
106
else failwith "invalid n for -store-multiple"
110
let odag = store_array_c n oloc output in
111
let annot = nonstandard_optimizer list_of_buddy_stores odag in
115
[For (Expr_assign (CVar i, CVar v),
116
Binop (" > ", CVar i, Integer 0),
118
[Expr_assign (CVar i, CPlus [CVar i; CUminus (byvl (Integer 1))]);
119
Expr_assign (CVar riarray, CPlus [CVar riarray;
120
byvl (CVar !Simd.ivs)]);
121
Expr_assign (CVar iiarray, CPlus [CVar iiarray;
122
byvl (CVar !Simd.ivs)]);
123
Expr_assign (CVar roarray, CPlus [CVar roarray;
124
byvl (CVar !Simd.ovs)]);
125
Expr_assign (CVar ioarray, CPlus [CVar ioarray;
126
byvl (CVar !Simd.ovs)]);
127
make_volatile_stride (CVar istride);
128
make_volatile_stride (CVar ostride)
135
Fcn ((if !Magic.standalone then "void" else "static void"), ename,
136
([Decl (C.constrealtypep, riarray);
137
Decl (C.constrealtypep, iiarray);
138
Decl (C.realtypep, roarray);
139
Decl (C.realtypep, ioarray);
140
Decl (C.stridetype, istride);
141
Decl (C.stridetype, ostride);
144
Decl ("INT", "ovs")]),
149
"static const kdft_desc desc = { %d, %s, %s, &GENUS, %s, %s, %s, %s };\n"
150
n (stringify name) (flops_of tree)
151
(stride_to_solverparm !uistride) (stride_to_solverparm !uostride)
152
(choose_simd "0" (stride_to_solverparm !uivstride))
153
(choose_simd "0" (stride_to_solverparm !uovstride))
156
(declare_register_fcn name) ^
158
" X(kdft_register)(p, " ^ ename ^ ", &desc);\n" ^
161
in ((unparse cvsid tree) ^ "\n" ^
162
(if !Magic.standalone then "" else desc ^ init))
166
parse speclist usage;
167
print_string (generate (check_size ()));