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/c-names.sml
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3095 - (download) (annotate)
Wed Mar 18 13:12:57 2015 UTC (4 years, 3 months ago) by jhr
File size: 3629 byte(s)
  working on reorg of names
(* c-names.sml
 *
 * COPYRIGHT (c) 2015 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 *
 * These are names and types used in the CPU-side C code.  It includes names from
 * RuntimeNames (c-util/runtime-names.sml) and CTypeNames (c-util/c-type-names.sml),
 * plus additional names.
 *)

structure CNames =
  struct

    open RuntimeNames

    local
      structure CTyN = CTypeNames
      structure RN = RuntimeNames
      structure CL = CLang
    in

  (* globals that specify the target characteristics.  These should be initialized
   * when the program object is created.
   *)
    val gIntTy = CTyN.gIntTy		(* external API type for Diderot ints *)
    val gCPUIntTy = ref CLang.voidTy	(* CPU-side shadow type for Diderot ints *)
    val gGPUIntTy = CTyN.gRealTy	(* OpenCL type matches C type *)
    val gRealTy = CTyN.gRealTy		(* external API type for Diderot reals *)
    val gCPURealTy = ref CLang.voidTy	(* CPU-side shadow type for Diderot reals *)
    val gGPURealTy = CTyN.gIntTy	(* OpenCL type matches C type *)
    val gRealStem = ref "?"
    val gRealSuffix = CTyN.gRealSuffix
    val gIntStem = ref "?"
    val gIntSuffix = CTyN.gIntSuffix
    val gIntFormat = CTyN.gIntFormat

 (* initialize globals based on target precision *)
    fun initTargetSpec (tgt : TargetUtil.target_desc) = (
	  CTypeNames.initTargetSpec tgt;
	  if #longint tgt
	    then (
              gCPUIntTy := CLang.T_Named "cl_long";
	      gIntStem := "long";
              gIntFormat := "%ld")
            else (
              gCPUIntTy := CLang.T_Named "cl_int";
	      gIntStem := "int";
              gIntFormat := "%d");
          if #double tgt
            then (
              gCPURealTy := CLang.T_Named "cl_double";
              gRealStem := "double")
            else (
              gCPURealTy := CLang.T_Named "cl_float";
              gRealStem := "float"))

  (* C-side OpenCL type names *)
    fun clVecTy n = concat["cl_", !gRealStem, Int.toString n]
    fun clIntVecTy n = concat["cl_", !gIntStem, Int.toString n]

    fun mkCLVec n = concat["VEC", Int.toString n]

  (* pointer to scheduler data structure *)
    val schedTyName = RN.qualifyName "Sched_t"
    fun schedPtrTy tgt = CL.T_Ptr(CL.T_Named(schedTyName tgt))

  (* names inherited from RuntimeNames *)
    val worldTyName = RN.worldTyName
    val worldPtrTy = RN.worldPtrTy
    val inputsTyName = RN.inputsTyName
    val inputsPtrTy = RN.inputsPtrTy
    val definedInpTyName = RN.definedInpTyName
    val definedInpPtrTy = RN.definedInpPtrTy
    val optionsTyName = RN.optionsTyName
    val optionsPtrTy = RN.optionsPtrTy
    val inputDesc = RN.inputDesc
    val inputGet = RN.inputGet
    val inputSet = RN.inputSet
    val inputSetByName = RN.inputSetByName
    val outputGet = RN.outputGet
    val snapshotGet = RN.snapshotGet
    val initDefaults = RN.initDefaults
    val registerOpts = RN.registerOpts
    val registerOutputOpts = RN.registerOutputOpts
    val initInputs = RN.initInputs
    val initDefined = RN.initDefined
    val checkDefined = RN.checkDefined
    val shutdown = RN.shutdown
    val initially = RN.initially
    val allocInitially = RN.allocInitially
    val strandDescTy = RN.strandDescTy
    val strandDesc = RN.strandDesc
    val strands = RN.strands
    val setImage = RN.setImage
    val loadImage = RN.loadImage
    val freeImage = RN.freeImage
    val loadDynSeq = RN.loadDynSeq
    val loadDynSeqFromFile = RN.loadDynSeqFromFile
    val inputOpt = RN.inputOpt
    val imageTyName = RN.imageTyName
    val imagePtrTy = RN.imagePtrTy
    val dynSeqTy = RN.dynSeqTy

    end (* local *)
  end

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