2
* Copyright (c) 1997-1999 Massachusetts Institute of Technology
3
* Copyright (c) 2003 Matteo Frigo
4
* Copyright (c) 2003 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_noinline.ml,v 1.1 2003/04/17 11:07:19 athena Exp $ *)
27
let cvsid = "$Id: gen_notw_noinline.ml,v 1.1 2003/04/17 11:07:19 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"
63
let sign = !Genutil.sign
64
and name = !Magic.codelet_name in
65
let ename = expand_name name in
66
let name0 = ename ^ "_0" in
68
let vl = choose_simd "1" "VL"
71
let vistride = either_stride (!uistride) (C.SVar istride)
72
and vostride = either_stride (!uostride) (C.SVar ostride)
75
let _ = Simd.ovs := stride_to_string "ovs" !uovstride in
76
let _ = Simd.ivs := stride_to_string "ivs" !uivstride in
78
let locations = unique_array_c n in
81
(C.array_subscript riarray vistride)
82
(C.array_subscript iiarray vistride)
84
let output = Fft.dft sign n (load_array_c n input) in
87
(C.array_subscript roarray vostride)
88
(C.array_subscript ioarray vostride)
90
let odag = store_array_c n oloc output in
91
let annot = standard_optimizer odag in
94
Fcn ("static void", name0,
95
([Decl (C.constrealtypep, riarray);
96
Decl (C.constrealtypep, iiarray);
97
Decl (C.realtypep, roarray);
98
Decl (C.realtypep, ioarray)]
99
@ (if stride_fixed !uistride then []
100
else [Decl (C.stridetype, istride)])
101
@ (if stride_fixed !uostride then []
102
else [Decl (C.stridetype, ostride)])
104
(if stride_fixed !uivstride then [] else
105
[Decl ("int", !Simd.ivs)]))
107
(if stride_fixed !uovstride then [] else
108
[Decl ("int", !Simd.ovs)]))
110
add_constants (Asch annot))
113
"static void " ^ ename ^
114
"(const " ^ C.realtype ^ " *ri, const " ^ C.realtype ^ " *ii, "
115
^ C.realtype ^ " *ro, " ^ C.realtype ^ " *io,\n" ^
116
C.stridetype ^ " is, " ^ C.stridetype ^ " os, " ^
117
" int v, int ivs, int ovs)\n" ^
120
"for (i = v; i > 0; i -= " ^ vl ^ ") {\n" ^
123
(if stride_fixed !uistride then "" else ", is") ^
124
(if stride_fixed !uostride then "" else ", os") ^
126
(if stride_fixed !uivstride then "" else ", ivs")) ^
128
(if stride_fixed !uovstride then "" else ", ovs")) ^
132
"ri += ivs; ii += ivs; ro += %s; io += %s;\n"
135
"ri += VL * %s; ii += VL * %s; ro += VL * %s; io += VL * %s;\n"
136
!Simd.ivs !Simd.ivs !Simd.ovs !Simd.ovs)) ^
141
"static const kdft_desc desc = { %d, \"%s\", %s, &GENUS, %s, %s, %s, %s };\n"
142
n name (flops_of tree0)
143
(stride_to_solverparm !uistride) (stride_to_solverparm !uostride)
144
(choose_simd "0" (stride_to_solverparm !uivstride))
145
(choose_simd "0" (stride_to_solverparm !uovstride))
148
(declare_register_fcn name) ^
150
" X(kdft_register)(p, " ^ ename ^ ", &desc);\n" ^
153
in ((unparse cvsid tree0) ^ "\n" ^
160
parse speclist usage;
161
print_string (generate (check_size ()));