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

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/simplify/simplify.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/simplify/simplify.sml

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

revision 4371, Sat Aug 6 11:48:16 2016 UTC revision 4378, Mon Aug 8 15:20:44 2016 UTC
# Line 424  Line 424 
424    
425    (* simplify a parallel map-reduce *)    (* simplify a parallel map-reduce *)
426      and simplifyReduction (cxt, rator, e, x, xs, resTy) = let      and simplifyReduction (cxt, rator, e, x, xs, resTy) = let
427                val result = SimpleVar.new ("res", Var.LocalVar, cvtTy resTy)
428              (* convert the reduction operator from a variable to a Reductions.t value *)
429              val rator' = if Var.same(BV.red_all, rator) then Reductions.ALL              val rator' = if Var.same(BV.red_all, rator) then Reductions.ALL
430                    else if Var.same(BV.red_exists, rator) then Reductions.EXISTS                    else if Var.same(BV.red_exists, rator) then Reductions.EXISTS
431                    else if Var.same(BV.red_max, rator) then Reductions.MAX                    else if Var.same(BV.red_max, rator) then Reductions.MAX
432    (* use SUM and divide by number of strands *)
433                    else if Var.same(BV.red_mean, rator) then raise Fail "FIXME: mean reduction"                    else if Var.same(BV.red_mean, rator) then raise Fail "FIXME: mean reduction"
434                    else if Var.same(BV.red_min, rator) then Reductions.MIN                    else if Var.same(BV.red_min, rator) then Reductions.MIN
435                    else if Var.same(BV.red_product, rator) then Reductions.PRODUCT                    else if Var.same(BV.red_product, rator) then Reductions.PRODUCT
436                    else if Var.same(BV.red_sum, rator) then Reductions.SUM                    else if Var.same(BV.red_sum, rator) then Reductions.SUM
437    (* two passes *)
438                    else if Var.same(BV.red_variance, rator) then raise Fail "FIXME: variance reduction"                    else if Var.same(BV.red_variance, rator) then raise Fail "FIXME: variance reduction"
439                      else raise Fail "impossible: not a reduction"                      else raise Fail "impossible: not a reduction"
440              val x' = cvtVar x              val x' = cvtVar x
             val result = SimpleVar.new ("res", Var.LocalVar, cvtTy resTy)  
441              val (bodyStms, bodyResult) = simplifyExpToVar (cxt, e, [])              val (bodyStms, bodyResult) = simplifyExpToVar (cxt, e, [])
442  (* FIXME: need to handle reductions over active/stable subsets of strands *)            (* convert the domain from a variable to a StrandSets.t value *)
443                val domain = if Var.same(BV.set_active, xs) then StrandSets.ACTIVE
444                      else if Var.same(BV.set_all, xs) then StrandSets.ALL
445                      else if Var.same(BV.set_stable, xs) then StrandSets.STABLE
446                        else raise Fail "impossible: not a strand set"
447              val (func, args) = Util.makeFunction(              val (func, args) = Util.makeFunction(
448                    Var.nameOf rator, mkBlock(S.S_Return bodyResult :: bodyStms),                    Var.nameOf rator, mkBlock(S.S_Return bodyResult :: bodyStms),
449                    SimpleVar.typeOf bodyResult)                    SimpleVar.typeOf bodyResult)
450              val mapReduceStm = S.S_MapReduce{              val mapReduceStm = S.S_MapReduce[
451                      results = [result],                      S.MapReduce{
452                      reductions = [rator'],                          result = result, reduction = rator', mapf = func, args = args,
453                      body = func,                          source = x', domain = domain
454                      args = args,                        }]
                     source = x'  
                   }  
455              in              in
456                (result, mapReduceStm)                (result, mapReduceStm)
457              end              end

Legend:
Removed from v.4371  
changed lines
  Added in v.4378

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