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

SCM Repository

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

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

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

branches/charisee/src/compiler/high-to-mid/split.sml revision 3193, Mon Apr 27 21:19:16 2015 UTC branches/charisee_dev/src/compiler/high-to-mid/split.sml revision 3316, Sat Oct 17 01:40:08 2015 UTC
# Line 34  Line 34 
34    
35      val numFlag=1   (*remove common subexpression*)      val numFlag=1   (*remove common subexpression*)
36      val testing=0      val testing=0
37      fun setEin(params,index,body)=Ein.EIN{params=params, index=index, body=body}      fun mkEin e = E.mkEin e
38      fun assignEinApp(y,params,index,body,args)= (y,DstIL.EINAPP(setEin(params,index,body),args))      val einappzero= DstIL.EINAPP(mkEin([],[],E.Const 0),[])
     val einappzero=DstIL.EINAPP(setEin([],[],E.Const 0),[])  
39      fun setEinZero y=  (y,einappzero)      fun setEinZero y=  (y,einappzero)
40      fun cleanParams e =cleanP.cleanParams e      fun cleanParams e =cleanP.cleanParams e
41      fun cleanIndex e =cleanI.cleanIndex e      fun cleanIndex e =cleanI.cleanIndex e
42      fun printEINAPP e=MidToString.printEINAPP e      fun toStringBind e= MidToString.toStringBind e
43      fun itos i =Int.toString i      fun itos i =Int.toString i
     fun filterSca e=Filter.filterSca e  
44      fun err str=raise Fail str      fun err str=raise Fail str
45      val cnt = ref 0      val cnt = ref 0
46      fun incUse (DstIL.V{useCnt, ...}) = (useCnt := !useCnt + 1)      fun incUse (DstIL.V{useCnt, ...}) = (useCnt := !useCnt + 1)
# Line 116  Line 114 
114          | _           => 2          | _           => 2
115      (*end case*))      (*end case*))
116    
   
   
117      fun rewriteOp3(name,sx,e1,x)=let      fun rewriteOp3(name,sx,e1,x)=let
118          val ((y, DstIL.EINAPP(ein,args)),fieldset,flag)=x          val ((y, DstIL.EINAPP(ein,args)),fieldset,flag)=x
119          val params=Ein.params ein          val params=Ein.params ein
# Line 138  Line 134 
134          | 2     => (e1,params,args,[],fieldset)             (*not lifted*)          | 2     => (e1,params,args,[],fieldset)             (*not lifted*)
135          (*end*))          (*end*))
136    
   
   
   
137      fun rewriteOps(name,list1,params,index,sx,args,fieldset0,flag)=let      fun rewriteOps(name,list1,params,index,sx,args,fieldset0,flag)=let
138          fun m([],rest,params,args,code,fieldset)=(rest,params,args,code,fieldset)          fun m([],rest,params,args,code,fieldset)=(rest,params,args,code,fieldset)
139          | m(e1::es,rest,params,args,code,fieldset)=let          | m(e1::es,rest,params,args,code,fieldset)=let
# Line 264  Line 257 
257    
258  val (e1',params',args',code,fieldset)=  rewriteOps("add",e1,params,index,[],args,fieldset,flag)  val (e1',params',args',code,fieldset)=  rewriteOps("add",e1,params,index,[],args,fieldset,flag)
259  fun pb es=String.concatWith "\n\n\t-*-" (List.map P.printbody es)  fun pb es=String.concatWith "\n\n\t-*-" (List.map P.printbody es)
260  val _ =print("\n****Inside Add:"^Int.toString(length index)^"\n -"^ pb e1 ^"----- newbies\n-"^ pb e1')  (*)val _ =print("\n****Inside Add:"^Int.toString(length index)^"\n -"^ pb e1 ^"----- newbies\n-"^ pb e1')*)
261    
262  val body =E.Add e1'  val body =E.Add e1'
263  val einapp= rewriteOrig(y,body,params',index,[],args')  val einapp= rewriteOrig(y,body,params',index,[],args')
# Line 320  Line 313 
313              of E.Probe (E.Conv _,_)   => default              of E.Probe (E.Conv _,_)   => default
314              | E.Probe(E.Field _,_)    => raise Fail str              | E.Probe(E.Field _,_)    => raise Fail str
315              | E.Probe _               => raise Fail str              | E.Probe _               => raise Fail str
316              | E.Conv _                => zero              | E.Conv _                => raise Fail "should have been swept"
317              | E.Field _               => zero              | E.Field _               => raise Fail "should have been swept"
318              | E.Apply _               => zero              | E.Apply _               => raise Fail "should have been swept"
319              | E.Lift e                => zero              | E.Lift e                => raise Fail "should have been swept"
320              | E.Delta _               => default              | E.Delta _               => default
321              | E.Epsilon _             => default              | E.Epsilon _             => default
322              | E.Eps2 _                => default              | E.Eps2 _                => default
# Line 347  Line 340 
340              | E.Sum(_,E.Probe(E.Conv _,_))    => default              | E.Sum(_,E.Probe(E.Conv _,_))    => default
341              | E.Sum(sx,E.Prod e1)     => handleSumProd(y,e1,params,index,sx,args,fieldset,flag)              | E.Sum(sx,E.Prod e1)     => handleSumProd(y,e1,params,index,sx,args,fieldset,flag)
342              | E.Sum(sx,E.Delta d)     => handleSumProd(y,[E.Delta d],params,index,sx,args,fieldset,flag)              | E.Sum(sx,E.Delta d)     => handleSumProd(y,[E.Delta d],params,index,sx,args,fieldset,flag)
343                | E.Sum(sx,E.Tensor _)    => default
344              | E.Sum(sx,_)             => err(" summation not distributed:"^str)              | E.Sum(sx,_)             => err(" summation not distributed:"^str)
345              | E.Add e1                => handleAdd(y,e1,params,index,args,fieldset,flag)              | E.Add e1                => handleAdd(y,e1,params,index,args,fieldset,flag)
346                | E.Prod[E.Tensor(id0,[]),E.Tensor(id1,[i]),E.Tensor(id2,[])]=>
347                        rewrite (E.Prod[E.Prod[E.Tensor(id0,[]),E.Tensor(id2,[])],E.Tensor(id1,[i])])
348              | E.Prod e1               => handleProd(y,e1,params,index,args,fieldset,flag)              | E.Prod e1               => handleProd(y,e1,params,index,args,fieldset,flag)
349              | E.Partial _             => err(" Partial used after normalize")              | E.Partial _             => err(" Partial used after normalize")
350              | E.Krn _                 => err("Krn used before expand")              | E.Krn _                 => err("Krn used before expand")
# Line 381  Line 377 
377          | itercode(e1::newbies,rest,code,cnt)=let          | itercode(e1::newbies,rest,code,cnt)=let
378              val ((einapp3,code3),_) = split(e1,fieldset,numFlag)              val ((einapp3,code3),_) = split(e1,fieldset,numFlag)
379              val (rest4,code4)=itercode(code3,[],[],cnt+1)              val (rest4,code4)=itercode(code3,[],[],cnt+1)
380                  val _ =print(String.concat[printEINAPP(e1),"\n\t===>\n",printEINAPP(einapp3),"\nand\n",(String.concatWith",\n\t"(List.map printEINAPP (code4@rest4)))])                  val _ =testp [toStringBind(e1),"\n\t===>\n",toStringBind(einapp3),"\nand\n",(String.concatWith",\n\t"(List.map toStringBind (code4@rest4)))]
381              in              in
382                  itercode(newbies,rest@[einapp3],code4@( rest4)@code,cnt+2)                  itercode(newbies,rest@[einapp3],code4@( rest4)@code,cnt+2)
383              end              end
# Line 396  Line 392 
392          (* **** split in parts **** *)          (* **** split in parts **** *)
393          (*          (*
394          val ((einapp4,newbies4),fieldset)=split(einapp3,fieldset,0)          val ((einapp4,newbies4),fieldset)=split(einapp3,fieldset,0)
395          val _ =testp["\n\t===>\n",printEINAPP(einapp4),"\nand\n",(String.concatWith",\n\t"(List.map printEINAPP newbies4))]          val _ =testp["\n\t===>\n",toStringBind(einapp4),"\nand\n",(String.concatWith",\n\t"(List.map toStringBind newbies4))]
396          val (newbies5)= iterMultiple(einapp4,newbies4,fieldset)          val (newbies5)= iterMultiple(einapp4,newbies4,fieldset)
397          *)          *)
398    

Legend:
Removed from v.3193  
changed lines
  Added in v.3316

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