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

SCM Repository

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

View of /branches/vis12/src/compiler/high-to-mid/test.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1685 - (download) (annotate)
Sun Jan 22 15:23:36 2012 UTC (7 years, 10 months ago) by jhr
File size: 1821 byte(s)
  Create a branch to implement things that we need for the Vis 2012 paper
(* test.sml
 *
 * COPYRIGHT (c) 2010 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 *
 * Test driver to the generation of probe code
 *)

structure Test =
  struct

    structure II = ImageInfo
    structure FD = FieldDef
    structure K = Kernel
    structure DstIL = MidIL

    structure PP = SSAPPFn(DstIL)

    local
      structure VSet = DstIL.Var.Set
    in
      fun checkCode (result, code, pos) = let
	    fun checkVar bvs x = if VSet.member(bvs, x)
		  then ()
		  else print(concat["variable ", DstIL.Var.toString x, " used before definition\n"])
	    fun chkAssign ((y, rhs), bvs) = (
		  case rhs
		   of DstIL.VAR x => checkVar bvs x
		    | DstIL.LIT _ => ()
		    | DstIL.OP(_, xs) => List.app (checkVar bvs) xs
		    | DstIL.CONS xs => List.app (checkVar bvs) xs
		  (* end case *);
		  VSet.add (bvs, y))
	    val bvs = List.foldl chkAssign (VSet.singleton pos) code
	    in
	      checkVar bvs result
	    end
    end

    fun expand fld = let
	  val result = DstIL.Var.new "result"
	  val pos = DstIL.Var.new "pos"
	  val code = Probe.expand (result, fld, pos)
	  in
	    print(concat["expand (", FD.toString fld, "):\n"]);
	    List.app (fn s => print("\t" ^ PP.assignToString s ^ "\n")) code;
	    checkCode (result, code, pos)
	  end

  (* fake 2D image info *)
    val img2d = II.ImgInfo{
	    id = OS.FileSys.fileId "/dev/null",
	    dim = 2,
	    ty = ([], RawTypes.RT_Float),
	    origin = [],
	    sizes = []
	  }

  (* fake 3D image info *)
    val img3d = II.ImgInfo{
	    id = OS.FileSys.fileId "/dev/null",
	    dim = 3,
	    ty = ([], RawTypes.RT_Float),
	    origin = [],
	    sizes = []
	  }

    val fld2d = FD.convolve(img2d, K.bspln3)
    val fld2d' = FD.diff(FD.convolve(img2d, K.bspln3))
    val fld3d = FD.convolve(img3d, K.bspln3)

  end

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