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

SCM Repository

[diderot] View of /branches/vis12-cl/src/compiler/cl-target/cl-names.sml
ViewVC logotype

View of /branches/vis12-cl/src/compiler/cl-target/cl-names.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2739 - (download) (annotate)
Sat Sep 27 17:23:34 2014 UTC (4 years, 11 months ago) by jhr
File size: 3471 byte(s)
  Working on OpenCL
(* cl-names.sml
 *
 * COPYRIGHT (c) 2013 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 *
 * These are names used in the generated OpenCL code.
 *)

structure CLNames =
  struct

    local
      structure Ty = TreeIL.Ty
      structure F = Format
      structure RN = RuntimeNames
    in

    val globalsTy = CNames.globalsTy
    val strandTy = CNames.strandTy
    val strandInit = CNames.strandInit

    val gIntTy = RN.gGPUIntTy		(* external API type for Diderot ints *)
    val gRealTy = RN.gGPURealTy		(* external API type for Diderot reals *)

    fun vecTy n = concat[!RN.gRealStem, Int.toString n]
    fun ivecTy n = concat[!RN.gIntStem, Int.toString n]
    fun addVecSuffix stem n = concat[stem, Int.toString n, !RN.gRealSuffix]

  (* scalar math functions *)
    val max = "max"
    val min = "min"
    val fabs = "fabs"

  (* clamp and lerp *)
    val clamp = "clamp"
    val lerp = "mix"

  (* vector math functions *)
    fun mkVec 3 = "VEC3" (* for OpenCL 1.0 *)
      | mkVec n = concat["(", !RN.gRealStem, Int.toString n, ")"]  (* cast syntax *)
    val truncToInt = addVecSuffix "truncToInt"
    val dot = "dot"
    val cross = "cross"
    val length = "length"
    val normalize = "normalize"
    fun vecitof n = concat["convert_float", Int.toString n]
    fun vecftoi n = concat["convert_int", Int.toString n]
  (* matrix operations *)
    fun zeroMat (n, m) = concat["zero", Int.toString n, "x", Int.toString m, !RN.gRealSuffix]
    fun identityMat n = concat["identity", Int.toString n, "x", Int.toString n, !RN.gRealSuffix]
    fun trace n = concat["trace", Int.toString n, "x", Int.toString n, !RN.gRealSuffix]
    fun norm (n, m) = concat["norm", Int.toString n, "x", Int.toString m, !RN.gRealSuffix]
    fun copyMat (n, m) = concat["copy", Int.toString n, "x", Int.toString m, !RN.gRealSuffix]
    fun scaleMat (n, m) = concat["scale", Int.toString n, "x", Int.toString m, !RN.gRealSuffix]
    fun addMat (n, m) = concat["add", Int.toString n, "x", Int.toString m, !RN.gRealSuffix]
    fun subMat (n, m) = concat["sub", Int.toString n, "x", Int.toString m, !RN.gRealSuffix]
    fun mulVecMat (m, n) = F.format "mulVec%dMat%dx%d%s"
          [F.INT m, F.INT m, F.INT n, F.STR(!RN.gRealSuffix)]
    fun mulMatVec (m, n) = F.format "mulMat%dx%dVec%d%s"
          [F.INT n, F.INT m, F.INT n, F.STR(!RN.gRealSuffix)]
    fun mulMatMat (m, n, p) = F.format "mulMat%dx%dMat%dx%d%s"
          [F.INT m, F.INT n, F.INT n, F.INT p, F.STR(!RN.gRealSuffix)]

  (* Math utility functions *)
    val evecs2x2 = "Diderot_evecs2x2"
    val evecs3x3 = "Diderot_evecs3x3"
    val evals2x2 = "Diderot_evals2x2"
    val evals3x3 = "Diderot_evals3x3"
    fun matTy (n, m) = concat["Diderot_Mat", Int.toString n, "x", Int.toString m, "_t"]

  (* Status_t symbols *)
    val kActive = "DIDEROT_ACTIVE"
    val kDie = "DIDEROT_DIE"
    val kStabilize = "DIDEROT_STABILIZE"
    val kStable = "DIDEROT_STABLE"

  (* Diderot runtime system hooks *)
    val toImageSpace = addVecSuffix "ToImageSpace" 
    fun toWorldSpace ty = let
          val suffix = (case ty
                 of Ty.TensorTy[d] => [Int.toString d, !RN.gRealSuffix]
                  | Ty.TensorTy[m,n] => [Int.toString n, "x", Int.toString n, !RN.gRealSuffix]
                (* end case *))
          in
            concat("ToWorldSpace" :: suffix)
          end
    val inside = addVecSuffix "Inside"
    val strandDescTy = "Strand_t"

    end (* local *)
  end

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