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

SCM Repository

[diderot] Annotation of /branches/vis15/src/compiler/common/reductions.sml
ViewVC logotype

Annotation of /branches/vis15/src/compiler/common/reductions.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4588 - (view) (download)

1 : jhr 4337 (* reductions.sml
2 :     *
3 :     * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
4 :     *
5 :     * COPYRIGHT (c) 2016 The University of Chicago
6 :     * All rights reserved.
7 :     *)
8 :    
9 :     structure Reductions : sig
10 :    
11 : jhr 4588 (* the reduction operators supported in map-reduce computations. Note that these
12 :     * do not include the synthetic reductions, such as "mean"
13 :     *)
14 :     datatype t
15 :     = ALL (* boolean and; unit is true *)
16 :     | EXISTS (* boolean or; unit is false *)
17 :     | IMAX (* integer max; unit is DIDEROT_INT_MIN *)
18 :     | RMAX (* real max; unit is -∞ *)
19 :     | IMIN (* integer min; unit is DIDEROT_INT_MAX *)
20 :     | RMIN (* real min; unit is +∞ *)
21 :     | IPRODUCT (* integer product; unit is 1 *)
22 :     | RPRODUCT (* real product; unit is 1 *)
23 :     | ISUM (* integer sum; unit is 0 *)
24 :     | RSUM (* real sum; unit is 0 *)
25 : jhr 4337
26 :     val toString : t -> string
27 :     val same : t * t -> bool
28 :     val hash : t -> word
29 :    
30 :     (* return the identity value for a reduction operator *)
31 :     val identity : t -> Literal.t
32 :    
33 :     end = struct
34 :    
35 :     (* the reduction operators supported in map-reduce computations *)
36 : jhr 4588 datatype t
37 :     = ALL | EXISTS
38 :     | IMAX | RMAX
39 :     | IMIN | RMIN
40 :     | IPRODUCT | RPRODUCT
41 :     | ISUM | RSUM
42 : jhr 4337
43 :     fun toString ALL = "all"
44 :     | toString EXISTS = "exists"
45 : jhr 4588 | toString IMAX = "max<int>"
46 :     | toString RMAX = "max<real>"
47 :     | toString IMIN = "min<int>"
48 :     | toString RMIN = "min<real>"
49 :     | toString IPRODUCT = "product<int>"
50 :     | toString RPRODUCT = "product<real>"
51 :     | toString ISUM = "sum<int>"
52 :     | toString RSUM = "sum<real>"
53 : jhr 4337
54 :     fun same (ALL, ALL) = true
55 :     | same (EXISTS, EXISTS) = true
56 : jhr 4588 | same (IMAX, IMAX) = true
57 :     | same (RMAX, RMAX) = true
58 :     | same (IMIN, IMIN) = true
59 :     | same (RMIN, RMIN) = true
60 :     | same (IPRODUCT, IPRODUCT) = true
61 :     | same (RPRODUCT, RPRODUCT) = true
62 :     | same (ISUM, ISUM) = true
63 :     | same (RSUM, RSUM) = true
64 : jhr 4337 | same _ = false
65 :    
66 :     fun hash ALL = 0w13
67 :     | hash EXISTS = 0w17
68 : jhr 4588 | hash IMAX = 0w23
69 :     | hash RMAX = 0w31
70 :     | hash IMIN = 0w37
71 :     | hash RMIN = 0w41
72 :     | hash IPRODUCT = 0w43
73 :     | hash RPRODUCT = 0w47
74 :     | hash ISUM = 0w53
75 :     | hash RSUM = 0w57
76 : jhr 4337
77 :     fun identity ALL = Literal.Bool true
78 :     | identity EXISTS = Literal.Bool false
79 : jhr 4588 | identity IMAX = Literal.Int (IntLit.minInt())
80 :     | identity RMAX = Literal.Real RealLit.negInf
81 :     | identity IMIN = Literal.Int (IntLit.maxInt())
82 :     | identity RMIN = Literal.Real RealLit.posInf
83 :     | identity IPRODUCT = Literal.Int 1
84 :     | identity RPRODUCT = Literal.Real RealLit.one
85 :     | identity ISUM = Literal.Int 0
86 :     | identity RSUM = Literal.Real (RealLit.zero false)
87 : jhr 4337
88 :     end

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