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 2708 - (view) (download)

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

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