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

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/mid-to-low/field-to-low.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/mid-to-low/field-to-low.sml

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

revision 3727, Wed Apr 6 18:35:46 2016 UTC revision 3728, Wed Apr 6 20:05:42 2016 UTC
# Line 18  Line 18 
18     *    sx     -- summation bounds     *    sx     -- summation bounds
19     *    prod   -- body of summation, which is a product of Ein expressions     *    prod   -- body of summation, which is a product of Ein expressions
20     *    params -- the formal parameters of the enclosing Ein expression     *    params -- the formal parameters of the enclosing Ein expression
21     *    args   -- the actual arguments of the enclosing Ein expression     *    midArgs -- the MidIR actual arguments of the enclosing Ein expression
22       *    lowArgs -- the actual arguments of the enclosing Ein expression
23     *)     *)
24      val expand : {      val expand : {
25              avail : AvailRHS.t,              avail : AvailRHS.t,
26              mapp : int IntRedBlackMap.map,              mapp : int IntRedBlackMap.map,
27              sx : Ein.sumrange list,              sx : Ein.sumrange list,
28              prod : ein_exp list,              prod : Ein.ein_exp list,
29    (* FIXME: do we need the params? *)
30              params : Ein.param_kind list,              params : Ein.param_kind list,
31              args : LowIR.var list              midArgs : MidIR.var list,
32                lowArgs : LowIR.var list
33            }  -> LowIR.var            }  -> LowIR.var
34    
35    end = struct    end = struct
# Line 46  Line 49 
49            val k1 = stripK k1            val k1 = stripK k1
50            val rest = List.map stripK rest            val rest = List.map stripK rest
51            in            in
52              (img, k1, k1::rest)              (#1 img, #1 k1, k1::rest)
53            end            end
54        | partition _ = raise Fail "missing image/kernel"        | partition _ = raise Fail "missing image/kernel"
55    
56    (* get the image and kernel arguments. *)    (* expand a MidIR probe to LowIR code. *)
57      fun getArgs (args, (imgId, _, _), (kernId, _, _)) = let      fun expand {avail, mapp, sx, prod, params, midArgs, lowArgs} = let
58            val imgArg = List.nth(args, imgId)            val (imgId, kernId, kexps) = partition prod
59            val imgInfo = (case IR.Var.getDef ()          (* get the image argument *)
60              val (imgArg, imgInfo) = let
61                    val imgArg = List.nth(lowArgs, imgId)
62                    val imgInfo = (case IR.Var.getDef imgArg
63                   of IR.OP(Op.LoadImage(Ty.ImageTy img, _), _) => img                   of IR.OP(Op.LoadImage(Ty.ImageTy img, _), _) => img
64                    | IR.GLOBAL gv => raise Fail "FIXME: input variable"                    | IR.GLOBAL gv => raise Fail "FIXME: input variable"
65                    | _ => raise Fail "unable to get image argument"                    | _ => raise Fail "unable to get image argument"
66                  (* end case *))                  (* end case *))
           val h = (case IR.Var.getDef (List.nth(args, kernId))  
                  of IR.OP(Op.Kernel h) => h  
                   | _ => raise Fail "unable to get kernel argument"  
                 (* end case *))  
67            in            in
68              (imgArg, imgInfo, h)                    (imgArg, imgInfo)
69            end            end
70            (* get the kernel argument.  We use the MidIR args, because there are no kernels
71    (* expand a MidIR probe to LowIR code. *)           * in LowIR.
72      fun expand {avail, mapp, sx, prod, params, args} = let           *)
73            val (img, k1, kexps) = partition prod            val h = (case MidIR.Var.getDef (List.nth(midArgs, kernId))
74            val (imgArg, imgInfo, h) = getArgs (args, img, k1)                   of MidIR.OP(MidOps.Kernel h, []) => h
75                      | _ => raise Fail "unable to get kernel argument"
76                    (* end case *))
77          (* get the outermost index; note that the (lb, ub) will be the same for all          (* get the outermost index; note that the (lb, ub) will be the same for all
78           * of the indices, since the same kernel (and support) is used for all axes.           * of the indices, since the same kernel (and support) is used for all axes.
79           *)           *)

Legend:
Removed from v.3727  
changed lines
  Added in v.3728

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