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

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/high-to-mid/translate-cfexp.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/high-to-mid/translate-cfexp.sml

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

revision 5570, Wed May 30 22:09:45 2018 UTC revision 5572, Thu May 31 12:54:04 2018 UTC
# Line 7  Line 7 
7   * COPYRIGHT (c) 2016 The University of Chicago   * COPYRIGHT (c) 2016 The University of Chicago
8   * All rights reserved.   * All rights reserved.
9   *)   *)
10    
11  structure TranslateCFExp : sig  structure TranslateCFExp : sig
12    
13    (* FIXME: add comment explaining function and arguments *)
14      val transform_CFExp : MidIR.var * Ein.ein * MidIR.var list      val transform_CFExp : MidIR.var * Ein.ein * MidIR.var list
15            -> MidIR.var list * Ein.param_kind list * Ein.ein_exp            -> MidIR.var list * Ein.param_kind list * Ein.ein_exp
16    
# Line 127  Line 129 
129          (* rewrites a single variable          (* rewrites a single variable
130          * rewritement instances of arg at pid position with arg at idx position          * rewritement instances of arg at pid position with arg at idx position
131          *)          *)
132            fun single_TF (pid, args, params, idx, e) = let            fun singleTF (pid, args, params, idx, e) = let
133                      (*check if the current parameter is a sequence and get dimension*)                      (*check if the current parameter is a sequence and get dimension*)
134                      (*Note Dev branch supports sequence parameter*)                      (*Note Dev branch supports sequence parameter*)
135                      val dim = (case List.nth(params, idx)                      val dim = (case List.nth(params, idx)
# Line 136  Line 138 
138                              | p => raise Fail("unsupported argument type:"^paramToString(idx, p))                              | p => raise Fail("unsupported argument type:"^paramToString(idx, p))
139                          (* end case *))                          (* end case *))
140                      (*variable arg, and param*)                      (*variable arg, and param*)
141                      val arg_new = List.nth(args, idx)                      val newArg = List.nth(args, idx)
142                      val param_new = List.nth(params, idx)                      val newParam = List.nth(params, idx)
143                      val arg_rewrited = List.nth(args, pid)                      val rwArg = List.nth(args, pid)
144                      (*id keeps track of placement and puts it in mapp*)                      (*id keeps track of placement and puts it in mapp*)
145                      fun findArg(_, es, newargs, [], newparams, mapp) = ((List.rev newargs)@es, List.rev newparams, mapp)                      fun findArg(_, es, newargs, [], newparams, mapp) =
146                              (List.revAppend(newargs, es), List.rev newparams, mapp)
147                      | findArg(id, e1::es, newargs, p1::ps, newparams, mapp) =                      | findArg(id, e1::es, newargs, p1::ps, newparams, mapp) =
148                          if(IR.Var.same(e1, arg_rewrited))                            if (IR.Var.same(e1, rwArg))
149                          then findArg(id+1, es, arg_new::newargs, ps, param_new::newparams, ISet.add(mapp, id))                              then findArg(id+1, es, newArg::newargs, ps, newParam::newparams, ISet.add(mapp, id))
150                          else findArg(id+1, es, e1::newargs, ps , p1::newparams, mapp)                          else findArg(id+1, es, e1::newargs, ps , p1::newparams, mapp)
151                      val (args, params, mapp) = findArg(0, args, [], params, [], ISet.empty)                      val (args, params, mapp) = findArg(0, args, [], params, [], ISet.empty)
152                      (* get dimension of vector that is being broken into components*)                      (* get dimension of vector that is being broken into components*)
153                      val param_pos = List.nth(params, pid)                      val param_pos = List.nth(params, pid)
154                      (* rewrite position tensor with deltas in body *)                      (* rewrite position tensor with deltas in body *)
155                      val e = replace (e, dim, mapp)                      val e = replace (e, dim, mapp)
156                  in (args, params, e) end                  in
157                      (args, params, e)
158                    end
159          (*iterate over all the input tensor variable expressions *)          (*iterate over all the input tensor variable expressions *)
160            fun iter ([], args, params, _, e) = (args, params, e)            fun iter ([], args, params, _, e) = (args, params, e)
161              | iter ((pid, E.T)::es, args, params, idx::idxs, e) = let              | iter ((pid, E.T)::es, args, params, idx::idxs, e) = let
# Line 161  Line 166 
166                  end                  end
167              | iter ((pid, E.F)::es, args, params, idx::idxs, e) = let              | iter ((pid, E.F)::es, args, params, idx::idxs, e) = let
168                (*variable is treated as a field so it needs to be expanded into its components*)                (*variable is treated as a field so it needs to be expanded into its components*)
169                  val (args, params, e) = single_TF (pid, args, params, idx, e)                  val (args, params, e) = singleTF (pid, args, params, idx, e)
170                  in                  in
171                    iter(es, args, params, idxs, e)                    iter(es, args, params, idxs, e)
172                  end                  end
# Line 196  Line 201 
201          (*check that the number of into parameters matches number of probed arguments*)          (*check that the number of into parameters matches number of probed arguments*)
202            val n_pargs = length(cfexp_ids)            val n_pargs = length(cfexp_ids)
203            val n_probe = length(probe_ids)            val n_probe = length(probe_ids)
204            val _ = if(not(n_pargs = n_probe))            val _ = if (n_pargs <> n_probe)
205                    then raise  Fail(concat[" n_pargs:", Int.toString( n_pargs), "n_probe:", Int.toString(n_probe)])                      then raise Fail(concat[
206                    else 1                          "n_pargs:", Int.toString( n_pargs), "n_probe:", Int.toString(n_probe)
207                          ])
208                        else ()
209          (* replace polywrap args/params with probed position(s) args/params *)          (* replace polywrap args/params with probed position(s) args/params *)
210            val (args, params, e) = polyArgs(params, e, args, cfexp_ids, probe_ids)            val (args, params, e) = polyArgs(params, e, args, cfexp_ids, probe_ids)
211          (* normalize ein by cleaning it up and differntiating*)          (* normalize ein by cleaning it up and differntiating*)

Legend:
Removed from v.5570  
changed lines
  Added in v.5572

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