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

SCM Repository

[diderot] Diff of /branches/vis12-cl/src/compiler/c-util/runtime-names.sml
ViewVC logotype

Diff of /branches/vis12-cl/src/compiler/c-util/runtime-names.sml

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

revision 3087, Tue Mar 17 16:35:47 2015 UTC revision 3088, Tue Mar 17 18:27:27 2015 UTC
# Line 1  Line 1 
1  (* runtime-names.sml  (* runtime-names.sml
2   *   *
3   * COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu)   * COPYRIGHT (c) 2015 The Diderot Project (http://diderot-language.cs.uchicago.edu)
4   * All rights reserved.   * All rights reserved.
5   *   *
6   * These are names that are used in the common parts of the runtime system.   * These are C-code names, types, and variables that are common to all of the targets.
7   *)   *)
8    
9  structure RuntimeNames =  structure RuntimeNames : sig
10    struct  
11      (* qualify a name by the target's namespace *)
12        val qualifyName : string -> Properties.props -> string
13      (* qualify a composite name by the target's namespace *)
14        val qualifyName' : string -> (Properties.props * string) -> string
15    
16      (* the name/type of the world type *)
17        val worldTyName : Properties.props -> string
18        val worldPtrTy : Properties.props -> CLang.ty
19    
20      (* the name/type of the program's global variables struct *)
21        val globalsTyName : Properties.props -> string
22        val globalsPtrTy : Properties.props -> CLang.ty
23    
24      (* the name/type of the program's input variables struct *)
25        val inputsTyName : Properties.props -> string
26        val inputsPtrTy : Properties.props -> CLang.ty
27    
28      (* the name/type of the program's defined-inputs struct *)
29        val definedInpTyName : Properties.props -> string
30        val definedInpPtrTy : Properties.props -> CLang.ty
31    
32      (* the holder for command-line options *)
33        val optionsTyName : string
34        val optionsPtrTy : CLang.ty
35    
36      (* names for input and output variable operations *)
37        val inputDesc      : (Properties.props * string) -> string
38        val inputGet       : (Properties.props * string) -> string
39        val inputSet       : (Properties.props * string) -> string
40        val inputSetByName : (Properties.props * string) -> string
41        val outputGet      : (Properties.props * string) -> string
42        val snapshotGet    : (Properties.props * string) -> string
43    
44      (* names of generated functions *)
45        val initGlobals : string                       (* function for initializing program globals *)
46        val freeGlobals : string                       (* function for freeing program globals *)
47        val initDefaults : string                      (* function for initializing input defaults *)
48        val registerOpts : string                      (* function for registering command-line options *)
49        val registerOutputOpts : string                (* function for registering output redirection options *)
50        val initInputs : string                        (* function for initializing global inputs *)
51        val initDefined : Properties.props -> string   (* function for initializing input-defined flags *)
52        val checkDefined : Properties.props -> string  (* function for checking input-defined flags *)
53        val shutdown : Properties.props -> string      (* function that gets called at the end *)
54        val initially : Properties.props -> string     (* function for creating initial strands *)
55        val allocInitially : string                    (* function for allocating initial strands *)
56    
57      (* Math utility functions *)
58        val evecs2x2 : string
59        val evecs3x3 : string
60        val evals2x2 : string
61        val evals3x3 : string
62    
63      (* strand initialization function *)
64        val strandInit : string -> string
65    
66      (* the name/type of a strand object *)
67        val strandTyName : string -> string
68        val strandPtrTy : string -> CLang.ty
69    
70        val strandDescTy : CLang.ty
71        val strandDesc : string -> string
72        val strands : string
73    
74      (* Run-time system functions for images *)
75        val setImage : int -> string
76        val loadImage : int -> string
77        val freeImage : int -> string
78    
79      (* Run-time system functions for dynamic sequences *)
80        val loadDynSeq : TreeIL.Ty.ty -> string
81        val loadDynSeqFromFile : TreeIL.Ty.ty -> string
82    
83      (* functions for defining program-input command-line options *)
84        val inputOpt : TreeIL.Ty.ty -> string
85    
86      (* Status_t symbols *)
87        val kActive = "DIDEROT_ACTIVE"
88        val kDie = "DIDEROT_DIE"
89        val kStabilize = "DIDEROT_STABILIZE"
90    
91      end = struct
92    
     local  
93        structure Ty = TreeIL.Ty        structure Ty = TreeIL.Ty
94        structure CL = CLang
95    
96        fun qualifyName name (tgt : Properties.props) = #namespace tgt ^ name        fun qualifyName name (tgt : Properties.props) = #namespace tgt ^ name
97        fun qualifyName' fixed (tgt : Properties.props, name) =        fun qualifyName' fixed (tgt : Properties.props, name) =
98              concat[#namespace tgt, fixed, "_", name]              concat[#namespace tgt, fixed, "_", name]
     in  
99    
100    (* generated types *)    (* the name/type of the world type *)
101      val worldTy = qualifyName "World_t"      val worldTyName = qualifyName "World_t"
102      val globalsTy = qualifyName "Globals_t"      fun worldPtrTy tgt = CL.T_Ptr(CL.T_Named(worldTyName tgt))
103      val inputsTy = qualifyName "Inputs_t"       (* type of struct used to hold command-line *)  
104                                                  (* inputs. *)    (* the name/type of the program's global variables struct *)
105      val definedInpTy = qualifyName "DefinedInputs_t"      val globalsTyName = qualifyName "Globals_t"
106                                                  (* type of struct used to hold command-line *)      fun globalsPtrTy tgt = CL.T_Ptr(CL.T_Named(globalsTyName tgt))
107                                                  (* inputs. *)  
108      (* the name/type of the program's input variables struct *)
109        val inputsTyName = qualifyName "Inputs_t"
110        fun inputsPtrTy tgt = CL.T_Ptr(CL.T_Named(inputsTyName tgt))
111    
112      (* the name/type of the program's defined-inputs struct *)
113        val definedInpTyName = qualifyName "DefinedInputs_t"
114        fun definedInpPtrTy tgt = CL.T_Ptr(CL.T_Named(definedInpTyName tgt))
115    
116      (* the holder for command-line options *)
117        val optionsTyName = "Diderot_Options_t"
118        val optionsPtrTy = CL.T_Ptr(CL.T_Named optionsTyName)
119    
120    (* generate names for input and output variables *)    (* generate names for input and output variables *)
121      val inputDesc = qualifyName' "InVarDesc"      val inputDesc = qualifyName' "InVarDesc"
# Line 41  Line 133 
133      val registerOutputOpts = "RegisterOutputOpts" (* function for registering output redirection options *)      val registerOutputOpts = "RegisterOutputOpts" (* function for registering output redirection options *)
134      val initInputs = "InitInputs"               (* function for initializing global inputs *)      val initInputs = "InitInputs"               (* function for initializing global inputs *)
135      val initDefined = qualifyName "InitDefined" (* function for initializing input-defined flags *)      val initDefined = qualifyName "InitDefined" (* function for initializing input-defined flags *)
136      val checkDefined = qualifyName "ChkDefined" (* function for initializing input-defined flags *)      val checkDefined = qualifyName "ChkDefined" (* function for checking input-defined flags *)
137      val shutdown = qualifyName "Shutdown"       (* function that gets called at the end *)      val shutdown = qualifyName "Shutdown"       (* function that gets called at the end *)
138      val initially = qualifyName "Initially"     (* function for creating initial strands *)      val initially = qualifyName "Initially"     (* function for creating initial strands *)
139        val allocInitially = "AllocInitially"
140    
141      (* Math utility functions *)
142        val evecs2x2 = "Diderot_evecs2x2"
143        val evecs3x3 = "Diderot_evecs3x3"
144        val evals2x2 = "Diderot_evals2x2"
145        val evals3x3 = "Diderot_evals3x3"
146    
147      (* strand initialization function *)
148      fun strandInit strand = strand ^ "_InitState"      fun strandInit strand = strand ^ "_InitState"
149      fun strandTy strand = concat["Strand_", strand, "_t"]  
150      (* the name/type of a strand object *)
151        fun strandTyName strand = concat["Strand_", strand, "_t"]
152        fun strandPtrTy strand = CL.T_Ptr(CL.T_Named(strandTyName strand))
153    
154        val strandDescTy = CL.T_Named "Strand_t"
155      fun strandDesc strand = concat["Strand_", strand]      fun strandDesc strand = concat["Strand_", strand]
     val numStrands = "Diderot_NumStrands"  
156      val strands = "Diderot_Strands"      val strands = "Diderot_Strands"
157    
158    (* Diderot runtime system hooks *)    (* Run-time system functions for images *)
159      fun setImage dim = concat["Diderot_SetImage", Int.toString dim, "D"]      fun setImage dim = concat["Diderot_SetImage", Int.toString dim, "D"]
160      fun loadImage dim = concat["Diderot_LoadImage", Int.toString dim, "D"]      fun loadImage dim = concat["Diderot_LoadImage", Int.toString dim, "D"]
161      fun freeImage dim = concat["Diderot_FreeImage", Int.toString dim, "D"]      fun freeImage dim = concat["Diderot_FreeImage", Int.toString dim, "D"]
162    
163      (* Run-time system functions for dynamic sequences *)
164      fun loadDynSeq ty = (case ty      fun loadDynSeq ty = (case ty
165             of Ty.BoolTy => "Diderot_DynSeqLoadBool"             of Ty.BoolTy => "Diderot_DynSeqLoadBool"
166              | Ty.IntTy => "Diderot_DynSeqLoadInt"              | Ty.IntTy => "Diderot_DynSeqLoadInt"
# Line 66  Line 173 
173              | Ty.TensorTy _ => "Diderot_DynSeqLoadRealFromFile"              | Ty.TensorTy _ => "Diderot_DynSeqLoadRealFromFile"
174              | ty => raise Fail("unsupported sequence type " ^ Ty.toString ty)              | ty => raise Fail("unsupported sequence type " ^ Ty.toString ty)
175            (* end case *))            (* end case *))
     val strandDescTy = "Strand_t"  
     val optionsTy = "Diderot_Options_t"  
     val allocInitially = "AllocInitially"  
     val inState = "Diderot_InState"  
   
   (* Math utility functions *)  
     val evecs2x2 = "Diderot_evecs2x2"  
     val evecs3x3 = "Diderot_evecs3x3"  
     val evals2x2 = "Diderot_evals2x2"  
     val evals3x3 = "Diderot_evals3x3"  
176    
177    (* functions for defining program inputs; note that sequences and images come from    (* functions for defining program-input command-line options; note that sequences
178     * nrrd files, which are specified by their filenames.     * and images come from nrrd files, which are specified by their filenames.
179     *)     *)
180      fun input ty = (case ty      fun inputOpt ty = (case ty
181             of Ty.StringTy => "Diderot_OptAddString"             of Ty.StringTy => "Diderot_OptAddString"
182              | Ty.BoolTy => "Diderot_OptAddBool"              | Ty.BoolTy => "Diderot_OptAddBool"
183              | Ty.IntTy => "Diderot_OptAddInt"              | Ty.IntTy => "Diderot_OptAddInt"
# Line 93  Line 190 
190              | ty => raise Fail("unsupported input type " ^ Ty.toString ty)              | ty => raise Fail("unsupported input type " ^ Ty.toString ty)
191            (* end case *))            (* end case *))
192    
193      end (* local *)    (* Status_t symbols *)
194        val kActive = "DIDEROT_ACTIVE"
195        val kDie = "DIDEROT_DIE"
196        val kStabilize = "DIDEROT_STABILIZE"
197    
198        val toImageSpace = addVecSuffix "ToImageSpace"
199        fun toWorldSpace ty = let
200              val suffix = (case ty
201                     of Ty.TensorTy[d] => [Int.toString d]
202                      | Ty.TensorTy[m,n] => [Int.toString n, "x", Int.toString n]
203                      | Ty.TensorTy[m,n,p] => [Int.toString n, "x", Int.toString n, "x", Int.toString p]
204                    (* end case *))
205              in
206                concat("ToWorldSpace" :: suffix)
207              end
208        val inside = addVecSuffix "Inside"
209    
210      (* image index control operations *)
211        fun indexControl (dim, ctl) = concat["Index", IndexCtl.toString ctl, Int.toString dim]
212    
213    end    end

Legend:
Removed from v.3087  
changed lines
  Added in v.3088

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