# SCM Repository

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

Parent Directory | Revision Log

Revision

Original Path:

File size: 1261 byte(s)

**3828**- (**download**) (**annotate**)*Thu May 5 19:55:46 2016 UTC*(3 years, 4 months ago) by*jhr*Original Path:

*branches/vis15/src/compiler/low-to-tree/default-layout.sml*File size: 1261 byte(s)

Working on merge

(* default-layout.sml * * Functions for splitting LowIR vectors into TreeIR composite vectors. * * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu) * * COPYRIGHT (c) 2016 The University of Chicago * All rights reserved. *) structure DefaultLayout = struct (* given a list of native vector sizes in ascending order, return a function for * mapping vector widths to TreeTypes.VecTy values. *) fun layout (sizes : int list) = let (* find smallest supported vector width that is >= n; return the largest * size if n is bigger than the largest supported vector. *) fun find (n, []) = raise Fail "impossible" | find (n, [sz]) = sz | find (sz::szs) = if (n <= sz) then sz else find(n, szs) (* split n into pieces *) fun split (n, pieces) = let val sz = find (n, sizes) val pieces = sz :: pieces val m = n - sz in if (m = 0) then (false, rev pieces) else if (m < 0) then (true, rev pieces) else split (m, pieces) end in fn n => let val (padded, pieces) = split (n, []) in TreeTypes.VecTy(n, padded, pieces) end end (* layout for a scalar target *) fun scalar w = TreeTypes.VecTy(w, false, List.tabulate(w, fn _ => 1)) end

root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |

Powered by ViewVC 1.0.0 |