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

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

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