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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2400 - (view) (download)

1 : jhr 351 (* test.sml
2 :     *
3 : jhr 435 * COPYRIGHT (c) 2010 The Diderot Project (http://diderot-language.cs.uchicago.edu)
4 : jhr 351 * 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 : cchiw 2400 | DstIL.EINAPP(_,xs)=> List.app(checkVar bvs) xs
33 : jhr 374 (* end case *);
34 :     VSet.add (bvs, y))
35 :     val bvs = List.foldl chkAssign (VSet.singleton pos) code
36 :     in
37 :     checkVar bvs result
38 :     end
39 :     end
40 :    
41 : jhr 351 fun expand fld = let
42 : jhr 374 val result = DstIL.Var.new "result"
43 :     val pos = DstIL.Var.new "pos"
44 :     val code = Probe.expand (result, fld, pos)
45 : jhr 351 in
46 :     print(concat["expand (", FD.toString fld, "):\n"]);
47 : jhr 374 List.app (fn s => print("\t" ^ PP.assignToString s ^ "\n")) code;
48 :     checkCode (result, code, pos)
49 : jhr 351 end
50 :    
51 : jhr 353 (* fake 2D image info *)
52 :     val img2d = II.ImgInfo{
53 :     id = OS.FileSys.fileId "/dev/null",
54 :     dim = 2,
55 :     ty = ([], RawTypes.RT_Float),
56 :     origin = [],
57 :     sizes = []
58 :     }
59 :    
60 : jhr 352 (* fake 3D image info *)
61 :     val img3d = II.ImgInfo{
62 :     id = OS.FileSys.fileId "/dev/null",
63 :     dim = 3,
64 :     ty = ([], RawTypes.RT_Float),
65 :     origin = [],
66 :     sizes = []
67 :     }
68 :    
69 : jhr 353 val fld2d = FD.convolve(img2d, K.bspln3)
70 : jhr 373 val fld2d' = FD.diff(FD.convolve(img2d, K.bspln3))
71 : jhr 353 val fld3d = FD.convolve(img3d, K.bspln3)
72 : jhr 352
73 : jhr 351 end

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