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 2086 - (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 :     hasDie : bool, (* true for programs that have "die" *)
28 :     hasNew : bool, (* true for programs that have "new" *)
29 :     hasCom : bool, (* true for programs that have strand communication *)
30 :     hasReduce : bool (* true for programs that have global reduce *)
31 :     }
32 :    
33 :     (* create the property record from the target description and program properties *)
34 :     fun mkProps (tgt : TargetUtil.target_desc, props : StrandUtil.program_prop list) = {
35 :     srcFile = #srcFile tgt,
36 :     outDir = #outDir tgt,
37 :     outBase = #outBase tgt,
38 :     exec = #exec tgt,
39 :     snapshot = #snapshot tgt,
40 :     target = #target tgt,
41 :     namespace = #namespace tgt,
42 :     parallel = #parallel tgt,
43 :     double = #double tgt,
44 :     longint = #longint tgt,
45 :     debug = #debug tgt,
46 :     bsp = #bsp tgt,
47 :     hasDie = StrandUtil.hasProp StrandUtil.StrandsMayDie props,
48 :     hasNew = StrandUtil.hasProp StrandUtil.NewStrands props,
49 :     hasCom = StrandUtil.hasProp StrandUtil.StrandCommunication props,
50 :     hasReduce = StrandUtil.hasProp StrandUtil.GlobalReduce props
51 :     }
52 :    
53 :     (* returns false if BSP style execution should always be used;
54 :     * this property can be set on the command line, but
55 :     * also holds when program has communication, etc.
56 :     *)
57 :     fun noBSP (p : props) = not(#bsp p orelse #hasCom p orelse #hasReduce p)
58 :    
59 :     (* return true if we need to keep two copies of the state: in and out. *)
60 :     fun dualState (p : props) = (#hasCom p)
61 :    
62 :     (* convert a target specification to the name of the runtime library *)
63 :     fun runtimeName (props : props) = let
64 :     val l = if #debug props then ["-debug.o"] else [".o"]
65 :     val l = if #parallel props then "-par"::l else l
66 :     val p = if #double props then "-d" else "-f"
67 :     val t = (case #target props
68 :     of TargetUtil.TARGET_C => "-c"
69 :     | TargetUtil.TARGET_CL => "-cl"
70 :     | TargetUtil.TARGET_CUDA => "-cuda"
71 :     (* end case *))
72 :     in
73 :     OS.Path.concat(
74 :     Paths.diderotLib,
75 :     String.concat("diderot-rt" :: t :: p :: l))
76 :     end
77 :    
78 :     (* return the CPP floating-point precision definition for the target *)
79 :     fun floatPrecisionDef (p : props) = if #double p
80 :     then "DIDEROT_DOUBLE_PRECISION"
81 :     else "DIDEROT_SINGLE_PRECISION"
82 :    
83 :     (* return the CPP integer precision definition for the target *)
84 :     fun intPrecisionDef (p : props) = if #longint p
85 :     then "DIDEROT_LONGINT"
86 :     else "DIDEROT_INT"
87 :    
88 :     (* return the CPP target definition for the target *)
89 :     fun targetDef (p : props) = (case #target p
90 :     of TargetUtil.TARGET_C => if #parallel p
91 :     then "DIDEROT_TARGET_PARALLEL"
92 :     else "DIDEROT_TARGET_C"
93 :     | TargetUtil.TARGET_CL => "DIDEROT_TARGET_CL"
94 :     | TargetUtil.TARGET_CUDA => "DIDEROT_TARGET_CUDA"
95 :     (* end case *))
96 :    
97 :     end

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