Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Annotation of /branches/vis15/src/compiler/low-to-tree/default-layout.sml
ViewVC logotype

Annotation of /branches/vis15/src/compiler/low-to-tree/default-layout.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3828 - (view) (download)

1 : jhr 3828 (* default-layout.sml
2 :     *
3 :     * Functions for splitting LowIR vectors into TreeIR composite vectors.
4 :     *
5 :     * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
6 :     *
7 :     * COPYRIGHT (c) 2016 The University of Chicago
8 :     * All rights reserved.
9 :     *)
10 :    
11 :     structure DefaultLayout =
12 :     struct
13 :    
14 :     (* given a list of native vector sizes in ascending order, return a function for
15 :     * mapping vector widths to TreeTypes.VecTy values.
16 :     *)
17 :     fun layout (sizes : int list) = let
18 :     (* find smallest supported vector width that is >= n; return the largest
19 :     * size if n is bigger than the largest supported vector.
20 :     *)
21 :     fun find (n, []) = raise Fail "impossible"
22 :     | find (n, [sz]) = sz
23 :     | find (sz::szs) = if (n <= sz) then sz else find(n, szs)
24 :     (* split n into pieces *)
25 :     fun split (n, pieces) = let
26 :     val sz = find (n, sizes)
27 :     val pieces = sz :: pieces
28 :     val m = n - sz
29 :     in
30 :     if (m = 0)
31 :     then (false, rev pieces)
32 :     else if (m < 0)
33 :     then (true, rev pieces)
34 :     else split (m, pieces)
35 :     end
36 :     in
37 :     fn n => let
38 :     val (padded, pieces) = split (n, [])
39 :     in
40 :     TreeTypes.VecTy(n, padded, pieces)
41 :     end
42 :     end
43 :    
44 :     (* layout for a scalar target *)
45 :     fun scalar w = TreeTypes.VecTy(w, false, List.tabulate(w, fn _ => 1))
46 :    
47 :     end

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0