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

SCM Repository

[diderot] Diff of /branches/charisee/src/compiler/mid-to-low/evalImg-set.sml
ViewVC logotype

Diff of /branches/charisee/src/compiler/mid-to-low/evalImg-set.sml

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

revision 3448, Fri Nov 20 20:33:38 2015 UTC revision 3542, Mon Jan 4 19:47:38 2016 UTC
# Line 8  Line 8 
8      structure Var = LowIL.Var      structure Var = LowIL.Var
9      structure E = Ein      structure E = Ein
10      structure P=Printer      structure P=Printer
   
11      structure H=HelperSet      structure H=HelperSet
12    
   
13          in          in
14    
15      val testing=0  
16      fun lookup e =H.lookup e      fun lookup e =H.lookup e
17      fun insert e=H.insertP e      fun insert e=H.insertP e
18      fun find e=H.find e      fun find e=H.find e
# Line 25  Line 23 
23      fun mkAddInt e= H.mkAddInt e      fun mkAddInt e= H.mkAddInt e
24      fun mkAddPtr e = H.mkAddPtr e      fun mkAddPtr e = H.mkAddPtr e
25      fun mkProdInt e= H.mkProdInt e      fun mkProdInt e= H.mkProdInt e
   
26      fun iTos n=Int.toString n      fun iTos n=Int.toString n
27      fun err str=raise Fail(str)      fun err str=raise Fail(str)
28      val intTy=DstTy.IntTy      val intTy=DstTy.IntTy
29      fun testp n =(case testing      val testing=false
30          of 0 => 1      fun testp n =if (testing) then (print(String.concat n);1) else 1
         | _  => (print(String.concat n);1)  
         (*end case *))  
31      fun psize n=foldl (fn (a,b) => b*a) 1 n      fun psize n=foldl (fn (a,b) => b*a) 1 n
32      fun asize n=foldl (fn (a,b) => b+a) 0 n      fun asize n=foldl (fn (a,b) => b+a) 0 n
33    
# Line 45  Line 40 
40      * createImgVar() uses  mkpos(), getPosAddr() and getImgAddr() to get imgvar      * createImgVar() uses  mkpos(), getPosAddr() and getImgAddr() to get imgvar
41      *)      *)
42      fun mkImg(setOrig,mappOrig,lhs,params,args, sx,(_,v_alpha,pos0::px),v,imgarg,lb,range0,range1)=let      fun mkImg(setOrig,mappOrig,lhs,params,args, sx,(_,v_alpha,pos0::px),v,imgarg,lb,range0,range1)=let
   
43          val dim=ImageInfo.dim v          val dim=ImageInfo.dim v
44          val ptyTy=DstTy.AddrTy v          val ptyTy=DstTy.AddrTy v
45          val sizes=ImageInfo.sizes v          val sizes=ImageInfo.sizes v
46          val (setBase,vBase,base)=assgn(setOrig,DstOp.baseAddr v,[imgarg],"baseAddr",ptyTy)   (*base address*)          val (setBase,vBase,base)=assgn(setOrig,DstOp.baseAddr v,[imgarg],"baseAddr",ptyTy)
47          val (setShapeShift,vShapeShift,ShapeShiftcode)= mkInt(setBase,psize (ImageInfo.voxelShape v)) (*shift of the image field.*)          (*base address*)
48            val (setShapeShift,vShapeShift,ShapeShiftcode)= mkInt(setBase,psize (ImageInfo.voxelShape v))
49            (*shift of the image field.*)
50    
51          (*Since the image is loaded as a vector          (*Since the image is loaded as a vector
52          * we evaluate the first position just once          * we evaluate the first position just once
# Line 75  Line 70 
70              in              in
71                  (setC,vC,A@B@C,sxx)                  (setC,vC,A@B@C,sxx)
72              end              end
   
   
73          (* mkpos:ein_exp list*var list*DstIL.assgn list          (* mkpos:ein_exp list*var list*DstIL.assgn list
74          * transform ein_exp to low-il          * transform ein_exp to low-il
75          * returns var for the position          * returns var for the position
# Line 96  Line 89 
89                  in mkpos(setD,es,mapp,rest@[rest'],code@code') end                  in mkpos(setD,es,mapp,rest@[rest'],code@code') end
90              | e1::_ => raise Fail("Incorrect pos for Image: "^P.printbody e1)              | e1::_ => raise Fail("Incorrect pos for Image: "^P.printbody e1)
91              (*end case*))              (*end case*))
   
92          (* getPosAddr:var list->var*DstIL.assgn list          (* getPosAddr:var list->var*DstIL.assgn list
93          * create position addr based on image info's shapeshift,image info's sizes,and args          * create position addr based on image info's shapeshift,image info's sizes,and args
94          * args are the variables for this specific positions. V_([x,y])          * args are the variables for this specific positions. V_([x,y])
# Line 120  Line 112 
112                  val( setG,vG,G)= mkProdInt(setF,[vShapeShift,vF])                  val( setG,vG,G)= mkProdInt(setF,[vShapeShift,vF])
113                  in (setG,vG,A@B@C@D@E@F@G) end                  in (setG,vG,A@B@C@D@E@F@G) end
114              (*end case*))              (*end case*))
   
115          (* getImgAddr:int list *var->var*DstIL.assgn list          (* getImgAddr:int list *var->var*DstIL.assgn list
116          * creates image address with ^position address,imgType, and base address          * creates image address with ^position address,imgType, and base address
117          * imgType are  image specific indices V[0,1](_)          * imgType are  image specific indices V[0,1](_)
# Line 136  Line 127 
127                  in (setC,vC,A@B@C)end                  in (setC,vC,A@B@C)end
128              | [i,j] => let              | [i,j] => let
129                  val [a,b]=ImageInfo.voxelShape v                  val [a,b]=ImageInfo.voxelShape v
130                  (*val _=print(String.concat[Int.toString i,"-",Int.toString j,"\nvoxel",Int.toString a,"-",Int.toString b])*)  
131                  val (setA,vA,A)= mkAddPtr(setImgAddr,[vBase,vPosAddr],ptyTy)                  val (setA,vA,A)= mkAddPtr(setImgAddr,[vBase,vPosAddr],ptyTy)
132                  val (setB,vB,B)= mkInt (setA,(b*j)+i)                  val (setB,vB,B)= mkInt (setA,(b*j)+i)
133                  val (setC,vC,C)= mkAddPtr(setB,[vB, vA],ptyTy)                  val (setC,vC,C)= mkAddPtr(setB,[vB, vA],ptyTy)
# Line 158  Line 149 
149              end              end
150    
151          val range0List=List.tabulate(range0+1,fn e=>e)          val range0List=List.tabulate(range0+1,fn e=>e)
   
152          (* sumPos:index_id * var list*lowil.assgn list*dict*int          (* sumPos:index_id * var list*lowil.assgn list*dict*int
153          * ->var*lowil.assgn list          * ->var*lowil.assgn list
154          * sumPos iterates over the summation indices and creates mapp          * sumPos iterates over the summation indices and creates mapp
# Line 184  Line 174 
174              val mapp=insert (sid, n') dict              val mapp=insert (sid, n') dict
175              val (set',lft',code')=sumPos(setSx,sxx,lft,[],mapp,range0List)              val (set',lft',code')=sumPos(setSx,sxx,lft,[],mapp,range0List)
176              in (set',lft',code@code') end              in (set',lft',code@code') end
   
177          | sumPos(setSx,sid::sxx,lft,code,dict,r::es)=let          | sumPos(setSx,sid::sxx,lft,code,dict,r::es)=let
178              val n'=lb+r              val n'=lb+r
179              val _=testp["\n insert",iTos sid, "->",iTos n']              val _=testp["\n insert",iTos sid, "->",iTos n']
# Line 193  Line 182 
182              in              in
183                  sumPos(set',sid::sxx,lft',code@code',dict,es)                  sumPos(set',sid::sxx,lft',code@code',dict,es)
184              end              end
   
   
 (*        fun sumPos(setSx,[],lft,code,dict,_)=let  
 val (set',lft', code')= createImgVar(setSx, dict)  
 in (set',[lft']@lft,code'@code) end  
 | sumPos(setSx,[sid],lft,code,dict,0)=let  
 val n'=lb  
 val _=testp["\n insert",iTos sid, "->",iTos n']  
 val mapp=insert (sid, n') dict  
 val (set',lft', code')= createImgVar(setSx, mapp)  
 in (set',[lft']@lft,code'@code) end  
 | sumPos(setSx,[sid],lft,code,dict,r)=let  
 val n'=lb+r  
 val _=testp["\n insert",iTos sid, "->",iTos n']  
 val mapp=insert (sid, n') dict  
 val (set',lft', code')= createImgVar(setSx, mapp)  
 in sumPos(set',[sid],[lft']@lft,code'@code,dict,r-1) end  
 | sumPos(setSx,sid::sxx,lft,code,dict,0)=let  
 val n'=lb  
 val _=testp["\n insert",iTos sid, "->",iTos n']  
 val mapp=insert (sid, n') dict  
 val (set',lft',code')=sumPos(setSx,sxx,lft,[],mapp,range0)  
 in (set',lft',code'@code) end  
   
 | sumPos(setSx,sid::sxx,lft,code,dict,r)=let  
 val n'=lb+r  
 val _=testp["\n insert",iTos sid, "->",iTos n']  
 val mapp=insert (sid, n') dict  
 val (set',lft',code')=sumPos(setSx,sxx,lft,[],mapp,range0)  
 in  
 sumPos(set',sid::sxx,lft',code'@code,dict,r-1)  
 end  
 *)  
185          val(setSx,lft,code)=sumPos(setPos0,sxx,[],[],mappOrig,range0List)          val(setSx,lft,code)=sumPos(setPos0,sxx,[],[],mappOrig,range0List)
 val q=base@ShapeShiftcode@Pos0code@code  
   
186          in          in
187              (setSx,lft,base@ShapeShiftcode@Pos0code@code)              (setSx,lft,base@ShapeShiftcode@Pos0code@code)
188          end          end

Legend:
Removed from v.3448  
changed lines
  Added in v.3542

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