SCM Repository
View of /branches/pure-cfg/src/compiler/codegen/target-sig.sml
Parent Directory
|
Revision Log
Revision 812 -
(download)
(annotate)
Tue Apr 12 18:01:07 2011 UTC (11 years, 2 months ago) by jhr
File size: 5622 byte(s)
Tue Apr 12 18:01:07 2011 UTC (11 years, 2 months ago) by jhr
File size: 5622 byte(s)
Added codegen support for vector-matrix, matrix-vector, and matrix-matrix multiplication
(* target-sig.sml * * COPYRIGHT (c) 2010 The Diderot Project (http://diderot-language.cs.uchicago.edu) * All rights reserved. * * Support for generating C-like code (e.g., C, OpenCL, or CUDA) *) signature TARGET = sig type program type strand type var type exp type stm type ty (* the maximum width of a vector of reals on the target. This value takes into * account the actual size of reals (i.e., 32 or 64 bits). *) val vectorWidth : unit -> int (* target types *) val boolTy : ty val intTy : ty val realTy : ty val vecTy : int -> ty val ivecTy : int -> ty val tensorTy : int list -> ty (* for tensors of order > 0 *) val stringTy : ty val imageTy : ImageInfo.info -> ty val imageDataTy : ImageInfo.info -> ty val newProgram : unit -> program (* output the code to a file. The string is the basename of the file, the extension * is provided by the target. *) val generate : string * program -> unit (* register the global initialization part of a program *) val globalInit : program * stm -> unit (* register the initially code for a program *) val initially : { prog : program, isArray : bool, iterPrefix : stm, iters : (var * exp * exp) list, createPrefix : stm, strand : Atom.atom, args : exp list } -> unit structure Var : sig val global : program * ty * string -> var val param : ty * string -> var val state : strand * ty * string -> var val var : ty * string -> var val tmp : ty -> var end (* expression construction *) structure Expr : sig (* return true if the given expression from is allowed as a subexpression *) val allowedInline : exp -> bool (* variable references *) val global : var -> exp val getState : var -> exp val param : var -> exp val var : var -> exp (* literals *) val intLit : IntegerLit.integer -> exp val floatLit : FloatLit.float -> exp val stringLit : string -> exp val boolLit : bool -> exp (* select a fixed element from a vector *) val select : int * exp -> exp (* vector and matrix subscripting *) val subscript1 : exp * exp -> exp val subscript2 : exp * exp * exp -> exp (* vector (and scalar) arithmetic *) val add : exp * exp -> exp val mul : exp * exp -> exp val sub : exp * exp -> exp val divide : exp * exp -> exp val neg : exp -> exp val abs : exp -> exp val dot : exp * exp -> exp (* dot product *) val mulVecMat : exp * exp -> exp (* vector-matrix multiplication *) val mulMatVec : exp * exp -> exp (* matrix-vector multiplication *) val mulMatMat : exp * exp -> exp (* matrix-matrix multiplication *) val cross : exp * exp -> exp (* cross product *) val length : exp -> exp (* vector length *) val normalize : exp -> exp (* normalize vector *) (* matrix operations *) val trace : exp -> exp (* comparisons *) val lt : exp * exp -> exp val lte : exp * exp -> exp val equ : exp * exp -> exp val neq : exp * exp -> exp val gte : exp * exp -> exp val gt : exp * exp -> exp (* logical connectives *) val not : exp -> exp val && : exp * exp -> exp val || : exp * exp -> exp (* misc functions *) val min : exp * exp -> exp val max : exp * exp -> exp val lerp : exp * exp * exp -> exp (* rounding *) val trunc : exp -> exp (* truncate real to integral real *) val round : exp -> exp (* round real to integral real *) val floor : exp -> exp (* real to integral real floor *) val ceil : exp -> exp (* real to integral real ceiling *) (* conversions *) val toInt : exp -> exp (* real to integer *) val toReal : exp -> exp (* integer to real *) (* runtime system hooks *) val imageAddr : exp -> exp (* based address of image data *) val getImgData : exp -> exp (* fetch a data value from the *) (* specified address and convert to *) (* a real *) val posToImgSpace : exp * exp -> exp (* map world-space pos to image-space *) val inside : exp * exp * int -> exp (* inside image domain test, *) (* where params are: dim, pos, *) (* img , and border width *) (* other basis functions *) val apply : ILBasis.name * exp list -> exp end (* statement construction *) structure Stmt : sig val comment : string list -> stm val assignState : var * exp -> stm val decl : var * exp option -> stm (* local variable declaration *) val assign : var * exp -> stm val block : stm list -> stm val ifthen : exp * stm -> stm val ifthenelse : exp * stm * stm -> stm val for : var * exp * exp * stm -> stm (* special Diderot forms *) val cons : var * exp list -> stm list val getImgData : var * exp -> stm list (* load a vector of data from the *) (* specified address and convert to *) (* a vector *) val loadImage : var * int * exp -> stm list val input : var * string * exp option -> stm list val exit : unit -> stm (* update method exits *) val active : unit -> stm val stabilize : unit -> stm val die : unit -> stm end (* strands *) structure Strand : sig (* define a strand with the given name *) val define : program * Atom.atom -> strand (* return the strand with the given name *) val lookup : program * Atom.atom -> strand (* register the strand-state initialization code. The variables are the strand * parameters. *) val init : strand * var list * stm -> unit (* register a strand method *) val method : strand * string * stm -> unit (* register the strand's output *) val output : strand * var -> unit end end
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |