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 3576, Tue Jan 12 17:45:05 2016 UTC revision 3577, Tue Jan 12 19:12:44 2016 UTC
# Line 11  Line 11 
11    end = struct    end = struct
12    
13      structure E = Ein      structure E = Ein
14      structure DstIL = MidIL      structure DstIR = MidIR
15      structure DstOp = MidOps      structure DstOp = MidOps
16      structure T = TransformEin      structure T = TransformEin
17      structure MidToS = MidToString      structure DstV = DstIR.Var
18      structure DstV = DstIL.Var      structure DstTy = MidTypes
19      structure DstTy = MidILTypes      structure T = CoordSpaceTransform
20    
21      (* This file expands probed fields      (* This file expands probed fields
22      * Take a look at ProbeEin tex file for examples      * Take a look at ProbeEin tex file for examples
23      * Note that the original field is an EIN operator in the form <V_alpha * H^(deltas)>(midIL.var list )      * Note that the original field is an EIN operator in the form <V_alpha * H^(deltas)>(midIR.var list )
24      * Param_ids are used to note the placement of the argument in the midIL.var list      * Param_ids are used to note the placement of the argument in the midIR.var list
25      * Index_ids  keep track of the shape of an Image or differentiation.      * Index_ids  keep track of the shape of an Image or differentiation.
26      * Mu  bind Index_id      * Mu  bind Index_id
27      * Generally, we will refer to the following      * Generally, we will refer to the following
# Line 45  Line 45 
45      fun transformToIndexSpace e = T.transformToIndexSpace e      fun transformToIndexSpace e = T.transformToIndexSpace e
46      fun transformToImgSpace e = T.transformToImgSpace  e      fun transformToImgSpace e = T.transformToImgSpace  e
47    
48      fun mkEin e = Ein.mkEin e      fun mkEin (params, index, body) = Ein.EIN{params = params, index = index, body = body}
49      fun mkEinApp (rator, args) = DstIL.EINAPP(rator, args)      fun mkEinApp (rator, args) = DstIR.EINAPP(rator, args)
50      fun setConst e = E.setConst e      fun setConst e = E.setConst e
51      fun setNeg e = E.setNeg e      fun setNeg e = E.setNeg e
52      fun setExp e = E.setExp e      fun setExp e = E.setExp e
# Line 55  Line 55 
55      fun setProd e= E.setProd e      fun setProd e= E.setProd e
56      fun setAdd e= E.setAdd e      fun setAdd e= E.setAdd e
57    
58      fun getRHSDst x  = (case DstIL.Var.binding x      fun getRHSDst x  = (case DstIR.Var.binding x
59             of DstIL.VB_RHS(DstIL.OP(rator, args)) => (rator, args)             of DstIR.VB_RHS(DstIR.OP(rator, args)) => (rator, args)
60              | DstIL.VB_RHS(DstIL.VAR x') => getRHSDst x'              | DstIR.VB_RHS(DstIR.VAR x') => getRHSDst x'
61              | vb => raise Fail(concat[              | vb => raise Fail(concat[
62                    "expected rhs operator for ", DstIL.Var.toString x,                    "expected rhs operator for ", DstIR.Var.toString x,
63                    " but found ", DstIL.vbToString vb                    " but found ", DstIR.vbToString vb
64                  ])                  ])
65            (* end case *))            (* end case *))
66    
67      (* getArgsDst:MidIL.Var* MidIL.Var->int, ImageInfo, int      (* getArgsDst:MidIR.Var* MidIR.Var->int, ImageInfo, int
68          uses the Param_ids for the image, kernel,          uses the Param_ids for the image, kernel,
69          and position tensor to get the Mid-IL arguments          and position tensor to get the Mid-IR arguments
70      returns the support of ther kernel, and image      returns the support of ther kernel, and image
71      *)      *)
72      fun getArgsDst (hArg, imgArg, args) = (case (getRHSDst hArg, getRHSDst imgArg)      fun getArgsDst (hArg, imgArg, args) = (case (getRHSDst hArg, getRHSDst imgArg)
# Line 77  Line 77 
77                    ])                    ])
78            (* end case *))            (* end case *))
79    
80      (*handleArgs():int*int*int*Mid IL.Var list      (*handleArgs():int*int*int*Mid IR.Var list
81          ->int*Mid.ILVars list* code*int* low-il-var          ->int*Mid.IRVars list* code*int* low-il-var
82          * uses the Param_ids for the image, kernel, and tensor          * uses the Param_ids for the image, kernel, and tensor
83          * and gets the mid-IL vars for each.          * and gets the mid-IR vars for each.
84          *Transforms the position to index space          *Transforms the position to index space
85          *P is the mid-il var for the (transformation matrix)transpose          *P is the mid-il var for the (transformation matrix)transpose
86      *)      *)
# Line 159  Line 159 
159        | multiMergePs e = multiPs e        | multiMergePs e = multiPs e
160    
161    
162      (* replaceProbe:ein_exp* params *midIL.var list * int list* sum_id list      (* replaceProbe:ein_exp* params *midIR.var list * int list* sum_id list
163              -> ein_exp* *code              -> ein_exp* *code
164      * Transforms position to world space      * Transforms position to world space
165      * transforms result back to index_space      * transforms result back to index_space
166      * rewrites body      * rewrites body
167      * replace probe with expanded version      * replace probe with expanded version
168      *)      *)
169       fun replaceProbe (testN, (y, DstIL.EINAPP(e,args)), p, sx) = let       fun replaceProbe (testN, (y, DstIR.EINAPP(e,args)), p, sx) = let
170          val params = Ein.params e          val params = Ein.params e
171          val fid = length(params)          val fid = length(params)
172          val nid = fid+1          val nid = fid+1
# Line 218  Line 218 
218              (splitvar, ein0, sizes, dx, alpha')              (splitvar, ein0, sizes, dx, alpha')
219          end          end
220    
221      fun liftProbe (printStrings, (y, DstIL.EINAPP(e, args)), p, sx) = let      fun liftProbe (printStrings, (y, DstIR.EINAPP(e, args)), p, sx) = let
222    
223          val params = Ein.params e          val params = Ein.params e
224          val index = Ein.index e          val index = Ein.index e
# Line 236  Line 236 
236          val rtn0 = (case splitvar          val rtn0 = (case splitvar
237              of false => [(y, mkEinApp(ein0, [PArg,FArg]))]              of false => [(y, mkEinApp(ein0, [PArg,FArg]))]
238              | _      => let              | _      => let
239                  val bind3 = (y, DstIL.EINAPP(SummationEin.main ein0, [PArg, FArg]))                  val bind3 = (y, DstIR.EINAPP(SummationEin.main ein0, [PArg, FArg]))
240                  in                  in
241                      Split.splitEinApp bind3                      Split.splitEinApp bind3
242                  end                  end
# Line 259  Line 259 
259      * Looks to see if the expression has a probe. If so, replaces it.      * Looks to see if the expression has a probe. If so, replaces it.
260      * Note how we keeps eps expressions so only generate pieces that are used      * Note how we keeps eps expressions so only generate pieces that are used
261      *)      *)
262     fun expandEinOp (e as (y, DstIL.EINAPP(ein, args)), fieldset) = let     fun expandEinOp (e as (y, DstIR.EINAPP(ein, args)), fieldset) = let
263          fun rewriteBody b=(case b          fun rewriteBody b=(case b
264              of  (E.Probe(E.Conv(_,_,_,[]),_))              of  (E.Probe(E.Conv(_,_,_,[]),_))
265                  => replaceProbe(0,e,b,[])                  => replaceProbe(0,e,b,[])
# Line 276  Line 276 
276              | _ => [e]              | _ => [e]
277              (* end case *))              (* end case *))
278          val (fieldset,var) = (case valnumflag          val (fieldset,var) = (case valnumflag
279              of true => einSet.rtnVar(fieldset,y,DstIL.EINAPP(ein,args))              of true => einSet.rtnVar(fieldset,y,DstIR.EINAPP(ein,args))
280              | _     => (fieldset,NONE)              | _     => (fieldset,NONE)
281          (* end case *))          (* end case *))
282    
# Line 290  Line 290 
290    
291          in  (case var          in  (case var
292              of NONE => ((rewriteBody(Ein.body ein), fieldset, matchField(Ein.body ein), 0))              of NONE => ((rewriteBody(Ein.body ein), fieldset, matchField(Ein.body ein), 0))
293              | SOME v => (("\n mapp_replacing"^(P.printerE ein)^":");([(y,DstIL.VAR v)], fieldset, matchField(Ein.body ein), 1))              | SOME v => (("\n mapp_replacing"^(P.printerE ein)^":");([(y,DstIR.VAR v)], fieldset, matchField(Ein.body ein), 1))
294              (* end case *))              (* end case *))
295          end          end
296    

Legend:
Removed from v.3576  
changed lines
  Added in v.3577

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