hessml-ffi-opencl 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +42 -0
- data/Rakefile +66 -0
- data/VERSION +1 -0
- data/examples/capabilities.rb +30 -0
- data/ffi-opencl.gemspec +61 -0
- data/interfaces/cl.h +866 -0
- data/interfaces/cl.i +45 -0
- data/interfaces/cl_gl.h +227 -0
- data/interfaces/cl_platform.h +262 -0
- data/lib/ffi-opencl/cl.rb +366 -0
- data/lib/ffi-opencl/platform.rb +10 -0
- data/lib/ffi-opencl.rb +12 -0
- data/spec/ffi-opencl_spec.rb +7 -0
- data/spec/spec_helper.rb +9 -0
- data/tasks/generator.rake +11 -0
- metadata +84 -0
data/interfaces/cl.i
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
%module opencl
|
2
|
+
|
3
|
+
%{
|
4
|
+
module CL
|
5
|
+
extend FFI::Library
|
6
|
+
%}
|
7
|
+
|
8
|
+
#define CL_API_ENTRY
|
9
|
+
#define CL_API_CALL
|
10
|
+
#define CL_API_SUFFIX__VERSION_1_0
|
11
|
+
#define __attribute__(x)
|
12
|
+
|
13
|
+
typedef signed char int8_t;
|
14
|
+
typedef short int16_t;
|
15
|
+
typedef int int32_t;
|
16
|
+
typedef long long int64_t;
|
17
|
+
typedef unsigned char uint8_t;
|
18
|
+
typedef unsigned short uint16_t;
|
19
|
+
typedef unsigned int uint32_t;
|
20
|
+
typedef unsigned long long uint64_t;
|
21
|
+
|
22
|
+
typedef unsigned int GLenum;
|
23
|
+
typedef unsigned char GLboolean;
|
24
|
+
typedef unsigned int GLbitfield;
|
25
|
+
typedef void GLvoid;
|
26
|
+
typedef signed char GLbyte;
|
27
|
+
typedef short GLshort;
|
28
|
+
typedef int GLint;
|
29
|
+
typedef unsigned char GLubyte;
|
30
|
+
typedef unsigned short GLushort;
|
31
|
+
typedef unsigned int GLuint;
|
32
|
+
typedef int GLsizei;
|
33
|
+
typedef float GLfloat;
|
34
|
+
typedef float GLclampf;
|
35
|
+
typedef double GLdouble;
|
36
|
+
typedef double GLclampd;
|
37
|
+
|
38
|
+
|
39
|
+
%include cl_platform.h
|
40
|
+
%include cl.h
|
41
|
+
%include cl_gl.h
|
42
|
+
|
43
|
+
%{
|
44
|
+
end
|
45
|
+
%}
|
data/interfaces/cl_gl.h
ADDED
@@ -0,0 +1,227 @@
|
|
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
|
+
#ifndef __OPENCL_CL_GL_H
|
25
|
+
#define __OPENCL_CL_GL_H
|
26
|
+
|
27
|
+
#ifdef __APPLE__
|
28
|
+
#include <OpenCL/cl_platform.h>
|
29
|
+
#else
|
30
|
+
#include <CL/cl_platform.h>/**********************************************************************************
|
31
|
+
* Copyright (c) 2008-2009 The Khronos Group Inc.
|
32
|
+
*
|
33
|
+
* Permission is hereby granted, free of charge, to any person obtaining a
|
34
|
+
* copy of this software and/or associated documentation files (the
|
35
|
+
* "Materials"), to deal in the Materials without restriction, including
|
36
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
37
|
+
* distribute, sublicense, and/or sell copies of the Materials, and to
|
38
|
+
* permit persons to whom the Materials are furnished to do so, subject to
|
39
|
+
* the following conditions:
|
40
|
+
*
|
41
|
+
* The above copyright notice and this permission notice shall be included
|
42
|
+
* in all copies or substantial portions of the Materials.
|
43
|
+
*
|
44
|
+
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
45
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
46
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
47
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
48
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
49
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
50
|
+
* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
51
|
+
**********************************************************************************/
|
52
|
+
|
53
|
+
#ifndef __OPENCL_CL_GL_H
|
54
|
+
#define __OPENCL_CL_GL_H
|
55
|
+
|
56
|
+
#ifdef __APPLE__
|
57
|
+
#include <OpenCL/cl_platform.h>
|
58
|
+
#else
|
59
|
+
#include <CL/cl_platform.h>
|
60
|
+
#include <cl_platform.h>
|
61
|
+
#endif
|
62
|
+
|
63
|
+
#ifdef __cplusplus
|
64
|
+
extern "C" {
|
65
|
+
#endif
|
66
|
+
|
67
|
+
// NOTE: Make sure that appropriate GL header file is included separately
|
68
|
+
|
69
|
+
typedef cl_uint cl_gl_object_type;
|
70
|
+
typedef cl_uint cl_gl_texture_info;
|
71
|
+
typedef cl_uint cl_gl_platform_info;
|
72
|
+
|
73
|
+
// cl_gl_object_type
|
74
|
+
#define CL_GL_OBJECT_BUFFER 0x2000
|
75
|
+
#define CL_GL_OBJECT_TEXTURE2D 0x2001
|
76
|
+
#define CL_GL_OBJECT_TEXTURE3D 0x2002
|
77
|
+
#define CL_GL_OBJECT_RENDERBUFFER 0x2003
|
78
|
+
|
79
|
+
// cl_gl_texture_info
|
80
|
+
#define CL_GL_TEXTURE_TARGET 0x2004
|
81
|
+
#define CL_GL_MIPMAP_LEVEL 0x2005
|
82
|
+
|
83
|
+
extern CL_API_ENTRY cl_mem CL_API_CALL
|
84
|
+
clCreateFromGLBuffer(cl_context /* context */,
|
85
|
+
cl_mem_flags /* flags */,
|
86
|
+
GLuint /* bufobj */,
|
87
|
+
int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
|
88
|
+
|
89
|
+
extern CL_API_ENTRY cl_mem CL_API_CALL
|
90
|
+
clCreateFromGLTexture2D(cl_context /* context */,
|
91
|
+
cl_mem_flags /* flags */,
|
92
|
+
GLenum /* target */,
|
93
|
+
GLint /* miplevel */,
|
94
|
+
GLuint /* texture */,
|
95
|
+
cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
|
96
|
+
|
97
|
+
extern CL_API_ENTRY cl_mem CL_API_CALL
|
98
|
+
clCreateFromGLTexture3D(cl_context /* context */,
|
99
|
+
cl_mem_flags /* flags */,
|
100
|
+
GLenum /* target */,
|
101
|
+
GLint /* miplevel */,
|
102
|
+
GLuint /* texture */,
|
103
|
+
cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
|
104
|
+
|
105
|
+
extern CL_API_ENTRY cl_mem CL_API_CALL
|
106
|
+
clCreateFromGLRenderbuffer(cl_context /* context */,
|
107
|
+
cl_mem_flags /* flags */,
|
108
|
+
GLuint /* renderbuffer */,
|
109
|
+
cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
|
110
|
+
|
111
|
+
extern CL_API_ENTRY cl_int CL_API_CALL
|
112
|
+
clGetGLObjectInfo(cl_mem /* memobj */,
|
113
|
+
cl_gl_object_type * /* gl_object_type */,
|
114
|
+
GLuint * /* gl_object_name */) CL_API_SUFFIX__VERSION_1_0;
|
115
|
+
|
116
|
+
extern CL_API_ENTRY cl_int CL_API_CALL
|
117
|
+
clGetGLTextureInfo(cl_mem /* memobj */,
|
118
|
+
cl_gl_texture_info /* param_name */,
|
119
|
+
size_t /* param_value_size */,
|
120
|
+
void * /* param_value */,
|
121
|
+
size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
|
122
|
+
|
123
|
+
extern CL_API_ENTRY cl_int CL_API_CALL
|
124
|
+
clEnqueueAcquireGLObjects(cl_command_queue /* command_queue */,
|
125
|
+
cl_uint /* num_objects */,
|
126
|
+
const cl_mem * /* mem_objects */,
|
127
|
+
cl_uint /* num_events_in_wait_list */,
|
128
|
+
const cl_event * /* event_wait_list */,
|
129
|
+
cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
|
130
|
+
|
131
|
+
extern CL_API_ENTRY cl_int CL_API_CALL
|
132
|
+
clEnqueueReleaseGLObjects(cl_command_queue /* command_queue */,
|
133
|
+
cl_uint /* num_objects */,
|
134
|
+
const cl_mem * /* mem_objects */,
|
135
|
+
cl_uint /* num_events_in_wait_list */,
|
136
|
+
const cl_event * /* event_wait_list */,
|
137
|
+
cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
|
138
|
+
|
139
|
+
#ifdef __cplusplus
|
140
|
+
}
|
141
|
+
#endif
|
142
|
+
|
143
|
+
#endif // __OPENCL_CL_GL_H
|
144
|
+
|
145
|
+
#endif
|
146
|
+
|
147
|
+
#ifdef __cplusplus
|
148
|
+
extern "C" {
|
149
|
+
#endif
|
150
|
+
|
151
|
+
// NOTE: Make sure that appropriate GL header file is included separately
|
152
|
+
|
153
|
+
typedef cl_uint cl_gl_object_type;
|
154
|
+
typedef cl_uint cl_gl_texture_info;
|
155
|
+
typedef cl_uint cl_gl_platform_info;
|
156
|
+
|
157
|
+
// cl_gl_object_type
|
158
|
+
#define CL_GL_OBJECT_BUFFER 0x2000
|
159
|
+
#define CL_GL_OBJECT_TEXTURE2D 0x2001
|
160
|
+
#define CL_GL_OBJECT_TEXTURE3D 0x2002
|
161
|
+
#define CL_GL_OBJECT_RENDERBUFFER 0x2003
|
162
|
+
|
163
|
+
// cl_gl_texture_info
|
164
|
+
#define CL_GL_TEXTURE_TARGET 0x2004
|
165
|
+
#define CL_GL_MIPMAP_LEVEL 0x2005
|
166
|
+
|
167
|
+
extern CL_API_ENTRY cl_mem CL_API_CALL
|
168
|
+
clCreateFromGLBuffer(cl_context /* context */,
|
169
|
+
cl_mem_flags /* flags */,
|
170
|
+
GLuint /* bufobj */,
|
171
|
+
int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
|
172
|
+
|
173
|
+
extern CL_API_ENTRY cl_mem CL_API_CALL
|
174
|
+
clCreateFromGLTexture2D(cl_context /* context */,
|
175
|
+
cl_mem_flags /* flags */,
|
176
|
+
GLenum /* target */,
|
177
|
+
GLint /* miplevel */,
|
178
|
+
GLuint /* texture */,
|
179
|
+
cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
|
180
|
+
|
181
|
+
extern CL_API_ENTRY cl_mem CL_API_CALL
|
182
|
+
clCreateFromGLTexture3D(cl_context /* context */,
|
183
|
+
cl_mem_flags /* flags */,
|
184
|
+
GLenum /* target */,
|
185
|
+
GLint /* miplevel */,
|
186
|
+
GLuint /* texture */,
|
187
|
+
cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
|
188
|
+
|
189
|
+
extern CL_API_ENTRY cl_mem CL_API_CALL
|
190
|
+
clCreateFromGLRenderbuffer(cl_context /* context */,
|
191
|
+
cl_mem_flags /* flags */,
|
192
|
+
GLuint /* renderbuffer */,
|
193
|
+
cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
|
194
|
+
|
195
|
+
extern CL_API_ENTRY cl_int CL_API_CALL
|
196
|
+
clGetGLObjectInfo(cl_mem /* memobj */,
|
197
|
+
cl_gl_object_type * /* gl_object_type */,
|
198
|
+
GLuint * /* gl_object_name */) CL_API_SUFFIX__VERSION_1_0;
|
199
|
+
|
200
|
+
extern CL_API_ENTRY cl_int CL_API_CALL
|
201
|
+
clGetGLTextureInfo(cl_mem /* memobj */,
|
202
|
+
cl_gl_texture_info /* param_name */,
|
203
|
+
size_t /* param_value_size */,
|
204
|
+
void * /* param_value */,
|
205
|
+
size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
|
206
|
+
|
207
|
+
extern CL_API_ENTRY cl_int CL_API_CALL
|
208
|
+
clEnqueueAcquireGLObjects(cl_command_queue /* command_queue */,
|
209
|
+
cl_uint /* num_objects */,
|
210
|
+
const cl_mem * /* mem_objects */,
|
211
|
+
cl_uint /* num_events_in_wait_list */,
|
212
|
+
const cl_event * /* event_wait_list */,
|
213
|
+
cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
|
214
|
+
|
215
|
+
extern CL_API_ENTRY cl_int CL_API_CALL
|
216
|
+
clEnqueueReleaseGLObjects(cl_command_queue /* command_queue */,
|
217
|
+
cl_uint /* num_objects */,
|
218
|
+
const cl_mem * /* mem_objects */,
|
219
|
+
cl_uint /* num_events_in_wait_list */,
|
220
|
+
const cl_event * /* event_wait_list */,
|
221
|
+
cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
|
222
|
+
|
223
|
+
#ifdef __cplusplus
|
224
|
+
}
|
225
|
+
#endif
|
226
|
+
|
227
|
+
#endif // __OPENCL_CL_GL_H
|
@@ -0,0 +1,262 @@
|
|
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
|
+
#ifndef __CL_PLATFORM_H
|
25
|
+
#define __CL_PLATFORM_H
|
26
|
+
|
27
|
+
#ifdef __APPLE__
|
28
|
+
/* Contains #defines for AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER below */
|
29
|
+
#include <AvailabilityMacros.h>
|
30
|
+
#endif
|
31
|
+
|
32
|
+
#ifdef __cplusplus
|
33
|
+
extern "C" {
|
34
|
+
#endif
|
35
|
+
|
36
|
+
#define CL_API_ENTRY
|
37
|
+
#define CL_API_CALL
|
38
|
+
#ifdef __APPLE__
|
39
|
+
#define CL_API_SUFFIX__VERSION_1_0 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
|
40
|
+
#define CL_EXTENSION_WEAK_LINK __attribute__((weak_import))
|
41
|
+
#else
|
42
|
+
#define CL_API_SUFFIX__VERSION_1_0
|
43
|
+
#define CL_EXTENSION_WEAK_LINK
|
44
|
+
#endif
|
45
|
+
|
46
|
+
#if (defined (WIN32) && (_MSC_VER))
|
47
|
+
|
48
|
+
/* scalar types */
|
49
|
+
typedef signed __int8 cl_char;
|
50
|
+
typedef unsigned __int8 cl_uchar;
|
51
|
+
typedef signed __int16 cl_short;
|
52
|
+
typedef unsigned __int16 cl_ushort;
|
53
|
+
typedef signed __int32 cl_int;
|
54
|
+
typedef unsigned __int32 cl_uint;
|
55
|
+
typedef signed __int64 cl_long;
|
56
|
+
typedef unsigned __int64 cl_ulong;
|
57
|
+
|
58
|
+
typedef unsigned __int16 cl_half;
|
59
|
+
typedef float cl_float;
|
60
|
+
typedef double cl_double;
|
61
|
+
|
62
|
+
|
63
|
+
/*
|
64
|
+
* Vector types
|
65
|
+
*
|
66
|
+
* Note: OpenCL requires that all types be naturally aligned.
|
67
|
+
* This means that vector types must be naturally aligned.
|
68
|
+
* For example, a vector of four floats must be aligned to
|
69
|
+
* a 16 byte boundary (calculated as 4 * the natural 4-byte
|
70
|
+
* alignment of the float). The alignment qualifiers here
|
71
|
+
* will only function properly if your compiler supports them
|
72
|
+
* and if you don't actively work to defeat them. For example,
|
73
|
+
* in order for a cl_float4 to be 16 byte aligned in a struct,
|
74
|
+
* the start of the struct must itself be 16-byte aligned.
|
75
|
+
*
|
76
|
+
* Maintaining proper alignment is the user's responsibility.
|
77
|
+
*/
|
78
|
+
typedef signed __int8 cl_char2[2];
|
79
|
+
typedef signed __int8 cl_char4[4];
|
80
|
+
typedef signed __int8 cl_char8[8];
|
81
|
+
typedef signed __int8 cl_char16[16];
|
82
|
+
typedef unsigned __int8 cl_uchar2[2];
|
83
|
+
typedef unsigned __int8 cl_uchar4[4];
|
84
|
+
typedef unsigned __int8 cl_uchar8[8];
|
85
|
+
typedef unsigned __int8 cl_uchar16[16];
|
86
|
+
|
87
|
+
typedef signed __int16 cl_short2[2];
|
88
|
+
typedef signed __int16 cl_short4[4];
|
89
|
+
typedef signed __int16 cl_short8[8];
|
90
|
+
typedef signed __int16 cl_short16[16];
|
91
|
+
typedef unsigned __int16 cl_ushort2[2];
|
92
|
+
typedef unsigned __int16 cl_ushort4[4];
|
93
|
+
typedef unsigned __int16 cl_ushort8[8];
|
94
|
+
typedef unsigned __int16 cl_ushort16[16];
|
95
|
+
|
96
|
+
typedef signed __int32 cl_int2[2];
|
97
|
+
typedef signed __int32 cl_int4[4];
|
98
|
+
typedef signed __int32 cl_int8[8];
|
99
|
+
typedef signed __int32 cl_int16[16];
|
100
|
+
typedef unsigned __int32 cl_uint2[2];
|
101
|
+
typedef unsigned __int32 cl_uint4[4];
|
102
|
+
typedef unsigned __int32 cl_uint8[8];
|
103
|
+
typedef unsigned __int32 cl_uint16[16];
|
104
|
+
|
105
|
+
typedef signed __int64 cl_long2[2];
|
106
|
+
typedef signed __int64 cl_long4[4];
|
107
|
+
typedef signed __int64 cl_long8[8];
|
108
|
+
typedef signed __int64 cl_long16[16];
|
109
|
+
typedef unsigned __int64 cl_ulong2[2];
|
110
|
+
typedef unsigned __int64 cl_ulong4[4];
|
111
|
+
typedef unsigned __int64 cl_ulong8[8];
|
112
|
+
typedef unsigned __int64 cl_ulong16[16];
|
113
|
+
|
114
|
+
typedef float cl_float2[2];
|
115
|
+
typedef float cl_float4[4];
|
116
|
+
typedef float cl_float8[8];
|
117
|
+
typedef float cl_float16[16];
|
118
|
+
|
119
|
+
typedef double cl_double2[2];
|
120
|
+
typedef double cl_double4[4];
|
121
|
+
typedef double cl_double8[8];
|
122
|
+
typedef double cl_double16[16];
|
123
|
+
/* There are no vector types for half */
|
124
|
+
|
125
|
+
#else
|
126
|
+
|
127
|
+
#include <stdint.h>
|
128
|
+
|
129
|
+
/* scalar types */
|
130
|
+
typedef int8_t cl_char;
|
131
|
+
typedef uint8_t cl_uchar;
|
132
|
+
typedef int16_t cl_short __attribute__((aligned(2)));
|
133
|
+
typedef uint16_t cl_ushort __attribute__((aligned(2)));
|
134
|
+
typedef int32_t cl_int __attribute__((aligned(4)));
|
135
|
+
typedef uint32_t cl_uint __attribute__((aligned(4)));
|
136
|
+
typedef int64_t cl_long __attribute__((aligned(8)));
|
137
|
+
typedef uint64_t cl_ulong __attribute__((aligned(8)));
|
138
|
+
|
139
|
+
typedef uint16_t cl_half __attribute__((aligned(2)));
|
140
|
+
typedef float cl_float __attribute__((aligned(4)));
|
141
|
+
typedef double cl_double __attribute__((aligned(8)));
|
142
|
+
|
143
|
+
/*
|
144
|
+
* Vector types
|
145
|
+
*
|
146
|
+
* Note: OpenCL requires that all types be naturally aligned.
|
147
|
+
* This means that vector types must be naturally aligned.
|
148
|
+
* For example, a vector of four floats must be aligned to
|
149
|
+
* a 16 byte boundary (calculated as 4 * the natural 4-byte
|
150
|
+
* alignment of the float). The alignment qualifiers here
|
151
|
+
* will only function properly if your compiler supports them
|
152
|
+
* and if you don't actively work to defeat them. For example,
|
153
|
+
* in order for a cl_float4 to be 16 byte aligned in a struct,
|
154
|
+
* the start of the struct must itself be 16-byte aligned.
|
155
|
+
*
|
156
|
+
* Maintaining proper alignment is the user's responsibility.
|
157
|
+
*/
|
158
|
+
typedef int8_t cl_char2[2] __attribute__((aligned(2)));
|
159
|
+
typedef int8_t cl_char4[4] __attribute__((aligned(4)));
|
160
|
+
typedef int8_t cl_char8[8] __attribute__((aligned(8)));
|
161
|
+
typedef int8_t cl_char16[16] __attribute__((aligned(16)));
|
162
|
+
typedef uint8_t cl_uchar2[2] __attribute__((aligned(2)));
|
163
|
+
typedef uint8_t cl_uchar4[4] __attribute__((aligned(4)));
|
164
|
+
typedef uint8_t cl_uchar8[8] __attribute__((aligned(8)));
|
165
|
+
typedef uint8_t cl_uchar16[16] __attribute__((aligned(16)));
|
166
|
+
|
167
|
+
typedef int16_t cl_short2[2] __attribute__((aligned(4)));
|
168
|
+
typedef int16_t cl_short4[4] __attribute__((aligned(8)));
|
169
|
+
typedef int16_t cl_short8[8] __attribute__((aligned(16)));
|
170
|
+
typedef int16_t cl_short16[16] __attribute__((aligned(32)));
|
171
|
+
typedef uint16_t cl_ushort2[2] __attribute__((aligned(4)));
|
172
|
+
typedef uint16_t cl_ushort4[4] __attribute__((aligned(8)));
|
173
|
+
typedef uint16_t cl_ushort8[8] __attribute__((aligned(16)));
|
174
|
+
typedef uint16_t cl_ushort16[16] __attribute__((aligned(32)));
|
175
|
+
|
176
|
+
typedef int32_t cl_int2[2] __attribute__((aligned(8)));
|
177
|
+
typedef int32_t cl_int4[4] __attribute__((aligned(16)));
|
178
|
+
typedef int32_t cl_int8[8] __attribute__((aligned(32)));
|
179
|
+
typedef int32_t cl_int16[16] __attribute__((aligned(64)));
|
180
|
+
typedef uint32_t cl_uint2[2] __attribute__((aligned(8)));
|
181
|
+
typedef uint32_t cl_uint4[4] __attribute__((aligned(16)));
|
182
|
+
typedef uint32_t cl_uint8[8] __attribute__((aligned(32)));
|
183
|
+
typedef uint32_t cl_uint16[16] __attribute__((aligned(64)));
|
184
|
+
|
185
|
+
typedef int64_t cl_long2[2] __attribute__((aligned(16)));
|
186
|
+
typedef int64_t cl_long4[4] __attribute__((aligned(32)));
|
187
|
+
typedef int64_t cl_long8[8] __attribute__((aligned(64)));
|
188
|
+
typedef int64_t cl_long16[16] __attribute__((aligned(128)));
|
189
|
+
typedef uint64_t cl_ulong2[2] __attribute__((aligned(16)));
|
190
|
+
typedef uint64_t cl_ulong4[4] __attribute__((aligned(32)));
|
191
|
+
typedef uint64_t cl_ulong8[8] __attribute__((aligned(64)));
|
192
|
+
typedef uint64_t cl_ulong16[16] __attribute__((aligned(128)));
|
193
|
+
|
194
|
+
typedef float cl_float2[2] __attribute__((aligned(8)));
|
195
|
+
typedef float cl_float4[4] __attribute__((aligned(16)));
|
196
|
+
typedef float cl_float8[8] __attribute__((aligned(32)));
|
197
|
+
typedef float cl_float16[16] __attribute__((aligned(64)));
|
198
|
+
|
199
|
+
typedef double cl_double2[2] __attribute__((aligned(16)));
|
200
|
+
typedef double cl_double4[4] __attribute__((aligned(32)));
|
201
|
+
typedef double cl_double8[8] __attribute__((aligned(64)));
|
202
|
+
typedef double cl_double16[16] __attribute__((aligned(128)));
|
203
|
+
|
204
|
+
/* There are no vector types for half */
|
205
|
+
#endif
|
206
|
+
|
207
|
+
#include <stddef.h>
|
208
|
+
|
209
|
+
#define CL_CHAR_BIT 8
|
210
|
+
#define CL_SCHAR_MAX 127
|
211
|
+
#define CL_SCHAR_MIN (-127-1)
|
212
|
+
#define CL_CHAR_MAX CL_SCHAR_MAX
|
213
|
+
#define CL_CHAR_MIN CL_SCHAR_MIN
|
214
|
+
#define CL_UCHAR_MAX 255
|
215
|
+
#define CL_SHRT_MAX 32767
|
216
|
+
#define CL_SHRT_MIN (-32767-1)
|
217
|
+
#define CL_USHRT_MAX 65535
|
218
|
+
#define CL_INT_MAX 2147483647
|
219
|
+
#define CL_INT_MIN (-2147483647-1)
|
220
|
+
#define CL_UINT_MAX 0xffffffffU
|
221
|
+
#define CL_LONG_MAX ((cl_long) 0x7FFFFFFFFFFFFFFFLL)
|
222
|
+
#define CL_LONG_MIN ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL)
|
223
|
+
#define CL_ULONG_MAX ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL)
|
224
|
+
|
225
|
+
#define CL_FLT_DIG 6
|
226
|
+
#define CL_FLT_MANT_DIG 24
|
227
|
+
#define CL_FLT_MAX_10_EXP +38
|
228
|
+
#define CL_FLT_MAX_EXP +128
|
229
|
+
#define CL_FLT_MIN_10_EXP -37
|
230
|
+
#define CL_FLT_MIN_EXP -125
|
231
|
+
#define CL_FLT_RADIX 2
|
232
|
+
#define CL_FLT_MAX 0x1.fffffep127f
|
233
|
+
#define CL_FLT_MIN 0x1.0p-126f
|
234
|
+
#define CL_FLT_EPSILON 0x1.0p-23f
|
235
|
+
|
236
|
+
#define CL_DBL_DIG 15
|
237
|
+
#define CL_DBL_MANT_DIG 53
|
238
|
+
#define CL_DBL_MAX_10_EXP +308
|
239
|
+
#define CL_DBL_MAX_EXP +1024
|
240
|
+
#define CL_DBL_MIN_10_EXP -307
|
241
|
+
#define CL_DBL_MIN_EXP -1021
|
242
|
+
#define CL_DBL_RADIX 2
|
243
|
+
#define CL_DBL_MAX 0x1.fffffffffffffp1023
|
244
|
+
#define CL_DBL_MIN 0x1.0p-1022
|
245
|
+
#define CL_DBL_EPSILON 0x1.0p-52
|
246
|
+
|
247
|
+
// Extension function access
|
248
|
+
//
|
249
|
+
// Returns the extension function address for the given function name,
|
250
|
+
// or NULL if a valid function can not be found. The client must
|
251
|
+
// check to make sure the address is not NULL, before using or
|
252
|
+
// calling the returned function address.
|
253
|
+
//
|
254
|
+
#define __CL_STRINGIFY( _a ) # _a
|
255
|
+
void *__clGetExtensionFunctionAddress( const char * /* func_name */ ) CL_API_SUFFIX__VERSION_1_0;
|
256
|
+
#define clGetExtensionFunctionAddress(funcname) __clGetExtensionFunctionAddress( __CL_STRINGIFY(funcname))
|
257
|
+
|
258
|
+
#ifdef __cplusplus
|
259
|
+
}
|
260
|
+
#endif
|
261
|
+
|
262
|
+
#endif // __CL_PLATFORM_H
|