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/handleEin.sml
ViewVC logotype

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

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

revision 3304, Fri Oct 16 18:51:09 2015 UTC revision 3503, Thu Dec 17 23:13:57 2015 UTC
# Line 1  Line 1 
1  (* Expands probe ein  (* Expands probe ein
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 10  Line 12 
12    
13      structure E = Ein      structure E = Ein
14      structure DstIL = MidIL      structure DstIL = MidIL
     structure DstOp = MidOps  
15      structure P=Printer      structure P=Printer
     structure T=TransformEin  
16      structure MidToS=MidToString      structure MidToS=MidToString
17      structure DstV  = DstIL.Var      structure L=LiftEin
18      in      in
19    
20        val liftflag=true
21        val splitflag=true
22        val splitlimit=NONE
23      val testinitial=0      val testinitial=0
24      val testing=0      val testing=0
25      fun testp n=(case testing      fun testp n=(case testing
# Line 26  Line 29 
29      fun test0 n=(case testinitial      fun test0 n=(case testinitial
30          of 0=>testp n          of 0=>testp n
31          | _ => (print(String.concat n);1))          | _ => (print(String.concat n);1))
32      fun toStringBind e= MidToString.toStringBind e      fun toStringBind e= MidToS.toStringBind e
33      fun useCount (HighIL.V{useCnt, ...}) = !useCnt      fun useCount (HighIL.V{useCnt, ...}) = !useCnt
34      fun expandEinOp (srcy,bind00)=let      fun expandEinOp (srcy,bind00)=let
35            (*val _= raise Fail"development branch- do not use"*)
36    
37          val star="************"          val star="************"
38            val _= ("\n Start"^star)
39          val _ =test0[star,"\n Original EinApp",star,"\n\n","start get test",toStringBind bind00]          val _ =test0[star,"\n Original EinApp",star,"\n\n","start get test",toStringBind bind00]
40          val (y,einapp as DstIL.EINAPP(Ein.EIN{params, index, body},args))=bind00          val (y,einapp as DstIL.EINAPP(Ein.EIN{params, index, body},args))=bind00
41    
42    
43          (* ************* Sweep for 0's'*********** *)          (* ************* Sweep for 0's'*********** *)
44            val _ =testp["Pre Sweep\n",P.printbody body,"\n"]
45          val bodysweep=sweepEin.sweep body          val bodysweep=sweepEin.sweep body
46          val ein1=Ein.EIN{params=params, index=index, body=bodysweep}          val ein1=Ein.EIN{params=params, index=index, body=bodysweep}
47          val _=testp["Post Sweep\n",P.printbody bodysweep,"\n"]          val _=testp["Post Sweep\n",P.printbody bodysweep,"\n"]
# Line 45  Line 51 
51          val bind3 = (y,DstIL.EINAPP(SummationEin.main ein1,args))          val bind3 = (y,DstIL.EINAPP(SummationEin.main ein1,args))
52          val _ =testp["\n\n summation \n\n =>", toStringBind bind3]          val _ =testp["\n\n summation \n\n =>", toStringBind bind3]
53    
54            (* **************** lift - split ************* *)
55            val newbies5=  (case (splitflag,liftflag,splitlimit)
56                of (true,false,NONE) => Split.splitEinApp bind3
57          (* **************** split phase ************* *)          (* **************** split phase ************* *)
58          val (newbies5)= Split.splitEinApp bind3              | (true,false,SOME limit) =>let
59          val _ =test0["\n\n Returning \n\n =>",                  val _ = (String.concat["\nSPLit with limit",Int.toString(limit)])
60                    in Split.limitSplit(bind3,limit) end
61                | (true,true,SOME limit) =>  let
62                    (* **************** lift and split Limit ************* *)
63                    val (einapp1,e2a,fieldset)=L.testLift  bind3
64                    val _ = (String.concat["\nSPLit with limit",Int.toString(limit),"\n **** lift Length:",Int.toString(length(e2a))])
65    
66                   (* val t2=List.map (fn t=>Split.splitEinApp t) e2*)
67                    val t2=List.map (fn t =>Split.limitSplit2(t,limit,fieldset)) e2a
68                    val e2= List.foldr op@ [] t2
69                    val newbies4=Split.limitSplit2(einapp1,limit,fieldset)
70                    val _ = print(String.concat["\n split made pieces(",Int.toString(length(e2)-length(e2a)),") orig (", Int.toString(length(newbies4)),")"])
71                    in (e2@newbies4) end
72                | (true,true, NONE) => let
73                    (* **************** lift and split All ************* *)
74                    val (einapp1,e2a,_)=L.testLift  bind3
75                    val _ =  print(String.concat["\n **** lift Length"^(Int.toString(length(e2a)))])
76                    val e2= List.foldr op@ [] (List.map (fn t=>Split.splitEinApp t) e2a)
77                    val newbies4=Split.splitEinApp einapp1
78                    val _ = print(String.concat["\n split made pieces(",Int.toString(length(e2)-length(e2a)),") orig (", Int.toString(length(newbies4)),")"])
79                    in (e2@newbies4) end
80    
81    (*
82                | (false,true,_) => let
83                    val (einapp1,e2)=L.testLift  bind3
84                    val _ = ("\n **** lift Length"^(Int.toString(length(e2))))
85                    in (e2@[einapp1]) end
86                |  (false,false,_)=>Split.splitEinApp bind3
87    *)
88            (* end case *))
89            val _ = "************** TASH"
90            (**************** printing result ***************)
91            val _ =testp["\n\n Returning \n\n =>",
92              String.concatWith",\n\t"(List.map toStringBind newbies5)]              String.concatWith",\n\t"(List.map toStringBind newbies5)]
93            val n =length(newbies5)
94            val _ = if (n > 10) then print(String.concat["\n **** SPLIT Length",Int.toString(n)]) else print ""
95           (* ************** ProbeEIN *********** *)           (* ************** ProbeEIN *********** *)
         (*val code=List.map (fn e=>ProbeEin.expandEinOp e) (newbies5)*)  
   
96          (*gives probeEIN the set. Could split into a sepearate step*)          (*gives probeEIN the set. Could split into a sepearate step*)
97          val fieldset= einSet.EinSet.empty          val fieldset= einVarSet.EinVarSet.empty
98            val varset= einVarSet.VarSet.empty
99          val isField = ref 0          val isField = ref 0
100          val isFieldR = ref 0          val isFieldR = ref 0
101          val isReplaced = ref 0          val isReplaced = ref 0
102          fun iter([],_)=[]          fun iter([],_,_)=[]
103           | iter(e1::es,fieldset)= let           | iter(e1::es,fieldset,varset)= let
104              val (e2,fieldset,isFieldt,isReplacedt) = ProbeEin.expandEinOp(e1,fieldset)              val (e2,fieldset,varset,isFieldt,isReplacedt) = ProbeEin.expandEinOp(e1,fieldset,varset)
105              val rtn=[e2]@(iter(es,fieldset))              val rtn=[e2]@(iter(es,fieldset,varset))
106              val isFieldRt=if ((isFieldt+isReplacedt)=2) then 1 else 0              val isFieldRt=if ((isFieldt+isReplacedt)=2) then 1 else 0
107              in (isField:=(!isField)+isFieldt;isReplaced:=(!isReplaced )+isReplacedt;              in (isField:=(!isField)+isFieldt;isReplaced:=(!isReplaced )+isReplacedt;
108              isFieldR:=(!isFieldR)+isFieldRt;rtn)              isFieldR:=(!isFieldR)+isFieldRt;rtn)
109              end              end
110          val code=iter(newbies5, fieldset)          val code=iter(newbies5, fieldset,varset)
111            val flatcode= List.foldr op@ [] code
112    
113          val n= List.length(code)          val n= List.length(code)
114            val m= List.length(flatcode)
115            val _ =testp[HighIL.Var.name srcy ," Pieces",Int.toString (n),"\n"]
116    
117            val _ = if (n>5)            val _ = if (n>5)
118           then  (String.concat["\n\n",star,":Name:",HighIL.Var.name srcy ,            then  print(String.concat["\n",star,":Name:",HighIL.Var.name srcy ,
119              ":VarCount(",Int.toString(useCount srcy),")",              ":VarCount(",Int.toString(useCount srcy),")","\n\tPieces now: ",Int.toString (n),"flatcode",Int.toString (m),
                 "\n\t",star,"Pieces now: ",Int.toString (n),  
120              " Fields:",Int.toString(!isField)," isReplaced:",Int.toString(!isReplaced),              " Fields:",Int.toString(!isField)," isReplaced:",Int.toString(!isReplaced),
121              " Replaced_Fields:",Int.toString(!isFieldR)              " Replaced_Fields:",Int.toString(!isFieldR)])
122                 ,toStringBind bind3])              else print ""
             else  ""  
123    
124          val flatcode= List.foldr op@ [] code          val flatcode= List.foldr op@ [] code
         (*val _=List.map (fn(_,DstIL.EINAPP(e,_))=>checkEin.checkEIN e | _=> 1) flatcode*)  
125    
126    
127            (*val _=List.map (fn(_,DstIL.EINAPP(e,_))=>checkEin.checkEIN e | _=> 1) flatcode*)
128            val _=(star^"end")
129          in          in
130              List.map (fn (y,rator)=> DstIL.ASSGN(y,rator)) flatcode              List.map (fn (y,rator)=> DstIL.ASSGN(y,rator)) flatcode
131          end          end

Legend:
Removed from v.3304  
changed lines
  Added in v.3503

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