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

Diff of /branches/ein16/src/compiler/high-il/EpsHelpers.sml

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

revision 4409, Fri Aug 12 17:46:21 2016 UTC revision 4410, Fri Aug 12 18:28:32 2016 UTC
# Line 53  Line 53 
53          end          end
54      |doubleEps _ = raise Fail"None Epsilon Arguement"      |doubleEps _ = raise Fail"None Epsilon Arguement"
55    
56        fun doubleEps2 (E.G(E.Epsilon(a,b,c)), E.G(E.Epsilon(d,e,f))) = let
57            fun createDeltas (s, t, u, v) =
58                (* FIXME: what does the following comment mean? *)
59                (*If multiple summation ids are the same, it might not remove from the summation queue*)
60                if (s=u andalso t=v) orelse (s=v andalso t=u)
61                then NONE
62                else let
63                        val d1 = [E.G(E.Delta(s, u)), E.G(E.Delta(t, v))]
64                        val d2 = [E.G(E.Delta(s, v)), E.G(E.Delta(t, u))]
65                in
66                    SOME(d1, d2)
67                end
68            in
69                if (a=d) then createDeltas(b, c, e, f)
70                else if (a=e) then createDeltas(b, c, f, d)
71                else if (a=f) then createDeltas(b, c, d, e)
72                else if (b=d) then createDeltas(c, a, e, f)
73                else if (b=e) then createDeltas(c, a, f, d)
74                else if (b=f) then createDeltas(c, a, d, e)
75                else if (c=d) then createDeltas(a, b, e, f)
76                else if (c=e) then createDeltas(a, b, f, d)
77                else if (c=f) then createDeltas(a, b, d, e)
78                else NONE
79            end
80            | doubleEps2 _ = raise Fail "None Epsilon Argument"
81    
82    
83    
84      (*distributeEps:ein_exp list* ein_exp list      (*distributeEps:ein_exp list* ein_exp list
85      -> int*ein_exp list * ein_exp list *ein_exp list *sum_index_id list      -> int*ein_exp list * ein_exp list *ein_exp list *sum_index_id list
# Line 85  Line 112 
112              distEps(epsAll,[])              distEps(epsAll,[])
113          end          end
114    
115        fun distributeEps2 (epsAll, sumexp) = let
116            fun distEps ([], _) = NONE
117              | distEps ([e1], eps) = (case sumexp
118                of [E.Sum(sx, E.Opn(E.Prod, e2::ps))] => (case doubleEps2(e1, e2)
119                    of SOME(d1, d2) =>  SOME(eps, d1, d2, sx, ps)
120                    | NONE =>  NONE
121                    (* end case *))
122                | _ => NONE
123                (* end case *))
124            | distEps (e1::e2::current,eps) = (case doubleEps2(e1, e2)
125                of SOME(d1, d2) => SOME(eps@current, d1, d2, [], sumexp)
126                | _ => distEps(e2::current, eps@[e1])
127                (* end case *))
128            in
129                distEps (epsAll, [])
130            end
131    
132    
133      (*epsToDels:ein_exp list      (*epsToDels:ein_exp list
134          -> int*ein_exp * sum_index_id*ein_exp list *ein_exp list          -> int*ein_exp * sum_index_id*ein_exp list *ein_exp list
# Line 105  Line 149 
149              (*end case *))              (*end case *))
150          end          end
151    
152        fun epsToDels2 exps = let
153            val (epsAll, rest, sumexp) = F.filterEps exps
154            in
155                case distributeEps2(epsAll, sumexp)
156                    of NONE => if (length epsAll > 0)
157                        then (NONE, SOME epsAll, rest@sumexp)
158                        else (NONE, NONE, rest@sumexp)
159                    | SOME(epsUnused, d1, d2, sx, ps) => let
160                        (* d1, d2 are rewritten delta expressions *)
161                        (* in some cases there are embedded expressions of the form E.Sum(sx, ...ps)*)
162                        (* sx does not apply to the rest of the expression ("rest")*)
163                        (* return expression in pieces in order to preserve structure*)
164                        val a = E.Opn(E.Prod, epsUnused@d1@ps)
165                        val b = E.Opn(E.Prod, epsUnused@d2@ps)
166                        in
167                            (SOME(E.Op2(E.Sub, a, b), sx), NONE, rest)
168                        end
169                (*end case *)
170            end
171    
172    
173      (*reduceDelta:ein_exp*ein_exp* ein_exp list ->int *ein_exp      (*reduceDelta:ein_exp*ein_exp* ein_exp list ->int *ein_exp
174      *Apply deltas to tensors/fields      *Apply deltas to tensors/fields
175      *returns change or rewriten ein_exp      *returns change or rewriten ein_exp

Legend:
Removed from v.4409  
changed lines
  Added in v.4410

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