1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
/*
* Copyright (c) 2011, Denis Steckelmacher <steckdenis@yahoo.fr>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the copyright holderi nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* Types */
/* Standard types from Clang's stddef and stdint, Copyright (C) 2008 Eli Friedman */
typedef signed __INT64_TYPE__ int64_t;
typedef unsigned __INT64_TYPE__ uint64_t;
typedef signed __INT32_TYPE__ int32_t;
typedef unsigned __INT32_TYPE__ uint32_t;
typedef signed __INT16_TYPE__ int16_t;
typedef unsigned __INT16_TYPE__ uint16_t;
typedef signed __INT8_TYPE__ int8_t;
typedef unsigned __INT8_TYPE__ uint8_t;
#define __stdint_join3(a,b,c) a ## b ## c
#define __intn_t(n) __stdint_join3( int, n, _t)
#define __uintn_t(n) __stdint_join3(uint, n, _t)
typedef __typeof__(((int*)0)-((int*)0)) ptrdiff_t;
typedef __typeof__(sizeof(int)) size_t;
typedef __intn_t(__INTPTR_WIDTH__) intptr_t;
typedef __uintn_t(__INTPTR_WIDTH__) uintptr_t;
/* OpenCL types */
typedef uint8_t uchar;
typedef uint16_t ushort;
typedef uint32_t uint;
typedef uint64_t ulong;
typedef unsigned int sampler_t;
typedef struct image2d *image2d_t;
typedef struct image3d *image3d_t;
/* Vectors */
#define COAL_VECTOR(type, len) \
typedef type type##len __attribute__((ext_vector_type(len)))
#define COAL_VECTOR_SET(type) \
COAL_VECTOR(type, 2); \
COAL_VECTOR(type, 3); \
COAL_VECTOR(type, 4); \
COAL_VECTOR(type, 8); \
COAL_VECTOR(type, 16);
COAL_VECTOR_SET(char);
COAL_VECTOR_SET(uchar);
COAL_VECTOR_SET(short);
COAL_VECTOR_SET(ushort);
COAL_VECTOR_SET(int);
COAL_VECTOR_SET(uint);
COAL_VECTOR_SET(long);
COAL_VECTOR_SET(ulong);
COAL_VECTOR_SET(float);
#undef COAL_VECTOR_SET
#undef COAL_VECTOR
/* Address spaces */
#define __private __attribute__((address_space(0)))
#define __global __attribute__((address_space(1)))
#define __local __attribute__((address_space(2)))
#define __constant __attribute__((address_space(3)))
#define global __global
#define local __local
#define constant __constant
#define private __private
#define __write_only
#define __read_only const
#define write_only __write_only
#define read_only __read_only
/* Defines */
#define OVERLOAD __attribute__((overloadable))
#define CLK_NORMALIZED_COORDS_FALSE 0x00000000
#define CLK_NORMALIZED_COORDS_TRUE 0x00000001
#define CLK_ADDRESS_NONE 0x00000000
#define CLK_ADDRESS_MIRRORED_REPEAT 0x00000010
#define CLK_ADDRESS_REPEAT 0x00000020
#define CLK_ADDRESS_CLAMP_TO_EDGE 0x00000030
#define CLK_ADDRESS_CLAMP 0x00000040
#define CLK_FILTER_NEAREST 0x00000000
#define CLK_FILTER_LINEAR 0x00000100
#define CLK_LOCAL_MEM_FENCE 0x00000001
#define CLK_GLOBAL_MEM_FENCE 0x00000002
#define CLK_R 0x10B0
#define CLK_A 0x10B1
#define CLK_RG 0x10B2
#define CLK_RA 0x10B3
#define CLK_RGB 0x10B4
#define CLK_RGBA 0x10B5
#define CLK_BGRA 0x10B6
#define CLK_ARGB 0x10B7
#define CLK_INTENSITY 0x10B8
#define CLK_LUMINANCE 0x10B9
#define CLK_Rx 0x10BA
#define CLK_RGx 0x10BB
#define CLK_RGBx 0x10BC
#define CLK_SNORM_INT8 0x10D0
#define CLK_SNORM_INT16 0x10D1
#define CLK_UNORM_INT8 0x10D2
#define CLK_UNORM_INT16 0x10D3
#define CLK_UNORM_SHORT_565 0x10D4
#define CLK_UNORM_SHORT_555 0x10D5
#define CLK_UNORM_INT_101010 0x10D6
#define CLK_SIGNED_INT8 0x10D7
#define CLK_SIGNED_INT16 0x10D8
#define CLK_SIGNED_INT32 0x10D9
#define CLK_UNSIGNED_INT8 0x10DA
#define CLK_UNSIGNED_INT16 0x10DB
#define CLK_UNSIGNED_INT32 0x10DC
#define CLK_HALF_FLOAT 0x10DD
#define CLK_FLOAT 0x10DE
/* Typedefs */
typedef unsigned int cl_mem_fence_flags;
/* Management functions */
uint get_work_dim();
size_t get_global_size(uint dimindx);
size_t get_global_id(uint dimindx);
size_t get_local_size(uint dimindx);
size_t get_local_id(uint dimindx);
size_t get_num_groups(uint dimindx);
size_t get_group_id(uint dimindx);
size_t get_global_offset(uint dimindx);
void barrier(cl_mem_fence_flags flags);
/* Image functions */
float4 OVERLOAD read_imagef(image2d_t image, sampler_t sampler, int2 coord);
float4 OVERLOAD read_imagef(image3d_t image, sampler_t sampler, int4 coord);
float4 OVERLOAD read_imagef(image2d_t image, sampler_t sampler, float2 coord);
float4 OVERLOAD read_imagef(image3d_t image, sampler_t sampler, float4 coord);
int4 OVERLOAD read_imagei(image2d_t image, sampler_t sampler, int2 coord);
int4 OVERLOAD read_imagei(image3d_t image, sampler_t sampler, int4 coord);
int4 OVERLOAD read_imagei(image2d_t image, sampler_t sampler, float2 coord);
int4 OVERLOAD read_imagei(image3d_t image, sampler_t sampler, float4 coord);
uint4 OVERLOAD read_imageui(image2d_t image, sampler_t sampler, int2 coord);
uint4 OVERLOAD read_imageui(image3d_t image, sampler_t sampler, int4 coord);
uint4 OVERLOAD read_imageui(image2d_t image, sampler_t sampler, float2 coord);
uint4 OVERLOAD read_imageui(image3d_t image, sampler_t sampler, float4 coord);
void OVERLOAD write_imagef(image2d_t image, int2 coord, float4 color);
void OVERLOAD write_imagef(image3d_t image, int4 coord, float4 color);
void OVERLOAD write_imagei(image2d_t image, int2 coord, int4 color);
void OVERLOAD write_imagei(image3d_t image, int4 coord, int4 color);
void OVERLOAD write_imageui(image2d_t image, int2 coord, uint4 color);
void OVERLOAD write_imageui(image3d_t image, int4 coord, uint4 color);
int2 OVERLOAD get_image_dim(image2d_t image);
int4 OVERLOAD get_image_dim(image3d_t image);
int OVERLOAD get_image_width(image2d_t image);
int OVERLOAD get_image_width(image3d_t image);
int OVERLOAD get_image_height(image2d_t image);
int OVERLOAD get_image_height(image3d_t image);
int OVERLOAD get_image_depth(image3d_t image);
int OVERLOAD get_image_channel_data_type(image2d_t image);
int OVERLOAD get_image_channel_data_type(image3d_t image);
int OVERLOAD get_image_channel_order(image2d_t image);
int OVERLOAD get_image_channel_order(image3d_t image);
|