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

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/low-to-tree/low-to-tree.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/low-to-tree/low-to-tree.sml

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

revision 4380, Mon Aug 8 17:05:58 2016 UTC revision 4386, Tue Aug 9 13:51:49 2016 UTC
# Line 76  Line 76 
76  (* QUESTION: what about vector result/arguments? *)  (* QUESTION: what about vector result/arguments? *)
77            val f' = TreeFunc.new (            val f' = TreeFunc.new (
78                  IR.Func.name f, U.trType resTy, List.map U.trType paramTys,                  IR.Func.name f, U.trType resTy, List.map U.trType paramTys,
79                  needsWrld, hasGlobs)                  needsWrld, hasGlobs, Flatten.isMapFunc f)
80            in            in
81              setFn (f, f'); f'              setFn (f, f'); f'
82            end            end
# Line 924  Line 924 
924              doNode (IR.CFG.entry cfg, [], [])              doNode (IR.CFG.entry cfg, [], [])
925            end            end
926    
927      and trMapReduce (env, ys, mrs, stms) = let      and trMapReduce (env, ys, mrs as (_, _, x::_)::rest, stms) = let
928            fun getSet (_, _, x::_) = (case IR.Var.getDef x          (* get the strand type of the first map-reduce *)
929              val IR.OP(Op.Strands(Ty.StrandTy strand, _), _) = IR.Var.getDef x
930              val srcVar = U.newTempVar("strand", TTy.StrandPtrTy strand)
931              fun mkMR (y, (r, f, src::args), (mrs, stms)) = let
932                    val lhs = (case eqClassRepOf (env, y)
933                           of NOEQ => newMemLocal (env, y)
934                            | VAR y => y
935                            | _ => raise Fail "unexpected vector variable"
936                          (* end case *))
937                    val srcSet = (case IR.Var.getDef src
938                   of IR.OP(Op.Strands(_, set), _) => set                   of IR.OP(Op.Strands(_, set), _) => set
939                    | rhs => raise Fail("expected Strands, but found " ^ IR.RHS.toString rhs)                    | rhs => raise Fail("expected Strands, but found " ^ IR.RHS.toString rhs)
940                  (* end case *))                  (* end case *))
941          (* get the least-upper bound of the domains *)                  val (es, stms') = singleArgs (env, args)
942            val srcSet = List.foldl                  val mr = T.MapReduce(lhs, r, getFuncVar f, T.E_Var srcVar :: es, srcSet)
943                  (fn (mr, set) => StrandSets.join(getSet mr, set))                  in
944                    (getSet (hd mrs))                    (mr :: mrs, stms' @ stms)
945                      mrs                  end
946              val (mrs, stms) = ListPair.foldl mkMR ([], stms) (ys, mrs)
947              val mrStm = T.S_MapReduce(List.rev mrs, srcVar)
948            in            in
949  raise Fail "trMapReduce"              mrStm :: stms
950            end            end
951    
952      fun trCFG info cfg = ScopeVars.assignScopes ([], trCFGWithEnv (Env.new info, cfg))      fun trCFG info cfg = ScopeVars.assignScopes ([], trCFGWithEnv (Env.new info, cfg))
# Line 949  Line 960 
960    (* Convert a user-defined function.  We need to check for language features    (* Convert a user-defined function.  We need to check for language features
961     * that require the world pointer (e.g., printing) and for references to global variables.     * that require the world pointer (e.g., printing) and for references to global variables.
962     *)     *)
963      fun trFunc info (IR.Func{name, params, body}) =      fun trFunc info (IR.Func{name, params, body}) = let
           if Flatten.isMapFunc name  
             then NONE  
             else let  
964                val params' = List.map U.newParamVar params                val params' = List.map U.newParamVar params
965                val env = Env.new info                val env = Env.new info
966                val _ = ListPair.appEq                val _ = ListPair.appEq
# Line 962  Line 970 
970                val {needsWorld, usesGlobals} = Util.analyzeBlock body'                val {needsWorld, usesGlobals} = Util.analyzeBlock body'
971                val name' = mkFuncVar (name, needsWorld, usesGlobals)                val name' = mkFuncVar (name, needsWorld, usesGlobals)
972                in                in
973                  SOME(T.Func{name = name', params = params', body = body'})              T.Func{name = name', params = params', body = body'}
974                end                end
975    
976    (* Build a strand method from a TreeIR block.  We need to check for language features    (* Build a strand method from a TreeIR block.  We need to check for language features
# Line 1019  Line 1027 
1027                  inputs = List.map (Inputs.map mkGlobalVar) inputs,                  inputs = List.map (Inputs.map mkGlobalVar) inputs,
1028                  constInit = trCFG constInit,                  constInit = trCFG constInit,
1029                  globals = List.map mkGlobalVar globals,                  globals = List.map mkGlobalVar globals,
1030                  funcs = List.mapPartial (trFunc info) funcs,                  funcs = List.map (trFunc info) funcs,
1031                  globInit = trCFG globInit,                  globInit = trCFG globInit,
1032                  strand = trStrand info strand,                  strand = trStrand info strand,
1033                  create = Create.map trCFG create,                  create = Create.map trCFG create,

Legend:
Removed from v.4380  
changed lines
  Added in v.4386

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