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

SCM Repository

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

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

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

revision 2923, Tue Mar 3 15:33:44 2015 UTC revision 3017, Mon Mar 9 15:52:22 2015 UTC
# Line 119  Line 119 
119      fun rewriteOps(name,list1,params,index,sx,args)=let      fun rewriteOps(name,list1,params,index,sx,args)=let
120          fun m([],rest,params,args,code)=(rest,params,args,code)          fun m([],rest,params,args,code)=(rest,params,args,code)
121          | m(e1::es,rest,params,args,code)=let          | m(e1::es,rest,params,args,code)=let
122    
123              val (e1',params',args',code')= rewriteOp(name,e1,params,index,sx,args)              val (e1',params',args',code')= rewriteOp(name,e1,params,index,sx,args)
124              in              in
125                  m(es,rest@[e1'],params',args',code@code')                  m(es,rest@[e1'],params',args',code@code')
# Line 249  Line 250 
250          val default=((y,einapp),[])          val default=((y,einapp),[])
251          val sumIndex=ref []          val sumIndex=ref []
252          val str="Poorly formed EIN operator. Argument needs to be applied in High-IL"^(P.printbody body)          val str="Poorly formed EIN operator. Argument needs to be applied in High-IL"^(P.printbody body)
253            val _=testp["\n\nStarting split",P.printbody body]
254          fun rewrite b=(case b          fun rewrite b=(case b
255              of E.Probe (E.Conv _,_)   => default              of E.Probe (E.Conv _,_)   => default
256              | E.Probe(E.Field _,_)    => raise Fail str              | E.Probe(E.Field _,_)    => raise Fail str
# Line 275  Line 277 
277              | E.Sum(sx,E.Neg n)       => rewrite (E.Neg(E.Sum(sx,n)))              | E.Sum(sx,E.Neg n)       => rewrite (E.Neg(E.Sum(sx,n)))
278              | E.Sum(sx,E.Add a)       => rewrite (E.Add(List.map (fn e=> E.Sum(sx,e)) a))              | E.Sum(sx,E.Add a)       => rewrite (E.Add(List.map (fn e=> E.Sum(sx,e)) a))
279              | E.Sum(sx,E.Sub (e1,e2)) => rewrite (E.Sub(E.Sum(sx,e1),E.Sum(sx,e2)))              | E.Sum(sx,E.Sub (e1,e2)) => rewrite (E.Sub(E.Sum(sx,e1),E.Sum(sx,e2)))
280              | E.Sum(sx,E.Div(e1,e2))  => rewrite(E.Div(E.Sum(sx,e1),E.Sum(sx,e2)))              | E.Sum(sx,E.Div(e1,e2))  => rewrite (E.Sum(sx,E.Prod[e1,E.Div(E.Const 1,e2)]))
281              | E.Sum(sx,E.Lift e )     => rewrite (E.Lift(E.Sum(sx,e)))              | E.Sum(sx,E.Lift e )     => rewrite (E.Lift(E.Sum(sx,e)))
282              | E.Sum(sx,E.PowReal(e,n1)) => rewrite (E.PowReal(E.Sum(sx,e),n1))              | E.Sum(sx,E.PowReal(e,n1)) => rewrite (E.PowReal(E.Sum(sx,e),n1))
283              | E.Sum(sx,E.Sqrt e)        => rewrite (E.Sqrt(E.Sum(sx,e)))              | E.Sum(sx,E.Sqrt e)        => rewrite (E.Sqrt(E.Sum(sx,e)))
# Line 309  Line 311 
311          | E.Sum(sx,E.Neg n)             => rewrite(E.Neg(E.Sum(sx,n)))          | E.Sum(sx,E.Neg n)             => rewrite(E.Neg(E.Sum(sx,n)))
312          | E.Sum(sx,E.Add a)             => rewrite(E.Add(List.map (fn e=> E.Sum(sx,e)) a))          | E.Sum(sx,E.Add a)             => rewrite(E.Add(List.map (fn e=> E.Sum(sx,e)) a))
313          | E.Sum(sx,E.Sub (e1,e2))       => rewrite(E.Sub(E.Sum(sx,e1),E.Sum(sx,e2)))          | E.Sum(sx,E.Sub (e1,e2))       => rewrite(E.Sub(E.Sum(sx,e1),E.Sum(sx,e2)))
314          | E.Sum(sx,E.Div(e1,e2))        => rewrite( E.Div(E.Sum(sx,e1),E.Sum(sx,e2)))         (* | E.Sum(sx,E.Div(e1,e2))        => rewrite( E.Div(E.Sum(sx,e1),E.Sum(sx,e2)))*)
315          | E.Sum(sx,E.Lift e )           => rewrite (E.Lift(E.Sum(sx,e)))          | E.Sum(sx,E.Lift e )           => rewrite (E.Lift(E.Sum(sx,e)))
316          | E.Sum(sx,E.PowReal(e,n1))     => rewrite(E.PowReal(E.Sum(sx,e),n1))          | E.Sum(sx,E.PowReal(e,n1))     => rewrite(E.PowReal(E.Sum(sx,e),n1))
317          | E.Sum(sx,E.Sqrt e)            => rewrite(E.Sqrt(E.Sum(sx,e)))          | E.Sum(sx,E.Sqrt e)            => rewrite(E.Sqrt(E.Sum(sx,e)))
# Line 326  Line 328 
328          | _                             => b          | _                             => b
329      (*end case*))      (*end case*))
330      val body =rewrite body      val body =rewrite body
331        val _ =testp["\nAfter distributeSummation \n",P.printbody body]
332      val ein=SummationEin.cleanSummation(Ein.EIN{params=params, index=index, body=body})      val ein=SummationEin.cleanSummation(Ein.EIN{params=params, index=index, body=body})
333      val einapp2= (y,DstIL.EINAPP(ein,args))      val einapp2= (y,DstIL.EINAPP(ein,args))
334      in      in
# Line 339  Line 342 
342       * recursively split ein expression into smaller pieces       * recursively split ein expression into smaller pieces
343      *)      *)
344      fun iterMultiple(einapp2,newbies2)=let      fun iterMultiple(einapp2,newbies2)=let
345          fun itercode([],rest,code)=(rest,code)          fun itercode([],rest,code,_)=(rest,code)
346          | itercode(e1::newbies,rest,code)=let          | itercode(e1::newbies,rest,code,cnt)=let
347              val (einapp3,code3) =(*split(e1)*) distributeSummation e1              val _ =testp["\n\n******* split term **",Int.toString cnt," *****","\n \n",printEINAPP(e1),"\n=>\n"]
348              val _ =testp["\n\n******* split ***** \n",printEINAPP(e1),"\n=>\n",printEINAPP(einapp3),"\nand\n",(String.concatWith",\n\t"(List.map printEINAPP code3))]              val (einapp3,code3) = distributeSummation e1
349              val (rest4,code4)=itercode(code3,[],[])              val _ =testp["\n\t===>\n",printEINAPP(einapp3),"\nand\n",(String.concatWith",\n\t"(List.map printEINAPP code3))]
350              in itercode(newbies,rest@[einapp3],code4@rest4@code)              val (rest4,code4)=itercode(code3,[],[],cnt+1)
351                in itercode(newbies,rest@[einapp3],code4@rest4@code,cnt+2)
352              end              end
353          val(rest,code)= itercode(newbies2,[],[])          val(rest,code)= itercode(newbies2,[],[],1)
354          in          in
355              (einapp2,code@rest)              (einapp2,code@rest)
356          end          end
357    
358      fun iterSplit(y,einapp as DstIL.EINAPP(Ein.EIN{params, index, body},args))=let      fun iterSplit(y,einapp as DstIL.EINAPP(Ein.EIN{params, index, body},args))=let
359          val bodysweep=handleE.sweep body          val bodysweep=handleE.sweep body
360          val _=testp["\n\n Sweep\n",P.printbody bodysweep,"\n"]          val _=testp["\nPresweep\n",P.printbody body,"\n\n Sweep\n",P.printbody bodysweep,"\n"]
361          val ein=SummationEin.cleanSummation(Ein.EIN{params=params, index=index, body=bodysweep})          val ein=SummationEin.cleanSummation(Ein.EIN{params=params, index=index, body=bodysweep})
362          val _=testp["\n\n Clean Summation\n",P.printbody(Ein.body ein),"\n"]          val _=testp["\n\n Clean Summation\n",P.printbody(Ein.body ein),"\n"]
363          val einapp2=(y,DstIL.EINAPP(ein, args))          val einapp2=(y,DstIL.EINAPP(ein, args))
364              (*assignEinApp(y,params,index,body,args)*)          val _ =testp["\n\n******* split term **",Int.toString (0)," ***** \n \t==>\n",printEINAPP(einapp2)]
365          val (einapp3,newbies2)=distributeSummation einapp2          val (einapp3,newbies2)=distributeSummation einapp2
366            val _ =testp["\n\t===>\n",printEINAPP(einapp3),"\nand\n",(String.concatWith",\n\t"(List.map printEINAPP newbies2))]
367    
368      in      in
369          iterMultiple(einapp3,newbies2)          iterMultiple(einapp3,newbies2)
370      end      end
# Line 369  Line 375 
375      fun gettest einapp=(case testing      fun gettest einapp=(case testing
376          of 0=>iterSplit(einapp)          of 0=>iterSplit(einapp)
377          | _=>let          | _=>let
378              val star="\n************* SPLIT********\n"              val star="\n************* SPLIT INITIAL********\n"
379              val _ =testp[star,"\n","start get test",printEINAPP einapp]              val _ =testp[star,"\n","start get test",printEINAPP einapp]
380              val (einapp2,newbies)=iterSplit(einapp)              val (einapp2,newbies)=iterSplit(einapp)
381              val _ =testp["\n\n Returning \n\n =>",printEINAPP einapp2,              val _ =testp["\n\n Returning \n\n =>",printEINAPP einapp2,

Legend:
Removed from v.2923  
changed lines
  Added in v.3017

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