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 3678 - (download) (annotate)
Mon Feb 15 19:36:00 2016 UTC (3 years, 8 months ago) by cchiw
File size: 3322 byte(s)
added counter to avail and various baseline improvements
(* 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 sumflag = true
    val probeflag = true
    val floatflag = true
    val liftflag = false
    val splitflag = false
    val limit = NONE

    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 bodysweep = sweepEin.sweep body
        val ein = Ein.EIN{params=params, index=index, body=bodysweep}


        (* ************** distribute and push Summation*********** *)
        val bind3 =  case sumflag
            of false => (y,DstIL.EINAPP( ein,args))
            | _ => (y,DstIL.EINAPP(SummationEin.main ein,args))

        (* **************** lift - split ************* *)
        val newbies5=  (case (floatflag,liftflag,splitflag,limit)
            of (true,_,_,_)                                         (*Float*)
                => List.map (fn MidIL.ASSGN(i)=> i ) (FloatEin.transform bind3)
            | (false,true,_,_) =>   let
                val (einapp1,e2,_)=L.testLift  bind3
                in (e2@[einapp1]) end                              (*LIFT*)
            | (false,false,true,NONE) =>  Split.splitEinApp bind3 (*SPLIT*)
            (* **************** split phase ************* *)
            | (false,false,true, SOME limit) => Split.limitSplit(bind3,limit)
        (* end case *))

         (* ************** ProbeEIN *********** *)
        (*gives probeEIN the set. Could split into a sepearate step*)
        val fieldset= einVarSet.EinVarSet.empty
        val varset= einVarSet.VarSet.empty
        val isField = ref 0
        val isFieldR = ref 0
        val isReplaced = ref 0
        fun iter([],_,_)=[]
         | iter(e1::es,fieldset,varset)= let
            val (e2,fieldset,varset,isFieldt,isReplacedt) = ProbeEin.expandEinOp(e1,fieldset,varset)
            val rtn=[e2]@(iter(es,fieldset,varset))
            val isFieldRt=if ((isFieldt+isReplacedt)=2) then 1 else 0
            in (isField:=(!isField)+isFieldt;isReplaced:=(!isReplaced )+isReplacedt;
            isFieldR:=(!isFieldR)+isFieldRt;rtn)
            end

        val flatcode = (case  probeflag
            of true =>  List.foldr op@ [] (iter(newbies5, fieldset,varset))
            | _ => newbies5)

        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