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

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

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

revision 2525, Tue Jan 21 19:14:22 2014 UTC revision 2553, Sun Mar 2 19:53:33 2014 UTC
# Line 122  Line 122 
122          in m(list1,[])          in m(list1,[])
123          end          end
124    
125        fun filterIndex(E.V v)= if(v>intialn) then [] else [E.V v]
126    
127    
128        (*find all indices *)
     (*find outer index for expression, removes summation indices *)  
129      fun findOuterIndex(body,n)=(case body      fun findOuterIndex(body,n)=(case body
130          of  E.Tensor(id,ix)=> ix          of  E.Tensor(id,ix)=> ix
131              | E.Const _=> []              | E.Const _=> []
# Line 152  Line 152 
152    
153      val ix=findOuterIndex(e, intialn)      val ix=findOuterIndex(e, intialn)
154    
     fun q(E.V p,E.V n)=""(*"print(String.concat["\n", Int.toString(p),"===>>",Int.toString(n),"\n"])*)  
155    
156      fun g([],index',_,_,mapp)=(index',mapp)  
157          | g(e::es,index',n,c, mapp)= let      val g=print(String.concat["\n\n --",P.printbody(e),"length of binding-", Int.toString(length(index))," Outer", Int.toString(length(ix)),"\n"])
158    
159        fun q(E.V p,E.V n)=print(String.concat["\n", Int.toString(p),"===>>",Int.toString(n),"\n"])
160    
161    
162        (*Mapps just outer indices *)
163        fun g([],index',_,c,mapp,outer)=(index',c,mapp,outer)
164            | g(e::es,index',n,c, mapp,outer)= let
165              val b=List.find (fn(E.V v)=>v=n) ix              val b=List.find (fn(E.V v)=>v=n) ix
166                  in case b                  in case b
167                      of NONE=>g(es,index',n+1, c, mapp)                      of NONE=>(g(es,index',n+1, c, mapp,outer))
168                      |_=> let val mapp'=insert(E.V n, E.V c) mapp                      |_=> let val mapp'=insert(E.V n, E.V c) mapp
169                      val y=q(E.V n,E.V c)                      val gg=print "Found, and inserting"
170                      in g(es, index'@[e], n+1, c+1, mapp') end                      in g(es, index'@[e], n+1, c+1, mapp',outer@[(E.V n)]) end
171                  end                  end
172    
173      val (index',mapp)=g(index,[],0,0,empty)      val (index',c,mapp,outer)=g(index,[],0,0,empty,[])
174    
175        val mm=print ("FInal count"^Int.toString(c))
176        val adjustment= intialn-c
177    
178        fun addIndextoMapp([],n,mapp)=(mapp,n)
179            | addIndextoMapp((s,_,_)::es,n,mapp)= let
     fun createMapp([],n,mapp)=(mapp,n)  
         | createMapp((s,_,_)::es,n,mapp)= let  
180              val E.V p=s              val E.V p=s
181            (* val qq=print ("\n Inserting")*)              val n'=(p-adjustment)
182              val y=q(s,E.V n)              val y=q( s,E.V n')
183              val m=insert(s, E.V n) mapp (*check here*)              val m=insert(s, E.V n') mapp
184              in createMapp(es,n+1, m) end              in addIndextoMapp(es,n+1, m) end
185    
186    
187    
# Line 202  Line 208 
208          | E.Add e=> E.Add(List.map (fn(e1)=>rewrite(e1,n,smapp,embed)) e)          | E.Add e=> E.Add(List.map (fn(e1)=>rewrite(e1,n,smapp,embed)) e)
209          | E.Sub(e1,e2)=>  E.Sub(rewrite(e1,n,smapp,embed),rewrite(e2,n,smapp,embed))          | E.Sub(e1,e2)=>  E.Sub(rewrite(e1,n,smapp,embed),rewrite(e2,n,smapp,embed))
210          | E.Div(e1,e2)=>  E.Div(rewrite(e1,n,smapp,embed),rewrite(e2,n,smapp,embed))          | E.Div(e1,e2)=>  E.Div(rewrite(e1,n,smapp,embed),rewrite(e2,n,smapp,embed))
   
         | E.Sum(sx,E.Prod e) =>let  
   
                 (*  val level=(Int.toString(embed))  
             val q=print "\n START *************************************\n"  
 val qqqq=print level  
 *)  
 val (mm,nn)=createMapp(sx,n,smapp)  
   
   
   
             val k=E.Prod(List.map (fn(e1)=> rewrite(e1,nn,mm,embed+1)) e)  
             in E.Sum((List.map (fn(e1, lb,ub)=>(rewriteIndex(e1,mm),lb,ub)) sx),k) end  
   
211          | E.Sum(sx,e)=> let          | E.Sum(sx,e)=> let
212      (*              val (mm,nn)=addIndextoMapp(sx,n,smapp)
             val q=print "\n START *************************************\n "  
   val level=(Int.toString(embed))  
 val qqqq=print level*)  
   
        val (mm,nn)=createMapp(sx,n,smapp)  
   
   
   
213              val m=E.Sum((List.map (fn(e1, lb,ub)=>(rewriteIndex(e1,mm),lb,ub)) sx),rewrite(e,nn,mm,embed+1))              val m=E.Sum((List.map (fn(e1, lb,ub)=>(rewriteIndex(e1,mm),lb,ub)) sx),rewrite(e,nn,mm,embed+1))
 (*  
                 val qq=print level  
                 val q=print "END *************************************\n "  
   
 *)  
214              in m end              in m end
   
215          | E.Prod e=> E.Prod(List.map (fn(e1)=>rewrite(e1,n,smapp,embed)) e)          | E.Prod e=> E.Prod(List.map (fn(e1)=>rewrite(e1,n,smapp,embed)) e)
216          | E.Neg e=> E.Neg(rewrite(e, n, smapp,embed))          | E.Neg e=> E.Neg(rewrite(e, n, smapp,embed))
217          |  E.Krn (h,dx, pos)=>          |  E.Krn (h,dx, pos)=>
# Line 249  Line 227 
227      val e'=rewrite(e, length ix, mapp,0)      val e'=rewrite(e, length ix, mapp,0)
228    
229      in      in
230          (ix,index',e')          (outer,index',e')
231      end      end
232    
233    

Legend:
Removed from v.2525  
changed lines
  Added in v.2553

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