Mercurial > projects > cl4d
comparison opencl/c/orgHeaders/cl_platform.h @ 0:3cea44337083
initial commit
author | Trass3r |
---|---|
date | Wed, 02 Dec 2009 17:40:59 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3cea44337083 |
---|---|
1 /********************************************************************************** | |
2 * Copyright (c) 2008-2009 The Khronos Group Inc. | |
3 * | |
4 * Permission is hereby granted, free of charge, to any person obtaining a | |
5 * copy of this software and/or associated documentation files (the | |
6 * "Materials"), to deal in the Materials without restriction, including | |
7 * without limitation the rights to use, copy, modify, merge, publish, | |
8 * distribute, sublicense, and/or sell copies of the Materials, and to | |
9 * permit persons to whom the Materials are furnished to do so, subject to | |
10 * the following conditions: | |
11 * | |
12 * The above copyright notice and this permission notice shall be included | |
13 * in all copies or substantial portions of the Materials. | |
14 * | |
15 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | |
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | |
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | |
21 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. | |
22 **********************************************************************************/ | |
23 | |
24 /* $Revision: 9283 $ on $Date: 2009-10-14 10:18:57 -0700 (Wed, 14 Oct 2009) $ */ | |
25 | |
26 #ifndef __CL_PLATFORM_H | |
27 #define __CL_PLATFORM_H | |
28 | |
29 #ifdef __APPLE__ | |
30 /* Contains #defines for AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER below */ | |
31 #include <AvailabilityMacros.h> | |
32 #endif | |
33 | |
34 #ifdef __cplusplus | |
35 extern "C" { | |
36 #endif | |
37 | |
38 #define CL_API_ENTRY | |
39 #define CL_API_CALL | |
40 #ifdef __APPLE__ | |
41 #define CL_API_SUFFIX__VERSION_1_0 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER | |
42 #define CL_EXTENSION_WEAK_LINK __attribute__((weak_import)) | |
43 #else | |
44 #define CL_API_SUFFIX__VERSION_1_0 | |
45 #define CL_EXTENSION_WEAK_LINK | |
46 #endif | |
47 | |
48 #if (defined (WIN32) && (_MSC_VER)) | |
49 | |
50 /* scalar types */ | |
51 typedef signed __int8 cl_char; | |
52 typedef unsigned __int8 cl_uchar; | |
53 typedef signed __int16 cl_short; | |
54 typedef unsigned __int16 cl_ushort; | |
55 typedef signed __int32 cl_int; | |
56 typedef unsigned __int32 cl_uint; | |
57 typedef signed __int64 cl_long; | |
58 typedef unsigned __int64 cl_ulong; | |
59 | |
60 typedef unsigned __int16 cl_half; | |
61 typedef float cl_float; | |
62 typedef double cl_double; | |
63 | |
64 | |
65 /* | |
66 * Vector types | |
67 * | |
68 * Note: OpenCL requires that all types be naturally aligned. | |
69 * This means that vector types must be naturally aligned. | |
70 * For example, a vector of four floats must be aligned to | |
71 * a 16 byte boundary (calculated as 4 * the natural 4-byte | |
72 * alignment of the float). The alignment qualifiers here | |
73 * will only function properly if your compiler supports them | |
74 * and if you don't actively work to defeat them. For example, | |
75 * in order for a cl_float4 to be 16 byte aligned in a struct, | |
76 * the start of the struct must itself be 16-byte aligned. | |
77 * | |
78 * Maintaining proper alignment is the user's responsibility. | |
79 */ | |
80 typedef signed __int8 cl_char2[2]; | |
81 typedef signed __int8 cl_char4[4]; | |
82 typedef signed __int8 cl_char8[8]; | |
83 typedef signed __int8 cl_char16[16]; | |
84 typedef unsigned __int8 cl_uchar2[2]; | |
85 typedef unsigned __int8 cl_uchar4[4]; | |
86 typedef unsigned __int8 cl_uchar8[8]; | |
87 typedef unsigned __int8 cl_uchar16[16]; | |
88 | |
89 typedef signed __int16 cl_short2[2]; | |
90 typedef signed __int16 cl_short4[4]; | |
91 typedef signed __int16 cl_short8[8]; | |
92 typedef signed __int16 cl_short16[16]; | |
93 typedef unsigned __int16 cl_ushort2[2]; | |
94 typedef unsigned __int16 cl_ushort4[4]; | |
95 typedef unsigned __int16 cl_ushort8[8]; | |
96 typedef unsigned __int16 cl_ushort16[16]; | |
97 | |
98 typedef signed __int32 cl_int2[2]; | |
99 typedef signed __int32 cl_int4[4]; | |
100 typedef signed __int32 cl_int8[8]; | |
101 typedef signed __int32 cl_int16[16]; | |
102 typedef unsigned __int32 cl_uint2[2]; | |
103 typedef unsigned __int32 cl_uint4[4]; | |
104 typedef unsigned __int32 cl_uint8[8]; | |
105 typedef unsigned __int32 cl_uint16[16]; | |
106 | |
107 typedef signed __int64 cl_long2[2]; | |
108 typedef signed __int64 cl_long4[4]; | |
109 typedef signed __int64 cl_long8[8]; | |
110 typedef signed __int64 cl_long16[16]; | |
111 typedef unsigned __int64 cl_ulong2[2]; | |
112 typedef unsigned __int64 cl_ulong4[4]; | |
113 typedef unsigned __int64 cl_ulong8[8]; | |
114 typedef unsigned __int64 cl_ulong16[16]; | |
115 | |
116 typedef float cl_float2[2]; | |
117 typedef float cl_float4[4]; | |
118 typedef float cl_float8[8]; | |
119 typedef float cl_float16[16]; | |
120 | |
121 typedef double cl_double2[2]; | |
122 typedef double cl_double4[4]; | |
123 typedef double cl_double8[8]; | |
124 typedef double cl_double16[16]; | |
125 /* There are no vector types for half */ | |
126 | |
127 #define CL_CHAR_BIT 8 | |
128 #define CL_SCHAR_MAX 127 | |
129 #define CL_SCHAR_MIN (-127-1) | |
130 #define CL_CHAR_MAX CL_SCHAR_MAX | |
131 #define CL_CHAR_MIN CL_SCHAR_MIN | |
132 #define CL_UCHAR_MAX 255 | |
133 #define CL_SHRT_MAX 32767 | |
134 #define CL_SHRT_MIN (-32767-1) | |
135 #define CL_USHRT_MAX 65535 | |
136 #define CL_INT_MAX 2147483647 | |
137 #define CL_INT_MIN (-2147483647-1) | |
138 #define CL_UINT_MAX 0xffffffffU | |
139 #define CL_LONG_MAX ((cl_long) 0x7FFFFFFFFFFFFFFFLL) | |
140 #define CL_LONG_MIN ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL) | |
141 #define CL_ULONG_MAX ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL) | |
142 | |
143 #define CL_FLT_DIG 6 | |
144 #define CL_FLT_MANT_DIG 24 | |
145 #define CL_FLT_MAX_10_EXP +38 | |
146 #define CL_FLT_MAX_EXP +128 | |
147 #define CL_FLT_MIN_10_EXP -37 | |
148 #define CL_FLT_MIN_EXP -125 | |
149 #define CL_FLT_RADIX 2 | |
150 #define CL_FLT_MAX 340282346638528859811704183484516925440.0f | |
151 #define CL_FLT_MIN 1.175494350822287507969e-38f | |
152 #define CL_FLT_EPSILON 0x1.0p-23f | |
153 | |
154 #define CL_DBL_DIG 15 | |
155 #define CL_DBL_MANT_DIG 53 | |
156 #define CL_DBL_MAX_10_EXP +308 | |
157 #define CL_DBL_MAX_EXP +1024 | |
158 #define CL_DBL_MIN_10_EXP -307 | |
159 #define CL_DBL_MIN_EXP -1021 | |
160 #define CL_DBL_RADIX 2 | |
161 #define CL_DBL_MAX 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0 | |
162 #define CL_DBL_MIN 2.225073858507201383090e-308 | |
163 #define CL_DBL_EPSILON 2.220446049250313080847e-16 | |
164 | |
165 | |
166 #else | |
167 | |
168 #include <stdint.h> | |
169 | |
170 /* scalar types */ | |
171 typedef int8_t cl_char; | |
172 typedef uint8_t cl_uchar; | |
173 typedef int16_t cl_short __attribute__((aligned(2))); | |
174 typedef uint16_t cl_ushort __attribute__((aligned(2))); | |
175 typedef int32_t cl_int __attribute__((aligned(4))); | |
176 typedef uint32_t cl_uint __attribute__((aligned(4))); | |
177 typedef int64_t cl_long __attribute__((aligned(8))); | |
178 typedef uint64_t cl_ulong __attribute__((aligned(8))); | |
179 | |
180 typedef uint16_t cl_half __attribute__((aligned(2))); | |
181 typedef float cl_float __attribute__((aligned(4))); | |
182 typedef double cl_double __attribute__((aligned(8))); | |
183 | |
184 /* | |
185 * Vector types | |
186 * | |
187 * Note: OpenCL requires that all types be naturally aligned. | |
188 * This means that vector types must be naturally aligned. | |
189 * For example, a vector of four floats must be aligned to | |
190 * a 16 byte boundary (calculated as 4 * the natural 4-byte | |
191 * alignment of the float). The alignment qualifiers here | |
192 * will only function properly if your compiler supports them | |
193 * and if you don't actively work to defeat them. For example, | |
194 * in order for a cl_float4 to be 16 byte aligned in a struct, | |
195 * the start of the struct must itself be 16-byte aligned. | |
196 * | |
197 * Maintaining proper alignment is the user's responsibility. | |
198 */ | |
199 typedef int8_t cl_char2[2] __attribute__((aligned(2))); | |
200 typedef int8_t cl_char4[4] __attribute__((aligned(4))); | |
201 typedef int8_t cl_char8[8] __attribute__((aligned(8))); | |
202 typedef int8_t cl_char16[16] __attribute__((aligned(16))); | |
203 typedef uint8_t cl_uchar2[2] __attribute__((aligned(2))); | |
204 typedef uint8_t cl_uchar4[4] __attribute__((aligned(4))); | |
205 typedef uint8_t cl_uchar8[8] __attribute__((aligned(8))); | |
206 typedef uint8_t cl_uchar16[16] __attribute__((aligned(16))); | |
207 | |
208 typedef int16_t cl_short2[2] __attribute__((aligned(4))); | |
209 typedef int16_t cl_short4[4] __attribute__((aligned(8))); | |
210 typedef int16_t cl_short8[8] __attribute__((aligned(16))); | |
211 typedef int16_t cl_short16[16] __attribute__((aligned(32))); | |
212 typedef uint16_t cl_ushort2[2] __attribute__((aligned(4))); | |
213 typedef uint16_t cl_ushort4[4] __attribute__((aligned(8))); | |
214 typedef uint16_t cl_ushort8[8] __attribute__((aligned(16))); | |
215 typedef uint16_t cl_ushort16[16] __attribute__((aligned(32))); | |
216 | |
217 typedef int32_t cl_int2[2] __attribute__((aligned(8))); | |
218 typedef int32_t cl_int4[4] __attribute__((aligned(16))); | |
219 typedef int32_t cl_int8[8] __attribute__((aligned(32))); | |
220 typedef int32_t cl_int16[16] __attribute__((aligned(64))); | |
221 typedef uint32_t cl_uint2[2] __attribute__((aligned(8))); | |
222 typedef uint32_t cl_uint4[4] __attribute__((aligned(16))); | |
223 typedef uint32_t cl_uint8[8] __attribute__((aligned(32))); | |
224 typedef uint32_t cl_uint16[16] __attribute__((aligned(64))); | |
225 | |
226 typedef int64_t cl_long2[2] __attribute__((aligned(16))); | |
227 typedef int64_t cl_long4[4] __attribute__((aligned(32))); | |
228 typedef int64_t cl_long8[8] __attribute__((aligned(64))); | |
229 typedef int64_t cl_long16[16] __attribute__((aligned(128))); | |
230 typedef uint64_t cl_ulong2[2] __attribute__((aligned(16))); | |
231 typedef uint64_t cl_ulong4[4] __attribute__((aligned(32))); | |
232 typedef uint64_t cl_ulong8[8] __attribute__((aligned(64))); | |
233 typedef uint64_t cl_ulong16[16] __attribute__((aligned(128))); | |
234 | |
235 typedef float cl_float2[2] __attribute__((aligned(8))); | |
236 typedef float cl_float4[4] __attribute__((aligned(16))); | |
237 typedef float cl_float8[8] __attribute__((aligned(32))); | |
238 typedef float cl_float16[16] __attribute__((aligned(64))); | |
239 | |
240 typedef double cl_double2[2] __attribute__((aligned(16))); | |
241 typedef double cl_double4[4] __attribute__((aligned(32))); | |
242 typedef double cl_double8[8] __attribute__((aligned(64))); | |
243 typedef double cl_double16[16] __attribute__((aligned(128))); | |
244 | |
245 /* There are no vector types for half */ | |
246 | |
247 /******************************************************************************/ | |
248 | |
249 // Macro names and corresponding values defined by OpenCL | |
250 | |
251 #define CL_CHAR_BIT 8 | |
252 #define CL_SCHAR_MAX 127 | |
253 #define CL_SCHAR_MIN (-127-1) | |
254 #define CL_CHAR_MAX CL_SCHAR_MAX | |
255 #define CL_CHAR_MIN CL_SCHAR_MIN | |
256 #define CL_UCHAR_MAX 255 | |
257 #define CL_SHRT_MAX 32767 | |
258 #define CL_SHRT_MIN (-32767-1) | |
259 #define CL_USHRT_MAX 65535 | |
260 #define CL_INT_MAX 2147483647 | |
261 #define CL_INT_MIN (-2147483647-1) | |
262 #define CL_UINT_MAX 0xffffffffU | |
263 #define CL_LONG_MAX ((cl_long) 0x7FFFFFFFFFFFFFFFLL) | |
264 #define CL_LONG_MIN ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL) | |
265 #define CL_ULONG_MAX ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL) | |
266 | |
267 #define CL_FLT_DIG 6 | |
268 #define CL_FLT_MANT_DIG 24 | |
269 #define CL_FLT_MAX_10_EXP +38 | |
270 #define CL_FLT_MAX_EXP +128 | |
271 #define CL_FLT_MIN_10_EXP -37 | |
272 #define CL_FLT_MIN_EXP -125 | |
273 #define CL_FLT_RADIX 2 | |
274 #define CL_FLT_MAX 0x1.fffffep127f | |
275 #define CL_FLT_MIN 0x1.0p-126f | |
276 #define CL_FLT_EPSILON 0x1.0p-23f | |
277 | |
278 #define CL_DBL_DIG 15 | |
279 #define CL_DBL_MANT_DIG 53 | |
280 #define CL_DBL_MAX_10_EXP +308 | |
281 #define CL_DBL_MAX_EXP +1024 | |
282 #define CL_DBL_MIN_10_EXP -307 | |
283 #define CL_DBL_MIN_EXP -1021 | |
284 #define CL_DBL_RADIX 2 | |
285 #define CL_DBL_MAX 0x1.fffffffffffffp1023 | |
286 #define CL_DBL_MIN 0x1.0p-1022 | |
287 #define CL_DBL_EPSILON 0x1.0p-52 | |
288 | |
289 #endif | |
290 | |
291 #include <stddef.h> | |
292 | |
293 | |
294 #ifdef __cplusplus | |
295 } | |
296 #endif | |
297 | |
298 #endif // __CL_PLATFORM_H |