Home My Page Projects Code Snippets Project Openings diderot

# SCM Repository

[diderot] Diff of /branches/charisee_dev/src/compiler/high-to-mid/ProbeEin.sml
 [diderot] / branches / charisee_dev / src / compiler / high-to-mid / ProbeEin.sml

# Diff of /branches/charisee_dev/src/compiler/high-to-mid/ProbeEin.sml

revision 2827, Tue Nov 11 00:18:38 2014 UTC revision 2829, Wed Nov 12 23:24:38 2014 UTC
# Line 45  Line 45
45
46  fun assign (x, rator, args) = (x, DstIL.OP(rator, args))  fun assign (x, rator, args) = (x, DstIL.OP(rator, args))
47  fun assignEin (x, rator, args) = ((x, DstIL.EINAPP(rator, args)))  fun assignEin (x, rator, args) = ((x, DstIL.EINAPP(rator, args)))
48    fun testp n=(case testing
49        of 0=> 1
50        | _ =>(print(String.concat n);1)
51        (*end case*))
52
53  (*Create fractional, and integer position vectors*)  (*Create fractional, and integer position vectors*)
54  fun transformToImgSpace  (dim,v,posx,imgArgDst)=let  fun transformToImgSpace  (dim,v,posx,imgArgDst)=let
# Line 54  Line 57
57      val M  = DstV.new ("M", DstTy.tensorTy [dim,dim])   (*transform dim by dim?*)      val M  = DstV.new ("M", DstTy.tensorTy [dim,dim])   (*transform dim by dim?*)
58      val T  = DstV.new ("T", DstTy.tensorTy [dim])   (*translate*)      val T  = DstV.new ("T", DstTy.tensorTy [dim])   (*translate*)
59      val x  = DstV.new ("x", DstTy.vecTy dim)            (*Image-Space position*)      val x  = DstV.new ("x", DstTy.vecTy dim)            (*Image-Space position*)
60        val x0  = DstV.new ("x0", DstTy.vecTy dim)
61        val x1  = DstV.new ("x1", DstTy.vecTy dim)
62      val f  = DstV.new ("f", DstTy.vecTy dim)            (*fractional*)      val f  = DstV.new ("f", DstTy.vecTy dim)            (*fractional*)
63      val nd = DstV.new ("nd", DstTy.vecTy dim)           (*real position*)      val nd = DstV.new ("nd", DstTy.vecTy dim)           (*real position*)
64      val n  = DstV.new ("n", DstTy.iVecTy dim)           (*integer position*)      val n  = DstV.new ("n", DstTy.iVecTy dim)           (*integer position*)
65      val PosToImgSpace=mk.transform(dim,dim)      val PosToImgSpace=mk.transform(dim,dim)
66        val PosToImgSpaceA=mk.transformA(dim,dim)
67        val PosToImgSpaceB=mk.transformB dim
68      val P  = DstV.new ("P", DstTy.tensorTy [dim,dim])   (*transform dim by dim?*)      val P  = DstV.new ("P", DstTy.tensorTy [dim,dim])   (*transform dim by dim?*)
69      val code=[      val code=[
70          assign(M, transform, [imgArgDst]),          assign(M, transform, [imgArgDst]),
71          assign(T, translate, [imgArgDst]),          assign(T, translate, [imgArgDst]),
72          assignEin(x, PosToImgSpace,[M,posx,T]) ,  (* MX+T*)          (*assignEin(x, PosToImgSpace,[M,posx,T]) ,  (* MX+T*)*)
73            assignEin(x0, PosToImgSpaceA,[M,posx]) ,
74            assignEin(x, PosToImgSpaceB,[x0,T]) ,
75
76          assign(nd, DstOp.Floor dim, [x]),   (*nd *)          assign(nd, DstOp.Floor dim, [x]),   (*nd *)
77          assignEin(f, mk.subTen([dim]),[x,nd]),           (*fractional*)          assignEin(f, mk.subTen([dim]),[x,nd]),           (*fractional*)
78          assign(n, DstOp.RealToInt dim, [nd]), (*real to Int*)          assign(n, DstOp.RealToInt dim, [nd]), (*real to Int*)
# Line 218  Line 228
228  *)  *)
229
230

(*Does not yet do transformation*)
231   (* Expand probe in place *)   (* Expand probe in place *)
232   fun replaceProbe(b,(params,args),index, sumIndex,origargs,dstargs)=let   fun replaceProbe(b,(params,args),index, sumIndex,origargs,dstargs)=let
233
# Line 247  Line 255
255
256
257      val (dim,argsA,code,s,PArg) = handleArgs(V,h,t,(params,args), origargs,0,dstargs)      val (dim,argsA,code,s,PArg) = handleArgs(V,h,t,(params,args), origargs,0,dstargs)
258      val _ =print("\nSupport is "^Int.toString s)      val _ =testp["\nSupport is ",Int.toString s]
259      val (_,_,dx, _,sxT,restT,_,_) = T.Transform(dx,shapebind,Vshapebind,dim,PArg,nsumshift,1,nid+1)      val (_,_,dx, _,sxT,restT,_,_) = T.Transform(dx,shapebind,Vshapebind,dim,PArg,nsumshift,1,nid+1)
260
261      val params'=params@[E.TEN(3,[dim]),E.TEN(1,[dim]),E.TEN(1,[dim,dim])]      val params'=params@[E.TEN(3,[dim]),E.TEN(1,[dim]),E.TEN(1,[dim,dim])]
# Line 257  Line 265
265          | _ => E.Sum(sxT, E.Prod(restT@[body'']))          | _ => E.Sum(sxT, E.Prod(restT@[body'']))
266          (*end case*))          (*end case*))
267      val args'=argsA@[PArg]      val args'=argsA@[PArg]
val _ =(case testing
of 0=> 1
| _ =>  let
268              val subexp=Ein.EIN{params=params', index=index, body=body'}              val subexp=Ein.EIN{params=params', index=index, body=body'}
269              val _= print(String.concat["\n Don't replace probe  \n \$\$\$ new sub-expression \$\$\$ \n",P.printerE(subexp),"\n"])      val _ = testp["\n Don't replace probe  \n \$\$\$ new sub-expression \$\$\$ \n",P.printerE(subexp),"\n"]
in 1 end
(* end case *))

270
271      in (body',(params',args') ,code)      in (body',(params',args') ,code)
272      end      end

Legend:
 Removed from v.2827 changed lines Added in v.2829