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 2748, Wed Oct 1 21:16:56 2014 UTC revision 2749, Wed Oct 1 23:11:09 2014 UTC
# Line 27  Line 27 
27      fun mkStmt(lhsExp,lhsKind,rator,nSize,oSize,A,splitTy,ops)= (case (rator nSize)      fun mkStmt(lhsExp,lhsKind,rator,nSize,oSize,A,splitTy,ops)= (case (rator nSize)
28          of DstOp.sumVec _ => (SOME( addSca ops),NONE)          of DstOp.sumVec _ => (SOME( addSca ops),NONE)
29          | DstOp.dotVec _  => (SOME( addSca ops),NONE)          | DstOp.dotVec _  => (SOME( addSca ops),NONE)
30          | _               => (case (lhsKind,ops)          | _               => (case lhsKind
31              of (TreeIL.VK_Local, _ ) =>(SOME (Dst.E_Mux(A,nSize,oSize,splitTy,ops)),NONE)              of TreeIL.VK_Local => (SOME (Dst.E_Mux(A,nSize,oSize,splitTy,ops)),NONE)
32              | _=> (NONE,SOME(Dst.S_StoreVec(lhsExp,A,nSize,oSize,splitTy,ops)))              | _=> (NONE,SOME(Dst.S_StoreVec(lhsExp,A,nSize,oSize,splitTy,ops)))
33              (*end case*))              (*end case*))
34          (*end case*))          (*end case*))
# Line 49  Line 49 
49          | getExp (Dst.E_Mux(_,_,_,_,ops))= List.nth(ops,count)          | getExp (Dst.E_Mux(_,_,_,_,ops))= List.nth(ops,count)
50          | getExp _ = t          | getExp _ = t
51      val exp =getExp t      val exp =getExp t
52      val _ =testp ["\n\t Arg",Dst.toString t, "====>>",Dst.toString exp]      val _ =testp ["\n\t Arg: ",Dst.toString t]
53      in      in
54          exp          exp
55      end      end
# Line 64  Line 64 
64      in      in
65          createOps (pieces, 0,indexAt, [])          createOps (pieces, 0,indexAt, [])
66      end      end
67      and mkCons(false,pieces,args)= let      and mkCons(pieces,args)= let
68          fun createOps ([], _,_, _,code) = code          fun createOps ([], _,_, _,_) = []
69          | createOps (nSize::es, count,offset,arg, code)=let          | createOps (nSize::es, count,offset,arg, code)=
70              val exp = Dst.E_Cons(Ty.TensorTy [nSize], List.take(arg,nSize))              [Dst.E_Cons(Ty.TensorTy [nSize], nSize,List.take(arg,nSize))]@
71              in                  createOps (es, count+1,offset + IntInf.fromInt nSize, List.drop(arg,nSize),code)
                 createOps (es, count+1,offset + IntInf.fromInt nSize, List.drop(arg,nSize),code@[exp])  
             end  
72          in          in
73              createOps (pieces, 0,0,args, [])              createOps (pieces, 0,0,args, [])
74          end          end
75        | mkCons(true,[nSize],args)=let      and mkFillCons(nSize,nOrig,args)=let
76              val nArg=length(args)              val nArg=length(args)
77              in if(nSize>nArg) then let              in if(nSize>nArg) then let
78                  val n=nSize-nArg                  val n=nSize-nArg
79                  val newArgs=List.tabulate(n, (fn _=>Dst.E_Lit(Literal.Int 0)))                  val newArgs=List.tabulate(n, (fn _=>Dst.E_Lit(Literal.Int 0)))
80                  in                  in
81                      [Dst.E_Cons(Ty.TensorTy [nSize], args@newArgs)]                  Dst.E_Cons(Ty.TensorTy [nSize], nOrig,args@newArgs)
82                  end                  end
83              else raise Fail( "more args then new size")              else raise Fail( "more args then new size")
84              end              end
85        | mkCons (_,pieces,_) =raise Fail ("To many peices for mkFill"^Ty.toString (DstTy.tensorTy pieces))  
86    
87    
88    
# Line 116  Line 114 
114      fun vecToTree(lhs,rator,nSize,oSize,pieces,argScas,argV',isFill)= let      fun vecToTree(lhs,rator,nSize,oSize,pieces,argScas,argV',isFill)= let
115    
116          val splitTy=DstTy.vectorLength pieces          val splitTy=DstTy.vectorLength pieces
117          val (indexAt', argVecs)=isMatrix2(argV',[])  
118            (*val (indexAt', argVecs)=isMatrix2(argV',[])*)
119            val indexAt'=0
120            val argVecs=argV'
121    
122    
123          val lhsKind=DstV.kind lhs          val lhsKind=DstV.kind lhs
124          val _ =testp ["\n\t LHS ",Dst.kindToString lhsKind,"- Var:",DstV.name lhs]          val _ =testp ["\n\t LHS ",Dst.kindToString lhsKind,"- Var:",DstV.name lhs]
# Line 130  Line 132 
132      end      end
133    
134    
135        (*isFIll is true, and there is one piece, use mkFillCons*)
136      fun consVecToTree(nSize,oSize,[piece],args,isFill)= let      fun consVecToTree(nSize,oSize,[piece],args,true)= let
137          val ops= mkCons(isFill,[piece],args)              val op1= mkFillCons(piece,oSize,args)
138          in (case ops              val aligned= isAligned true
139               of [op1] => op1              val splitTy=DstTy.vectorLength [nSize]
140              | _ => raise Fail "Not correct numbe of pieces"              in
141          (*end case*))                      Dst.E_Mux(aligned,nSize,oSize,splitTy,[op1])
142          end          end
143          | consVecToTree(nSize,oSize,pieces,args,isFill)= let          | consVecToTree(nSize,oSize,pieces,args,isFill)= let
144          val ops= mkCons(isFill,pieces,args)              val ops= mkCons(pieces,args)
145          val aligned= isAligned isFill          val aligned= isAligned isFill
146          val splitTy=DstTy.vectorLength pieces          val splitTy=DstTy.vectorLength pieces
147      in      in

Legend:
Removed from v.2748  
changed lines
  Added in v.2749

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