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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

branches/vis12-cl/src/compiler/cl-target/cl-names.sml revision 3088, Tue Mar 17 18:27:27 2015 UTC branches/vis12-cl/src/compiler/cl-target/ocl-names.sml revision 3095, Wed Mar 18 13:12:57 2015 UTC
# Line 1  Line 1 
1  (* cl-names.sml  (* ocl-names.sml
2   *   *
3   * COPYRIGHT (c) 2015 The Diderot Project (http://diderot-language.cs.uchicago.edu)   * COPYRIGHT (c) 2015 The Diderot Project (http://diderot-language.cs.uchicago.edu)
4   * All rights reserved.   * All rights reserved.
5   *   *
6   * These are names used in the generated OpenCL code.   * These are names used in the generated OpenCL code.  It includes names from
7     * RuntimeNames (c-util/runtime-names.sml), CTypeNames (c-util/c-type-names.sml),
8     * and MathNames, plus additional names.
9   *)   *)
10    
11  structure CLNames =  structure OCLNames =
12    struct    struct
13    
14      local      local
       structure Ty = TreeIL.Ty  
       structure F = Format  
15        structure RN = RuntimeNames        structure RN = RuntimeNames
16          structure CTyN = CTypeNames
17          structure MathN = MathNames
18          structure CL = CLang
19      in      in
20    
21      val globalsTy = CNames.globalsTy      val globalsTyName = RN.globalsTyName
22      val inputsTy = CNames.inputsTy      val globalsPtrTy = RN.globalsPtrTy
23      val strandTy = CNames.strandTy      val inputsPtrTy = RN.inputsPtrTy
24      val strandInit = CNames.strandInit      val strandTyName = RN.strandTyName
25      fun schedTy (tgt : Properties.props) = #namespace tgt ^ "Sched_t"      val strandPtrTy = RN.strandPtrTy
26        val strandInit = RN.strandInit
27      val gIntTy = RN.gGPUIntTy           (* external API type for Diderot ints *)  
28      val gRealTy = RN.gGPURealTy         (* external API type for Diderot reals *)      val sizesTyName = RN.qualifyName "Sizes_t"
29        fun sizesTy tgt = CL.T_Named(sizesTyName tgt)
30      fun vecTy n = concat[!RN.gRealStem, Int.toString n]  
31      fun ivecTy n = concat[!RN.gIntStem, Int.toString n]      val gIntTy = CNames.gGPUIntTy       (* external API type for Diderot ints *)
32      fun addVecSuffix stem n = concat[stem, Int.toString n, !RN.gRealSuffix]      val gRealTy = CNames.gGPURealTy     (* external API type for Diderot reals *)
33    
34      (* OpenCL vector types *)
35        val vecTy = CTyN.vecTy
36        fun ivecTy n = CL.T_Named (concat[!CNames.gIntStem, Int.toString n])
37    
38        val matTy = CTyN.matTy
39        val ten3Ty = CTyN.ten3Ty
40    
41    (* strand copy functions *)    (* strand copy functions *)
42      fun copyToGlobal name = name ^ "_CopyToGlobal"      fun copyToGlobal name = name ^ "_CopyToGlobal"
# Line 42  Line 52 
52      val schedKern = "SchedKern"      val schedKern = "SchedKern"
53      val compactKern = "CompactKern"      val compactKern = "CompactKern"
54    
55    (* scalar math functions *)    (* Status_t symbols *)
56        val kActive = RN.kActive
57        val kNew = RN.kNew
58        val kDie = RN.kDie
59        val kStabilize = RN.kStabilize
60        val kStable = RN.kStable
61    
62      (* Diderot image operations *)
63        val toImageSpace = RN.toImageSpace
64        val toWorldSpace = RN.toWorldSpace
65        val inside = RN.inside
66    
67      (* Math function names (some from MathNames) *)
68      val max = "max"      val max = "max"
69      val min = "min"      val min = "min"
70      val fabs = "fabs"      val fabs = "fabs"
71        val ceil = MathN.ceil
72    (* clamp and lerp *)      val floor = MathN.floor
73        val round = MathN.round
74        val trunc = MathN.trunc
75      val clamp = "clamp"      val clamp = "clamp"
76      val lerp = "mix"      val lerp = "mix"  (* lerp is called mix in OpenCL *)
77        val loadVec = MathN.loadVec
78    (* vector math functions *)      val scale = MathN.scale
79      fun mkVec 3 = "VEC3" (* for OpenCL 1.0 *)      val truncToInt = MathN.truncToInt
       | mkVec n = concat["(", !RN.gRealStem, Int.toString n, ")"]  (* cast syntax *)  
     val truncToInt = addVecSuffix "truncToInt"  
80      val dot = "dot"      val dot = "dot"
81      val cross = "cross"      val cross = "cross"
82      val length = "length"      val length = "length"
83      val normalize = "normalize"      val normalize = "normalize"
84      fun vecitof n = concat["convert_float", Int.toString n]      val vecitof = MathN.vecitof
85      fun vecftoi n = concat["convert_int", Int.toString n]      val vecftoi = MathN.vecftoi
86    (* matrix operations *)      val zeroMat = MathN.zeroMat
87      fun zeroMat (n, m) = concat["zero", Int.toString n, "x", Int.toString m, !RN.gRealSuffix]      val identityMat = MathN.identityMat
88      fun identityMat n = concat["identity", Int.toString n, "x", Int.toString n, !RN.gRealSuffix]      val trace = MathN.trace
89      fun trace n = concat["trace", Int.toString n, "x", Int.toString n, !RN.gRealSuffix]      val normMat = MathN.normMat
90      fun norm (n, m) = concat["norm", Int.toString n, "x", Int.toString m, !RN.gRealSuffix]      val copyMat = MathN.copyMat
91      fun copyMat (n, m) = concat["copy", Int.toString n, "x", Int.toString m, !RN.gRealSuffix]      val scaleMat = MathN.scaleMat
92      fun scaleMat (n, m) = concat["scale", Int.toString n, "x", Int.toString m, !RN.gRealSuffix]      val addMat = MathN.addMat
93      fun addMat (n, m) = concat["add", Int.toString n, "x", Int.toString m, !RN.gRealSuffix]      val subMat = MathN.subMat
94      fun subMat (n, m) = concat["sub", Int.toString n, "x", Int.toString m, !RN.gRealSuffix]      val mulVecMat = MathN.mulVecMat
95      fun mulVecMat (m, n) = F.format "mulVec%dMat%dx%d%s"      val mulMatVec = MathN.mulMatVec
96            [F.INT m, F.INT m, F.INT n, F.STR(!RN.gRealSuffix)]      val mulMatMat = MathN.mulMatMat
97      fun mulMatVec (m, n) = F.format "mulMat%dx%dVec%d%s"      val transposeMat = MathN.transposeMat
98            [F.INT n, F.INT m, F.INT n, F.STR(!RN.gRealSuffix)]      val evecs2x2 = MathN.evecs2x2
99      fun mulMatMat (m, n, p) = F.format "mulMat%dx%dMat%dx%d%s"      val evecs3x3 = MathN.evecs3x3
100            [F.INT m, F.INT n, F.INT n, F.INT p, F.STR(!RN.gRealSuffix)]      val evals2x2 = MathN.evals2x2
101        val evals3x3 = MathN.evals3x3
102    (* Math utility functions *)      val copyTen3 = MathN.copyTen3
103      val evecs2x2 = "Diderot_evecs2x2"      val normTen3 = MathN.normTen3
104      val evecs3x3 = "Diderot_evecs3x3"      val mulVecTen3 = MathN.mulVecTen3
105      val evals2x2 = "Diderot_evals2x2"      val mulTen3Vec = MathN.mulTen3Vec
106      val evals3x3 = "Diderot_evals3x3"      val colonMul = MathN.colonMul
     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"  
107    
108      end (* local *)      end (* local *)
109    end    end

Legend:
Removed from v.3088  
changed lines
  Added in v.3095

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