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

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/tree-ir/vector-layout.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/tree-ir/vector-layout.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3828, Thu May 5 19:55:46 2016 UTC revision 3832, Fri May 6 15:08:12 2016 UTC
# Line 8  Line 8 
8   * All rights reserved.   * All rights reserved.
9   *)   *)
10    
11  structure DefaultLayout =  (* hardware support:
12    struct   * SSE          128 bits
13     * AVX          256 bits (?)
14     * AVX2         256 bits
15     * AVX512       512 bits
16     *)
17    
18    structure DefaultLayout : sig
19    
20    (* given a list of native vector sizes in ascending order, return a function for    (* given a list of native vector sizes in ascending order, return a function for
21     * mapping vector widths to TreeTypes.VecTy values.     * mapping vector widths to TreeTypes.VecTy values.
22     *)     *)
23        val layout : int list -> int -> TreeTypes.vec_layout
24    
25      (* layout for a scalar target *)
26        val scalar : int -> TreeTypes.vec_layout
27    
28      (* `gccVectorSizes realIsDouble`
29       * returns a list of vector sizes that are valid for GCC vector extensions assuming
30       * a maximum width of 512 bits (AVX512).  The argument should be true if a Diderot
31       * real value is double precision.
32       *)
33        val gccVectorSizes : bool -> int list
34    
35      (* given a list of native vector sizes in ascending order, return a function for
36       * testing the validity of a layout.
37       *)
38        val valid : int list -> TreeTypes.vec_layout -> bool
39    
40      end = struct
41    
42      fun layout (sizes : int list) = let      fun layout (sizes : int list) = let
43          (* find smallest supported vector width that is >= n; return the largest          (* find smallest supported vector width that is >= n; return the largest
44           * size if n is bigger than the largest supported vector.           * size if n is bigger than the largest supported vector.
# Line 37  Line 62 
62              fn n => let              fn n => let
63                  val (padded, pieces) = split (n, [])                  val (padded, pieces) = split (n, [])
64                  in                  in
65                    TreeTypes.VecTy(n, padded, pieces)                    {wid=n, padded=padded, pieces=pieces}
66                  end                  end
67            end            end
68    
69    (* layout for a scalar target *)      fun scalar w = {wid=w, padded=false, pieces=List.tabulate(w, fn _ => 1)}
70      fun scalar w = TreeTypes.VecTy(w, false, List.tabulate(w, fn _ => 1))  
71        local
72          val log2MaxWidth = 6      (* maxWidth == 512/32 *)
73          fun twoToThe n = Word.toIntX(Word.<<(0w1, Word.fromInt n))
74        in
75        fun gccVectorSizes false = List.tabulate (log2MaxWidth, twoToThe)
76          | gccVectorSizes true = List.tabulate (log2MaxWidth-1, twoToThe)
77        end (* local *)
78    
79        fun valid (sizes : int list) = let
80              fun validSize sz = List.exists (op =) sizes
81              fun check {wid, padded, pieces} = let
82                    fun chkPieces ([], totWid) =
83                          (wid = totWid) orelse (padded andalso (wid < totWid))
84                      | chkPieces (p::ps, totWid) =
85                          validSize p andalso chkPieces (ps, p+totWid)
86              in
87                (wid > 0) andalso chkPieces (pieces, 0)
88              end
89    
90    end    end

Legend:
Removed from v.3828  
changed lines
  Added in v.3832

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