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

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/target-cpu/gen-global-update.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/target-cpu/gen-global-update.sml

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

revision 4379, Mon Aug 8 15:55:15 2016 UTC revision 4380, Mon Aug 8 17:05:58 2016 UTC
# Line 12  Line 12 
12    
13    end = struct    end = struct
14    
15        structure R = Reductions
16      structure Env = CodeGenEnv      structure Env = CodeGenEnv
17      structure CL = CLang      structure CL = CLang
18    
19  (* FIXME: add support for global map-reduce computations *)  (* FIXME: add support for global map-reduce computations *)
20    
21      (* make the C++ expression for a reduction *)
22        fun mkReduce (red, e1, e2) = (case red
23               of R.ALL => CL.mkBinOp(e1, CL.#&&, e2)
24                | R.EXISTS => CL.mkBinOp(e1, CL.#||, e2)
25                | R.MAX => CL.mkApply("std::max", [e1, e2])
26                | R.MIN => CL.mkApply("std::min", [e1, e2])
27                | R.PRODUCT => CL.mkBinOp(e1, CL.#*, e2)
28                | R.SUM => CL.mkBinOp(e1, CL.#+, e2)
29              (* end case *))
30    
31      (* code generation for sequential map-reduce *)
32    (*
33        accum = /* reduction identity */;
34        for (uint32_t id = 0;  id < this->_nstrands;  id++) {
35            S_strand *s = this->_outStrand[id];
36            if (/* s in strand set */) {
37                value = /* map code */
38                accum = REDUCE(value, accm);
39            }
40        }
41    *)
42    
43        fun genMapReduceSeq (env, mrs, src, srcSet) = let
44            (* define accumulators for lhs results *)
45              val (accs, accDcls) = let
46                    fun mkAcc ((x, r, _), (accs, stms)) = let
47                          val acc = CodeGenUtil.freshVar "acc"
48                          val ty = TypeToCxx.trType (env, TreeVar.ty x)
49                          val stm = CL.mkDeclInit(ty, acc, TreeToCxx.trLit(env, R.identity r))
50                          in
51                            (acc::accs, stm::stms)
52                          end
53                    in
54                      List.foldr mkAcc ([], []) mrs
55                    end
56              in
57    raise Fail "FIXME"
58              end
59    
60    (* generate the global-update code *)    (* generate the global-update code *)
61      fun gen (env, body) = let      fun gen (env, body) = let
62            val env = Env.insert(env, PseudoVars.world, "this")            val env = Env.insert(env, PseudoVars.world, "this")

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

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