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

SCM Repository

[diderot] View of /branches/lamont/src/compiler/c-util/runtime-names.sml
ViewVC logotype

View of /branches/lamont/src/compiler/c-util/runtime-names.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2298 - (download) (annotate)
Fri Mar 15 22:18:22 2013 UTC (6 years, 6 months ago) by jhr
File size: 5251 byte(s)
  Merging in changes from vis12 branch.
(* runtime-names.sml
 *
 * COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 *
 * These are names that are used in the common parts of the runtime system.
 *)

structure RuntimeNames =
  struct

    local
      structure Ty = TreeIL.Ty
      fun qualifyName name (tgt : Properties.props) = #namespace tgt ^ name
      fun qualifyName' fixed (tgt : Properties.props, name) =
            concat[#namespace tgt, fixed, "_", name]
    in

  (* generated types *)
    val worldTy = qualifyName "World_t"
    val globalsTy = qualifyName "Globals_t"
    val inputsTy = qualifyName "Inputs_t"	(* type of struct used to hold command-line *)
						(* inputs. *)
    val definedInpTy = qualifyName "DefinedInputs_t"
						(* type of struct used to hold command-line *)
						(* inputs. *)

  (* generate names for input and output variables *)
    val inputDesc = qualifyName' "InVarDesc"
    val inputGet = qualifyName' "InVarGet"
    val inputSet = qualifyName' "InVarSet"
    val inputSetByName = qualifyName' "InVarSetByName"
    val outputGet = qualifyName' "OutputGet"
    val snapshotGet = qualifyName' "Snapshot"

  (* names of generated types, functions, and globals *)
    val initGlobals = "InitGlobals"		(* function for initializing program globals *)
    val freeGlobals = "FreeGlobals"		(* function for freeing program globals *)
    val initDefaults = "InitDefaults"		(* function for initializing input defaults *)
    val registerOpts = "RegisterGlobalOpts"	(* function for registering command-line options *)
    val initInputs = "InitInputs"		(* function for initializing global inputs *)
    val initDefined = qualifyName "InitDefined"	(* function for initializing input-defined flags *)
    val checkDefined = qualifyName "ChkDefined"	(* function for initializing input-defined flags *)
    val shutdown = qualifyName "Shutdown"	(* function that gets called at the end *)
    val initially = qualifyName "Initially"	(* function for creating initial strands *)
    val globalFunName =  "Diderot_GlobalFun" (* function for processing global reductions *) 
    fun globalReduceName  strand =  strand ^ "_GlobalReduce" 
    fun strandInit strand = strand ^ "_InitState"
    fun strandTy strand = concat["Strand_", strand, "_t"]
    fun strandDesc strand = concat["Strand_", strand]
    val numStrands = "Diderot_NumStrands"
    val strands = "Diderot_Strands"

  (* Diderot runtime system hooks *)
    val statusTy = "Status_t"
    fun setImage dim = concat["Diderot_SetImage", Int.toString dim, "D"]
    fun loadImage dim = concat["Diderot_LoadImage", Int.toString dim, "D"]
    fun freeImage dim = concat["Diderot_FreeImage", Int.toString dim, "D"]
    fun loadDynSeq ty = (case ty
	   of Ty.BoolTy => "Diderot_DynSeqLoadBool"
	    | Ty.IntTy => "Diderot_DynSeqLoadInt"
	    | Ty.TensorTy _ => "Diderot_DynSeqLoadReal"
	    | ty => raise Fail("unsupported sequence type " ^ Ty.toString ty)
          (* end case *))
    fun loadDynSeqFromFile ty = (case ty
	   of Ty.BoolTy => "Diderot_DynSeqLoadBoolFromFile"
	    | Ty.IntTy => "Diderot_DynSeqLoadIntFromFile"
	    | Ty.TensorTy _ => "Diderot_DynSeqLoadRealFromFile"
	    | ty => raise Fail("unsupported sequence type " ^ Ty.toString ty)
          (* end case *))
    val mkDynSeqFun = "Diderot_DynSeqAlloc"
    val dynSeqTy = "Diderot_DynSeq_t" 
    val strandDescTy = "Strand_t"
    val worldTy = qualifyName "World_t"
    val globalTy = qualifyName "Globals_t"
    val optionsTy = "Diderot_Options_t"
    val allocInitially = "AllocInitially"
    val inState = "Diderot_InState"
    fun allocNewStrand strand = strand ^ "_AllocNewStrand"
    val strandPoolTy = "StrandPoolInfo_t" 
    val reduceIdx = "seq_reduceIdx" 

  (* Grid & Queries names *) 
    val sphereQuery  = "spherical_query" 
    val gridCxtName  = "gridCtx"
    val strandsName = "strands"
    val gridContextTy = "GridContext" 
    val gridDimName = "qGridDim" 
    val gridCellName = "qCellDim"
    val queryPoolTy = "QueryPool_t"
    val queryPoolName = "queryPool"
    val queryAllocFun = "Diderot_QueryAllocPool"
    val queryClearFun = "Diderot_QueryClearPool" 
    val queryPoolAddFun = "Diderot_QueryAddToPool"
    fun gridAllocFun d =  concat["Diderot_GridAllocGrid", Int.toString d, "D"] 
    fun gridBuildFun d =  concat["Diderot_GridBuild", Int.toString d, "D"]
 
  (* Math utility functions *)
    val evecs2x2 = "Diderot_evecs2x2"
    val evecs3x3 = "Diderot_evecs3x3"
    val evals2x2 = "Diderot_evals2x2"
    val evals3x3 = "Diderot_evals3x3"

  (* functions for defining program inputs; note that sequences and images come from
   * nrrd files, which are specified by their filenames.
   *)
    fun input ty = (case ty
	   of Ty.StringTy => "Diderot_OptAddString"
	    | Ty.BoolTy => "Diderot_OptAddBool"
	    | Ty.IntTy => "Diderot_OptAddInt"
	    | Ty.TensorTy[] => "Diderot_OptAddReal"
	    | Ty.TensorTy[2] => "Diderot_OptAddReal2"
	    | Ty.TensorTy[3] => "Diderot_OptAddReal3"
	    | Ty.TensorTy[4] => "Diderot_OptAddReal4"
	    | Ty.DynSeqTy _ => "Diderot_OptAddString"
            | Ty.ImageTy _ => "Diderot_OptAddString"
            | ty => raise Fail("unsupported input type " ^ Ty.toString ty)
	  (* end case *))

    end (* local *)
  end

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