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

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/high-to-mid/probe-ein.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/high-to-mid/probe-ein.sml

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

revision 4058, Mon Jun 27 16:16:21 2016 UTC revision 4059, Mon Jun 27 20:19:25 2016 UTC
# Line 39  Line 39 
39      structure T = CoordSpaceTransform      structure T = CoordSpaceTransform
40    
41      fun mkEin (params, index, body) = Ein.EIN{params = params, index = index, body = body}      fun mkEin (params, index, body) = Ein.EIN{params = params, index = index, body = body}
42    
43      fun incUse (IR.V{useCnt, ...}) = (useCnt := !useCnt + 1)      fun incUse (IR.V{useCnt, ...}) = (useCnt := !useCnt + 1)
44    
45      fun getRHSDst x = (case IR.Var.getDef x      fun getRHSDst x = (case IR.Var.getDef x
46             of IR.OP(rator, args) => (rator, args)             of IR.OP(rator, args) => (rator, args)
47              | rhs => raise Fail(concat[              | rhs => raise Fail(concat[
# Line 48  Line 50 
50                  ])                  ])
51            (* end case *))            (* end case *))
52    
53        fun axis dir = (case dir of 0 => "X" | 1 => "Y" | 2 => "Z" | _ => "dir" ^ Int.toString dir)
54    
55      fun checkImg imgArg = (case IR.Var.getDef imgArg      fun checkImg imgArg = (case IR.Var.getDef imgArg
56             of IR.OP(Op.LoadImage _, _) => imgArg             of IR.OP(Op.LoadImage _, _) => imgArg
57              | rhs => raise Fail (String.concat[              | rhs => raise Fail (String.concat[
# Line 104  Line 108 
108     * kernel, fractional position, support     * kernel, fractional position, support
109     *)     *)
110      fun liftKrn (avail, dir, dx, dim, h, vF, s) = let      fun liftKrn (avail, dir, dx, dim, h, vF, s) = let
111            val axis = (case dir of 0 => "X" | 1 => "Y" | 2 => "Z" | _ => "dir" ^ Int.toString dir)            val axis = axis dir
112            val range = 2*s            val range = 2*s
113          (* build position vector for EvalKernel *)          (* build position vector for EvalKernel *)
114            val vX = if (dim = 1)            val vX = if (dim = 1)
# Line 117  Line 121 
121                  Ty.TensorTy[range], IR.OP(Op.BuildPos s, [vX]))                  Ty.TensorTy[range], IR.OP(Op.BuildPos s, [vX]))
122            val nKernEvals = List.length dx + 1            val nKernEvals = List.length dx + 1
123            fun mkEval k = AvailRHS.addAssign (            fun mkEval k = AvailRHS.addAssign (
124                  avail, concat["keval", axis, "_del", Int.toString k],                  avail, concat["keval", axis, "_d", Int.toString k, "_"],
125                  Ty.TensorTy[range], IR.OP(Op.EvalKernel(range, h, k), [vPos]))                  Ty.TensorTy[range], IR.OP(Op.EvalKernel(range, h, k), [vPos]))
126            val vKs = List.tabulate(nKernEvals, fn k => mkEval k)            val vKs = List.tabulate(nKernEvals, fn k => mkEval k)
127            in            in
# Line 136  Line 140 
140    (* mkLdVoxel creates load voxel operator to represent image addressing *)    (* mkLdVoxel creates load voxel operator to represent image addressing *)
141      fun mkLdVoxel (avail, vI, vN, info, alpha, shape, dim, s, border) = let      fun mkLdVoxel (avail, vI, vN, info, alpha, shape, dim, s, border) = let
142         (* creates lb int *)         (* creates lb int *)
143           val vLb = AvailRHS.addAssign (avail, "lit", Ty.intTy,  IR.LIT(Literal.Int (1-(IntInf.fromInt s))))            val vLb = AvailRHS.addAssign (avail, "lit", Ty.intTy,
144                    IR.LIT(Literal.Int(IntInf.fromInt(1 - s))))
145           val seqTy = Ty.SeqTy(Ty.intTy, SOME dim)           val seqTy = Ty.SeqTy(Ty.intTy, SOME dim)
146         (*created n_0 +lb, n_1+lb*)         (*created n_0 +lb, n_1+lb*)
147           fun f i = let           fun f i = let
148                val vA = AvailRHS.addAssign (                val vA = AvailRHS.addAssign (
149                      avail, "idx", Ty.intTy,  IR.LIT(Literal.Int (IntInf.fromInt i)))                      avail, "idx", Ty.intTy,  IR.LIT(Literal.Int (IntInf.fromInt i)))
150                val vB = AvailRHS.addAssign (                val vB = AvailRHS.addAssign (
151                      avail, "subscript",                        avail, concat["n", axis i, "_"],
152                      Ty.intTy, IR.OP(Op.Subscript seqTy, [vN, vA]))                      Ty.intTy, IR.OP(Op.Subscript seqTy, [vN, vA]))
153                in                in
154                  AvailRHS.addAssign (avail, "add", Ty.intTy, IR.OP(Op.IAdd, [vB, vLb]))                  AvailRHS.addAssign (avail, "add", Ty.intTy, IR.OP(Op.IAdd, [vB, vLb]))
155                end                end
156              val vNs = List.tabulate (dim, f)
157          (* image positions *)          (* image positions *)
158            val s'= 2*s            val s'= 2*s
159            val supportshape =  List.tabulate(dim, fn _ => s')            val supportshape =  List.tabulate(dim, fn _ => s')
160            val ldty = Ty.TensorTy(shape@supportshape)            val ldty = Ty.TensorTy(shape@supportshape)
           val vNs = List.tabulate( dim, fn n => f n)  
161            val vSq = AvailRHS.addAssign (avail, "seq", seqTy, IR.SEQ(vNs, seqTy))            val vSq = AvailRHS.addAssign (avail, "seq", seqTy, IR.SEQ(vNs, seqTy))
162            val op1 = (case border            val op1 = (case border
163                   of NONE => Op.LoadVoxels (info, 2*s)                   of NONE => Op.LoadVoxels (info, s')
164                    | SOME b => Op.LoadVoxelsWithCtl (info, 2*s, b)                    | SOME b => Op.LoadVoxelsWithCtl (info, s', b)
165                  (* end case *))                  (* end case *))
166            in            in
167              AvailRHS.addAssign (avail, "ldvox", ldty, IR.OP(op1, [vI, vSq]))              AvailRHS.addAssign (avail, "ldvox", ldty, IR.OP(op1, [vI, vSq]))

Legend:
Removed from v.4058  
changed lines
  Added in v.4059

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