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

SCM Repository

[diderot] Diff of /branches/charisee/src/compiler/tree-il/lowOp-to-treeOp.sml
ViewVC logotype

Diff of /branches/charisee/src/compiler/tree-il/lowOp-to-treeOp.sml

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

revision 3194, Wed May 13 02:57:42 2015 UTC revision 3195, Wed May 20 21:02:12 2015 UTC
# Line 115  Line 115 
115                  createOps (es, count+1,offset + IntInf.fromInt nSize, code@[exp])                  createOps (es, count+1,offset + IntInf.fromInt nSize, code@[exp])
116              end              end
117          in (case (oldrator,pieces,argVecs)          in (case (oldrator,pieces,argVecs)
118              of   (SrcOp.sumVec _,[nSize],[a]) =>let              of  (SrcOp.sumVec _,_,_) =>let
                 val args=[getArg(isFill,lhsKind,a,0, nSize, oSize, (0))]  
                 in  
                     [Dst.E_Op(DstOp.sumVec([nSize],oSize),args)]  
                 end  
             | (SrcOp.sumVec _,_,_) =>let  
119                  val code=createOps (pieces, 0,indexAt, [])                  val code=createOps (pieces, 0,indexAt, [])
120                  val args=List.foldr op@ [] (List.map (fn(_,args)=>args) code)                  val args=List.foldr op@ [] (List.map (fn(_,args)=>args) code)
121                  in                  in
122                     (* List.map (fn(nSize,args)=> Dst.E_Op(DstOp.sumVec([nSize],nSize),args)) code*)                     (* List.map (fn(nSize,args)=> Dst.E_Op(DstOp.sumVec([nSize],nSize),args)) code*)
123                   [Dst.E_Op(DstOp.sumVec(pieces,oSize),args)]                   [Dst.E_Op(DstOp.sumVec(pieces,oSize),args)]
   
   
124                  end                  end
125              | _ => let              | _ => let
126                  val code=createOps (pieces, 0,indexAt, [])                  val code=createOps (pieces, 0,indexAt, [])
# Line 138  Line 131 
131          end          end
132    
133      (* Same funciton as above      (* Same funciton as above
134      *Except this first scans for special case ProjectTensor LowIL Op.      * Except this first scans for special case ProjectLast LowIL Op.
135      *ProjectTensor is an op that slices a vector from a higher order tensor      * ProjectLast is an op that slices a vector from a higher order tensor
136      * That vec could be in pieces      * That vec could be in pieces
137      * So we load each one and the next step wraps a mux around it      * So we load each one and the next step wraps a mux around it
138      * We can assume the higher order tensor is an array      * We can assume the higher order tensor is an array
139      * This rewrites the PorjectTensor op as an E_LoadArr.      * This rewrites the ProjectLast op as an E_LoadArr.
140      *Otherwise hand off to above function      *Otherwise hand off to above function
141      *)      *)
142      fun mkOps(isFill,lhsKind,oldrator,rator,oSize,pieces,argScas,argVecs,indexAt)=  (case (oldrator,pieces,argVecs)      fun mkOps(isFill,lhsKind,oldrator,rator,oSize,pieces,argScas,argVecs,indexAt)=  (case (oldrator,pieces,argVecs)
143          of (SrcOp.ProjectTensor(_,_,indTy,argTy),_,[a]) => let          of (SrcOp.ProjectLast(_,_,indTy,argTy),_,[a]) => let
144              val A=isAlignedLoad(isFill,argTy)              val A=isAlignedLoad(isFill,argTy)
145    
146                (*shift based on type of argument*)
147              val shift=(case (indTy,argTy)              val shift=(case (indTy,argTy)
148                  of (Ty.indexTy[i],Ty.TensorTy[_,argTyX])=> i*argTyX                  of (Ty.indexTy[i],Ty.TensorTy[_,argTyX])=> i*argTyX
149                      | (Ty.indexTy[j,i],Ty.TensorTy[_,argTyY,argTyX])=> j*(argTyX*argTyY)+i*argTyX                      | (Ty.indexTy[j,i],Ty.TensorTy[_,argTyY,argTyX])=> j*(argTyX*argTyY)+i*argTyX
150                      |  _ =>raise Fail "Project Tensor of a unhandled size"                      |  _ =>raise Fail "ProjectLast Tensor of a unhandled size" (*add this later*)
151                      (*end case *))                      (*end case *))
152              fun mkLoad ([], _, code) = code              fun mkLoad ([], _, code) = code
153              | mkLoad (nSize::es, offset, code)=              | mkLoad (nSize::es, offset, code)=
# Line 161  Line 156 
156              in              in
157                  mkLoad (pieces, IntInf.fromInt shift, [])                  mkLoad (pieces, IntInf.fromInt shift, [])
158              end              end
159        | (SrcOp.ProjectFirst(_,vecIX,Ty.indexTy[i],Ty.TensorTy[argTy,argTyX]),_,args)=> let
160                fun f cnt = Dst.E_Op(DstOp.IndexTensor(false,Ty.indexTy [cnt,i],Ty.TensorTy[argTy,argTyX]),args)
161                val indops=List.tabulate(vecIX, fn e=> f e)
162                val econs=[Dst.E_Cons(oSize, oSize,indops)]
163                in econs end
164    
165          | (SrcOp.sumVec _,[nSize],[a]) =>  [Dst.E_Op(DstOp.sumVec([nSize],oSize), [getArg(isFill,lhsKind,a,0, nSize, oSize, 0)])]          | (SrcOp.sumVec _,[nSize],[a]) =>  [Dst.E_Op(DstOp.sumVec([nSize],oSize), [getArg(isFill,lhsKind,a,0, nSize, oSize, 0)])]
166          | _ => mkGenericOps(isFill,lhsKind,oldrator,rator,oSize,pieces,argScas,argVecs,indexAt)          | _ => mkGenericOps(isFill,lhsKind,oldrator,rator,oSize,pieces,argScas,argVecs,indexAt)
167          (*end case*))          (*end case*))
# Line 169  Line 170 
170      (*vecToTree:TreeIL.Var.kind*LowILOP*TreeILOP*int*int*int list*TreeILExp list *TreeILExp list *bool->TreeILExp List      (*vecToTree:TreeIL.Var.kind*LowILOP*TreeILOP*int*int*int list*TreeILExp list *TreeILExp list *bool->TreeILExp List
171      *Main function that turns a low-il vector operation into tree-il stmt      *Main function that turns a low-il vector operation into tree-il stmt
172      *)      *)
173      fun vecToTree(lhs,origrator,rator,nSize,oSize,pieces,argScas,argVecs,isFill)= let      fun vecToTree(lhs,origrator,rator,nSize,oSize,pieces,argScas,argVecs,isFill)=(case origrator
174            of (* SrcOp.ProjectFirst(_,vecIX,Ty.indexTy[i],Ty.TensorTy[argTy,argTyX])=> let
175                    fun f cnt = Dst.E_Op(DstOp.IndexTensor(false,Ty.indexTy [cnt,i],Ty.TensorTy[argTy,argTyX]),[a])
176                    val indops=List.tabulate(vecIX, fn e=> f e)
177                    val econs=Dst.E_Cons(nSize, nSize,ops)
178                    in
179                        mkStmt(lhs,lhsKind,origrator,isFill,oSize,aligned,splitTy,econs)
180                    end
181            |*) _=> let
182          val splitTy=DstTy.vectorLength pieces          val splitTy=DstTy.vectorLength pieces
183          val aligned= isAlignedStore(isFill,length pieces)          val aligned= isAlignedStore(isFill,length pieces)
184          val indexAt=IntInf.fromInt 0          val indexAt=IntInf.fromInt 0
# Line 180  Line 189 
189      in      in
190          mkStmt(lhs,lhsKind,origrator,isFill,oSize,aligned,splitTy,ops)          mkStmt(lhs,lhsKind,origrator,isFill,oSize,aligned,splitTy,ops)
191      end      end
192        (* end case*))
193    
194    
195      (* consVecToTree:int*int*int list*TreeIL.Exp* bool->TreeIL.Exp      (* consVecToTree:int*int*int list*TreeIL.Exp* bool->TreeIL.Exp
196       * Takes Cons of a vector and returns TreeIL.exp inside E_Mux.       * Takes Cons of a vector and returns TreeIL.exp inside E_Mux.

Legend:
Removed from v.3194  
changed lines
  Added in v.3195

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