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

SCM Repository

[diderot] Annotation of /branches/vis12/src/compiler/cl-target/cl-target.sml
ViewVC logotype

Annotation of /branches/vis12/src/compiler/cl-target/cl-target.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2077 - (view) (download)

1 : jhr 1671 (* cl-target.sml
2 :     *
3 :     * COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu)
4 :     * All rights reserved.
5 :     *)
6 :    
7 :     structure CLTarget : TARGET =
8 :     struct
9 :    
10 :     structure IL = TreeIL
11 :     structure V = IL.Var
12 :     structure Ty = IL.Ty
13 :     structure CL = CLang
14 :     structure RN = RuntimeNames
15 : jhr 1853 structure N = CNames
16 : jhr 1671 structure ToCL = TreeToCL
17 : jhr 2077 structure SU = StrandUtil
18 : jhr 1671 structure HF = CLHeaderFrag
19 :     structure SF = CLSchedFrag
20 :    
21 :     (* revmap f l == List.rev(List.map f l) *)
22 :     fun revmap f = let
23 :     fun rmap ([], l) = l
24 :     | rmap (x::r, l) = rmap (r, f x :: l)
25 :     in
26 :     fn l => rmap (l, [])
27 :     end
28 :    
29 :     (* common arithmetic *)
30 :     fun #+# (a, b) = CL.mkBinOp(a, CL.#+, b)
31 :     fun #*# (a, b) = CL.mkBinOp(a, CL.#*, b)
32 :     infix 5 #+#
33 :     infix 6 #*#
34 :    
35 :     (* translate TreeIL types to shadow types *)
36 :     fun shadowTy ty = (case ty
37 :     of Ty.BoolTy => CL.T_Named "cl_uint"
38 :     | Ty.IntTy => CL.T_Named(RN.shadowIntTy ())
39 :     | Ty.TensorTy[] => CL.T_Named(RN.shadowRealTy ())
40 :     | Ty.TensorTy[n] => CL.T_Named(RN.shadowVecTy n)
41 :     | Ty.TensorTy[n, m] => CL.T_Named(RN.shadowMatTy(n,m))
42 : jhr 1793 | Ty.ImageTy info => CL.T_Named(RN.shadowImageTy(ImageInfo.dim info))
43 : jhr 1671 | _ => raise Fail(concat["TreeToC.trType(", Ty.toString ty, ")"])
44 :     (* end case *))
45 :    
46 :     (* FIXME: add comments that more clearly explain the difference between convertToShadow and
47 :     * convertStrandToShadow
48 :     *)
49 :     (* translate TreeIL types to shadow types *)
50 :     fun convertToShadow (ty, name) = (case ty
51 :     of Ty.IntTy => CL.mkAssign(
52 :     CL.mkSelect(CL.mkVar RN.shadowGlaobalsName, name),
53 :     CL.mkIndirect(CL.mkVar RN.globalsVarName, name))
54 :     | Ty.TensorTy[n]=> CL.mkCall(RN.convertToShadowVec n, [
55 :     CL.mkUnOp(CL.%&, CL.mkSelect(CL.mkVar RN.shadowGlaobalsName, name)),
56 :     CL.mkIndirect(CL.mkVar RN.globalsVarName, name)
57 :     ])
58 : jhr 1793 | Ty.ImageTy info => CL.mkCall(RN.shadowImageFunc(ImageInfo.dim info), [
59 : jhr 1671 CL.mkVar "context",
60 :     CL.mkUnOp(CL.%&, CL.mkSelect(CL.mkVar RN.shadowGlaobalsName, name)),
61 :     CL.mkIndirect(CL.mkVar RN.globalsVarName, name)
62 :     ])
63 :     | Ty.TensorTy[n, m] => CL.mkCall(RN.convertToShadowMat(m,n), [
64 :     CL.mkSelect(CL.mkVar RN.shadowGlaobalsName, name),
65 :     CL.mkIndirect(CL.mkVar RN.globalsVarName, name)
66 :     ])
67 :     | _ => CL.mkAssign(
68 :     CL.mkSelect(CL.mkVar RN.shadowGlaobalsName,name),
69 :     CL.mkIndirect(CL.mkVar RN.globalsVarName, name))
70 :     (* end case *))
71 :    
72 :     (* generate code to convert strand TreeIL types to shadow types *)
73 :     fun convertStrandToShadow (ty, name, selfIn, selfOut) = (case ty
74 :     of Ty.IntTy => CL.mkAssign(
75 :     CL.mkIndirect(CL.mkVar selfIn, name),
76 :     CL.mkIndirect(CL.mkVar selfOut, name))
77 :     | Ty.TensorTy[n]=> CL.mkCall(RN.convertToShadowVec n, [
78 :     CL.mkUnOp(CL.%&, CL.mkIndirect(CL.mkVar selfIn, name)),
79 :     CL.mkIndirect(CL.mkVar selfOut, name)
80 :     ])
81 :     | Ty.TensorTy[n, m] => CL.mkCall(RN.convertToShadowMat(m,n), [
82 :     CL.mkUnOp(CL.%&, CL.mkIndirect(CL.mkVar selfIn, name)),
83 :     CL.mkIndirect(CL.mkVar selfOut, name)
84 :     ])
85 :     | _ => CL.mkAssign(
86 :     CL.mkIndirect(CL.mkVar selfIn, name),
87 :     CL.mkIndirect(CL.mkVar selfOut, name))
88 :     (* end case *))
89 :    
90 :     (* helper functions for specifying parameters in various address spaces *)
91 : jhr 1853 fun clParam spc (ty, x) = CL.PARAM([spc], ty, x)
92 :     val globalParam = clParam "__global"
93 :     val constantParam = clParam "__constant"
94 :     val localParam = clParam "__local"
95 :     val privateParam = clParam "__private"
96 : jhr 1671
97 :     (* OpenCL global pointer type *)
98 :     fun globalPtr ty = CL.T_Qual("__global", CL.T_Ptr ty)
99 :    
100 :     (* lvalue/rvalue state variable *)
101 :     fun lvalueSV name = CL.mkIndirect(CL.mkVar "selfOut", name)
102 :     fun rvalueSV name = CL.mkIndirect(CL.mkVar "selfIn", name)
103 :    
104 :     (* C variable translation *)
105 :     structure TrCVar =
106 :     struct
107 :     type env = CL.typed_var TreeIL.Var.Map.map
108 :     fun lookup (env, x) = (case V.Map.find (env, x)
109 :     of SOME(CL.V(_, x')) => x'
110 :     | NONE => raise Fail(concat["TrCVar.lookup(_, ", V.name x, ")"])
111 :     (* end case *))
112 :     (* translate a variable that occurs in an l-value context (i.e., as the target of an assignment) *)
113 :     fun lvalueVar (env, x) = (case V.kind x
114 : jhr 1706 of IL.VK_Local => CL.mkVar(lookup(env, x))
115 :     | _ => CL.mkIndirect(CL.mkVar RN.globalsVarName, lookup(env, x))
116 : jhr 1671 (* end case *))
117 :     (* translate a variable that occurs in an r-value context *)
118 :     fun rvalueVar (env, x) = (case V.kind x
119 : jhr 1706 of IL.VK_Local => CL.mkVar(lookup(env, x))
120 :     | _ => CL.mkIndirect(CL.mkVar RN.globalsVarName, lookup(env, x))
121 : jhr 1671 (* end case *))
122 :     (* translate a strand state variable that occurs in an l-value context *)
123 :     fun lvalueStateVar (IL.SV{name, ...}) = lvalueSV name
124 :     (* translate a strand state variable that occurs in an r-value context *)
125 :     fun rvalueStateVar (IL.SV{name, ...}) = rvalueSV name
126 :     end
127 :    
128 :     structure ToC = TreeToCFn (TrCVar)
129 :    
130 :     type var = CL.typed_var
131 :     type exp = CL.exp
132 :     type stm = CL.stm
133 :    
134 :     (* OpenCL specific types *)
135 :     val clIntTy = CL.T_Named "cl_int"
136 :     val clProgramTy = CL.T_Named "cl_program"
137 :     val clKernelTy = CL.T_Named "cl_kernel"
138 :     val clCmdQueueTy = CL.T_Named "cl_command_queue"
139 :     val clContextTy = CL.T_Named "cl_context"
140 :     val clDeviceIdTy = CL.T_Named "cl_device_id"
141 :     val clPlatformIdTy = CL.T_Named "cl_platform_id"
142 :     val clMemoryTy = CL.T_Named "cl_mem"
143 :     val globPtrTy = CL.T_Ptr(CL.T_Named RN.globalsTy)
144 :     (* FIXME: what are these for? *)
145 :     datatype shadow_env = STRAND_SHADOW | GLOBAL_SHADOW
146 :    
147 :     (* variable or field that is mirrored between host and GPU *)
148 :     type mirror_var = {
149 :     (* FIXME: perhaps it would be cleaner to just track the TreeIL type of the variable? *)
150 :     hostTy : CL.ty, (* variable type on Host (i.e., C type) *)
151 :     shadowTy : CL.ty, (* host-side shadow type of GPU type *)
152 :     gpuTy : CL.ty, (* variable's type on GPU (i.e., OpenCL type) *)
153 :     hToS: stm, (* the statement that converts the variable to its *)
154 :     (* shadow representation *)
155 :     var : CL.var (* variable name *)
156 :     }
157 :    
158 :     datatype strand = Strand of {
159 :     name : string,
160 :     tyName : string,
161 :     state : mirror_var list,
162 :     output : (Ty.ty * CL.var), (* the strand's output variable (only one for now) *)
163 :     code : CL.decl list ref,
164 :     init_code: CL.decl ref
165 :     }
166 :    
167 :     datatype program = Prog of {
168 : jhr 1705 tgt : TargetUtil.target_desc, (* info about target *)
169 : jhr 2077 hasDie : bool, (* true for programs that have "die" *)
170 :     hasNew : bool, (* true for programs that have "new" *)
171 :     hasCom : bool, (* true for programs that have strand communication *)
172 :     hasReduce : bool, (* true for programs that have global reduce *)
173 : jhr 1671 globals : mirror_var list ref,
174 :     topDecls : CL.decl list ref,
175 :     strands : strand AtomTable.hash_table,
176 :     initially : CL.decl ref,
177 :     numDims: int ref, (* number of dimensions in initially iteration *)
178 :     imgGlobals: (string * int) list ref,
179 :     prFn: CL.decl ref,
180 :     outFn: CL.decl ref
181 :     }
182 :    
183 :     datatype env = ENV of {
184 :     info : env_info,
185 :     vMap : var V.Map.map,
186 :     scope : scope
187 :     }
188 :    
189 :     and env_info = INFO of {
190 :     prog : program
191 :     }
192 :    
193 :     and scope
194 :     = NoScope
195 :     | GlobalScope
196 :     | InitiallyScope
197 :     | StrandScope (* strand initialization *)
198 :     | MethodScope of StrandUtil.method_name (* method body; vars are state variables *)
199 :    
200 :     (* the supprted widths of vectors of reals on the target. *)
201 :     (* FIXME: for OpenCL 1.1, 3 is also valid *)
202 :     fun vectorWidths () = [2, 4, 8, 16]
203 :    
204 :     (* we do not support printing on the OpenCL target *)
205 :     val supportsPrinting = false
206 :    
207 :     (* tests for whether various expression forms can appear inline *)
208 :     fun inlineCons n = (n < 2) (* vectors are inline, but not matrices *)
209 :     val inlineMatrixExp = false (* can matrix-valued expressions appear inline? *)
210 :    
211 :     (* TreeIL to target translations *)
212 :     structure Tr =
213 :     struct
214 :     fun fragment (ENV{info, vMap, scope}, blk) = let
215 :     val (vMap, stms) = (case scope
216 :     of GlobalScope => ToC.trFragment (vMap, blk)
217 :     | InitiallyScope => ToC.trFragment (vMap, blk)
218 :     | _ => ToCL.trFragment (vMap, blk)
219 :     (* end case *))
220 :     in
221 :     (ENV{info=info, vMap=vMap, scope=scope}, stms)
222 :     end
223 :     fun block (ENV{vMap, scope, ...}, blk) = (case scope
224 :     of StrandScope => ToC.trBlock (vMap, blk)
225 :     | MethodScope name => ToCL.trBlock (vMap, blk)
226 :     | InitiallyScope => ToCL.trBlock (vMap, blk)
227 :     | _ => ToC.trBlock (vMap, blk)
228 :     (* end case *))
229 : nseltzer 1870 fun free (ENV{vMap, ...}, blk) = ToC.trFree (vMap, blk)
230 : jhr 1671 fun exp (ENV{vMap, ...}, e) = ToCL.trExp(vMap, e)
231 :     end
232 :    
233 :     (* variables *)
234 :     structure Var =
235 :     struct
236 :     fun mirror (ty, name, shadowEnv) = {
237 :     hostTy = ToC.trType ty,
238 :     shadowTy = shadowTy ty,
239 :     gpuTy = ToCL.trType ty,
240 :     hToS = case shadowEnv
241 :     of GLOBAL_SHADOW => convertToShadow (ty, name)
242 :     | STRAND_SHADOW => convertStrandToShadow(ty, name, "selfIn", "selfOut")
243 :     (* end case *),
244 :     var = name
245 :     }
246 :     fun name (ToCL.V(_, name)) = name
247 :     fun global (Prog{globals, imgGlobals, ...}, name, ty) = let
248 :     val x = mirror (ty, name, GLOBAL_SHADOW)
249 : jhr 1793 fun isImgGlobal (Ty.ImageTy info, name) =
250 :     imgGlobals := (name, ImageInfo.dim info) :: !imgGlobals
251 : jhr 1671 | isImgGlobal _ = ()
252 :     in
253 :     globals := x :: !globals;
254 :     isImgGlobal (ty, name);
255 :     ToCL.V(#gpuTy x, name)
256 :     end
257 :     fun param x = ToCL.V(ToCL.trType(V.ty x), V.name x)
258 :     end
259 :    
260 :     (* environments *)
261 :     structure Env =
262 :     struct
263 :     (* create a new environment *)
264 :     fun new prog = ENV{
265 :     info=INFO{prog = prog},
266 :     vMap = V.Map.empty,
267 :     scope = NoScope
268 :     }
269 :     (* define the current translation context *)
270 :     fun setScope scope (ENV{info, vMap, ...}) = ENV{info=info, vMap=vMap, scope=scope}
271 :     val scopeGlobal = setScope GlobalScope
272 :     val scopeInitially = setScope InitiallyScope
273 :     fun scopeStrand env = setScope StrandScope env
274 :     fun scopeMethod (env, name) = setScope (MethodScope name) env
275 :     (* bind a TreeIL varaiable to a target variable *)
276 :     fun bind (ENV{info, vMap, scope}, x, x') = ENV{
277 :     info = info,
278 :     vMap = V.Map.insert(vMap, x, x'),
279 :     scope = scope
280 :     }
281 :     end
282 :    
283 : jhr 1853 (* strands *)
284 :     structure Strand =
285 :     struct
286 :    
287 :     fun define (Prog{strands, ...}, strandId, state) = let
288 :     val name = Atom.toString strandId
289 :     (* the output state variable *)
290 :     val outputVar = (case List.filter IL.StateVar.isOutput state
291 :     of [] => raise Fail("no output specified for strand " ^ name)
292 :     | [x] => (IL.StateVar.ty x, IL.StateVar.name x)
293 :     | _ => raise Fail("multiple outputs in " ^ name)
294 :     (* end case *))
295 :     (* the state variables *)
296 :     val state = let
297 :     fun cvt x = Var.mirror (IL.StateVar.ty x, IL.StateVar.name x, STRAND_SHADOW)
298 :     in
299 :     List.map cvt state
300 :     end
301 :     val strand = Strand{
302 :     name = name,
303 :     tyName = RN.strandTy name,
304 :     state = state,
305 :     output = outputVar,
306 :     code = ref [],
307 :     init_code = ref (CL.D_Comment(["no init code"]))
308 :     }
309 :     in
310 :     AtomTable.insert strands (strandId, strand);
311 :     strand
312 :     end
313 :    
314 :     (* return the strand with the given name *)
315 :     fun lookup (Prog{strands, ...}, strandId) = AtomTable.lookup strands strandId
316 :    
317 :     (* register the strand-state initialization code. The variables are the strand
318 :     * parameters.
319 :     *)
320 :     fun init (Strand{name, tyName, code, init_code, ...}, params, init) = let
321 :     val fName = RN.strandInit name
322 :     val params =
323 :     clParam "" (CL.T_Ptr(CL.T_Named tyName), "selfOut") ::
324 :     List.map (fn (ToCL.V(ty, x)) => CL.PARAM([], ty, x)) params
325 :     val initFn = CL.D_Func([], CL.voidTy, fName, params, init)
326 :     in
327 :     init_code := initFn
328 :     end
329 :    
330 :     (* register a strand method *)
331 :     fun method (Strand{name, tyName, code,...}, methName, body) = let
332 :     val params = [
333 :     globalParam (CL.T_Ptr(CL.T_Named tyName), "selfIn"),
334 :     globalParam (CL.T_Ptr(CL.T_Named tyName), "selfOut"),
335 :     globalParam (CL.T_Ptr(CL.T_Named (RN.globalsTy)), RN.globalsVarName),
336 :     clParam "" (CL.T_Named(RN.imageDataType), RN.globalImageDataName)
337 :     ]
338 :     val (fName,resTy) = (case methName
339 :     of StrandUtil.Update => (RN.strandUpdate,CL.T_Named "StrandStatus_t")
340 :     | StrandUtil.Stabilize => (name ^ StrandUtil.nameToString methName, CL.voidTy)
341 :     (* end case *))
342 :     val methFn = CL.D_Func([], resTy, fName, params, body)
343 :     in
344 :     code := methFn :: !code
345 :     end
346 :    
347 :     end (* Strand *)
348 :    
349 : jhr 1671 (* programs *)
350 :     structure Program =
351 :     struct
352 : jhr 2076 fun new (tgt : TargetUtil.target_desc, props) = (
353 : jhr 1705 RN.initTargetSpec (#double tgt);
354 :     CNames.initTargetSpec {double = #double tgt, long = false};
355 : jhr 1671 Prog{
356 : jhr 1705 tgt = tgt,
357 : jhr 2077 hasDie = SU.hasProp SU.StrandsMayDie props,
358 :     hasNew = SU.hasProp SU.NewStrands props,
359 :     hasCom = SU.hasProp SU.StrandCommunication props,
360 :     hasReduce = SU.hasProp SU.GlobalReduce props,
361 : jhr 1671 globals = ref [],
362 :     topDecls = ref [],
363 :     strands = AtomTable.mkTable (16, Fail "strand table"),
364 :     initially = ref(CL.D_Comment["missing initially"]),
365 :     numDims = ref 0,
366 :     imgGlobals = ref[],
367 :     prFn = ref(CL.D_Comment(["No Print Function"])),
368 :     outFn = ref(CL.D_Comment(["No Output Function"]))
369 :     })
370 :    
371 :     (* register the code that is used to register command-line options for input variables *)
372 : jhr 1803 fun inputs (Prog{topDecls, ...}, env, blk) = let
373 : jhr 1671 val inputsFn = CL.D_Func(
374 :     [], CL.voidTy, RN.registerOpts,
375 :     [CL.PARAM([], CL.T_Ptr(CL.T_Named RN.optionsTy), "opts")],
376 : jhr 1803 Tr.block (env, blk))
377 : jhr 1671 in
378 :     topDecls := inputsFn :: !topDecls
379 :     end
380 :    
381 :     (* register the global initialization part of a program *)
382 :     fun init (Prog{topDecls, ...}, init) = let
383 :     val globalsDecl = CL.mkAssign(CL.mkVar RN.globalsVarName,
384 :     CL.mkApply("malloc", [CL.mkSizeof(CL.T_Named RN.globalsTy)]))
385 :     val initFn = CL.D_Func(
386 :     [], CL.voidTy, RN.initGlobals, [],
387 :     CL.mkBlock[
388 :     globalsDecl,
389 :     CL.mkCall(RN.initGlobalsHelper, [CL.mkVar RN.globalsVarName])
390 :     ])
391 :     val initHelperFn = CL.D_Func(
392 :     [], CL.voidTy, RN.initGlobalsHelper,
393 :     [CL.PARAM([], globPtrTy, RN.globalsVarName)],
394 :     init)
395 :     val shutdownFn = CL.D_Func(
396 :     [], CL.voidTy, RN.shutdown,
397 :     [CL.PARAM([], CL.T_Ptr(CL.T_Named RN.worldTy), "wrld")],
398 :     CL.S_Block[])
399 :     in
400 :     topDecls := shutdownFn :: initFn :: initHelperFn :: !topDecls
401 :     end
402 : nseltzer 1870 (* register the global destruction part of a program *)
403 :     fun free (Prog{tgt, topDecls, ...}, free) = let
404 :     val worldTy = CL.T_Ptr(CL.T_Named(N.worldTy tgt))
405 :     val globTy = CL.T_Ptr(CL.T_Named(N.globalTy tgt))
406 :     val free = CL.mkBlock(
407 :     CL.mkDeclInit(globTy, "glob", CL.mkIndirect(CL.mkVar "wrld", "globals")) ::
408 :     CL.unBlock free @ [CL.mkReturn(SOME(CL.mkVar "false"))])
409 :     val freeFn = CL.D_Func(
410 :     ["static"], CL.boolTy, N.freeGlobals,
411 :     [CL.PARAM([], worldTy, "wrld")],
412 :     free)
413 :     in
414 :     topDecls := freeFn :: !topDecls
415 :     end
416 : jhr 1671
417 :     (* create and register the initially function for a program *)
418 :     fun initially {
419 : jhr 1718 prog = Prog{tgt, strands, initially, numDims, ...},
420 : jhr 1671 isArray : bool,
421 :     iterPrefix : stm list,
422 :     iters : (var * exp * exp) list,
423 :     createPrefix : stm list,
424 :     strand : Atom.atom,
425 :     args : exp list
426 :     } = let
427 :     val name = Atom.toString strand
428 :     val nDims = List.length iters
429 : jhr 1718 val worldTy = CL.T_Ptr(CL.T_Named(N.worldTy tgt))
430 : jhr 1671 fun mapi f xs = let
431 :     fun mapf (_, []) = []
432 :     | mapf (i, x::xs) = f(i, x) :: mapf(i+1, xs)
433 :     in
434 :     mapf (0, xs)
435 :     end
436 :     val baseInit = mapi (fn (i, (_, e, _)) => (i, CL.I_Exp e)) iters
437 :     val sizeInit = mapi
438 :     (fn (i, (CL.V(ty, _), lo, hi)) =>
439 :     (i, CL.I_Exp(CL.mkBinOp(hi, CL.#-, lo) #+# CL.mkIntTy(1, ty)))
440 :     ) iters
441 :     (* code to allocate the world and initial strands *)
442 :     val wrld = "wrld"
443 :     val allocCode = [
444 :     CL.mkComment["allocate initial block of strands"],
445 :     CL.mkDecl(CL.T_Array(CL.int32, SOME nDims), "base", SOME(CL.I_Array baseInit)),
446 :     CL.mkDecl(CL.T_Array(CL.uint32, SOME nDims), "size", SOME(CL.I_Array sizeInit)),
447 :     CL.mkDecl(worldTy, wrld,
448 :     SOME(CL.I_Exp(CL.mkApply(N.allocInitially, [
449 :     CL.mkVar "ProgramName",
450 :     CL.mkUnOp(CL.%&, CL.mkVar(N.strandDesc name)),
451 :     CL.mkBool isArray,
452 :     CL.mkIntTy(IntInf.fromInt nDims, CL.int32),
453 :     CL.mkVar "base",
454 :     CL.mkVar "size"
455 :     ]))))
456 :     ]
457 :     (* create the loop nest for the initially iterations *)
458 :     val indexVar = "ix"
459 :     val strandTy = CL.T_Ptr(CL.T_Named(N.strandTy name))
460 :     fun mkLoopNest [] = CL.mkBlock(createPrefix @ [
461 :     CL.mkDecl(strandTy, "sp",
462 :     SOME(CL.I_Exp(
463 :     CL.mkCast(strandTy,
464 :     CL.mkApply(N.inState, [CL.mkVar "wrld", CL.mkVar indexVar]))))),
465 :     CL.mkCall(N.strandInit name, CL.mkVar "sp" :: args),
466 :     CL.mkAssign(CL.mkVar indexVar, CL.mkVar indexVar #+# CL.mkIntTy(1, CL.uint32))
467 :     ])
468 :     | mkLoopNest ((CL.V(ty, param), lo, hi)::iters) = let
469 :     val body = mkLoopNest iters
470 :     in
471 :     CL.mkFor(
472 :     [(ty, param, lo)],
473 :     CL.mkBinOp(CL.mkVar param, CL.#<=, hi),
474 :     [CL.mkPostOp(CL.mkVar param, CL.^++)],
475 :     body)
476 :     end
477 :     val iterCode = [
478 :     CL.mkComment["initially"],
479 :     CL.mkDecl(CL.uint32, indexVar, SOME(CL.I_Exp(CL.mkIntTy(0, CL.uint32)))),
480 :     mkLoopNest iters
481 :     ]
482 :     val body = CL.mkBlock(
483 :     iterPrefix @
484 :     allocCode @
485 :     iterCode @
486 :     [CL.mkReturn(SOME(CL.mkVar "wrld"))])
487 : jhr 1718 val initFn = CL.D_Func([], worldTy, N.initially tgt, [], body)
488 : jhr 1671 in
489 :     numDims := nDims;
490 :     initially := initFn
491 :     end
492 :    
493 :    
494 :     (***** OUTPUT *****)
495 :    
496 :     fun genStrandPrint (Strand{name, tyName, state, output, code, ...}) = let
497 :     (* the print function *)
498 :     val prFnName = concat[name, "Print"]
499 :     val prFn = let
500 :     val params = [
501 :     CL.PARAM([], CL.T_Ptr(CL.T_Named "FILE"), "outS"),
502 :     CL.PARAM([], CL.T_Ptr(CL.T_Named(RN.strandShadowTy tyName)), "self")
503 :     ]
504 :     val (ty, x) = output
505 :     val outState = CL.mkIndirect(CL.mkVar "self", x)
506 :     val prArgs = (case ty
507 :     of Ty.IntTy => [CL.mkStr(!N.gIntFormat ^ "\n"), outState]
508 :     | Ty.SeqTy(Ty.IntTy, d) => let
509 :     fun sel i = CL.mkApply(
510 :     "VSUB",
511 :     [outState, CL.mkInt(IntInf.fromInt i)])
512 :     val fmt = CL.mkStr(
513 :     String.concatWith " " (List.tabulate(d, fn _ => !N.gIntFormat))
514 :     ^ "\n")
515 :     val args = List.tabulate (d, sel)
516 :     in
517 :     fmt :: args
518 :     end
519 :     | Ty.TensorTy[] => [CL.mkStr "%f\n", outState]
520 :     | Ty.TensorTy[d] => let
521 :     fun sel i = CL.mkApply(
522 :     "VSUB",
523 :     [outState, CL.mkInt(IntInf.fromInt i)])
524 :     val fmt = CL.mkStr(
525 :     String.concatWith " " (List.tabulate(d, fn _ => "%f"))
526 :     ^ "\n")
527 :     val args = List.tabulate (d, sel)
528 :     in
529 :     fmt :: args
530 :     end
531 :     | _ => raise Fail("genStrand: unsupported output type " ^ Ty.toString ty)
532 :     (* end case *))
533 :     in
534 :     CL.D_Func(["static"], CL.voidTy, prFnName, params,
535 :     CL.mkCall("fprintf", CL.mkVar "outS" :: prArgs))
536 :     end
537 :     in
538 :     prFn
539 :     end
540 :    
541 : jhr 1705 fun genStrandTyDef (targetTy,Strand{state,...}, tyName) = (case state
542 :     of [] => CL.D_Comment(["No Strand Defintiion Included"])
543 : jhr 1716 | _ => CL.D_StructDef(
544 :     NONE,
545 :     revmap (fn x => (targetTy x, #var x)) state,
546 :     SOME tyName)
547 : jhr 1705 (* end case *))
548 : jhr 1671
549 :     (* generates the globals buffers and arguments function *)
550 :     fun genConvertShadowTypes (Strand{name, tyName, state,...}) = let
551 : jhr 1705 (* Declare opencl setup objects *)
552 : jhr 1671 val errVar = "err"
553 :     val params = [
554 :     CL.PARAM([], CL.T_Ptr(CL.T_Named tyName), "selfOut"),
555 :     CL.PARAM([], CL.T_Ptr(CL.T_Named(RN.strandShadowTy tyName)), "selfIn")
556 :     ]
557 :     val body = List.map (fn (x:mirror_var) => #hToS x) state
558 :     in
559 :     CL.D_Func([], CL.voidTy, RN.strandConvertName name, params, CL.mkBlock body)
560 :     end
561 :    
562 :     (* generates the opencl buffers for the image data *)
563 :     fun getGlobalDataBuffers (globals, imgGlobals, contextVar, errVar) = let
564 :     val globalBuffErr = "error creating OpenCL global buffer\n"
565 :     fun errorFn msg = CL.mkIfThen(CL.mkBinOp(CL.mkVar errVar, CL.#!=, CL.mkVar "CL_SUCCESS"),
566 :     CL.mkBlock([CL.mkCall("fprintf",[CL.mkVar "stderr", CL.mkStr msg]),
567 :     CL.mkCall("exit",[CL.mkInt 1])]))
568 :     val shadowTypeDecl =
569 :     CL.mkDecl(CL.T_Named(RN.shadowGlobalsTy), RN.shadowGlaobalsName, NONE)
570 :     val globalToShadowStms = List.map (fn (x:mirror_var) => #hToS x) globals
571 :     val globalBufferDecl = CL.mkDecl(clMemoryTy,concat[RN.globalsVarName,"_cl"],NONE)
572 :     val globalBuffer = CL.mkAssign(CL.mkVar(concat[RN.globalsVarName,"_cl"]),
573 :     CL.mkApply("clCreateBuffer", [
574 :     CL.mkVar contextVar,
575 :     CL.mkBinOp(CL.mkVar "CL_MEM_READ_ONLY", CL.#|, CL.mkVar "CL_MEM_COPY_HOST_PTR"),
576 :     CL.mkSizeof(CL.T_Named RN.shadowGlobalsTy),
577 :     CL.mkUnOp(CL.%&,CL.mkVar RN.shadowGlaobalsName),
578 :     CL.mkUnOp(CL.%&,CL.mkVar errVar)
579 :     ]))
580 :     fun genDataBuffers ([],_,_,_) = []
581 :     | genDataBuffers ((var,nDims)::globals, contextVar, errVar,errFn) = let
582 :     val hostVar = CL.mkIndirect(CL.mkVar RN.globalsVarName, var)
583 :     val size = CL.mkIndirect(hostVar, "dataSzb")
584 :     in
585 :     CL.mkDecl(clMemoryTy, RN.addBufferSuffixData var ,NONE) ::
586 :     CL.mkAssign(CL.mkVar(RN.addBufferSuffixData var),
587 :     CL.mkApply("clCreateBuffer", [
588 :     CL.mkVar contextVar,
589 :     CL.mkVar "CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR",
590 :     size,
591 :     CL.mkIndirect(hostVar, "data"),
592 :     CL.mkUnOp(CL.%&,CL.mkVar errVar)
593 :     ])) ::
594 :     errFn(concat["error in creating ",RN.addBufferSuffixData var, " global buffer\n"]) ::
595 :     genDataBuffers(globals,contextVar,errVar,errFn)
596 :     end
597 :     in
598 :     [shadowTypeDecl] @ globalToShadowStms
599 :     @ [globalBufferDecl, globalBuffer,errorFn(globalBuffErr)]
600 :     @ genDataBuffers(imgGlobals,contextVar,errVar,errorFn)
601 :     end
602 :    
603 :     (* generates the kernel arguments for the image data *)
604 :     fun genGlobalArguments (globals, count, kernelVar, errVar) = let
605 :     val globalArgErr = "error creating OpenCL global argument\n"
606 :     fun errorFn msg = CL.mkIfThen(CL.mkBinOp(CL.mkVar errVar, CL.#!=, CL.mkVar "CL_SUCCESS"),
607 :     CL.mkBlock([CL.mkCall("fprintf",[CL.mkVar "stderr", CL.mkStr msg]),
608 :     CL.mkCall("exit",[CL.mkInt 1])]))
609 :     val globalArgument = CL.mkExpStm(CL.mkAssignOp(CL.mkVar errVar,CL.&=,
610 :     CL.mkApply("clSetKernelArg",
611 :     [CL.mkVar kernelVar,
612 :     CL.mkPostOp(CL.mkVar count, CL.^++),
613 :     CL.mkApply("sizeof",[CL.mkVar "cl_mem"]),
614 :     CL.mkUnOp(CL.%&,CL.mkVar(concat[RN.globalsVarName,"_cl"]))])))
615 :     fun genDataArguments ([],_,_,_,_) = []
616 :     | genDataArguments ((var,nDims)::globals,count,kernelVar,errVar,errFn) =
617 :     CL.mkExpStm(CL.mkAssignOp(CL.mkVar errVar,CL.$=,
618 :     CL.mkApply("clSetKernelArg",
619 :     [CL.mkVar kernelVar,
620 :     CL.mkPostOp(CL.mkVar count, CL.^++),
621 :     CL.mkApply("sizeof",[CL.mkVar "cl_mem"]),
622 :     CL.mkUnOp(CL.%&,CL.mkVar(RN.addBufferSuffixData var))]))) ::
623 :     errFn(concat["error in creating ",RN.addBufferSuffixData var, " argument\n"]) ::
624 :     genDataArguments (globals,count,kernelVar,errVar,errFn)
625 :     in
626 :     globalArgument :: errorFn globalArgErr ::
627 :     genDataArguments(globals, count, kernelVar, errVar,errorFn)
628 :     end
629 :    
630 :     (* generates the globals buffers and arguments function *)
631 :     fun genGlobalBuffersArgs (globals,imgGlobals) = let
632 :     (* Delcare opencl setup objects *)
633 :     val errVar = "err"
634 :     val params = [
635 :     CL.PARAM([],CL.T_Named("cl_context"), "context"),
636 :     CL.PARAM([],CL.T_Named("cl_kernel"), "kernel"),
637 :     CL.PARAM([],CL.T_Named("cl_command_queue"), "cmdQ"),
638 :     CL.PARAM([],CL.T_Named("int"), "argStart")
639 :     ]
640 :     val body = (case globals
641 :     of [] => [CL.mkReturn(NONE)]
642 :     | _ => let
643 :     val clGlobalBuffers =
644 :     getGlobalDataBuffers(globals, !imgGlobals, "context", errVar)
645 :     val clGlobalArguments =
646 :     genGlobalArguments(!imgGlobals, "argStart", "kernel", errVar)
647 :     in
648 :     (* Body: put all the statments together *)
649 :     CL.mkDecl(clIntTy, errVar, SOME(CL.I_Exp(CL.mkInt 0)))
650 :     :: clGlobalBuffers @ clGlobalArguments
651 :     end
652 :     (*end of case*))
653 :     in
654 :     CL.D_Func([],CL.voidTy,RN.globalsSetupName,params,CL.mkBlock(body))
655 :     end
656 :    
657 :     (* generate the global image meta-data and data parameters *)
658 :     fun genKeneralGlobalParams ((name,tyname)::[],line) =
659 :     concat[line, "__global void *", RN.addBufferSuffixData name]
660 :     | genKeneralGlobalParams ([],line) = line
661 :     | genKeneralGlobalParams ((name,tyname)::rest, line) =
662 :     genKeneralGlobalParams(rest, concat[line, "__global void *", RN.addBufferSuffixData name, ",\n"])
663 :    
664 :     fun genUpdateMethod (Strand{name, tyName, state,...}, globals, imgGlobals) = let
665 :     val imageDataStms = List.map
666 :     (fn (x,_) => concat[
667 :     RN.globalImageDataName, ".", RN.imageDataName x, " = ",
668 :     RN.addBufferSuffixData x, ";","\n"
669 :     ])
670 :     (!imgGlobals)
671 :     fun select ([], a, _) = a
672 :     | select (_, _, b) = b
673 :     val placeHolders = [
674 :     (RN.place_holders, tyName),
675 :     (RN.p_addDatPtr, select (!imgGlobals, "", ",")),
676 :     (RN.p_addGlobals, select (!globals, "", ",")),
677 :     (RN.p_globals, select (!globals, "", "__global Diderot_Globals_t *diderotGlobals")),
678 :     (RN.p_globalVar, select (!globals, "0", RN.globalsVarName)),
679 :     (RN.p_dataVar, select (!globals, "0", RN.globalImageDataName)),
680 :     (RN.p_dataPtr, genKeneralGlobalParams (!imgGlobals, "")),
681 :     (RN.p_dataAssign, select (!imgGlobals, "",
682 :     String.concat("Diderot_data_ptr_t diderotDataPtrs;\n" :: imageDataStms)))
683 :     ]
684 :     in
685 :     CL.verbatim [CLUpdateFrag.text] placeHolders
686 :     end
687 :    
688 :     fun genStrandCopy(Strand{tyName,name,state,...}) = let
689 :     val params = [
690 :     CL.PARAM(["__global"], CL.T_Ptr(CL.T_Named tyName), "selfIn"),
691 :     CL.PARAM(["__global"], CL.T_Ptr(CL.T_Named tyName), "selfOut")
692 :     ]
693 :     val assignStms = List.rev(
694 :     List.map
695 :     (fn x => CL.mkAssign(lvalueSV(#var x), rvalueSV(#var x)))
696 :     state)
697 :     in
698 :     CL.D_Func([""], CL.voidTy, RN.strandCopy, params,CL.mkBlock(assignStms))
699 :     end
700 :    
701 :     (* generate a global structure type definition from the list of globals *)
702 :     fun genGlobalStruct (_, [], _) = CL.D_Comment(["No Global Definition"])
703 :     | genGlobalStruct (targetTy, globals, tyName) = let
704 :     val globs = List.map (fn (x : mirror_var) => (targetTy x, #var x)) globals
705 :     in
706 : jhr 1716 CL.D_StructDef(NONE, globs, SOME tyName)
707 : jhr 1671 end
708 :    
709 :     (* generate a global structure type definition from the image data of the image globals *)
710 :     fun genImageDataStruct ([], _) = CL.D_Comment(["No Image Data Ptrs Definition"])
711 :     | genImageDataStruct (imgGlobals, tyName) = let
712 :     val globs = List.map
713 :     (fn (x, _) => (globalPtr CL.voidTy, RN.imageDataName x))
714 :     imgGlobals
715 :     in
716 : jhr 1716 CL.D_StructDef(NONE, globs, SOME tyName)
717 : jhr 1671 end
718 :    
719 :     fun genGlobals (declFn, targetTy, globals) = let
720 :     fun doVar (x : mirror_var) = declFn (CL.D_Var([], targetTy x, #var x, NONE))
721 :     in
722 :     List.app doVar globals
723 :     end
724 :    
725 :     fun genOutputFun(Strand{name, output,tyName, state, code,...}) = let
726 :     (* the output function *)
727 :     val outFnName = concat[name, "_Output"]
728 :     val outFun = let
729 :     val params = [
730 :     CL.PARAM([], CL.T_Ptr CL.voidTy, "outS"),
731 :     CL.PARAM([], CL.T_Ptr(CL.T_Named tyName), "self")
732 :     ]
733 :     (* the type and access expression for the strand's output variable *)
734 :     val (outTy, outState) = (#1 output, CL.mkIndirect(CL.mkVar "self", #2 output))
735 :     val outState = CL.mkUnOp(CL.%&, outState)
736 :     in
737 :     CL.D_Func(["static"], CL.voidTy, outFnName, params,
738 :     CL.mkCall("memcpy", [CL.mkVar "outS", outState, CL.mkSizeof(shadowTy outTy)] ))
739 :     end
740 :     in
741 :     outFun
742 :     end
743 :    
744 :     fun genStrandDesc (outFn,Strand{name, output,tyName, state, code,...}) = let
745 :     (* the output function *)
746 :     val outFnName = concat[name, "_Output"]
747 :     (* the strand's descriptor object *)
748 :     val descI = let
749 :     fun fnPtr (ty, f) = CL.I_Exp(CL.mkCast(CL.T_Named ty, CL.mkVar f))
750 :     val (outTy, _) = output
751 :     in
752 :     CL.I_Struct[
753 :     ("name", CL.I_Exp(CL.mkStr name)),
754 :     ("stateSzb", CL.I_Exp(CL.mkSizeof(CL.T_Named(RN.strandTy name)))),
755 :     ("shadowStrandSzb", CL.I_Exp(CL.mkSizeof(CL.T_Named(RN.strandShadowTy (RN.strandTy name))))),
756 :     (* FIXME: we may need to add a shadowOutputSzb field too for OpenCL *)
757 :     ("outputSzb", CL.I_Exp(CL.mkSizeof(shadowTy outTy))),
758 : jhr 1789 (* DEPRECATED
759 : jhr 1671 ("nrrdType", CL.I_Exp(CL.mkInt (NrrdTypes.toNrrdType outTy))),
760 : jhr 1789 ("nrrdSzb", CL.I_Exp(CL.mkInt (NrrdTypes.toNrrdSize outTy))),
761 :     *)
762 : jhr 1671 ("update", fnPtr("update_method_t", "0")),
763 :     ("strandCopy", fnPtr("convert_method_t", RN.strandConvertName name)),
764 :     ("print", fnPtr("print_method_t", RN.strandPrintName name)),
765 :     ("output", fnPtr("output_method_t", outFnName)) (* FIXME *)
766 :     ]
767 :     end
768 :     val desc = CL.D_Var([], CL.T_Named N.strandDescTy, N.strandDesc name, SOME descI)
769 :     in
770 :     desc
771 :     end
772 :    
773 :     (* generate the table of strand descriptors *)
774 :     fun genStrandTable (declFn, strands) = let
775 :     val nStrands = length strands
776 :     fun genInit (Strand{name, ...}) = CL.I_Exp(CL.mkUnOp(CL.%&, CL.mkVar(N.strandDesc name)))
777 :     fun genInits (_, []) = []
778 :     | genInits (i, s::ss) = (i, genInit s) :: genInits(i+1, ss)
779 :     in
780 :     declFn (CL.D_Var([], CL.int32, N.numStrands,
781 :     SOME(CL.I_Exp(CL.mkIntTy(IntInf.fromInt nStrands, CL.int32)))));
782 :     declFn (CL.D_Var([],
783 :     CL.T_Array(CL.T_Ptr(CL.T_Named N.strandDescTy), SOME nStrands),
784 :     N.strands,
785 :     SOME(CL.I_Array(genInits (0, strands)))))
786 :     end
787 :    
788 :     fun genSrc (baseName, prog) = let
789 :     val Prog{
790 : jhr 1713 tgt,
791 : jhr 1705 globals, topDecls, strands, initially,
792 : jhr 1671 imgGlobals, numDims,outFn, ...
793 :     } = prog
794 :     val clFileName = OS.Path.joinBaseExt{base=baseName, ext=SOME "cl"}
795 :     val cFileName = OS.Path.joinBaseExt{base=baseName, ext=SOME "c"}
796 :     val clOutS = TextIO.openOut clFileName
797 :     val cOutS = TextIO.openOut cFileName
798 :     val clppStrm = PrintAsCL.new clOutS
799 :     val cppStrm = PrintAsC.new cOutS
800 :     fun cppDecl dcl = PrintAsC.output(cppStrm, dcl)
801 :     fun clppDecl dcl = PrintAsCL.output(clppStrm, dcl)
802 :     val strands = AtomTable.listItems strands
803 :     val [strand as Strand{name, tyName, code, init_code, ...}] = strands
804 :     in
805 :     (* Generate the OpenCL file *)
806 :     (* Retrieve the header information *)
807 :     clppDecl (CL.verbatim [HF.text] [
808 :     ("OUTFILE", clFileName),
809 :     ("SRCFILE", OS.Path.joinBaseExt{base=baseName, ext=SOME "diderot"}),
810 : jhr 1713 ("DIDEROT_FLOAT_PRECISION", TargetUtil.floatPrecisionDef tgt),
811 :     ("DIDEROT_INT_PRECISION", TargetUtil.intPrecisionDef tgt)
812 : jhr 1671 ]);
813 :     (* if there are no globals, then define a dummy type *)
814 :     if List.null(!globals)
815 :     then clppDecl (CL.D_Verbatim["typedef void ", RN.globalsTy, ";\n"])
816 :     else ();
817 :     (* if there are no images, then define a dummy type *)
818 :     if List.null(!imgGlobals)
819 :     then clppDecl (CL.D_Verbatim["typedef void * ", RN.imageDataType, ";\n"])
820 :     else ();
821 :     (* Retrieve the scheduler kernels and functions *)
822 :     clppDecl (CL.D_Verbatim[SF.text]);
823 :     clppDecl (CL.D_Verbatim[CLEigen2x2Frag.text]);
824 :     clppDecl (CL.D_Verbatim[CLEigen3x3Frag.text]);
825 :     clppDecl (genGlobalStruct (#gpuTy, !globals, RN.globalsTy));
826 :     clppDecl (genImageDataStruct(!imgGlobals, RN.imageDataType));
827 :     clppDecl (genStrandTyDef(#gpuTy, strand, tyName));
828 :     List.app clppDecl (!code);
829 :     clppDecl (genStrandCopy strand);
830 :     clppDecl (genUpdateMethod(strand, globals, imgGlobals));
831 :     (* Generate the Host C file *)
832 :     cppDecl (CL.D_Verbatim[
833 : jhr 1713 concat["#define " ^ TargetUtil.floatPrecisionDef tgt, "\n"],
834 :     concat["#define " ^ TargetUtil.intPrecisionDef tgt, "\n"],
835 :     concat["#define " ^ TargetUtil.targetDef tgt, "\n"],
836 : jhr 1671 "#include \"Diderot/diderot.h\"\n"
837 : jhr 1705 ]);
838 :     case !globals
839 :     of [] => cppDecl (CL.D_Verbatim[concat["typedef void ", RN.globalsTy, ";\n"] ])
840 :     | _ => ()
841 :     (* end case *);
842 : jhr 1671 cppDecl (CL.D_Var(["static"], CL.charPtr, "ProgramName",
843 : jhr 1713 SOME(CL.I_Exp(CL.mkStr(#srcFile tgt)))));
844 : jhr 1671 cppDecl (genGlobalStruct (#hostTy, !globals, RN.globalsTy));
845 :     cppDecl (genGlobalStruct (#shadowTy, !globals, RN.shadowGlobalsTy));
846 :     (* FIXME: does this really need to be a global? *)
847 :     cppDecl (CL.D_Var(["static"], globPtrTy, RN.globalsVarName, NONE));
848 :     cppDecl (genStrandTyDef (#hostTy, strand, tyName));
849 :     cppDecl (genStrandTyDef (#shadowTy, strand, RN.strandShadowTy tyName));
850 :     cppDecl (genConvertShadowTypes strand);
851 :     cppDecl (!init_code);
852 :     cppDecl (genStrandPrint strand);
853 :     cppDecl (genOutputFun strand);
854 :     List.app cppDecl (List.rev (!topDecls));
855 :     cppDecl (genGlobalBuffersArgs (!globals,imgGlobals));
856 :     List.app (fn strand => cppDecl (genStrandDesc (outFn,strand))) strands;
857 :     genStrandTable (cppDecl, strands);
858 :     cppDecl (!initially);
859 :     PrintAsC.close cppStrm;
860 :     PrintAsCL.close clppStrm;
861 :     TextIO.closeOut cOutS;
862 :     TextIO.closeOut clOutS
863 :     end
864 :    
865 :     (* output the code to the filesystem. The string is the basename of the source file *)
866 : jhr 1705 fun generate (prog as Prog{tgt, ...}) = let
867 :     val {outDir, outBase, exec, double, parallel, debug, ...} = tgt
868 : jhr 1671 fun condCons (true, x, xs) = x::xs
869 :     | condCons (false, _, xs) = xs
870 :     (* generate the C compiler flags *)
871 :     val cflags = ["-I" ^ Paths.diderotInclude, "-I" ^ Paths.teemInclude]
872 : jhr 1843 val cflags = condCons (#cl Paths.cflags <> "", #cl Paths.cflags, cflags)
873 : jhr 1671 val cflags = condCons (parallel, #pthread Paths.cflags, cflags)
874 :     val cflags = if debug
875 :     then #debug Paths.cflags :: cflags
876 :     else #ndebug Paths.cflags :: cflags
877 :     val cflags = #base Paths.cflags :: cflags
878 :     (* generate the loader flags *)
879 :     val extraLibs = condCons (parallel, #pthread Paths.extraLibs, [])
880 :     val extraLibs = Paths.teemLinkFlags @ #base Paths.extraLibs :: extraLibs
881 :     val extraLibs = #cl Paths.extraLibs :: extraLibs
882 : jhr 1706 val rtLib = TargetUtil.runtimeName tgt
883 : jhr 1671 val ldOpts = rtLib :: extraLibs
884 : jhr 1705 val basename = OS.Path.joinDirFile{dir=outDir, file=outBase}
885 : jhr 1671 in
886 :     genSrc (basename, prog);
887 :     RunCC.compile (basename, cflags);
888 : jhr 1714 RunCC.linkExec (basename, ldOpts)
889 : jhr 1671 end
890 :    
891 :     end (* Program *)
892 :    
893 :     end
894 :    
895 :     structure CLBackEnd = CodeGenFn(CLTarget)

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