-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathphp_opencl.h
200 lines (176 loc) · 3.95 KB
/
php_opencl.h
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
197
198
199
200
/**
* The OpenCL PHP extension
*
* @package php-opencl
* @author Ryusuke SEKIYAMA <[email protected]>
* @copyright 2012 Ryusuke SEKIYAMA
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
#ifndef PHP_OPENCL_H
#define PHP_OPENCL_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <php.h>
#include <php_ini.h>
#include <SAPI.h>
#include <ext/standard/info.h>
#include <Zend/zend_extensions.h>
#include <OpenCL/opencl.h>
BEGIN_EXTERN_C()
#define PHPCL_VERSION "0.0.1"
#if defined(__GNUC__) && __GNUC__ >= 4
#define PHPCL_LOCAL __attribute__((visibility("hidden")))
#else
#define PHPCL_LOCAL
#endif
#define PHPCL_FUNCTION(name) PHPCL_LOCAL PHP_FUNCTION(name)
/* {{{ type definitions */
typedef enum {
/* scalar */
C_TYPE_BOOL,
C_TYPE_CHAR,
C_TYPE_UCHAR,
C_TYPE_SHORT,
C_TYPE_USHORT,
C_TYPE_INT,
C_TYPE_UINT,
C_TYPE_LONG,
C_TYPE_ULONG,
C_TYPE_FLOAT,
C_TYPE_HALF,
C_TYPE_DOUBLE,
C_TYPE_SIZE,
C_TYPE_PTRDIFF,
C_TYPE_INTPTR,
C_TYPE_UINTPTR,
C_TYPE_VOID,
/* vector */
C_TYPE_CHAR2,
C_TYPE_CHAR4,
C_TYPE_CHAR8,
C_TYPE_CHAR16,
C_TYPE_UCHAR2,
C_TYPE_UCHAR4,
C_TYPE_UCHAR8,
C_TYPE_UCHAR16,
C_TYPE_SHORT2,
C_TYPE_SHORT4,
C_TYPE_SHORT8,
C_TYPE_SHORT16,
C_TYPE_USHORT2,
C_TYPE_USHORT4,
C_TYPE_USHORT8,
C_TYPE_USHORT16,
C_TYPE_INT2,
C_TYPE_INT4,
C_TYPE_INT8,
C_TYPE_INT16,
C_TYPE_UINT2,
C_TYPE_UINT4,
C_TYPE_UINT8,
C_TYPE_UINT16,
C_TYPE_LONG2,
C_TYPE_LONG4,
C_TYPE_LONG8,
C_TYPE_LONG16,
C_TYPE_ULONG2,
C_TYPE_ULONG4,
C_TYPE_ULONG8,
C_TYPE_ULONG16,
C_TYPE_FLOAT2,
C_TYPE_FLOAT4,
C_TYPE_FLOAT8,
C_TYPE_FLOAT16,
C_TYPE_UFLOAT2,
C_TYPE_UFLOAT4,
C_TYPE_UFLOAT8,
C_TYPE_UFLOAT16,
C_TYPE_HALF2,
C_TYPE_HALF4,
C_TYPE_HALF8,
C_TYPE_HALF16,
C_TYPE_DOUBLE2,
C_TYPE_DOUBLE4,
C_TYPE_DOUBLE8,
C_TYPE_DOUBLE16,
/* other */
C_TYPE_IMAGE2D,
C_TYPE_IMAGE3D,
C_TYPE_SAMPLER,
C_TYPE_EVENT,
/* pointer */
C_TYPE_MEM_PTR,
C_TYPE_NULL_PTR
} phpcl_c_type_t;
typedef struct {
cl_context context;
zval *callback;
zval *data;
} phpcl_context_t;
typedef struct {
cl_mem memobj;
void *ptr;
} phpcl_memobj_t;
typedef struct {
cl_program program;
zval *callback;
zval *data;
} phpcl_program_t;
typedef enum {
INFO_TYPE_BITFIELD = 0,
INFO_TYPE_BOOL,
INFO_TYPE_SIZE,
INFO_TYPE_UINT,
INFO_TYPE_ULONG,
INFO_TYPE_STRING,
INFO_TYPE_PLATFORM,
INFO_TYPE_EXTRA,
} phpcl_info_type_t;
typedef struct {
const char *key;
cl_uint name;
phpcl_info_type_t type;
} phpcl_info_param_t;
typedef cl_int (*phpcl_get_info_func_t)(void *, /* obj1 */
void *, /* obj2 */
cl_uint, /* name */
size_t, /* value_size */
void *, /* value */
size_t * /* value_size_ret */);
typedef zval * (*phpcl_get_info_ex_func_t)(void *, /* obj1 */
void *, /* obj2 */
cl_uint /* name */
TSRMLS_DC);
/* }}} */
/* {{{ common functions */
const char *phpcl_errstr(cl_int errcode);
PHPCL_LOCAL zval *
phpcl_get_info(phpcl_get_info_func_t get_info,
phpcl_get_info_ex_func_t get_info_ex,
void *obj1, void *obj2,
const phpcl_info_param_t *param TSRMLS_DC);
PHPCL_LOCAL cl_device_id *
phpcl_context_get_devices(cl_context context,
cl_uint *num_devices_ret,
cl_int *errcode_ret);
int phpcl_le_platform(void);
int phpcl_le_device(void);
int phpcl_le_context(void);
int phpcl_le_command_queue(void);
int phpcl_le_mem(void);
int phpcl_le_event(void);
int phpcl_le_program(void);
int phpcl_le_kernel(void);
int phpcl_le_sampler(void);
/* }}} */
END_EXTERN_C()
#endif /* PHP_OPENCL_H */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/