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

# SCM Repository

[diderot] Diff of /branches/ein16/src/compiler/high-il/normalize-ein.sml
 [diderot] / branches / ein16 / src / compiler / high-il / normalize-ein.sml

# Diff of /branches/ein16/src/compiler/high-il/normalize-ein.sml

revision 2795, Tue Nov 4 21:58:11 2014 UTC revision 2838, Tue Nov 25 03:40:24 2014 UTC
# Line 37  Line 37
37      | E.Apply _   => (0,E.Sum(c1,e1))      | E.Apply _   => (0,E.Sum(c1,e1))
38      | E.Delta _   => (0,E.Sum(c1,e1))      | E.Delta _   => (0,E.Sum(c1,e1))
39      | E.Epsilon _ => (0,E.Sum(c1,e1))      | E.Epsilon _ => (0,E.Sum(c1,e1))
40        (*| E.Tensor []  => (1,e1)*)
41      | E.Tensor _  => (0,E.Sum(c1,e1))      | E.Tensor _  => (0,E.Sum(c1,e1))
42      | E.Neg e2    => (1,E.Neg(E.Sum(c1,e2)))      | E.Neg e2    => (1,E.Neg(E.Sum(c1,e2)))
43      | E.Sub (a,b) => (1,E.Sub(E.Sum(c1,a),E.Sum(c1,b)))      | E.Sub (a,b) => (1,E.Sub(E.Sum(c1,a),E.Sum(c1,b)))
# Line 129  Line 130
130
131  (*Apply normalize to each term in product list  (*Apply normalize to each term in product list
132  or Apply normalize to tail of each list*)  or Apply normalize to tail of each list*)
133  fun normalize (Ein.EIN{params, index, body}) = let  fun normalize (ee as Ein.EIN{params, index, body}) = let
134        val changed = ref false        val changed = ref false
135
136        fun rewriteBody body =(case body        fun rewriteBody body =(case body
# Line 244  Line 245
245                      end                      end
246                  (*end case*))                  (*end case*))
247
248                | E.Prod[E.Delta d, E.Neg e]=> (changed:=true;E.Neg(E.Prod[E.Delta d, e]))
249              | E.Prod(E.Delta d::es)=>let              | E.Prod(E.Delta d::es)=>let
250                  val (pre',eps, dels,post)= F.filterGreek(E.Delta d::es)                  val (pre',eps, dels,post)= F.filterGreek(E.Delta d::es)
251                  val (change,a)=G.reduceDelta(eps, dels, post)                  val (change,a)=G.reduceDelta(eps, dels, post)
# Line 269  Line 271
271              (*end case*))              (*end case*))
272
273              fun loop(body ,count) = let              fun loop(body ,count) = let
274                    val _ =print(String.concat["\n\n N =>",Int.toString(count),"--",P.printbody(body)])
275                  val body' = rewriteBody body                  val body' = rewriteBody body
276
277                             in                             in
278                if !changed                if !changed
279                  then let                  then  (changed := false ;loop(body',count+1))
val _= (case testing
of 1=> (print(String.concat["\nN =>",Int.toString(count),"--",P.printbody(body')]);1)
| _=> 1)
in
(changed := false ;loop(body',count+1))
end
280                  else (body',count)                  else (body',count)
281              end              end
282        val _ =print(String.concat["\n ******************* \n Start Normalize \n\n "])
283      val (b,count) = loop(body,0)      val (b,count) = loop(body,0)
284      val _ =(case testing      val _ =print(String.concat["\n Out of normalize \n",P.printbody(b),"\n    Final CounterXX:",Int.toString(count),"\n\n"])
of 1 => (print(String.concat["\n out of normalize \n",P.printbody(b),"\n    Final CounterXX:",Int.toString(count),"\n\n"]);1)
| _=> 1
(*end case*))
285      in      in
286                  (Ein.EIN{params=params, index=index, body=b},count)                  (Ein.EIN{params=params, index=index, body=b},count)
287      end      end

Legend:
 Removed from v.2795 changed lines Added in v.2838

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