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

SCM Repository

[diderot] View of /branches/charisee_dev/src/compiler/high-to-mid/handleEin.sml
ViewVC logotype

View of /branches/charisee_dev/src/compiler/high-to-mid/handleEin.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3443 - (download) (annotate)
Thu Nov 19 23:24:18 2015 UTC (3 years, 11 months ago) by cchiw
File size: 3921 byte(s)
blocked
(* Expands probe ein
 *
 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
 *
 * COPYRIGHT (c) 2015 The University of Chicago
 * All rights reserved.
 *)

structure handleEin = struct

    local
   
    structure E = Ein
    structure DstIL = MidIL
    structure P=Printer
    structure MidToS=MidToString
    (*structure L=LiftEin*)
    in

    val testinitial=0
    val testing=0
    fun testp n=(case testing
        of 0=> 1
        | _ =>(print(String.concat n);1)
        (*end case*))
    fun test0 n=(case testinitial
        of 0=>testp n
        | _ => (print(String.concat n);1))
    fun toStringBind e= MidToS.toStringBind e
    fun useCount (HighIL.V{useCnt, ...}) = !useCnt
    fun expandEinOp (srcy,bind00)=let
        val _= raise Fail"development branch- do not use"
        val star="************"
        val _= ("\n Start"^star)
        val _ =test0[star,"\n Original EinApp",star,"\n\n","start get test",toStringBind bind00]
        val (y,einapp as DstIL.EINAPP(Ein.EIN{params, index, body},args))=bind00
      

        (* ************* Sweep for 0's'*********** *)
        val _ =testp["Pre Sweep\n",P.printbody body,"\n"]
        val bodysweep=sweepEin.sweep body
        val ein1=Ein.EIN{params=params, index=index, body=bodysweep}
        val _ =testp["Post Sweep\n",P.printbody bodysweep,"\n"]


        (* ************** distribute and push Summation*********** *)
        val bind3 = (y,DstIL.EINAPP(SummationEin.main ein1,args))
        val _ =testp["\n\n summation \n\n =>", toStringBind bind3]

     (* **************** lift no split ************* *)
        (*
        val (einapp1,e2)=L.testLift  bind3
        val newbies5=e2@[einapp1]
        val _ =  print("\n **** lift Length"^(Int.toString(length(e2))))

        *)
    (* **************** lift and split************* *)
    (*
         val (einapp1,e2)=L.testLift  bind3
        val _ =  print("\n **** lift Length"^(Int.toString(length(e2))))
        val (newbies5)=Split.limitSplit(bind3,[],200)
    *)

        (* **************** split phase ************* *)

        val (newbies5)= Split.splitEinApp bind3



        (**************** printing result ***************)
        val _ =testp["\n\n Returning \n\n =>",
        String.concatWith",\n\t"(List.map toStringBind newbies5)]
        val n =length(newbies5)
        val _ = if (n > 10) then testp["\n **** SPLIT Length",Int.toString(n)] else 1
         (* ************** ProbeEIN *********** *)
        (*gives probeEIN the set. Could split into a sepearate step*)
        val fieldset= einSet.EinSet.empty
        val isField = ref 0
        val isFieldR = ref 0
        val isReplaced = ref 0
        fun iter([],_)=[]
         | iter(e1::es,fieldset)= let
            val (e2,fieldset,isFieldt,isReplacedt) = ProbeEin.expandEinOp(e1,fieldset)
            val rtn=[e2]@(iter(es,fieldset))
            val isFieldRt=if ((isFieldt+isReplacedt)=2) then 1 else 0
            in (isField:=(!isField)+isFieldt;isReplaced:=(!isReplaced )+isReplacedt;
            isFieldR:=(!isFieldR)+isFieldRt;rtn)
            end
        val code=iter(newbies5, fieldset)

        val n= List.length(code)
        val _ =testp[HighIL.Var.name srcy ," Pieces",Int.toString (n),"\n"]
(*
          val _ = if (n>5)
          then  print(String.concat["\n",star,":Name:",HighIL.Var.name srcy ,
            ":VarCount(",Int.toString(useCount srcy),")","Pieces now: ",Int.toString (n),
            " Fields:",Int.toString(!isField)," isReplaced:",Int.toString(!isReplaced),
            " Replaced_Fields:",Int.toString(!isFieldR)])
            else print ""
*)
            val flatcode= List.foldr op@ [] code


        (*val _=List.map (fn(_,DstIL.EINAPP(e,_))=>checkEin.checkEIN e | _=> 1) flatcode*)
        val _=(star^"end")
        in
            List.map (fn (y,rator)=> DstIL.ASSGN(y,rator)) flatcode
        end

  end; (* local *)

end (* local *)

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