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

revision 3316, Sat Oct 17 01:40:08 2015 UTC revision 3395, Tue Nov 10 18:23:07 2015 UTC
# Line 1  Line 1 
1  (* Currently under construction  (* Currently under construction
2   *   *
3   * COPYRIGHT (c) 2012 The Diderot Project (http://diderot-language.cs.uchicago.edu)   * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
4     *
5     * COPYRIGHT (c) 2015 The University of Chicago
6   * All rights reserved.   * All rights reserved.
7   *)   *)
8    
# Line 34  Line 36 
36    
37      val numFlag=1   (*remove common subexpression*)      val numFlag=1   (*remove common subexpression*)
38      val testing=0      val testing=0
39        val splitlimit=100
40      fun mkEin e = E.mkEin e      fun mkEin e = E.mkEin e
41      val einappzero= DstIL.EINAPP(mkEin([],[],E.Const 0),[])      val einappzero= DstIL.EINAPP(mkEin([],[],E.Const 0),[])
42      fun setEinZero y=  (y,einappzero)      fun setEinZero y=  (y,einappzero)
# Line 111  Line 114 
114          | E.Krn _     => err("Krn used before expand")          | E.Krn _     => err("Krn used before expand")
115          | E.Value _   => err("Value used before expand")          | E.Value _   => err("Value used before expand")
116          | E.Img _     => err("Probe used before expand")          | E.Img _     => err("Probe used before expand")
117    |  Ein.PowEmb(e1,sx1,n1) =>1
118          | _           => 2          | _           => 2
119      (*end case*))      (*end case*))
120    
# Line 298  Line 302 
302              (einapp,code,fieldset)              (einapp,code,fieldset)
303          end          end
304    
305    fun handlePowEmb(y,e1,sx1,n1,params,index,args,fieldset,flag)=let
306    val (e1',params',args',code,fieldset)=  rewriteOp("mag",e1,params,index,sx1,args,fieldset,flag)
307    val body= E.Sum(sx1,E.Prod[e1',e1'])
308    val einapp= rewriteOrig(y,body,params',index,sx1,args')
309    val _=print(String.concat["\nhandlePowEmb:",P.printbody(E.PowEmb(e1,sx1,n1)),"\n=>",
310    P.printbody(body)])
311    in
312    (einapp,code,fieldset)
313    end
314    
315    
316      (* split:var*ein_app-> (var*einap)*code      (* split:var*ein_app-> (var*einap)*code
317      * split ein expression into smaller pieces      * split ein expression into smaller pieces
318        note we leave summation around probe exp        note we leave summation around probe exp
# Line 350  Line 365 
365              | E.Krn _                 => err("Krn used before expand")              | E.Krn _                 => err("Krn used before expand")
366              | E.Value _               => err("Value used before expand")              | E.Value _               => err("Value used before expand")
367              | E.Img _                 => err("Probe used before expand")              | E.Img _                 => err("Probe used before expand")
368    | Ein.PowEmb(e1,sx1,n1) =>handlePowEmb(y,e1,sx1,n1,params,index,args,fieldset,flag)
369    
370              (*end case *))              (*end case *))
371          val (einapp2,newbies,fieldset) =rewrite body          val (einapp2,newbies,fieldset) =rewrite body
372          in          in
# Line 358  Line 375 
375          |split((y,app),fieldset,_) =(((y,app),[]),fieldset)          |split((y,app),fieldset,_) =(((y,app),[]),fieldset)
376    
377    
378      fun iterMultiple(einapp2,newbies2,fieldset)=let      fun iterAll2(einapp2,fields2)=let
379          fun itercode([],rest,code,_)=(rest,code)          val fieldset= einSet.EinSet.empty
380            val _ =print ("\nSPLit with limit"^(Int.toString(splitlimit)))
381            fun itercode([],rest,code,cnt)=(("\n Empty-SplitCount: "^Int.toString(cnt));(rest,code))
382            | itercode(e1::newbies,rest,code,cnt)=let            | itercode(e1::newbies,rest,code,cnt)=let
383                  val ((einapp3,code3),_) = split(e1,fieldset,numFlag)                  val ((einapp3,code3),_) = split(e1,fieldset,numFlag)
384                      val (rest4,code4)=itercode(code3,[],[],cnt+1)                      val (rest4,code4)=itercode(code3,[],[],cnt+1)
385                val _ =testp [toStringBind(e1),"\n\t===>\n",toStringBind(einapp3),"\nand\n",(String.concatWith",\n\t"(List.map toStringBind (code4@rest4)))]
386          in          in
387              itercode(newbies,rest@[einapp3],code4@( rest4)@code,cnt+2)                  if (length(rest@newbies@code) > splitlimit) then let
388                            val _ =("\n SplitCount: "^Int.toString(cnt))
389                            val code5=code4@rest4@code
390                            val rest5=rest@[einapp3]
391                            in
392                                (rest5,code5@newbies)(*tab4*)
393                            end
394                    else  itercode(newbies,rest@[einapp3],code4@rest4@code,cnt+2)
395          end          end
396              val(rest,code)= itercode(newbies2,[],[],1)          val(rest,code)= itercode([einapp2],[],[],0)
397          in          in
398              ((code)@rest@[einapp2])  
399                  fields2@code@rest (*B*)
400          end          end
401    
402    
403    
404    
405      fun iterAll(einapp2,fieldset)=let      fun iterAll(einapp2,fieldset)=let
406    
407          fun itercode([],rest,code,_)=(rest,code)          fun itercode([],rest,code,_)=(rest,code)
408          | itercode(e1::newbies,rest,code,cnt)=let          | itercode(e1::newbies,rest,code,cnt)=let
409              val ((einapp3,code3),_) = split(e1,fieldset,numFlag)              val ((einapp3,code3),_) = split(e1,fieldset,numFlag)
# Line 386  Line 417 
417              (code@rest)              (code@rest)
418          end          end
419    
     fun splitEinApp einapp3= let  
         val fieldset= einSet.EinSet.empty  
420    
         (* **** split in parts **** *)  
         (*  
         val ((einapp4,newbies4),fieldset)=split(einapp3,fieldset,0)  
         val _ =testp["\n\t===>\n",toStringBind(einapp4),"\nand\n",(String.concatWith",\n\t"(List.map toStringBind newbies4))]  
         val (newbies5)= iterMultiple(einapp4,newbies4,fieldset)  
         *)  
   
         (* **** split all at once **** *)  
         val (newbies5)= iterAll([einapp3],fieldset)  
421    
422        fun splitEinApp (einapp3,splitflag)= let
423            val fieldset= einSet.EinSet.empty
424            val (newbies5)=(case splitflag
425                of 1 =>let
426                    (* **** split single **** *)
427                    val ((einapp4,newbies4),fieldset)=split(einapp3,fieldset,0)
428                    in newbies4@[einapp4] end
429                | _=>   (* **** split all at once **** *)
430                    iterAll([einapp3],fieldset)
431            (* end case *))
432          in          in
433              newbies5              newbies5
434          end          end

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

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