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 3138, Thu Mar 26 16:27:35 2015 UTC revision 3174, Mon Mar 30 11:46:58 2015 UTC
# Line 17  Line 17 
17      structure DstV = DstIL.Var      structure DstV = DstIL.Var
18      in      in
19    
20        val testinitial=0
21      val testing=0      val testing=0
22      fun setEin(params,index,body)=Ein.EIN{params=params, index=index, body=body}      fun setEin(params,index,body)=Ein.EIN{params=params, index=index, body=body}
23      fun assignEinApp(y,params,index,body,args)= (y,DstIL.EINAPP(setEin(params,index,body),args))      fun assignEinApp(y,params,index,body,args)= (y,DstIL.EINAPP(setEin(params,index,body),args))
# Line 26  Line 27 
27          of 0=> 1          of 0=> 1
28          | _ =>(print(String.concat n);1)          | _ =>(print(String.concat n);1)
29          (*end case*))          (*end case*))
30      fun test0 n=(*print(String.concat n)*) 1      fun test0 n=(case testinitial
31            of 0=>1
32            | _ => (print(String.concat n);1))
33      val einappzero=DstIL.EINAPP(setEin([],[],E.Const 0),[])      val einappzero=DstIL.EINAPP(setEin([],[],E.Const 0),[])
34      fun setEinZero y=  (y,einappzero)      fun setEinZero y=  (y,einappzero)
35      fun filterSca e=Filter.filterSca e      fun filterSca e=Filter.filterSca e
36      fun printEINAPP e=MidToString.printEINAPP e      fun printEINAPP e=MidToString.printEINAPP e
37    
   
   
38      fun z e=String.concat["\n\n Found: ",P.printbody e,"=> 0\n"]      fun z e=String.concat["\n\n Found: ",P.printbody e,"=> 0\n"]
39      fun sweep e= (z e;case e      fun sweep e= (case e
40          of E.Tensor _           => e          of E.Tensor _           => e
41          | E.Add es             => E.Add(List.map sweep es)          | E.Add es             => E.Add(List.map sweep es)
42          | E.Sub(e1,e2)         => E.Sub(sweep e1,sweep e2)          | E.Sub(e1,e2)         => E.Sub(sweep e1,sweep e2)
# Line 122  Line 123 
123      |distributeSummation(y,app) =(y,app)      |distributeSummation(y,app) =(y,app)
124    
125    
126    
127      fun expandEinOp einapp00=let      fun expandEinOp einapp00=let
128    
129    
130          val star="************"          val star="************"
131          val _ =test0[star,"\n Original EinApp",star,"\n\n","start get test",printEINAPP einapp00]          val _ =test0[star,"\n Original EinApp",star,"\n\n","start get test",printEINAPP einapp00]
132          val (y,einapp as DstIL.EINAPP(Ein.EIN{params, index, body},args))=einapp00          val (y,einapp as DstIL.EINAPP(Ein.EIN{params, index, body},args))=einapp00
133    
134    
135          (* ************* Sweep for 0's'*********** *)          (* ************* Sweep for 0's'*********** *)
136          val bodysweep=sweep body          val bodysweep=sweep body
137          val ein1=Ein.EIN{params=params, index=index, body=bodysweep}          val ein1=Ein.EIN{params=params, index=index, body=bodysweep}
# Line 140  Line 145 
145          (* ************** distribute Summation*********** *)          (* ************** distribute Summation*********** *)
146          val einapp3 = distributeSummation einapp2          val einapp3 = distributeSummation einapp2
147    
148          (* ************** split initial *********** *)          (* **************** split phase ************* *)
149          val (einapp4,newbies4)=Split.split einapp3          val (newbies5)= Split.splitEinApp einapp3
150          val _ =testp["\n\t===>\n",printEINAPP(einapp4),"\nand\n",(String.concatWith",\n\t"(List.map printEINAPP newbies4))]            val _ =testp["\n\n Returning \n\n =>",
151                String.concatWith",\n\t"(List.map printEINAPP newbies5)]
152          (* ************** split Multiple *********** *)             (* val _ =print(String.concat[
153          val (einapp5,newbies5)= Split.iterMultiple(einapp4,newbies4)              "\n",star,"Number of pieces: ",Int.toString (List.length(newbies5))])
154          val _ =testp["\n\n Returning \n\n =>",printEINAPP einapp5,  *)
         " newbies\n\t",String.concatWith",\n\t"(List.map printEINAPP newbies5), "\n",star]  
   
155           (* ************** ProbeEIN *********** *)           (* ************** ProbeEIN *********** *)
156          val code=List.map (fn e=>ProbeEin.expandEinOp e) (newbies5@[einapp5])  
157              (*val code=List.map (fn e=>ProbeEin.expandEinOp e) (newbies5)*)
158            val fieldset= einSet.EinSet.empty
159            fun iter([],_)=[]
160             | iter(e1::es,fieldset)= let
161                val (e2,fieldset) = ProbeEin.expandEinOp(e1,fieldset)
162                in [e2]@(iter(es,fieldset))
163                end
164            val code=iter(newbies5, fieldset)
165    (*val _ =print(String.concat[
166    "\n",star,"Number of pieces now: ",Int.toString (List.length(code))])
167    *)
168          val flatcode= List.foldr op@ [] code          val flatcode= List.foldr op@ [] code
169          (*val _=List.map (fn(_,DstIL.EINAPP(e,_))=>checkEin.checkEIN e | _=> 1) flatcode*)          (*val _=List.map (fn(_,DstIL.EINAPP(e,_))=>checkEin.checkEIN e | _=> 1) flatcode*)
170    
171          in          in
172              List.map (fn (y,rator)=> DstIL.ASSGN(y,rator)) flatcode              List.map (fn (y,rator)=> DstIL.ASSGN(y,rator)) flatcode
173          end          end
174    
175    
   
176    end; (* local *)    end; (* local *)
177    
178  end (* local *)  end (* local *)

Legend:
Removed from v.3138  
changed lines
  Added in v.3174

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