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

SCM Repository

[diderot] View of /branches/vis15/src/compiler/mid-to-low/field-to-low.sml
ViewVC logotype

View of /branches/vis15/src/compiler/mid-to-low/field-to-low.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3728 - (download) (annotate)
Wed Apr 6 20:05:42 2016 UTC (3 years, 5 months ago) by jhr
File size: 2761 byte(s)
  working on merge
(* field-to-low.sml
 *
 * NOTE: this code will need to be changed if we ever want to support different kernels
 * for different axes
 *
 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
 *
 * COPYRIGHT (c) 2016 The University of Chicago
 * All rights reserved.
 *)

structure FieldToLow : sig

  (* expand a MidIR probe to LowIR code.  The arguments are:
   *
   *    avail   -- available LowIR assignments
   *    mapp    -- mapping from iteration indices to deBruijn indices
   *    sx      -- summation bounds
   *    prod    -- body of summation, which is a product of Ein expressions
   *    params  -- the formal parameters of the enclosing Ein expression
   *    midArgs -- the MidIR actual arguments of the enclosing Ein expression
   *    lowArgs -- the actual arguments of the enclosing Ein expression
   *)
    val expand : {
	    avail : AvailRHS.t,
	    mapp : int IntRedBlackMap.map,
	    sx : Ein.sumrange list,
	    prod : Ein.ein_exp list,
(* FIXME: do we need the params? *)
	    params : Ein.param_kind list,
	    midArgs : MidIR.var list,
	    lowArgs : LowIR.var list
	  }  -> LowIR.var

  end = struct

    structure IR = LowIR
    structure Ty = LowTypes
    structure Op = LowOps
    structure Var = LowIR.Var
    structure E = Ein
    structure Mk = MkLowIR
    structure IMap = IntRedBlackMap

  (* partition expressions into image and kernel expressions *)
    fun partition (E.Img img :: (kexps as k1::rest)) = let
	  fun stripK (E.Krn k) = k
	    | stripK _ = raise Fail "expected kernel"
	  val k1 = stripK k1
	  val rest = List.map stripK rest
	  in
	    (#1 img, #1 k1, k1::rest)
	  end
      | partition _ = raise Fail "missing image/kernel"

  (* expand a MidIR probe to LowIR code. *)
    fun expand {avail, mapp, sx, prod, params, midArgs, lowArgs} = let
	  val (imgId, kernId, kexps) = partition prod
	(* get the image argument *)
	  val (imgArg, imgInfo) = let
		val imgArg = List.nth(lowArgs, imgId)
		val imgInfo = (case IR.Var.getDef imgArg
		       of IR.OP(Op.LoadImage(Ty.ImageTy img, _), _) => img
			| IR.GLOBAL gv => raise Fail "FIXME: input variable"
			| _ => raise Fail "unable to get image argument"
		      (* end case *))
		in
		  (imgArg, imgInfo)
		end
	(* get the kernel argument.  We use the MidIR args, because there are no kernels
	 * in LowIR.
	 *)
	  val h = (case MidIR.Var.getDef (List.nth(midArgs, kernId))
		 of MidIR.OP(MidOps.Kernel h, []) => h
		  | _ => raise Fail "unable to get kernel argument"
		(* end case *))
	(* get the outermost index; note that the (lb, ub) will be the same for all
         * of the indices, since the same kernel (and support) is used for all axes.
	 *)
	  val (E.V sid, lb, ub) :: _ = sx
	  in
raise Fail "FIXME"
	  end

  end

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