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

SCM Repository

[diderot] Annotation of /trunk/src/compiler/high-to-mid/test.sml
ViewVC logotype

Annotation of /trunk/src/compiler/high-to-mid/test.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3349 - (view) (download)

1 : jhr 351 (* test.sml
2 :     *
3 : jhr 3349 * 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 351 * All rights reserved.
7 :     *
8 :     * Test driver to the generation of probe code
9 :     *)
10 :    
11 :     structure Test =
12 :     struct
13 :    
14 :     structure II = ImageInfo
15 :     structure FD = FieldDef
16 :     structure K = Kernel
17 :     structure DstIL = MidIL
18 :    
19 :     structure PP = SSAPPFn(DstIL)
20 :    
21 : jhr 374 local
22 :     structure VSet = DstIL.Var.Set
23 :     in
24 :     fun checkCode (result, code, pos) = let
25 :     fun checkVar bvs x = if VSet.member(bvs, x)
26 :     then ()
27 :     else print(concat["variable ", DstIL.Var.toString x, " used before definition\n"])
28 :     fun chkAssign ((y, rhs), bvs) = (
29 :     case rhs
30 :     of DstIL.VAR x => checkVar bvs x
31 :     | DstIL.LIT _ => ()
32 :     | DstIL.OP(_, xs) => List.app (checkVar bvs) xs
33 :     | DstIL.CONS xs => List.app (checkVar bvs) xs
34 :     (* end case *);
35 :     VSet.add (bvs, y))
36 :     val bvs = List.foldl chkAssign (VSet.singleton pos) code
37 :     in
38 :     checkVar bvs result
39 :     end
40 :     end
41 :    
42 : jhr 351 fun expand fld = let
43 : jhr 374 val result = DstIL.Var.new "result"
44 :     val pos = DstIL.Var.new "pos"
45 :     val code = Probe.expand (result, fld, pos)
46 : jhr 351 in
47 :     print(concat["expand (", FD.toString fld, "):\n"]);
48 : jhr 374 List.app (fn s => print("\t" ^ PP.assignToString s ^ "\n")) code;
49 :     checkCode (result, code, pos)
50 : jhr 351 end
51 :    
52 : jhr 353 (* fake 2D image info *)
53 :     val img2d = II.ImgInfo{
54 :     id = OS.FileSys.fileId "/dev/null",
55 :     dim = 2,
56 :     ty = ([], RawTypes.RT_Float),
57 :     origin = [],
58 :     sizes = []
59 :     }
60 :    
61 : jhr 352 (* fake 3D image info *)
62 :     val img3d = II.ImgInfo{
63 :     id = OS.FileSys.fileId "/dev/null",
64 :     dim = 3,
65 :     ty = ([], RawTypes.RT_Float),
66 :     origin = [],
67 :     sizes = []
68 :     }
69 :    
70 : jhr 353 val fld2d = FD.convolve(img2d, K.bspln3)
71 : jhr 373 val fld2d' = FD.diff(FD.convolve(img2d, K.bspln3))
72 : jhr 353 val fld3d = FD.convolve(img3d, K.bspln3)
73 : jhr 352
74 : jhr 351 end

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