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

SCM Repository

[diderot] Annotation of /trunk/src/compiler/codegen/target-sig.sml
ViewVC logotype

Annotation of /trunk/src/compiler/codegen/target-sig.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3349 - (view) (download)

1 : jhr 433 (* target-sig.sml
2 :     *
3 : jhr 3349 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
4 :     *
5 :     * COPYRIGHT (c) 2015 The University of Chicago
6 : jhr 433 * All rights reserved.
7 :     *
8 :     * Support for generating C-like code (e.g., C, OpenCL, or CUDA)
9 :     *)
10 :    
11 :     signature TARGET =
12 :     sig
13 :    
14 : jhr 451 type program
15 : jhr 511 type strand
16 : jhr 1116 type var
17 : jhr 454 type exp
18 :     type stm
19 : jhr 451
20 : jhr 1116 (* environment for mapping from TreeIL variables to target variables. It is also used to
21 :     * track the translation context (e.g., global initialization vs. strand initialization, etc.
22 :     *)
23 :     type env
24 : jhr 451
25 : jhr 1116 (* the supprted widths of vectors of reals on the target. This value takes into
26 :     * account the actual size of reals (i.e., 32 or 64 bits).
27 :     *)
28 :     val vectorWidths : unit -> int list
29 :    
30 : jhr 1640 (* does the target support printing? Note that if the target is parallel, then printing
31 :     * will not be supported.
32 :     *)
33 :     val supportsPrinting : bool
34 :    
35 : jhr 1116 (* tests for whether various expression forms can appear inline *)
36 : jhr 1640 val inlineCons : int -> bool (* can n'th-order tensor construction appear inline *)
37 :     val inlineMatrixExp : bool (* can matrix-valued expressions appear inline? *)
38 : jhr 1116
39 :     (* TreeIL to target translations *)
40 :     structure Tr : sig
41 : jhr 1640 val fragment : env * TreeIL.block -> env * stm list
42 :     val block : env * TreeIL.block -> stm
43 :     val exp : env * TreeIL.exp -> exp
44 : jhr 451 end
45 :    
46 : jhr 1116 (* variables *)
47 :     structure Var : sig
48 : jhr 1640 val name : var -> string
49 : jhr 2005 val global : program * string * TreeIL.Ty.ty -> var (* global variables *)
50 :     val param : env * TreeIL.var -> var (* strand parameters *)
51 : jhr 451 end
52 :    
53 : jhr 1116 (* environments *)
54 :     structure Env : sig
55 :     (* create a new environment *)
56 : jhr 1640 val new : program -> env
57 : jhr 1116 (* define the current translation context *)
58 : jhr 1640 val scopeGlobal : env -> env (* global initialization *)
59 :     val scopeInitially : env -> env (* initial strand creation *)
60 :     val scopeStrand : env -> env (* strand initialization; the vars are *)
61 :     (* all of the state vars *)
62 :     val scopeMethod : env * StrandUtil.method_name -> env (* method body; the vars are just the *)
63 :     (* varying state variables *)
64 : jhr 1116 (* bind a TreeIL variable to a target variable *)
65 : jhr 1640 val bind : env * TreeIL.var * var -> env
66 : jhr 451 end
67 :    
68 : jhr 1116 (* programs *)
69 :     structure Program : sig
70 : jhr 1640 val new : {
71 :     name : string, (* stem of source file *)
72 :     double : bool, (* true for double-precision support *)
73 :     parallel : bool, (* true for multithreaded (or multi-GPU) target *)
74 :     debug : bool (* true for debug support in executable *)
75 :     } -> program
76 :     val inputs : program * stm -> unit (* register options for input-variables *)
77 :     val init : program * stm -> unit (* initialization of program globals *)
78 : jhr 1116 (* register the initially code for a program *)
79 : jhr 1640 val initially : {
80 :     prog : program,
81 :     isArray : bool,
82 :     iterPrefix : stm list,
83 :     iters : (var * exp * exp) list,
84 :     createPrefix : stm list,
85 :     strand : Atom.atom,
86 :     args : exp list
87 :     } -> unit
88 : jhr 1116 (* output the code to a file. The string is the basename of the file, the extension
89 :     * is provided by the target.
90 :     *)
91 : jhr 1640 val generate : string * program -> unit
92 : jhr 1116 end
93 :    
94 :     (* strands *)
95 :     structure Strand : sig
96 :     (* define a strand with the given name *)
97 : jhr 1640 val define : program * Atom.atom * TreeIL.state_var list -> strand
98 : jhr 1116 (* return the strand with the given name *)
99 : jhr 1640 val lookup : program * Atom.atom -> strand
100 : jhr 1116 (* register the strand-state initialization code. The variables are the strand
101 :     * parameters.
102 :     *)
103 : jhr 1640 val init : strand * var list * stm -> unit
104 : jhr 1116 (* register a strand method *)
105 : jhr 1640 val method : strand * StrandUtil.method_name * stm -> unit
106 : jhr 1116 end
107 :    
108 : jhr 433 end

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