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

SCM Repository

[diderot] Annotation of /branches/vis12/src/compiler/codegen/properties.sml
ViewVC logotype

Annotation of /branches/vis12/src/compiler/codegen/properties.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3291 - (view) (download)

1 : jhr 2086 (* properties.sml
2 :     *
3 : jhr 3291 * 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 2086 * All rights reserved.
7 :     *
8 :     * Properties, including the target description, that affect code generation.
9 :     *)
10 :    
11 :     structure Properties =
12 :     struct
13 :    
14 :     type props = {
15 : jhr 3220 (* properties from the command line *)
16 : jhr 3223 diderotc : string, (* the diderotc command used to invoke this compiler *)
17 :     argv : string list, (* command-line arguments used to invoke this compiler *)
18 :     version : string, (* version message string for this compiler *)
19 : jhr 2086 (* properties from the target description *)
20 : jhr 2805 srcFile : string, (* source filename *)
21 :     outDir : string, (* directory to put output *)
22 :     outBase : string, (* basename for output or name of executable *)
23 :     exec : bool, (* generate standalone executable? *)
24 :     snapshot : bool, (* generate functions to get snapshots? *)
25 :     target : TargetUtil.target, (* target platform *)
26 :     namespace : string, (* optional namespace prefix *)
27 :     parallel : bool, (* parallel components? *)
28 :     double : bool, (* true for double-precision candidates *)
29 :     longint : bool, (* true for 64-bit integers (not currently used) *)
30 :     debug : bool, (* true if debugging of the target is enabled *)
31 :     bsp : bool, (* true if BSP style execution should always be used *)
32 : jhr 2086 (* properties from analysing the program *)
33 : jhr 2805 hasGlobals : bool, (* true if the program has global variables *)
34 :     hasInputs : bool, (* true if the program has input variables *)
35 : jhr 2786 isArray : bool, (* true for programs that use a fixed array of strands *)
36 : jhr 2805 hasDynSeq : bool, (* true for programs that have create dynamic sequences;
37 :     * this does not include programs that just load sequences
38 :     * from nrrd files. *)
39 :     hasStabilize : bool, (* true for programs with user-defined stabilize methods *)
40 :     hasDie : bool, (* true for programs that have "die" *)
41 :     hasNew : bool, (* true for programs that have "new" *)
42 :     hasCom : bool, (* true for programs that have strand communication *)
43 :     hasReduce : bool (* true for programs that have global reduce *)
44 : jhr 2086 }
45 :    
46 :     (* create the property record from the target description and program properties *)
47 : jhr 3220 fun mkProps (tgt : TargetUtil.target_desc, props : StrandUtil.program_prop list) : props =
48 : jhr 3223 {
49 :     diderotc = CommandLine.name(),
50 :     argv = CommandLine.arguments(),
51 :     version = #version tgt,
52 : jhr 2805 srcFile = #srcFile tgt,
53 :     outDir = #outDir tgt,
54 :     outBase = #outBase tgt,
55 :     exec = #exec tgt,
56 :     snapshot = #snapshot tgt,
57 :     target = #target tgt,
58 :     namespace = #namespace tgt,
59 :     parallel = #parallel tgt,
60 :     double = #double tgt,
61 :     longint = #longint tgt,
62 :     debug = #debug tgt,
63 :     bsp = #bsp tgt,
64 :     hasGlobals = StrandUtil.hasProp StrandUtil.HasGlobals props,
65 :     hasInputs = StrandUtil.hasProp StrandUtil.HasInputs props,
66 :     isArray = StrandUtil.hasProp StrandUtil.StrandArray props,
67 :     hasDynSeq = StrandUtil.hasProp StrandUtil.DynamicSeq props,
68 :     hasStabilize = StrandUtil.hasProp StrandUtil.HasStabilizeMethod props,
69 :     hasDie = StrandUtil.hasProp StrandUtil.StrandsMayDie props,
70 :     hasNew = StrandUtil.hasProp StrandUtil.NewStrands props,
71 :     hasCom = StrandUtil.hasProp StrandUtil.StrandCommunication props,
72 :     hasReduce = StrandUtil.hasProp StrandUtil.GlobalReduce props
73 :     }
74 : jhr 2086
75 :     (* returns false if BSP style execution should always be used;
76 :     * this property can be set on the command line, but
77 :     * also holds when program has communication, etc.
78 :     *)
79 :     fun noBSP (p : props) = not(#bsp p orelse #hasCom p orelse #hasReduce p)
80 :    
81 : jhr 2805 (* returns true if the program does not use inter-strand communication *)
82 :     fun noComm (p : props) = not(#hasCom p)
83 :    
84 : jhr 2086 (* return true if we need to keep two copies of the state: in and out. *)
85 :     fun dualState (p : props) = (#hasCom p)
86 :    
87 :     (* convert a target specification to the name of the runtime library *)
88 :     fun runtimeName (props : props) = let
89 : jhr 2805 val l = if #debug props then ["-debug.o"] else [".o"]
90 :     val l = if #parallel props then "-par"::l else l
91 :     val p = if #double props then "-d" else "-f"
92 :     val t = (case #target props
93 :     of TargetUtil.TARGET_C => "-c"
94 :     | TargetUtil.TARGET_CL => "-cl"
95 :     | TargetUtil.TARGET_CUDA => "-cuda"
96 :     (* end case *))
97 :     in
98 :     OS.Path.concat(
99 :     Paths.diderotLib(),
100 :     String.concat("diderot-rt" :: t :: p :: l))
101 :     end
102 : jhr 2086
103 :     (* return the CPP floating-point precision definition for the target *)
104 :     fun floatPrecisionDef (p : props) = if #double p
105 : jhr 2805 then "DIDEROT_DOUBLE_PRECISION"
106 :     else "DIDEROT_SINGLE_PRECISION"
107 : jhr 2086
108 :     (* return the CPP integer precision definition for the target *)
109 :     fun intPrecisionDef (p : props) = if #longint p
110 : jhr 2805 then "DIDEROT_LONGINT"
111 :     else "DIDEROT_INT"
112 : jhr 2086
113 :     (* return the CPP target definition for the target *)
114 :     fun targetDef (p : props) = (case #target p
115 : jhr 2805 of TargetUtil.TARGET_C => if #parallel p
116 :     then "DIDEROT_TARGET_PARALLEL"
117 :     else "DIDEROT_TARGET_C"
118 :     | TargetUtil.TARGET_CL => "DIDEROT_TARGET_CL"
119 :     | TargetUtil.TARGET_CUDA => "DIDEROT_TARGET_CUDA"
120 :     (* end case *))
121 : jhr 2086
122 :     end

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