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

SCM Repository

[diderot] View of /branches/femprime/src/compiler/high-to-mid/handle-ein.sml
ViewVC logotype

View of /branches/femprime/src/compiler/high-to-mid/handle-ein.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5048 - (download) (annotate)
Thu Jul 13 01:09:59 2017 UTC (2 years, 3 months ago) by cchiw
File size: 2800 byte(s)
put evalfem in ein ir
(* handle-ein.sml
 *
 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
 *
 * COPYRIGHT (c) 2016 The University of Chicago
 * All rights reserved.
 *)

structure HandleEin : sig

    val expand : MidIR.var * Ein.ein * MidIR.var list -> MidIR.assignment list

  end = struct
   
    structure E = Ein
    structure SrcIR = HighIR
    structure DstIR = MidIR

    fun useCount (SrcIR.V{useCnt, ...}) = !useCnt

    fun expand (lhs, ein, args) = let
        (*DEBUG*)
         fun ll ([],cnt) = ""
           | ll (a1::args,cnt) = String.concat["\n\t", Int.toString(cnt),"_", MidTypes.toString(DstIR.Var.ty a1), " ", MidIR.Var.name(a1),",", ll(args,cnt+1)]

         val _ = print(String.concat["\n\n  **************  **************  **************  expand ***********\n:",MidIR.Var.name(lhs),"=", EinPP.toString(ein),"-",ll(args,0)])

        (* ************** distribute and push Summation*********** *)
          val ein' = EinSums.transform ein

        val _ = print(String.concat["\n\n  **************   EinSums ***********\n:",EinPP.toString(ein'),"-",ll(args,0)])



            fun prntNewbies(newbies, id) = let
                val _ = print(id)
                in  List.map (fn (lhs,DstIR.EINAPP(e,a))=> print(String.concat["\n\n ->:", MidTypes.toString(DstIR.Var.ty lhs)," ",DstIR.Var.name(lhs),"=",EinPP.toString(e) ,"-",ll(a,0)])  | _ => print "") newbies
                end

          fun iter([], ys) = ys
            | iter(e1::es, ys) = let
            val (lhs, DstIR.EINAPP(e, a)) = e1
            val y1 = FloatEin.transform (lhs, e, a)
            in
                iter(es, ys@y1)
            end
        (* **************** poly-ein phase ************* *)
        (*val newbies = PolyEin.transform (lhs, ein', args)*)
         val newbies = [(lhs, DstIR.EINAPP(ein', args))]
        val _ = prntNewbies(newbies, "post poly transform")
        (* **************** split phase ************* *)
        val newbies =iter(newbies, [])
        val _ = prntNewbies(newbies, "\n\n\npost floatx1")
        val newbies =iter(newbies, [])
        val _ = prntNewbies(newbies, "\n\n\npost floatx2")
        (* **************** expand-fem ************* *)
        val _ = print "\n\n\nbefore translating fields"
        val newbies  = List.foldr (fn (e,acc)=>  translateField.transform(e)@acc ) []  newbies
        val _ = prntNewbies(newbies, "\n\n\npost transform fields")
        (* ************** ProbeEIN *********** *)

            val _ =print "about to call probe ein"
          val avail = AvailRHS.new()
          val _ = List.app (ProbeEin.expand avail) (newbies);
          val stmts = List.rev (AvailRHS.getAssignments avail)
          val asgn = List.map DstIR.ASSGN stmts
          in
            asgn
          end

  end (* HandleEin *)

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