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

SCM Repository

[diderot] Annotation of /branches/pure-cfg/src/include/Diderot/shadow-types.h
ViewVC logotype

Annotation of /branches/pure-cfg/src/include/Diderot/shadow-types.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1357 - (view) (download) (as text)

1 : jhr 1354 /*! \file shadow-types.h
2 :     *
3 :     * \author John Reppy
4 :     *
5 :     * Type definitions for the shadow globals.
6 :     */
7 :    
8 :     /*
9 :     * COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu)
10 :     * All rights reserved.
11 :     */
12 :    
13 :     #ifndef _SHADOW_TYPES_H_
14 :     #define _SHADOW_TYPES_H_
15 :    
16 :     #if defined(CL_VERSION_1_1)
17 :     # define HAS_VEC3_TYPE
18 :     #endif
19 :    
20 :     #if defined(DIDEROT_SINGLE_PRECISION)
21 :     typedef cl_float Shadow_real_t;
22 :     typedef cl_float2 Shadow_vec2_t;
23 :     #ifdef HAS_VEC3_TYPE
24 :     typedef cl_float3 Shadow_vec3_t;
25 :     #else
26 :     typedef cl_float4 Shadow_vec3_t;
27 :     #endif
28 :     typedef cl_float4 Shadow_vec4_t;
29 :     #else
30 :     typedef cl_double Shadow_real_t;
31 :     typedef cl_double2 Shadow_vec2_t;
32 :     #ifdef HAS_VEC3_TYPE
33 :     typedef cl_double3 Shadow_vec3_t;
34 :     #else
35 :     typedef cl_double4 Shadow_vec3_t;
36 :     #endif
37 :     typedef cl_double4 Shadow_vec4_t;
38 :     #endif
39 :     typedef Shadow_vec2_t Shadow_Mat2x2_t[2];
40 :     typedef Shadow_vec3_t Shadow_Mat3x3_t[3];
41 :     typedef Shadow_vec4_t Shadow_Mat4x4_t[4];
42 :    
43 : jhr 1357 // Shadow of GPU-side image types. Note that these should have the same organization as
44 :     // the Diderot_image[123]D_t types defined in cl-types.h
45 :    
46 : jhr 1354 //! shadow wrapper for 1D image data
47 :     typedef struct {
48 : jhr 1357 cl_mem data; //!< GPU-side memory object for data.
49 :     cl_int size[1];
50 :     Shadow_real_t s; //!< scaling from world-space to image-space
51 :     Shadow_real_t t; //!< translation from world-space to image-space
52 : jhr 1354 } Shadow_image1D_t;
53 :    
54 :     //! shadow wrapper for 2D image data
55 :     typedef struct {
56 : jhr 1357 cl_mem data; //!< GPU-side memory object for data.
57 :     cl_int size[2]; //!< sizes (fast to slow)
58 :     Shadow_Mat2x2_t w2i; //!< affine tranform from world space to index space. This is the
59 :     //! inverse of the index to world-space transform that is loaded from
60 :     //! the Nrrd file.
61 :     Shadow_vec2_t tVec; //!< translation part of world to index transform
62 :     Shadow_Mat2x2_t w2iT; //!< transpose w3i
63 : jhr 1354 } Shadow_image2D_t;
64 :    
65 :     //! shadow wrapper for 3D image data
66 :     typedef struct {
67 : jhr 1357 cl_mem data; //!< GPU-side memory object for data.
68 :     cl_int size[3]; //!< sizes (fast to slow)
69 :     Shadow_Mat3x3_t w2i; //!< affine tranform from world space to index space. This is the
70 :     //! inverse of the index to world-space transform that is loaded from
71 :     //! the Nrrd file.
72 :     Shadow_vec3_t tVec; //!< translation part of world to index transform
73 :     Shadow_Mat3x3_t w2iT; //!< transpose w3i
74 : jhr 1354 } Shadow_image3D_t;
75 :    
76 : jhr 1355 /*! \brief initialize a shadow 2D vector from a host vector.
77 :     * \param dst the shadow value to initialize (an array)
78 :     * \param src the host vector to shadow.
79 :     *
80 :     * Note that the correctness of this function depends on the fact that
81 :     * the Shadow_vec2_t type is an array.
82 :     */
83 :     STATIC_INLINE void ShadowVec2 (Shadow_vec2_t dst, Diderot_vec2_t src)
84 :     {
85 :     dst[0] = ((Diderot_union2_t)(src)).r[0];
86 :     dst[1] = ((Diderot_union2_t)(src)).r[1];
87 :     }
88 :    
89 :     /*! \brief initialize a shadow 3D vector from a host vector.
90 :     * \param dst the shadow value to initialize (an array)
91 :     * \param src the host vector to shadow.
92 :     *
93 :     * Note that the correctness of this function depends on the fact that
94 :     * the Shadow_vec3_t type is an array.
95 :     */
96 :     STATIC_INLINE void ShadowVec3 (Shadow_vec3_t dst, Diderot_vec3_t src)
97 :     {
98 :     dst[0] = ((Diderot_union3_t)(src)).r[0];
99 :     dst[1] = ((Diderot_union3_t)(src)).r[1];
100 :     dst[2] = ((Diderot_union3_t)(src)).r[2];
101 :     }
102 :    
103 :     /*! \brief initialize a shadow 4D vector from a host vector.
104 :     * \param dst the shadow value to initialize (an array)
105 :     * \param src the host vector to shadow.
106 :     *
107 :     * Note that the correctness of this function depends on the fact that
108 :     * the Shadow_vec4_t type is an array.
109 :     */
110 :     STATIC_INLINE void ShadowVec4 (Shadow_vec4_t dst, Diderot_vec4_t src)
111 :     {
112 :     dst[0] = ((Diderot_union4_t)(src)).r[0];
113 :     dst[1] = ((Diderot_union4_t)(src)).r[1];
114 :     dst[2] = ((Diderot_union4_t)(src)).r[2];
115 :     dst[3] = ((Diderot_union4_t)(src)).r[3];
116 :     }
117 :    
118 :     /*! \brief initialize a shadow 2x2 matrix from a host matrix.
119 :     * \param dst the shadow value to initialize (an array of arrays)
120 :     * \param src the host matrix to shadow.
121 :     */
122 :     STATIC_INLINE void ShadowMat2x2 (Shadow_Mat2x2_t dst, Diderot_Mat2x2_t src)
123 :     {
124 :     ShadowVec2 (dst[0], src[0].v);
125 :     ShadowVec2 (dst[1], src[1].v);
126 :     }
127 :    
128 :     /*! \brief initialize a shadow 3x3 matrix from a host matrix.
129 :     * \param dst the shadow value to initialize (an array of arrays)
130 :     * \param src the host matrix to shadow.
131 :     */
132 :     STATIC_INLINE void ShadowMat3x3 (Shadow_Mat3x3_t dst, Diderot_Mat3x3_t src)
133 :     {
134 :     ShadowVec3 (dst[0], src[0].v);
135 :     ShadowVec3 (dst[1], src[1].v);
136 :     ShadowVec3 (dst[2], src[2].v);
137 :     }
138 :    
139 :     /*! \brief initialize a shadow 4x4 matrix from a host matrix.
140 :     * \param dst the shadow value to initialize (an array of arrays)
141 :     * \param src the host matrix to shadow.
142 :     */
143 :     STATIC_INLINE void ShadowMat4x4 (Shadow_Mat4x4_t dst, Diderot_Mat4x4_t src)
144 :     {
145 :     ShadowVec4 (dst[0], src[0].v);
146 :     ShadowVec4 (dst[1], src[1].v);
147 :     ShadowVec4 (dst[2], src[2].v);
148 :     ShadowVec4 (dst[3], src[3].v);
149 :     }
150 :    
151 : jhr 1354 /*! \brief initialize a shadow for a 1D image
152 :     * \param cxt the OpenCL context used to allocate the shadow buffer
153 :     * \param dst the pointer to the shadow image
154 :     * \param src the source image to shadow
155 :     */
156 :     void ShadowImage1D (cl_context cxt, Shadow_image1D_t *dst, Diderot_image1D_t *img);
157 :    
158 :     /*! \brief initialize a shadow for a 2D image
159 :     * \param cxt the OpenCL context used to allocate the shadow buffer
160 :     * \param dst the pointer to the shadow image
161 :     * \param src the source image to shadow
162 :     */
163 :     void ShadowImage2D (cl_context cxt, Shadow_image2D_t *dst, Diderot_image2D_t *img);
164 :    
165 :     /*! \brief initialize a shadow for a 3D image
166 :     * \param cxt the OpenCL context used to allocate the shadow buffer
167 :     * \param dst the pointer to the shadow image
168 :     * \param src the source image to shadow
169 :     */
170 :     void ShadowImage3D (cl_context cxt, Shadow_image3D_t *dst, Diderot_image3D_t *img);
171 :    
172 :     #endif /* !_SHADOW_TYPES_H_ */

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