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

SCM Repository

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

Annotation of /branches/pure-cfg/src/compiler/cl-target/cl-target.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1407 - (view) (download)

1 : jhr 1315 (* cl-target.sml
2 : lamonts 1244 *
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 1273 structure ToCL = TreeToCL
16 : lamonts 1305 structure N = CNames
17 : lamonts 1244
18 : jhr 1358 (* translate TreeIL types to shadow types *)
19 :     fun shadowTy ty = (case ty
20 : jhr 1363 of Ty.BoolTy => CL.T_Named "cl_bool"
21 : jhr 1358 | Ty.StringTy => raise Fail "unexpected string type"
22 :     | Ty.IVecTy 1 => CL.T_Named(RN.shadowIntTy ())
23 :     | Ty.IVecTy n => raise Fail "unexpected int vector type"
24 :     | Ty.TensorTy[] => CL.T_Named(RN.shadowRealTy ())
25 :     | Ty.TensorTy[n] => CL.T_Named(RN.shadowVecTy n)
26 :     | Ty.TensorTy[n, m] => CL.T_Named(RN.shadowMatTy(n,m))
27 :     | Ty.ImageTy(ImageInfo.ImgInfo{dim, ...}) => CL.T_Named(RN.shadowImageTy dim)
28 :     | _ => raise Fail(concat["TreeToC.trType(", Ty.toString ty, ")"])
29 :     (* end case *))
30 :    
31 : jhr 1343 (* helper functions for specifying parameters in various address spaces *)
32 :     fun clParam (spc, ty, x) = CL.PARAM([spc], ty, x)
33 :     fun globalParam (ty, x) = CL.PARAM(["__global"], ty, x)
34 :     fun constantParam (ty, x) = CL.PARAM(["__constant"], ty, x)
35 :     fun localParam (ty, x) = CL.PARAM(["__local"], ty, x)
36 :     fun privateParam (ty, x) = CL.PARAM(["__private"], ty, x)
37 :    
38 : jhr 1315 (* C variable translation *)
39 :     structure TrCVar =
40 : lamonts 1305 struct
41 :     type env = CL.typed_var TreeIL.Var.Map.map
42 :     fun lookup (env, x) = (case V.Map.find (env, x)
43 :     of SOME(CL.V(_, x')) => x'
44 : jhr 1315 | NONE => raise Fail(concat["TrCVar.lookup(_, ", V.name x, ")"])
45 : lamonts 1305 (* end case *))
46 :     (* translate a variable that occurs in an l-value context (i.e., as the target of an assignment) *)
47 :     fun lvalueVar (env, x) = (case V.kind x
48 : jhr 1315 of IL.VK_Global => CL.mkIndirect(CL.mkVar RN.globalsVarName, lookup(env, x))
49 : lamonts 1305 | IL.VK_State strand => CL.mkIndirect(CL.mkVar "selfOut", lookup(env, x))
50 :     | IL.VK_Local => CL.mkVar(lookup(env, x))
51 :     (* end case *))
52 :     (* translate a variable that occurs in an r-value context *)
53 :     fun rvalueVar (env, x) = (case V.kind x
54 : jhr 1315 of IL.VK_Global => CL.mkIndirect(CL.mkVar RN.globalsVarName, lookup(env, x))
55 : lamonts 1305 | IL.VK_State strand => CL.mkIndirect(CL.mkVar "selfIn", lookup(env, x))
56 :     | IL.VK_Local => CL.mkVar(lookup(env, x))
57 :     (* end case *))
58 : jhr 1285 end
59 :    
60 :     structure ToC = TreeToCFn (TrCVar)
61 :    
62 :     type var = CL.typed_var
63 : lamonts 1244 type exp = CL.exp
64 :     type stm = CL.stm
65 :    
66 : jhr 1313 (* OpenCL specific types *)
67 :     val clIntTy = CL.T_Named "cl_int"
68 : jhr 1279 val clProgramTy = CL.T_Named "cl_program"
69 :     val clKernelTy = CL.T_Named "cl_kernel"
70 :     val clCmdQueueTy = CL.T_Named "cl_command_queue"
71 :     val clContextTy = CL.T_Named "cl_context"
72 :     val clDeviceIdTy = CL.T_Named "cl_device_id"
73 :     val clPlatformIdTy = CL.T_Named "cl_platform_id"
74 :     val clMemoryTy = CL.T_Named "cl_mem"
75 : jhr 1313 val globPtrTy = CL.T_Ptr(CL.T_Named RN.globalsTy)
76 : jhr 1279
77 : jhr 1307 (* variable or field that is mirrored between host and GPU *)
78 :     type mirror_var = {
79 :     hostTy : CL.ty, (* variable type on Host (i.e., C type) *)
80 : jhr 1358 shadowTy : CL.ty, (* host-side shadow type of GPU type *)
81 : jhr 1307 gpuTy : CL.ty, (* variable's type on GPU (i.e., OpenCL type) *)
82 :     var : CL.var (* variable name *)
83 :     }
84 :    
85 : lamonts 1244 datatype strand = Strand of {
86 : jhr 1261 name : string,
87 :     tyName : string,
88 : jhr 1307 state : mirror_var list ref,
89 : jhr 1358 output : (Ty.ty * CL.var) option ref, (* the strand's output variable (only one for now) *)
90 : lamonts 1271 code : CL.decl list ref,
91 : jhr 1273 init_code: CL.decl ref
92 : lamonts 1244 }
93 :    
94 :     datatype program = Prog of {
95 : jhr 1307 name : string, (* stem of source file *)
96 : jhr 1261 double : bool, (* true for double-precision support *)
97 :     parallel : bool, (* true for multithreaded (or multi-GPU) target *)
98 :     debug : bool, (* true for debug support in executable *)
99 : jhr 1307 globals : mirror_var list ref,
100 : jhr 1261 topDecls : CL.decl list ref,
101 :     strands : strand AtomTable.hash_table,
102 : lamonts 1305 initially : CL.decl ref,
103 : jhr 1333 numDims: int ref, (* number of dimensions in initially iteration *)
104 : jhr 1273 imgGlobals: (string * int) list ref,
105 :     prFn: CL.decl ref
106 :     }
107 : lamonts 1244
108 :     datatype env = ENV of {
109 : jhr 1261 info : env_info,
110 :     vMap : var V.Map.map,
111 :     scope : scope
112 : lamonts 1244 }
113 :    
114 :     and env_info = INFO of {
115 : jhr 1261 prog : program
116 : lamonts 1244 }
117 :    
118 :     and scope
119 :     = NoScope
120 :     | GlobalScope
121 :     | InitiallyScope
122 : jhr 1261 | StrandScope of TreeIL.var list (* strand initialization *)
123 :     | MethodScope of TreeIL.var list (* method body; vars are state variables *)
124 : lamonts 1244
125 : jhr 1273 (* the supprted widths of vectors of reals on the target. *)
126 :     (* FIXME: for OpenCL 1.1, 3 is also valid *)
127 :     fun vectorWidths () = [2, 4, 8, 16]
128 : lamonts 1244
129 :     (* tests for whether various expression forms can appear inline *)
130 : jhr 1261 fun inlineCons n = (n < 2) (* vectors are inline, but not matrices *)
131 :     val inlineMatrixExp = false (* can matrix-valued expressions appear inline? *)
132 : lamonts 1244
133 :     (* TreeIL to target translations *)
134 :     structure Tr =
135 :     struct
136 : jhr 1261 fun fragment (ENV{info, vMap, scope}, blk) = let
137 : jhr 1308 val (vMap, stms) = (case scope
138 : jhr 1326 of GlobalScope => ToC.trFragment (vMap, blk)
139 : jhr 1321 (* NOTE: if we move strand initialization to the GPU, then we'll have to change the following code! *)
140 : jhr 1326 | InitiallyScope => ToC.trFragment (vMap, blk)
141 :     | _ => ToCL.trFragment (vMap, blk)
142 :     (* end case *))
143 : jhr 1261 in
144 :     (ENV{info=info, vMap=vMap, scope=scope}, stms)
145 :     end
146 : jhr 1315 fun block (ENV{vMap, scope, ...}, blk) = let
147 : jhr 1326 fun saveState cxt stateVars trAssign (env, args, stm) = (
148 :     ListPair.foldrEq
149 :     (fn (x, e, stms) => trAssign(env, x, e)@stms)
150 :     [stm]
151 :     (stateVars, args)
152 :     ) handle ListPair.UnequalLengths => (
153 :     print(concat["saveState ", cxt, ": length mismatch; ", Int.toString(List.length args), " args\n"]);
154 :     raise Fail(concat["saveState ", cxt, ": length mismatch"]))
155 :     in
156 :     case scope
157 : jhr 1315 (* NOTE: if we move strand initialization to the GPU, then we'll have to change the following code! *)
158 : jhr 1326 of StrandScope stateVars =>
159 : jhr 1353 ToCL.trBlock (vMap, saveState "StrandScope" stateVars ToCL.trAssign, blk)
160 : jhr 1326 | MethodScope stateVars =>
161 :     ToCL.trBlock (vMap, saveState "MethodScope" stateVars ToCL.trAssign, blk)
162 :     | InitiallyScope => ToCL.trBlock (vMap, fn (_, _, stm) => [stm], blk)
163 :     | _ => ToC.trBlock (vMap, fn (_, _, stm) => [stm], blk)
164 :     (* end case *)
165 :     end
166 : jhr 1273 fun exp (ENV{vMap, ...}, e) = ToCL.trExp(vMap, e)
167 : lamonts 1244 end
168 :    
169 :     (* variables *)
170 :     structure Var =
171 :     struct
172 : jhr 1358 fun mirror (ty, name) = {
173 :     hostTy = ToC.trType ty,
174 :     shadowTy = shadowTy ty,
175 :     gpuTy = ToCL.trType ty,
176 :     var = name
177 :     }
178 : jhr 1273 fun name (ToCL.V(_, name)) = name
179 : jhr 1307 fun global (Prog{globals, imgGlobals, ...}, name, ty) = let
180 : jhr 1358 val x = mirror (ty, name)
181 : jhr 1307 fun isImgGlobal (Ty.ImageTy(ImageInfo.ImgInfo{dim, ...}), name) =
182 :     imgGlobals := (name,dim) :: !imgGlobals
183 :     | isImgGlobal _ = ()
184 : jhr 1261 in
185 : jhr 1307 globals := x :: !globals;
186 :     isImgGlobal (ty, name);
187 :     ToCL.V(#gpuTy x, name)
188 : jhr 1261 end
189 : jhr 1273 fun param x = ToCL.V(ToCL.trType(V.ty x), V.name x)
190 : jhr 1261 fun state (Strand{state, ...}, x) = let
191 : jhr 1307 val ty = V.ty x
192 : jhr 1358 val x' = mirror (ty, V.name x)
193 : jhr 1261 in
194 :     state := x' :: !state;
195 : jhr 1307 ToCL.V(#gpuTy x', #var x')
196 : jhr 1261 end
197 : lamonts 1244 end
198 :    
199 :     (* environments *)
200 :     structure Env =
201 :     struct
202 :     (* create a new environment *)
203 : jhr 1261 fun new prog = ENV{
204 :     info=INFO{prog = prog},
205 :     vMap = V.Map.empty,
206 :     scope = NoScope
207 :     }
208 : lamonts 1244 (* define the current translation context *)
209 : jhr 1261 fun setScope scope (ENV{info, vMap, ...}) = ENV{info=info, vMap=vMap, scope=scope}
210 :     val scopeGlobal = setScope GlobalScope
211 :     val scopeInitially = setScope InitiallyScope
212 :     fun scopeStrand (env, svars) = setScope (StrandScope svars) env
213 :     fun scopeMethod (env, svars) = setScope (MethodScope svars) env
214 : lamonts 1244 (* bind a TreeIL varaiable to a target variable *)
215 : jhr 1261 fun bind (ENV{info, vMap, scope}, x, x') = ENV{
216 :     info = info,
217 :     vMap = V.Map.insert(vMap, x, x'),
218 :     scope = scope
219 :     }
220 : lamonts 1244 end
221 :    
222 :     (* programs *)
223 :     structure Program =
224 :     struct
225 : jhr 1278 fun new {name, double, parallel, debug} = (
226 : jhr 1261 RN.initTargetSpec double;
227 : jhr 1286 CNames.initTargetSpec double;
228 : jhr 1261 Prog{
229 : jhr 1307 name = name,
230 : jhr 1261 double = double, parallel = parallel, debug = debug,
231 : jhr 1331 globals = ref [],
232 : jhr 1261 topDecls = ref [],
233 :     strands = AtomTable.mkTable (16, Fail "strand table"),
234 : jhr 1307 initially = ref(CL.D_Comment["missing initially"]),
235 : jhr 1332 numDims = ref 0,
236 : jhr 1307 imgGlobals = ref[],
237 :     prFn = ref(CL.D_Comment(["No Print Function"]))
238 : jhr 1261 })
239 : jhr 1357
240 : jhr 1261 (* register the code that is used to register command-line options for input variables *)
241 :     fun inputs (Prog{topDecls, ...}, stm) = let
242 :     val inputsFn = CL.D_Func(
243 :     [], CL.voidTy, RN.registerOpts,
244 :     [CL.PARAM([], CL.T_Ptr(CL.T_Named RN.optionsTy), "opts")],
245 :     stm)
246 :     in
247 :     topDecls := inputsFn :: !topDecls
248 :     end
249 :    
250 : jhr 1286 (* register the global initialization part of a program *)
251 : jhr 1307 fun init (Prog{topDecls, ...}, init) = let
252 : jhr 1331 val globalsDecl = CL.mkAssign(CL.E_Var RN.globalsVarName,
253 : jhr 1358 CL.mkApply("malloc", [CL.mkSizeof(CL.T_Named RN.globalsTy)]))
254 : jhr 1331 val initFn = CL.D_Func(
255 : lamonts 1316 [], CL.voidTy, RN.initGlobals, [],
256 : jhr 1358 CL.mkBlock[
257 : lamonts 1398 globalsDecl,
258 :     CL.mkCall(RN.initGlobalsHelper, [CL.mkVar RN.globalsVarName])
259 :     ])
260 : jhr 1357 val initHelperFn = CL.D_Func(
261 : jhr 1358 [], CL.voidTy, RN.initGlobalsHelper,
262 : lamonts 1398 [CL.PARAM([], globPtrTy, RN.globalsVarName)],
263 : jhr 1286 init)
264 : jhr 1307 val shutdownFn = CL.D_Func(
265 :     [], CL.voidTy, RN.shutdown,
266 :     [CL.PARAM([], CL.T_Ptr(CL.T_Named RN.worldTy), "wrld")],
267 :     CL.S_Block[])
268 :     in
269 : jhr 1357 topDecls := shutdownFn :: initFn :: initHelperFn :: !topDecls
270 : jhr 1307 end
271 : jhr 1357
272 : jhr 1333 (* create and register the initially function for a program *)
273 : jhr 1307 fun initially {
274 : jhr 1332 prog = Prog{name=progName, strands, initially, numDims, ...},
275 : jhr 1307 isArray : bool,
276 :     iterPrefix : stm list,
277 :     iters : (var * exp * exp) list,
278 :     createPrefix : stm list,
279 :     strand : Atom.atom,
280 :     args : exp list
281 :     } = let
282 :     val name = Atom.toString strand
283 :     val nDims = List.length iters
284 :     val worldTy = CL.T_Ptr(CL.T_Named N.worldTy)
285 :     fun mapi f xs = let
286 :     fun mapf (_, []) = []
287 :     | mapf (i, x::xs) = f(i, x) :: mapf(i+1, xs)
288 :     in
289 :     mapf (0, xs)
290 :     end
291 :     val baseInit = mapi (fn (i, (_, e, _)) => (i, CL.I_Exp e)) iters
292 :     val sizeInit = mapi
293 :     (fn (i, (CL.V(ty, _), lo, hi)) =>
294 :     (i, CL.I_Exp(CL.mkBinOp(CL.mkBinOp(hi, CL.#-, lo), CL.#+, CL.E_Int(1, ty))))
295 :     ) iters
296 :     (* code to allocate the world and initial strands *)
297 :     val wrld = "wrld"
298 :     val allocCode = [
299 :     CL.mkComment["allocate initial block of strands"],
300 :     CL.mkDecl(CL.T_Array(CL.int32, SOME nDims), "base", SOME(CL.I_Array baseInit)),
301 :     CL.mkDecl(CL.T_Array(CL.uint32, SOME nDims), "size", SOME(CL.I_Array sizeInit)),
302 :     CL.mkDecl(worldTy, wrld,
303 : lamonts 1341 SOME(CL.I_Exp(CL.E_Apply(RN.allocInitially, [
304 : jhr 1307 CL.mkVar "ProgramName",
305 :     CL.mkUnOp(CL.%&, CL.E_Var(N.strandDesc name)),
306 :     CL.E_Bool isArray,
307 :     CL.E_Int(IntInf.fromInt nDims, CL.int32),
308 :     CL.E_Var "base",
309 :     CL.E_Var "size"
310 :     ]))))
311 :     ]
312 : lamonts 1316 (* create the loop nest for the initially iterations
313 : jhr 1307 val indexVar = "ix"
314 :     val strandTy = CL.T_Ptr(CL.T_Named(N.strandTy name))
315 :     fun mkLoopNest [] = CL.mkBlock(createPrefix @ [
316 :     CL.mkDecl(strandTy, "sp",
317 :     SOME(CL.I_Exp(
318 :     CL.E_Cast(strandTy,
319 :     CL.E_Apply(N.inState, [CL.E_Var "wrld", CL.E_Var indexVar]))))),
320 : jhr 1315 CL.mkCall(N.strandInit name,
321 : jhr 1326 CL.E_Var RN.globalsVarName :: CL.E_Var "sp" :: args),
322 : jhr 1307 CL.mkAssign(CL.E_Var indexVar, CL.mkBinOp(CL.E_Var indexVar, CL.#+, CL.E_Int(1, CL.uint32)))
323 :     ])
324 :     | mkLoopNest ((CL.V(ty, param), lo, hi)::iters) = let
325 :     val body = mkLoopNest iters
326 :     in
327 :     CL.mkFor(
328 :     [(ty, param, lo)],
329 :     CL.mkBinOp(CL.E_Var param, CL.#<=, hi),
330 :     [CL.mkPostOp(CL.E_Var param, CL.^++)],
331 :     body)
332 :     end
333 :     val iterCode = [
334 :     CL.mkComment["initially"],
335 :     CL.mkDecl(CL.uint32, indexVar, SOME(CL.I_Exp(CL.E_Int(0, CL.uint32)))),
336 :     mkLoopNest iters
337 : lamonts 1316 ] *)
338 : jhr 1307 val body = CL.mkBlock(
339 :     iterPrefix @
340 :     allocCode @
341 :     [CL.mkReturn(SOME(CL.E_Var "wrld"))])
342 : lamonts 1316 val initFn = CL.D_Func([], worldTy, N.initially, [], body)
343 : jhr 1307 in
344 : jhr 1333 numDims := nDims;
345 : jhr 1307 initially := initFn
346 :     end
347 : jhr 1281
348 : lamonts 1305 (***** OUTPUT *****)
349 : jhr 1307 fun genStrandPrint (Strand{name, tyName, state, output, code,...}) = let
350 : jhr 1326 (* the print function *)
351 : jhr 1382 val prFnName = concat[name, "Print"]
352 : jhr 1307 val prFn = let
353 : jhr 1326 val params = [
354 :     CL.PARAM([], CL.T_Ptr(CL.T_Named "FILE"), "outS"),
355 : jhr 1358 CL.PARAM([], CL.T_Ptr(CL.T_Num(RawTypes.RT_UInt8)),"status"),
356 :     CL.PARAM([], CL.intTy,"numStrands"),
357 : jhr 1326 CL.PARAM([], CL.T_Ptr(CL.T_Named tyName), "self")
358 :     ]
359 :     val SOME(ty, x) = !output
360 : jhr 1358 val outState = CL.mkSelect(CL.mkSubscript(CL.mkVar "self", CL.E_Var "i"), x)
361 : jhr 1326 val prArgs = (case ty
362 :     of Ty.IVecTy 1 => [CL.E_Str(!N.gIntFormat ^ "\n"), outState]
363 :     | Ty.IVecTy d => let
364 :     val fmt = CL.mkStr(
365 :     String.concatWith " " (List.tabulate(d, fn _ => !N.gIntFormat))
366 :     ^ "\n")
367 :     val args = List.tabulate (d, fn i => ToC.ivecIndex(outState, d, i))
368 :     in
369 :     fmt :: args
370 :     end
371 :     | Ty.TensorTy[] => [CL.mkStr "%f\n", outState]
372 :     | Ty.TensorTy[d] => let
373 :     val fmt = CL.mkStr(
374 :     String.concatWith " " (List.tabulate(d, fn _ => "%f"))
375 :     ^ "\n")
376 :     val args = List.tabulate (d, fn i => ToC.vecIndex(outState, d, i))
377 :     in
378 :     fmt :: args
379 :     end
380 :     | _ => raise Fail("genStrand: unsupported output type " ^ Ty.toString ty)
381 :     (* end case *))
382 : jhr 1358 val forBody = CL.mkIfThen(
383 :     CL.mkBinOp(CL.mkSubscript(CL.E_Var "status",CL.E_Var "i"), CL.#==, CL.E_Var "DIDEROT_STABILIZE"),
384 :     CL.mkBlock([CL.mkCall("fprintf", CL.mkVar "outS" :: prArgs)]))
385 :     val body = CL.mkFor(
386 : lamonts 1346 [(CL.intTy, "i", CL.mkInt 0)],
387 : lamonts 1347 CL.mkBinOp(CL.E_Var "i", CL.#<, CL.E_Var "numStrands"),
388 : lamonts 1346 [CL.mkPostOp(CL.E_Var "i", CL.^++)],
389 :     forBody)
390 : jhr 1326 in
391 : jhr 1358 CL.D_Func(["static"], CL.voidTy, prFnName, params, body)
392 : jhr 1326 end
393 : jhr 1307 in
394 : jhr 1326 prFn
395 : jhr 1307 end
396 : lamonts 1305
397 : jhr 1307 fun genStrandTyDef (targetTy, Strand{tyName, state,...}) =
398 : jhr 1261 (* the type declaration for the strand's state struct *)
399 :     CL.D_StructDef(
400 : jhr 1307 List.rev (List.map (fn x => (targetTy x, #var x)) (!state)),
401 :     tyName)
402 : jhr 1358
403 : jhr 1307 (* generates the opencl buffers for the image data *)
404 : lamonts 1398 fun getGlobalDataBuffers (globals, imgGlobals, contextVar, errVar) = let
405 : jhr 1344 val globalBuffErr = "error creating OpenCL global buffer"
406 :     fun errorFn msg = CL.mkIfThen(CL.mkBinOp(CL.E_Var errVar, CL.#!=, CL.E_Var "CL_SUCCESS"),
407 :     CL.mkBlock([CL.mkCall("fprintf",[CL.E_Var "stderr", CL.E_Str msg]),
408 :     CL.mkCall("exit",[CL.mkInt 1])]))
409 : jhr 1405 val shadowTypeDecl =
410 :     CL.mkDecl(CL.T_Named(RN.shadowGlobalsTy), RN.shadowGlaobalsName, NONE)
411 : lamonts 1398 val globalImagesToShadowStms = List.map (fn (var,nDims) =>
412 :     CL.mkCall((RN.shadowImageFunc nDims), [
413 :     CL.mkVar contextVar,
414 : jhr 1405 CL.mkUnOp(CL.%&,CL.mkSelect(CL.mkVar(RN.shadowGlaobalsName),var)),
415 :     (* FIXME: for vectors and matrices, we need to invoke the appropriate shadow function from shadow-types.h *)
416 : lamonts 1398 CL.mkIndirect(CL.mkVar(RN.globalsVarName),var)
417 :     ])) imgGlobals
418 : jhr 1405 (* Converts only the non-image-field types into their corresponding global shadow types *)
419 : jhr 1406 fun convertToShadow ((global:mirror_var)::rest,(imgGlobal,nDim)::restImages) =
420 :     (* FIXME: for vectors and matrices, we need to invoke the appropriate shadow function from shadow-types.h.
421 :     * also, we should be able to combine this case and the following one to reduce redundancy.
422 :     *)
423 : jhr 1405 if (#var global) = imgGlobal
424 :     then convertToShadow(rest,restImages)
425 :     else CL.mkAssign(CL.mkSelect(CL.mkVar RN.shadowGlaobalsName, #var global),
426 :     CL.mkIndirect(CL.mkVar(RN.globalsVarName), #var global)) ::
427 :     convertToShadow(rest,(imgGlobal,nDim)::restImages)
428 : lamonts 1398 | convertToShadow ((global:mirror_var)::rest, []) =
429 : jhr 1405 CL.mkAssign(CL.mkSelect(CL.mkVar(RN.shadowGlaobalsName),#var global),
430 :     CL.mkIndirect(CL.mkVar(RN.globalsVarName), #var global)) ::
431 :     convertToShadow(rest,[])
432 : jhr 1406 (* FIXME: what if the second argument is non-nil? *)
433 :     | convertToShadow ([], _) = []
434 : lamonts 1398 val globalToShadowStms = convertToShadow(globals,imgGlobals)
435 : jhr 1358 val globalBufferDecl = CL.mkDecl(clMemoryTy,concat[RN.globalsVarName,"_cl"],NONE)
436 : jhr 1307 val globalBuffer = CL.mkAssign(CL.mkVar(concat[RN.globalsVarName,"_cl"]),
437 :     CL.mkApply("clCreateBuffer", [
438 :     CL.mkVar contextVar,
439 : jhr 1407 CL.mkBinOp(CL.mkVar "CL_MEM_READ_ONLY", CL.#|, CL.mkVar "CL_MEM_COPY_HOST_PTR"),
440 : lamonts 1398 CL.mkSizeof(CL.T_Named RN.shadowGlobalsTy),
441 :     CL.mkUnOp(CL.%&,CL.mkVar RN.shadowGlaobalsName),
442 : jhr 1307 CL.mkUnOp(CL.%&,CL.mkVar errVar)
443 :     ]))
444 : lamonts 1341 fun genDataBuffers ([],_,_,_) = []
445 :     | genDataBuffers ((var,nDims)::globals, contextVar, errVar,errFn) = let
446 : jhr 1326 val hostVar = CL.mkIndirect(CL.mkVar RN.globalsVarName, var)
447 : lamonts 1398 val size = CL.mkIndirect(hostVar, "dataSzb")
448 : jhr 1326 in
449 : lamonts 1398 CL.mkDecl(clMemoryTy, RN.addBufferSuffixData var ,NONE) ::
450 : jhr 1326 CL.mkAssign(CL.mkVar(RN.addBufferSuffixData var),
451 :     CL.mkApply("clCreateBuffer", [
452 :     CL.mkVar contextVar,
453 : lamonts 1398 CL.mkVar "CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR",
454 : jhr 1326 size,
455 :     CL.mkIndirect(hostVar, "data"),
456 :     CL.mkUnOp(CL.%&,CL.mkVar errVar)
457 : jhr 1344 ])) ::
458 : jhr 1358 errFn(concat["error in creating ",RN.addBufferSuffixData var, " global buffer"]) ::
459 :     genDataBuffers(globals,contextVar,errVar,errFn)
460 : jhr 1326 end
461 : jhr 1307 in
462 : lamonts 1398 [shadowTypeDecl] @ globalImagesToShadowStms @ globalToShadowStms
463 :     @ [globalBufferDecl, globalBuffer,errorFn(globalBuffErr)]
464 :     @ genDataBuffers(imgGlobals,contextVar,errVar,errorFn)
465 : jhr 1307 end
466 : lamonts 1264
467 : jhr 1309 (* generates the kernel arguments for the image data *)
468 : jhr 1313 fun genGlobalArguments (globals, count, kernelVar, errVar) = let
469 : jhr 1343 val globalArgErr = "error creating OpenCL global argument"
470 :     fun errorFn msg = CL.mkIfThen(CL.mkBinOp(CL.E_Var errVar, CL.#!=, CL.E_Var "CL_SUCCESS"),
471 : jhr 1344 CL.mkBlock([CL.mkCall("fprintf",[CL.E_Var "stderr", CL.E_Str msg]),
472 :     CL.mkCall("exit",[CL.mkInt 1])]))
473 : lamonts 1398 val globalArgument = CL.mkExpStm(CL.mkAssignOp(CL.mkVar errVar,CL.&=,
474 : jhr 1326 CL.mkApply("clSetKernelArg",
475 :     [CL.mkVar kernelVar,
476 :     CL.mkPostOp(CL.E_Var count, CL.^++),
477 :     CL.mkApply("sizeof",[CL.mkVar "cl_mem"]),
478 :     CL.mkUnOp(CL.%&,CL.mkVar(concat[RN.globalsVarName,"_cl"]))])))
479 : lamonts 1341 fun genDataArguments ([],_,_,_,_) = []
480 : lamonts 1398 | genDataArguments ((var,nDims)::globals,count,kernelVar,errVar,errFn) =
481 : lamonts 1341 CL.mkExpStm(CL.mkAssignOp(CL.mkVar errVar,CL.$=,
482 : jhr 1326 CL.mkApply("clSetKernelArg",
483 :     [CL.mkVar kernelVar,
484 :     CL.mkPostOp(CL.E_Var count, CL.^++),
485 :     CL.mkApply("sizeof",[CL.mkVar "cl_mem"]),
486 :     CL.mkUnOp(CL.%&,CL.mkVar(RN.addBufferSuffixData var))]))) ::
487 : jhr 1344 errFn(concat["error in creating ",RN.addBufferSuffixData var, " argument"]) ::
488 : lamonts 1341 genDataArguments (globals,count,kernelVar,errVar,errFn)
489 : jhr 1326 in
490 : lamonts 1341 [globalArgument,errorFn(globalArgErr)] @ genDataArguments(globals, count, kernelVar, errVar,errorFn)
491 : jhr 1326 end
492 : lamonts 1264
493 : lamonts 1305 (* generates the globals buffers and arguments function *)
494 : lamonts 1398 fun genGlobalBuffersArgs (globals,imgGlobals) = let
495 : jhr 1273 (* Delcare opencl setup objects *)
496 :     val errVar = "err"
497 :     val imgDataSizeVar = "image_dataSize"
498 : jhr 1315 val params = [
499 : lamonts 1305 CL.PARAM([],CL.T_Named("cl_context"), "context"),
500 : jhr 1307 CL.PARAM([],CL.T_Named("cl_kernel"), "kernel"),
501 : jhr 1344 CL.PARAM([],CL.T_Named("cl_command_queue"), "cmdQ"),
502 : jhr 1307 CL.PARAM([],CL.T_Named("int"), "argStart")
503 : jhr 1273 ]
504 : lamonts 1398 val clGlobalBuffers = getGlobalDataBuffers(globals,!imgGlobals, "context", errVar)
505 : jhr 1313 val clGlobalArguments = genGlobalArguments(!imgGlobals, "argStart", "kernel", errVar)
506 : jhr 1307 (* Body put all the statments together *)
507 : jhr 1314 val body = CL.mkDecl(clIntTy, errVar, SOME(CL.I_Exp(CL.mkInt 0)))
508 : jhr 1326 :: clGlobalBuffers @ clGlobalArguments
509 : jhr 1313 in
510 : jhr 1307 CL.D_Func([],CL.voidTy,RN.globalsSetupName,params,CL.mkBlock(body))
511 :     end
512 : lamonts 1305
513 : jhr 1307 (* generate the data and global parameters *)
514 :     fun genKeneralGlobalParams ((name,tyname)::rest) =
515 : jhr 1343 globalParam (CL.T_Ptr(CL.voidTy), RN.addBufferSuffixData name) ::
516 : jhr 1307 genKeneralGlobalParams rest
517 :     | genKeneralGlobalParams [] = []
518 :    
519 : jhr 1331 (* generate the main kernel function for the .cl file *)
520 : jhr 1307 fun genKernelFun (strand, nDims, globals, imgGlobals) = let
521 :     val Strand{name, tyName, state, output, code,...} = strand
522 :     val fName = RN.kernelFuncName;
523 :     val inState = "strand_in"
524 : lamonts 1341 val outState = "strand_out"
525 : jhr 1345 val tempVar = "tmp"
526 : jhr 1307 val params = [
527 : lamonts 1346 CL.PARAM(["__global"], CL.T_Ptr(CL.T_Named tyName), "selfIn"),
528 :     CL.PARAM(["__global"], CL.T_Ptr(CL.T_Named tyName), "selfOut"),
529 : jhr 1358 CL.PARAM(["__global"], CL.T_Ptr(CL.T_Num(RawTypes.RT_UInt8)), "strandStatus"),
530 : lamonts 1346 CL.PARAM(["__global"], CL.intTy, "width"),
531 : jhr 1358 CL.PARAM(["__global"], globPtrTy, RN.globalsVarName)
532 : jhr 1307 ] @ genKeneralGlobalParams(!imgGlobals)
533 :     val thread_ids = if nDims = 1
534 : jhr 1331 then [
535 :     CL.mkDecl(CL.intTy, "x",
536 :     SOME(CL.I_Exp(CL.mkApply(RN.getGlobalThreadId,[CL.mkInt 0]))))
537 :     ]
538 :     else if nDims = 2
539 :     then [
540 :     CL.mkDecl(CL.intTy, "x",
541 :     SOME(CL.I_Exp(CL.mkApply(RN.getGlobalThreadId,[CL.mkInt 0])))),
542 :     CL.mkDecl(CL.intTy, "y",
543 :     SOME(CL.I_Exp(CL.mkApply(RN.getGlobalThreadId,[CL.mkInt 1]))))
544 :     ]
545 :     else raise Fail "nDims > 2"
546 : jhr 1307 val strandDecl = [
547 : lamonts 1341 CL.mkDecl(CL.T_Ptr(CL.T_Named (concat["__global ",tyName])), inState, NONE),
548 :     CL.mkDecl(CL.T_Ptr(CL.T_Named (concat["__global ",tyName])), outState, NONE),
549 : jhr 1344 CL.mkDecl(CL.T_Ptr(CL.T_Named (concat["__global ",tyName])), tempVar, NONE)
550 : jhr 1331 ]
551 : lamonts 1398 val imageDataDecl = CL.mkDecl(CL.T_Named(RN.imageDataType),RN.globalImageDataName,NONE)
552 :     val imageDataStms = List.map (fn (x,_) =>
553 :     CL.mkAssign(CL.mkSelect(CL.mkVar(RN.globalImageDataName),RN.imageDataName x),
554 :     CL.mkVar(RN.addBufferSuffixData x))) (!imgGlobals)
555 :     val barrierCode = CL.mkIfThen(CL.mkBinOp(CL.E_Var "status",CL.#==,CL.E_Var "DIDEROT_ACTIVE"),
556 :     CL.mkBlock ([CL.mkAssign(CL.E_Var tempVar, CL.E_Var inState),
557 :     CL.mkAssign(CL.E_Var inState, CL.E_Var outState),
558 :     CL.mkAssign(CL.E_Var outState, CL.E_Var tempVar)]))
559 : jhr 1358 val barrierStm = CL.mkCall("barrier",[CL.E_Var "CLK_LOCAL_MEM_FENCE"])
560 : lamonts 1346 val index = if nDims = 1 then
561 :     CL.mkStr "x"
562 :     else
563 : jhr 1358 CL.mkBinOp(
564 : jhr 1332 CL.mkBinOp(CL.mkVar "x", CL.#*, CL.mkVar "width"), CL.#+, CL.mkVar "y")
565 : lamonts 1346
566 :     val strandObjects =
567 :     [ CL.mkAssign(CL.mkVar inState, CL.mkBinOp(CL.mkVar "selfIn",CL.#+,index)),
568 :     CL.mkAssign(CL.mkVar outState, CL.mkBinOp(CL.mkVar "selfOut",CL.#+,index))
569 : jhr 1358 ]
570 : lamonts 1346
571 : jhr 1358 val stabalizeStm = CL.mkAssign(CL.mkSubscript(CL.mkVar "strandStatus",index),
572 :     CL.E_Var "status")
573 : lamonts 1346 val status = CL.mkDecl(CL.intTy, "status", SOME(CL.I_Exp(CL.mkSubscript(CL.mkVar "strandStatus",index))))
574 : jhr 1333 val strandInitStm = CL.mkCall(RN.strandInit name, [
575 : lamonts 1398 CL.mkVar RN.globalsVarName,
576 :     CL.mkVar inState,
577 :     CL.mkVar "x",
578 : jhr 1333 (* FIXME: if nDims = 1, then "y" is not defined! the arguments to this call should really come from
579 :     * the initially code!
580 :     *)
581 : lamonts 1398 CL.mkVar "y"])
582 : jhr 1333 val local_vars = thread_ids
583 : lamonts 1398 @ [imageDataDecl]
584 :     @ imageDataStms
585 : jhr 1333 @ strandDecl
586 :     @ strandObjects
587 :     @ [strandInitStm,status]
588 : lamonts 1351 val while_exp = CL.mkBinOp(CL.mkVar "status",CL.#==, CL.mkVar RN.kActive)
589 : lamonts 1398 val whileBody = CL.mkBlock ([
590 : jhr 1307 CL.mkAssign(CL.mkVar "status",
591 :     CL.mkApply(RN.strandUpdate name,
592 : lamonts 1398 [CL.mkVar inState,
593 :     CL.mkVar outState,
594 :     CL.mkVar RN.globalsVarName,
595 :     CL.mkVar RN.globalImageDataName]))] @ [barrierCode,barrierStm] )
596 : jhr 1307 val whileBlock = [CL.mkWhile(while_exp, whileBody)]
597 : lamonts 1346 val body = CL.mkBlock(local_vars @ whileBlock @ [stabalizeStm])
598 : jhr 1307 in
599 :     CL.D_Func(["__kernel"], CL.voidTy, fName, params, body)
600 :     end
601 : jhr 1358
602 :     (* generate a global structure type definition from the list of globals *)
603 :     fun genGlobalStruct (targetTy, globals, tyName) = let
604 : jhr 1307 val globs = List.map (fn (x : mirror_var) => (targetTy x, #var x)) globals
605 :     in
606 : jhr 1358 CL.D_StructDef(globs, tyName)
607 : jhr 1307 end
608 : lamonts 1398
609 :     (* generate a global structure type definition from the image data of the image globals *)
610 :     fun genImageDataStruct (imgGlobals, tyName) = let
611 :     val globs = List.map (fn (x,_) => (CL.T_Ptr(CL.imageDataTy "__global"),(RN.imageDataName x))) imgGlobals
612 :     in
613 :     CL.D_StructDef(globs, tyName)
614 :     end
615 : lamonts 1341
616 : jhr 1307 fun genGlobals (declFn, targetTy, globals) = let
617 :     fun doVar (x : mirror_var) = declFn (CL.D_Var([], targetTy x, #var x, NONE))
618 :     in
619 :     List.app doVar globals
620 :     end
621 : lamonts 1264
622 : jhr 1326 fun genStrandDesc (Strand{name, output, ...}) = let
623 :     (* the strand's descriptor object *)
624 :     val descI = let
625 :     fun fnPtr (ty, f) = CL.I_Exp(CL.mkCast(CL.T_Named ty, CL.mkVar f))
626 :     val SOME(outTy, _) = !output
627 :     in
628 :     CL.I_Struct[
629 :     ("name", CL.I_Exp(CL.mkStr name)),
630 :     ("stateSzb", CL.I_Exp(CL.mkSizeof(CL.T_Named(N.strandTy name)))),
631 : jhr 1315 (*
632 : jhr 1326 ("outputSzb", CL.I_Exp(CL.mkSizeof(ToC.trTy outTy))),
633 : jhr 1315 *)
634 : jhr 1326 ("update", fnPtr("update_method_t", "0")),
635 : jhr 1382 ("print", fnPtr("print_method_t", name ^ "Print"))
636 : jhr 1326 ]
637 :     end
638 :     val desc = CL.D_Var([], CL.T_Named N.strandDescTy, N.strandDesc name, SOME descI)
639 :     in
640 :     desc
641 :     end
642 : jhr 1315
643 :     (* generate the table of strand descriptors *)
644 : jhr 1326 fun genStrandTable (declFn, strands) = let
645 :     val nStrands = length strands
646 :     fun genInit (Strand{name, ...}) = CL.I_Exp(CL.mkUnOp(CL.%&, CL.E_Var(N.strandDesc name)))
647 :     fun genInits (_, []) = []
648 :     | genInits (i, s::ss) = (i, genInit s) :: genInits(i+1, ss)
649 :     in
650 :     declFn (CL.D_Var([], CL.int32, N.numStrands,
651 :     SOME(CL.I_Exp(CL.E_Int(IntInf.fromInt nStrands, CL.int32)))));
652 :     declFn (CL.D_Var([],
653 :     CL.T_Array(CL.T_Ptr(CL.T_Named N.strandDescTy), SOME nStrands),
654 :     N.strands,
655 :     SOME(CL.I_Array(genInits (0, strands)))))
656 :     end
657 : jhr 1315
658 : jhr 1308 fun genSrc (baseName, prog) = let
659 : jhr 1326 val Prog{name,double, globals, topDecls, strands, initially, imgGlobals, numDims, ...} = prog
660 : jhr 1307 val clFileName = OS.Path.joinBaseExt{base=baseName, ext=SOME "cl"}
661 :     val cFileName = OS.Path.joinBaseExt{base=baseName, ext=SOME "c"}
662 :     val clOutS = TextIO.openOut clFileName
663 :     val cOutS = TextIO.openOut cFileName
664 :     val clppStrm = PrintAsCL.new clOutS
665 :     val cppStrm = PrintAsC.new cOutS
666 : jhr 1321 val progName = name
667 : jhr 1307 fun cppDecl dcl = PrintAsC.output(cppStrm, dcl)
668 :     fun clppDecl dcl = PrintAsCL.output(clppStrm, dcl)
669 :     val strands = AtomTable.listItems strands
670 :     val [strand as Strand{name, tyName, code, init_code, ...}] = strands
671 :     in
672 : jhr 1273 (* Generate the OpenCl file *)
673 :     clppDecl (CL.D_Verbatim([
674 :     if double
675 :     then "#define DIDEROT_DOUBLE_PRECISION"
676 :     else "#define DIDEROT_SINGLE_PRECISION",
677 :     "#define DIDEROT_TARGET_CL",
678 : lamonts 1305 "#include \"Diderot/cl-diderot.h\""
679 : jhr 1273 ]));
680 : jhr 1358 clppDecl (genGlobalStruct (#gpuTy, !globals, RN.globalsTy));
681 : lamonts 1398 clppDecl (genImageDataStruct(!imgGlobals,RN.imageDataType));
682 : jhr 1307 clppDecl (genStrandTyDef(#gpuTy, strand));
683 : jhr 1326 clppDecl (!init_code);
684 : jhr 1273 List.app clppDecl (!code);
685 : lamonts 1328 clppDecl (genKernelFun (strand, !numDims, globals, imgGlobals));
686 :     (* Generate the Host C file *)
687 : jhr 1273 cppDecl (CL.D_Verbatim([
688 :     if double
689 :     then "#define DIDEROT_DOUBLE_PRECISION"
690 :     else "#define DIDEROT_SINGLE_PRECISION",
691 :     "#define DIDEROT_TARGET_CL",
692 :     "#include \"Diderot/diderot.h\""
693 :     ]));
694 : jhr 1326 cppDecl (CL.D_Var(["static"], CL.charPtr, "ProgramName",
695 :     SOME(CL.I_Exp(CL.mkStr progName))));
696 : jhr 1358 cppDecl (genGlobalStruct (#hostTy, !globals, RN.globalsTy));
697 :     cppDecl (genGlobalStruct (#shadowTy, !globals, RN.shadowGlobalsTy));
698 :     (* FIXME: does this really need to be a global? *)
699 :     cppDecl (CL.D_Var(["static"], globPtrTy, RN.globalsVarName, NONE));
700 : jhr 1308 cppDecl (genStrandTyDef (#hostTy, strand));
701 : jhr 1307 cppDecl (genStrandPrint strand);
702 : jhr 1273 List.app cppDecl (List.rev (!topDecls));
703 : lamonts 1398 cppDecl (genGlobalBuffersArgs (!globals,imgGlobals));
704 : jhr 1326 List.app (fn strand => cppDecl (genStrandDesc strand)) strands;
705 :     genStrandTable (cppDecl, strands);
706 : jhr 1307 cppDecl (!initially);
707 :     PrintAsC.close cppStrm;
708 :     PrintAsCL.close clppStrm;
709 :     TextIO.closeOut cOutS;
710 :     TextIO.closeOut clOutS
711 :     end
712 : lamonts 1264
713 : jhr 1358 (* output the code to the filesystem. The string is the basename of the source file *)
714 : jhr 1307 fun generate (basename, prog as Prog{double, parallel, debug, ...}) = let
715 :     fun condCons (true, x, xs) = x::xs
716 :     | condCons (false, _, xs) = xs
717 :     (* generate the C compiler flags *)
718 :     val cflags = ["-I" ^ Paths.diderotInclude, "-I" ^ Paths.teemInclude]
719 :     val cflags = condCons (parallel, #pthread Paths.cflags, cflags)
720 :     val cflags = if debug
721 :     then #debug Paths.cflags :: cflags
722 :     else #ndebug Paths.cflags :: cflags
723 :     val cflags = #base Paths.cflags :: cflags
724 :     (* generate the loader flags *)
725 :     val extraLibs = condCons (parallel, #pthread Paths.extraLibs, [])
726 :     val extraLibs = Paths.teemLinkFlags @ #base Paths.extraLibs :: extraLibs
727 :     val extraLibs = #cl Paths.extraLibs :: extraLibs
728 :     val rtLib = TargetUtil.runtimeName {
729 :     target = TargetUtil.TARGET_CL,
730 :     parallel = parallel, double = double, debug = debug
731 :     }
732 :     val ldOpts = rtLib :: extraLibs
733 :     in
734 : lamonts 1341 genSrc (basename, prog);
735 : jhr 1307 RunCC.compile (basename, cflags);
736 :     RunCC.link (basename, ldOpts)
737 : jhr 1273 end
738 : lamonts 1244
739 : jhr 1273 end
740 : lamonts 1264
741 : lamonts 1244 (* strands *)
742 :     structure Strand =
743 :     struct
744 : jhr 1261 fun define (Prog{strands, ...}, strandId) = let
745 :     val name = Atom.toString strandId
746 :     val strand = Strand{
747 :     name = name,
748 :     tyName = RN.strandTy name,
749 :     state = ref [],
750 :     output = ref NONE,
751 : lamonts 1271 code = ref [],
752 : jhr 1273 init_code = ref (CL.D_Comment(["no init code"]))
753 : jhr 1261 }
754 :     in
755 :     AtomTable.insert strands (strandId, strand);
756 :     strand
757 :     end
758 : lamonts 1244
759 :     (* return the strand with the given name *)
760 : jhr 1261 fun lookup (Prog{strands, ...}, strandId) = AtomTable.lookup strands strandId
761 : lamonts 1244
762 :     (* register the strand-state initialization code. The variables are the strand
763 :     * parameters.
764 :     *)
765 : jhr 1308 fun init (Strand{name, tyName, code, init_code, ...}, params, init) = let
766 : jhr 1261 val fName = RN.strandInit name
767 :     val params =
768 : jhr 1343 globalParam (globPtrTy, RN.globalsVarName) ::
769 :     globalParam (CL.T_Ptr(CL.T_Named tyName), "selfOut") ::
770 : jhr 1273 List.map (fn (ToCL.V(ty, x)) => CL.PARAM([], ty, x)) params
771 : jhr 1261 val initFn = CL.D_Func([], CL.voidTy, fName, params, init)
772 :     in
773 : jhr 1273 init_code := initFn
774 : jhr 1261 end
775 : jhr 1358
776 : lamonts 1244 (* register a strand method *)
777 : lamonts 1271 fun method (Strand{name, tyName, code,...}, methName, body) = let
778 : jhr 1358 val fName = concat[name, "_", methName]
779 : jhr 1261 val params = [
780 : jhr 1343 globalParam (CL.T_Ptr(CL.T_Named tyName), "selfIn"),
781 :     globalParam (CL.T_Ptr(CL.T_Named tyName), "selfOut"),
782 : lamonts 1398 globalParam (CL.T_Ptr(CL.T_Named (RN.globalsTy)), RN.globalsVarName),
783 :     CL.PARAM([],CL.T_Named(RN.imageDataType),RN.globalImageDataName)
784 : jhr 1261 ]
785 :     val methFn = CL.D_Func([], CL.int32, fName, params, body)
786 :     in
787 : jhr 1273 code := methFn :: !code
788 : jhr 1261 end
789 :    
790 : jhr 1273 fun output (Strand{output, ...}, ty, ToCL.V(_, x)) = output := SOME(ty, x)
791 : lamonts 1244
792 :     end
793 :    
794 :     end
795 :    
796 :     structure CLBackEnd = CodeGenFn(CLTarget)

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