ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/OpenCL/OpenCL.xs
(Generate patch)

Comparing OpenCL/OpenCL.xs (file contents):
Revision 1.3 by root, Tue Nov 15 20:38:07 2011 UTC vs.
Revision 1.18 by root, Wed Nov 23 03:02:38 2011 UTC

2#include "perl.h" 2#include "perl.h"
3#include "XSUB.h" 3#include "XSUB.h"
4 4
5#include <CL/opencl.h> 5#include <CL/opencl.h>
6 6
7typedef cl_platform_id OpenCL__Platform; 7typedef cl_platform_id OpenCL__Platform;
8typedef cl_device_id OpenCL__Device; 8typedef cl_device_id OpenCL__Device;
9typedef cl_context OpenCL__Context; 9typedef cl_context OpenCL__Context;
10typedef cl_command_queue OpenCL__Queue; 10typedef cl_command_queue OpenCL__Queue;
11typedef cl_mem OpenCL__Memory; 11typedef cl_mem OpenCL__Memory;
12typedef cl_mem OpenCL__Buffer; 12typedef cl_mem OpenCL__Buffer;
13typedef cl_mem OpenCL__BufferObj;
13typedef cl_mem OpenCL__Image; 14typedef cl_mem OpenCL__Image;
14typedef cl_mem OpenCL__Image2D; 15typedef cl_mem OpenCL__Image2D;
15typedef cl_mem OpenCL__Image3D; 16typedef cl_mem OpenCL__Image3D;
16typedef cl_mem OpenCL__Memory_ornull; 17typedef cl_mem OpenCL__Memory_ornull;
17typedef cl_mem OpenCL__Buffer_ornull; 18typedef cl_mem OpenCL__Buffer_ornull;
18typedef cl_mem OpenCL__Image_ornull; 19typedef cl_mem OpenCL__Image_ornull;
19typedef cl_mem OpenCL__Image2D_ornull; 20typedef cl_mem OpenCL__Image2D_ornull;
20typedef cl_mem OpenCL__Image3D_ornull; 21typedef cl_mem OpenCL__Image3D_ornull;
21typedef cl_sampler OpenCL__Sampler; 22typedef cl_sampler OpenCL__Sampler;
22typedef cl_program OpenCL__Program; 23typedef cl_program OpenCL__Program;
23typedef cl_kernel OpenCL__Kernel; 24typedef cl_kernel OpenCL__Kernel;
24typedef cl_event OpenCL__Event; 25typedef cl_event OpenCL__Event;
26typedef cl_event OpenCL__UserEvent;
27
28typedef SV *FUTURE;
29
30/*****************************************************************************/
31
32/* up to two temporary buffers */
33static void *
34tmpbuf (size_t size)
35{
36 static int idx;
37 static void *buf [2];
38 static size_t len [2];
39
40 idx ^= 1;
41
42 if (len [idx] < size)
43 {
44 free (buf [idx]);
45 len [idx] = ((size + 31) & ~4095) + 4096 - 32;
46 buf [idx] = malloc (len [idx]);
47 }
48
49 return buf [idx];
50}
51
52/*****************************************************************************/
25 53
26typedef struct 54typedef struct
27{ 55{
28 IV iv; 56 IV iv;
29 const char *name; 57 const char *name;
63 }; 91 };
64 92
65 return iv2str (err, errstr, sizeof (errstr) / sizeof (errstr [0]), "ERROR(%d)"); 93 return iv2str (err, errstr, sizeof (errstr) / sizeof (errstr [0]), "ERROR(%d)");
66} 94}
67 95
96/*****************************************************************************/
97
98static cl_int res;
99
68#define FAIL(name,res) \ 100#define FAIL(name) \
69 croak ("cl" # name ": %s", err2str (res)); 101 croak ("cl" # name ": %s", err2str (res));
70 102
71#define NEED_SUCCESS(name,args) \ 103#define NEED_SUCCESS(name,args) \
72 do { \ 104 do { \
73 cl_int res = cl ## name args; \ 105 res = cl ## name args; \
74 \ 106 \
75 if (res) \ 107 if (res) \
76 FAIL (name, res); \ 108 FAIL (name); \
77 } while (0) 109 } while (0)
110
111#define NEED_SUCCESS_ARG(retdecl, name, args) \
112 retdecl = cl ## name args; \
113 if (res) \
114 FAIL (name);
115
116/*****************************************************************************/
78 117
79#define NEW_MORTAL_OBJ(class,ptr) sv_setref_pv (sv_newmortal (), class, ptr) 118#define NEW_MORTAL_OBJ(class,ptr) sv_setref_pv (sv_newmortal (), class, ptr)
80#define XPUSH_NEW_OBJ(class,ptr) XPUSHs (NEW_MORTAL_OBJ (class, ptr)) 119#define XPUSH_NEW_OBJ(class,ptr) XPUSHs (NEW_MORTAL_OBJ (class, ptr))
81 120
82/*TODO*/ 121static void *
83#define EVENT_LIST(items,count) cl_uint event_list_count = 0; cl_event *event_list_ptr = 0 122SvPTROBJ (const char *func, const char *svname, SV *sv, const char *pkg)
123{
124 if (SvROK (sv) && sv_derived_from (sv, pkg))
125 return (void *)SvIV (SvRV (sv));
126
127 croak ("%s: %s is not of type %s", func, svname, pkg);
128}
129
130/*****************************************************************************/
131
132static size_t
133img_row_pitch (cl_mem img)
134{
135 size_t res;
136 clGetImageInfo (img, CL_IMAGE_ROW_PITCH, sizeof (res), &res, 0);
137 return res;
138}
139
140static cl_event *
141event_list (SV **items, int count)
142{
143 cl_event *list = tmpbuf (sizeof (cl_event) * count);
144
145 while (count--)
146 list [count] = SvPTROBJ ("clEnqueue", "wait_events", items [count], "OpenCL::Event");
147
148 return list;
149}
150
151#define EVENT_LIST(items,count) \
152 cl_uint event_list_count = (count); \
153 cl_event *event_list_ptr = event_list (&ST (items), event_list_count)
84 154
85#define INFO(class) \ 155#define INFO(class) \
86{ \ 156{ \
87 size_t size; \ 157 size_t size; \
88 SV *sv; \
89 \
90 NEED_SUCCESS (Get ## class ## Info, (this, name, 0, 0, &size)); \ 158 NEED_SUCCESS (Get ## class ## Info, (this, name, 0, 0, &size)); \
91 sv = sv_2mortal (newSV (size)); \ 159 SV *sv = sv_2mortal (newSV (size)); \
92 SvUPGRADE (sv, SVt_PV); \ 160 SvUPGRADE (sv, SVt_PV); \
93 SvPOK_only (sv); \ 161 SvPOK_only (sv); \
94 SvCUR_set (sv, size); \ 162 SvCUR_set (sv, size); \
95 NEED_SUCCESS (Get ## class ## Info, (this, name, size, SvPVX (sv), 0)); \ 163 NEED_SUCCESS (Get ## class ## Info, (this, name, size, SvPVX (sv), 0)); \
96 XPUSHs (sv); \ 164 XPUSHs (sv); \
97} 165}
98 166
99static void *
100SvPTROBJ (const char *func, const char *svname, SV *sv, const char *pkg)
101{
102 if (SvROK (sv) && sv_derived_from (sv, pkg))
103 return (void *)SvIV (SvRV (sv));
104
105 croak ("%s: %s is not of type %s", func, svname, pkg);
106}
107
108MODULE = OpenCL PACKAGE = OpenCL 167MODULE = OpenCL PACKAGE = OpenCL
109 168
110PROTOTYPES: ENABLE 169PROTOTYPES: ENABLE
111 170
112BOOT: 171BOOT:
113{ 172{
114 HV *stash = gv_stashpv ("OpenCL", 1); 173 HV *stash = gv_stashpv ("OpenCL", 1);
115 static const ivstr *civ, const_iv[] = { 174 static const ivstr *civ, const_iv[] = {
116 { sizeof (cl_char ), "SIZEOF_CHAR" }, 175 { sizeof (cl_char ), "SIZEOF_CHAR" },
117 { sizeof (cl_uchar ), "SIZEOF_UCHAR" }, 176 { sizeof (cl_uchar ), "SIZEOF_UCHAR" },
118 { sizeof (cl_short ), "SIZEOF_SHORT" }, 177 { sizeof (cl_short ), "SIZEOF_SHORT" },
119 { sizeof (cl_ushort), "SIZEOF_USHORT"}, 178 { sizeof (cl_ushort), "SIZEOF_USHORT" },
120 { sizeof (cl_int ), "SIZEOF_INT" }, 179 { sizeof (cl_int ), "SIZEOF_INT" },
121 { sizeof (cl_uint ), "SIZEOF_UINT" }, 180 { sizeof (cl_uint ), "SIZEOF_UINT" },
122 { sizeof (cl_long ), "SIZEOF_LONG" }, 181 { sizeof (cl_long ), "SIZEOF_LONG" },
123 { sizeof (cl_ulong ), "SIZEOF_ULONG" }, 182 { sizeof (cl_ulong ), "SIZEOF_ULONG" },
124 { sizeof (cl_half ), "SIZEOF_HALF" }, 183 { sizeof (cl_half ), "SIZEOF_HALF" },
125 { sizeof (cl_float ), "SIZEOF_FLOAT" }, 184 { sizeof (cl_float ), "SIZEOF_FLOAT" },
185 { sizeof (cl_double), "SIZEOF_DOUBLE" },
126#include "constiv.h" 186#include "constiv.h"
127 }; 187 };
128 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) 188 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--)
129 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); 189 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
130} 190}
131 191
192cl_int
193errno ()
194 CODE:
195 errno = res;
196
132const char * 197const char *
133err2str (cl_int err) 198err2str (cl_int err)
134 199
135const char * 200const char *
136enum2str (cl_uint value) 201enum2str (cl_uint value)
137 202
138void 203void
139platforms () 204platforms ()
140 PPCODE: 205 PPCODE:
141{
142 cl_platform_id *list; 206 cl_platform_id *list;
143 cl_uint count; 207 cl_uint count;
144 int i; 208 int i;
145 209
146 NEED_SUCCESS (GetPlatformIDs, (0, 0, &count)); 210 NEED_SUCCESS (GetPlatformIDs, (0, 0, &count));
147 Newx (list, count, cl_platform_id); 211 list = tmpbuf (sizeof (*list) * count);
148 NEED_SUCCESS (GetPlatformIDs, (count, list, 0)); 212 NEED_SUCCESS (GetPlatformIDs, (count, list, 0));
149 213
150 EXTEND (SP, count); 214 EXTEND (SP, count);
151 for (i = 0; i < count; ++i) 215 for (i = 0; i < count; ++i)
152 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Platform", list [i])); 216 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Platform", list [i]));
153 217
154 Safefree (list);
155}
156
157void 218void
158context_from_type_simple (cl_device_type type = CL_DEVICE_TYPE_DEFAULT) 219context_from_type (FUTURE properties = 0, cl_device_type type = CL_DEVICE_TYPE_DEFAULT, FUTURE notify = 0)
159 PPCODE: 220 PPCODE:
160{
161 cl_int res;
162 cl_context ctx = clCreateContextFromType (0, type, 0, 0, &res); 221 NEED_SUCCESS_ARG (cl_context ctx, CreateContextFromType, (0, type, 0, 0, &res));
163
164 if (res)
165 FAIL (CreateContextFromType, res);
166
167 XPUSH_NEW_OBJ ("OpenCL::Context", ctx); 222 XPUSH_NEW_OBJ ("OpenCL::Context", ctx);
168} 223
224void
225context (FUTURE properties, FUTURE devices, FUTURE notify = 0)
226 PPCODE:
227 /* der Gipfel der Kunst */
169 228
170void 229void
171wait_for_events (...) 230wait_for_events (...)
172 CODE: 231 CODE:
173{
174 EVENT_LIST (0, items); 232 EVENT_LIST (0, items);
175 NEED_SUCCESS (WaitForEvents, (event_list_count, event_list_ptr)); 233 NEED_SUCCESS (WaitForEvents, (event_list_count, event_list_ptr));
176}
177 234
178PROTOTYPES: DISABLE 235PROTOTYPES: DISABLE
179 236
180MODULE = OpenCL PACKAGE = OpenCL::Platform 237MODULE = OpenCL PACKAGE = OpenCL::Platform
181 238
182void 239void
183info (OpenCL::Platform this, cl_platform_info name) 240info (OpenCL::Platform this, cl_platform_info name)
184 PPCODE: 241 PPCODE:
185 INFO (Platform) 242 INFO (Platform)
186 243
244#BEGIN:platform
245
246void
247profile (OpenCL::Platform this)
248 ALIAS:
249 profile = CL_PLATFORM_PROFILE
250 version = CL_PLATFORM_VERSION
251 name = CL_PLATFORM_NAME
252 vendor = CL_PLATFORM_VENDOR
253 extensions = CL_PLATFORM_EXTENSIONS
254 PPCODE:
255 size_t size;
256 NEED_SUCCESS (GetPlatformInfo, (this, ix, 0, 0, &size));
257 char *value = tmpbuf (size);
258 NEED_SUCCESS (GetPlatformInfo, (this, ix, size, value, 0));
259 EXTEND (SP, 1);
260 const int i = 0;
261 PUSHs (sv_2mortal (newSVpv (value, 0)));
262
263#END:platform
264
187void 265void
188devices (OpenCL::Platform this, cl_device_type type = CL_DEVICE_TYPE_ALL) 266devices (OpenCL::Platform this, cl_device_type type = CL_DEVICE_TYPE_ALL)
189 PPCODE: 267 PPCODE:
190{
191 cl_device_id *list; 268 cl_device_id *list;
192 cl_uint count; 269 cl_uint count;
193 int i; 270 int i;
194 271
195 NEED_SUCCESS (GetDeviceIDs, (this, type, 0, 0, &count)); 272 NEED_SUCCESS (GetDeviceIDs, (this, type, 0, 0, &count));
196 Newx (list, count, cl_device_id); 273 list = tmpbuf (sizeof (*list) * count);
197 NEED_SUCCESS (GetDeviceIDs, (this, type, count, list, 0)); 274 NEED_SUCCESS (GetDeviceIDs, (this, type, count, list, 0));
198 275
199 EXTEND (SP, count); 276 EXTEND (SP, count);
200 for (i = 0; i < count; ++i) 277 for (i = 0; i < count; ++i)
201 PUSHs (sv_setref_pv (sv_newmortal (), "OpenCL::Device", list [i])); 278 PUSHs (sv_setref_pv (sv_newmortal (), "OpenCL::Device", list [i]));
202 279
203 Safefree (list);
204}
205
206void 280void
281context (OpenCL::Platform this, FUTURE properties, SV *devices, FUTURE notify = 0)
282 PPCODE:
283 if (!SvROK (devices) || SvTYPE (SvRV (devices)) != SVt_PVAV)
284 croak ("OpenCL::Platform argument 'device' must be an arrayref with device objects, in call");
285
286 AV *av = (AV *)SvRV (devices);
287 cl_uint num_devices = av_len (av) + 1;
288 cl_device_id *device_list = tmpbuf (sizeof (cl_device_id) * num_devices);
289 int i;
290
291 for (i = num_devices; i--; )
292 device_list [i] = SvPTROBJ ("clCreateContext", "devices", *av_fetch (av, i, 0), "OpenCL::Device");
293
294 NEED_SUCCESS_ARG (cl_context ctx, CreateContext, (0, num_devices, device_list, 0, 0, &res));
295 XPUSH_NEW_OBJ ("OpenCL::Context", ctx);
296
297void
207context_from_type_simple (OpenCL::Platform this, cl_device_type type = CL_DEVICE_TYPE_DEFAULT) 298context_from_type (OpenCL::Platform this, FUTURE properties = 0, cl_device_type type = CL_DEVICE_TYPE_DEFAULT, FUTURE notify = 0)
208 PPCODE: 299 PPCODE:
209{
210 cl_int res;
211 cl_context_properties props[] = { CL_CONTEXT_PLATFORM, (cl_context_properties)this, 0 }; 300 cl_context_properties props[] = { CL_CONTEXT_PLATFORM, (cl_context_properties)this, 0 };
212 cl_context ctx = clCreateContextFromType (props, type, 0, 0, &res); 301 NEED_SUCCESS_ARG (cl_context ctx, CreateContextFromType, (props, type, 0, 0, &res));
213
214 if (res)
215 FAIL (CreateContextFromType, res);
216
217 XPUSH_NEW_OBJ ("OpenCL::Context", ctx); 302 XPUSH_NEW_OBJ ("OpenCL::Context", ctx);
218}
219 303
220MODULE = OpenCL PACKAGE = OpenCL::Device 304MODULE = OpenCL PACKAGE = OpenCL::Device
221 305
222void 306void
223info (OpenCL::Device this, cl_device_info name) 307info (OpenCL::Device this, cl_device_info name)
224 PPCODE: 308 PPCODE:
225 INFO (Device) 309 INFO (Device)
226 310
311#BEGIN:device
312
227void 313void
228context_simple (OpenCL::Device this) 314type (OpenCL::Device this)
229 PPCODE: 315 PPCODE:
230{ 316 cl_device_type value [1];
231 cl_int res; 317 NEED_SUCCESS (GetDeviceInfo, (this, CL_DEVICE_TYPE, sizeof (value), value, 0));
232 cl_context ctx = clCreateContext (0, 1, &this, 0, 0, &res); 318 EXTEND (SP, 1);
319 const int i = 0;
320 PUSHs (sv_2mortal (newSViv (value [i])));
233 321
234 if (res) 322void
235 FAIL (CreateContext, res); 323vendor_id (OpenCL::Device this)
324 ALIAS:
325 vendor_id = CL_DEVICE_VENDOR_ID
326 max_compute_units = CL_DEVICE_MAX_COMPUTE_UNITS
327 max_work_item_dimensions = CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS
328 preferred_vector_width_char = CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR
329 preferred_vector_width_short = CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT
330 preferred_vector_width_int = CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT
331 preferred_vector_width_long = CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG
332 preferred_vector_width_float = CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT
333 preferred_vector_width_double = CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE
334 max_clock_frequency = CL_DEVICE_MAX_CLOCK_FREQUENCY
335 max_read_image_args = CL_DEVICE_MAX_READ_IMAGE_ARGS
336 max_write_image_args = CL_DEVICE_MAX_WRITE_IMAGE_ARGS
337 image_support = CL_DEVICE_IMAGE_SUPPORT
338 max_samplers = CL_DEVICE_MAX_SAMPLERS
339 mem_base_addr_align = CL_DEVICE_MEM_BASE_ADDR_ALIGN
340 min_data_type_align_size = CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE
341 global_mem_cacheline_size = CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE
342 max_constant_args = CL_DEVICE_MAX_CONSTANT_ARGS
343 preferred_vector_width_half = CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF
344 native_vector_width_char = CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR
345 native_vector_width_short = CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT
346 native_vector_width_int = CL_DEVICE_NATIVE_VECTOR_WIDTH_INT
347 native_vector_width_long = CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG
348 native_vector_width_float = CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT
349 native_vector_width_double = CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE
350 native_vector_width_half = CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF
351 reference_count_ext = CL_DEVICE_REFERENCE_COUNT_EXT
352 PPCODE:
353 cl_uint value [1];
354 NEED_SUCCESS (GetDeviceInfo, (this, ix, sizeof (value), value, 0));
355 EXTEND (SP, 1);
356 const int i = 0;
357 PUSHs (sv_2mortal (newSVuv (value [i])));
236 358
237 XPUSH_NEW_OBJ ("OpenCL::Context", ctx); 359void
238} 360max_work_group_size (OpenCL::Device this)
361 ALIAS:
362 max_work_group_size = CL_DEVICE_MAX_WORK_GROUP_SIZE
363 image2d_max_width = CL_DEVICE_IMAGE2D_MAX_WIDTH
364 image2d_max_height = CL_DEVICE_IMAGE2D_MAX_HEIGHT
365 image3d_max_width = CL_DEVICE_IMAGE3D_MAX_WIDTH
366 image3d_max_height = CL_DEVICE_IMAGE3D_MAX_HEIGHT
367 image3d_max_depth = CL_DEVICE_IMAGE3D_MAX_DEPTH
368 max_parameter_size = CL_DEVICE_MAX_PARAMETER_SIZE
369 profiling_timer_resolution = CL_DEVICE_PROFILING_TIMER_RESOLUTION
370 PPCODE:
371 size_t value [1];
372 NEED_SUCCESS (GetDeviceInfo, (this, ix, sizeof (value), value, 0));
373 EXTEND (SP, 1);
374 const int i = 0;
375 PUSHs (sv_2mortal (newSVuv (value [i])));
376
377void
378max_work_item_sizes (OpenCL::Device this)
379 PPCODE:
380 size_t size;
381 NEED_SUCCESS (GetDeviceInfo, (this, CL_DEVICE_MAX_WORK_ITEM_SIZES, 0, 0, &size));
382 size_t *value = tmpbuf (size);
383 NEED_SUCCESS (GetDeviceInfo, (this, CL_DEVICE_MAX_WORK_ITEM_SIZES, size, value, 0));
384 int i, n = size / sizeof (*value);
385 EXTEND (SP, n);
386 for (i = 0; i < n; ++i)
387 PUSHs (sv_2mortal (newSVuv (value [i])));
388
389void
390address_bits (OpenCL::Device this)
391 PPCODE:
392 cl_bitfield value [1];
393 NEED_SUCCESS (GetDeviceInfo, (this, CL_DEVICE_ADDRESS_BITS, sizeof (value), value, 0));
394 EXTEND (SP, 1);
395 const int i = 0;
396 PUSHs (sv_2mortal (newSVuv (value [i])));
397
398void
399max_mem_alloc_size (OpenCL::Device this)
400 ALIAS:
401 max_mem_alloc_size = CL_DEVICE_MAX_MEM_ALLOC_SIZE
402 global_mem_cache_size = CL_DEVICE_GLOBAL_MEM_CACHE_SIZE
403 global_mem_size = CL_DEVICE_GLOBAL_MEM_SIZE
404 max_constant_buffer_size = CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE
405 local_mem_size = CL_DEVICE_LOCAL_MEM_SIZE
406 PPCODE:
407 cl_ulong value [1];
408 NEED_SUCCESS (GetDeviceInfo, (this, ix, sizeof (value), value, 0));
409 EXTEND (SP, 1);
410 const int i = 0;
411 PUSHs (sv_2mortal (newSVuv (value [i])));
412
413void
414single_fp_config (OpenCL::Device this)
415 ALIAS:
416 single_fp_config = CL_DEVICE_SINGLE_FP_CONFIG
417 double_fp_config = CL_DEVICE_DOUBLE_FP_CONFIG
418 half_fp_config = CL_DEVICE_HALF_FP_CONFIG
419 PPCODE:
420 cl_device_fp_config value [1];
421 NEED_SUCCESS (GetDeviceInfo, (this, ix, sizeof (value), value, 0));
422 EXTEND (SP, 1);
423 const int i = 0;
424 PUSHs (sv_2mortal (newSVuv (value [i])));
425
426void
427global_mem_cache_type (OpenCL::Device this)
428 PPCODE:
429 cl_device_mem_cache_type value [1];
430 NEED_SUCCESS (GetDeviceInfo, (this, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, sizeof (value), value, 0));
431 EXTEND (SP, 1);
432 const int i = 0;
433 PUSHs (sv_2mortal (newSVuv (value [i])));
434
435void
436local_mem_type (OpenCL::Device this)
437 PPCODE:
438 cl_device_local_mem_type value [1];
439 NEED_SUCCESS (GetDeviceInfo, (this, CL_DEVICE_LOCAL_MEM_TYPE, sizeof (value), value, 0));
440 EXTEND (SP, 1);
441 const int i = 0;
442 PUSHs (sv_2mortal (newSVuv (value [i])));
443
444void
445error_correction_support (OpenCL::Device this)
446 ALIAS:
447 error_correction_support = CL_DEVICE_ERROR_CORRECTION_SUPPORT
448 endian_little = CL_DEVICE_ENDIAN_LITTLE
449 available = CL_DEVICE_AVAILABLE
450 compiler_available = CL_DEVICE_COMPILER_AVAILABLE
451 host_unified_memory = CL_DEVICE_HOST_UNIFIED_MEMORY
452 PPCODE:
453 cl_bool value [1];
454 NEED_SUCCESS (GetDeviceInfo, (this, ix, sizeof (value), value, 0));
455 EXTEND (SP, 1);
456 const int i = 0;
457 PUSHs (sv_2mortal (value [i] ? &PL_sv_yes : &PL_sv_no));
458
459void
460execution_capabilities (OpenCL::Device this)
461 PPCODE:
462 cl_device_exec_capabilities value [1];
463 NEED_SUCCESS (GetDeviceInfo, (this, CL_DEVICE_EXECUTION_CAPABILITIES, sizeof (value), value, 0));
464 EXTEND (SP, 1);
465 const int i = 0;
466 PUSHs (sv_2mortal (newSVuv (value [i])));
467
468void
469properties (OpenCL::Device this)
470 PPCODE:
471 cl_command_queue_properties value [1];
472 NEED_SUCCESS (GetDeviceInfo, (this, CL_DEVICE_QUEUE_PROPERTIES, sizeof (value), value, 0));
473 EXTEND (SP, 1);
474 const int i = 0;
475 PUSHs (sv_2mortal (newSViv (value [i])));
476
477void
478platform (OpenCL::Device this)
479 PPCODE:
480 cl_platform_id value [1];
481 NEED_SUCCESS (GetDeviceInfo, (this, CL_DEVICE_PLATFORM, sizeof (value), value, 0));
482 EXTEND (SP, 1);
483 const int i = 0;
484 {
485 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Platform", value [i]));
486 }
487
488void
489name (OpenCL::Device this)
490 ALIAS:
491 name = CL_DEVICE_NAME
492 vendor = CL_DEVICE_VENDOR
493 driver_version = CL_DRIVER_VERSION
494 profile = CL_DEVICE_PROFILE
495 version = CL_DEVICE_VERSION
496 extensions = CL_DEVICE_EXTENSIONS
497 PPCODE:
498 size_t size;
499 NEED_SUCCESS (GetDeviceInfo, (this, ix, 0, 0, &size));
500 char *value = tmpbuf (size);
501 NEED_SUCCESS (GetDeviceInfo, (this, ix, size, value, 0));
502 EXTEND (SP, 1);
503 const int i = 0;
504 PUSHs (sv_2mortal (newSVpv (value, 0)));
505
506void
507parent_device_ext (OpenCL::Device this)
508 PPCODE:
509 cl_device_id value [1];
510 NEED_SUCCESS (GetDeviceInfo, (this, CL_DEVICE_PARENT_DEVICE_EXT, sizeof (value), value, 0));
511 EXTEND (SP, 1);
512 const int i = 0;
513 {
514 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Device", value [i]));
515 }
516
517void
518partition_types_ext (OpenCL::Device this)
519 ALIAS:
520 partition_types_ext = CL_DEVICE_PARTITION_TYPES_EXT
521 affinity_domains_ext = CL_DEVICE_AFFINITY_DOMAINS_EXT
522 partition_style_ext = CL_DEVICE_PARTITION_STYLE_EXT
523 PPCODE:
524 size_t size;
525 NEED_SUCCESS (GetDeviceInfo, (this, ix, 0, 0, &size));
526 cl_device_partition_property_ext *value = tmpbuf (size);
527 NEED_SUCCESS (GetDeviceInfo, (this, ix, size, value, 0));
528 int i, n = size / sizeof (*value);
529 EXTEND (SP, n);
530 for (i = 0; i < n; ++i)
531 PUSHs (sv_2mortal (newSVuv (value [i])));
532
533#END:device
239 534
240MODULE = OpenCL PACKAGE = OpenCL::Context 535MODULE = OpenCL PACKAGE = OpenCL::Context
241 536
242void 537void
243DESTROY (OpenCL::Context context) 538DESTROY (OpenCL::Context context)
248info (OpenCL::Context this, cl_context_info name) 543info (OpenCL::Context this, cl_context_info name)
249 PPCODE: 544 PPCODE:
250 INFO (Context) 545 INFO (Context)
251 546
252void 547void
253command_queue_simple (OpenCL::Context this, OpenCL::Device device) 548queue (OpenCL::Context this, OpenCL::Device device, cl_command_queue_properties properties = 0)
254 PPCODE: 549 PPCODE:
255{
256 cl_int res;
257 cl_command_queue queue = clCreateCommandQueue (this, device, 0, &res); 550 NEED_SUCCESS_ARG (cl_command_queue queue, CreateCommandQueue, (this, device, properties, &res));
258
259 if (res)
260 FAIL (CreateCommandQueue, res);
261
262 XPUSH_NEW_OBJ ("OpenCL::Queue", queue); 551 XPUSH_NEW_OBJ ("OpenCL::Queue", queue);
263} 552
553void
554user_event (OpenCL::Context this)
555 PPCODE:
556 NEED_SUCCESS_ARG (cl_event ev, CreateUserEvent, (this, &res));
557 XPUSH_NEW_OBJ ("OpenCL::UserEvent", ev);
264 558
265void 559void
266buffer (OpenCL::Context this, cl_mem_flags flags, size_t len) 560buffer (OpenCL::Context this, cl_mem_flags flags, size_t len)
267 PPCODE: 561 PPCODE:
268{
269 cl_int res;
270 cl_mem mem;
271
272 if (flags & (CL_MEM_USE_HOST_PTR | CL_MEM_COPY_HOST_PTR)) 562 if (flags & (CL_MEM_USE_HOST_PTR | CL_MEM_COPY_HOST_PTR))
273 croak ("clCreateBuffer: cannot use/copy host ptr when no data is given, use $context->buffer_sv instead?"); 563 croak ("clCreateBuffer: cannot use/copy host ptr when no data is given, use $context->buffer_sv instead?");
274 564
275 mem = clCreateBuffer (this, flags, len, 0, &res); 565 NEED_SUCCESS_ARG (cl_mem mem, CreateBuffer, (this, flags, len, 0, &res));
276
277 if (res)
278 FAIL (CreateBuffer, res);
279
280 XPUSH_NEW_OBJ ("OpenCL::Buffer", mem); 566 XPUSH_NEW_OBJ ("OpenCL::BufferObj", mem);
281}
282 567
283void 568void
284buffer_sv (OpenCL::Context this, cl_mem_flags flags, SV *data) 569buffer_sv (OpenCL::Context this, cl_mem_flags flags, SV *data)
285 PPCODE: 570 PPCODE:
286{
287 STRLEN len; 571 STRLEN len;
288 char *ptr = SvPVbyte (data, len); 572 char *ptr = SvPVbyte (data, len);
289 cl_int res;
290 cl_mem mem;
291 573
292 if (!(flags & (CL_MEM_USE_HOST_PTR | CL_MEM_COPY_HOST_PTR))) 574 if (!(flags & (CL_MEM_USE_HOST_PTR | CL_MEM_COPY_HOST_PTR)))
293 croak ("clCreateBuffer: have to specify use or copy host ptr when buffer data is given, use $context->buffer instead?"); 575 croak ("clCreateBuffer: have to specify use or copy host ptr when buffer data is given, use $context->buffer instead?");
294 576
295 mem = clCreateBuffer (this, flags, len, ptr, &res); 577 NEED_SUCCESS_ARG (cl_mem mem, CreateBuffer, (this, flags, len, ptr, &res));
296
297 if (res)
298 FAIL (CreateBuffer, res);
299
300 XPUSH_NEW_OBJ ("OpenCL::Buffer", mem); 578 XPUSH_NEW_OBJ ("OpenCL::BufferObj", mem);
301}
302 579
303void 580void
304image2d (OpenCL::Context this, cl_mem_flags flags, cl_channel_order channel_order, cl_channel_type channel_type, size_t width, size_t height, SV *data) 581image2d (OpenCL::Context this, cl_mem_flags flags, cl_channel_order channel_order, cl_channel_type channel_type, size_t width, size_t height, size_t row_pitch = 0, SV *data = &PL_sv_undef)
305 PPCODE: 582 PPCODE:
306{
307 STRLEN len; 583 STRLEN len;
308 char *ptr = SvPVbyte (data, len); 584 char *ptr = SvPVbyte (data, len);
309 const cl_image_format format = { channel_order, channel_type }; 585 const cl_image_format format = { channel_order, channel_type };
310 cl_int res;
311 cl_mem mem = clCreateImage2D (this, flags, &format, width, height, len / height, ptr, &res); 586 NEED_SUCCESS_ARG (cl_mem mem, CreateImage2D, (this, flags, &format, width, height, row_pitch, ptr, &res));
312
313 if (res)
314 FAIL (CreateImage2D, res);
315
316 XPUSH_NEW_OBJ ("OpenCL::Image2D", mem); 587 XPUSH_NEW_OBJ ("OpenCL::Image2D", mem);
317}
318 588
319void 589void
320image3d (OpenCL::Context this, cl_mem_flags flags, cl_channel_order channel_order, cl_channel_type channel_type, size_t width, size_t height, size_t depth, size_t slice_pitch, SV *data) 590image3d (OpenCL::Context this, cl_mem_flags flags, cl_channel_order channel_order, cl_channel_type channel_type, size_t width, size_t height, size_t depth, size_t row_pitch = 0, size_t slice_pitch = 0, SV *data = &PL_sv_undef)
321 PPCODE: 591 PPCODE:
322{
323 STRLEN len; 592 STRLEN len;
324 char *ptr = SvPVbyte (data, len); 593 char *ptr = SvPVbyte (data, len);
325 const cl_image_format format = { channel_order, channel_type }; 594 const cl_image_format format = { channel_order, channel_type };
326 cl_int res; 595 NEED_SUCCESS_ARG (cl_mem mem, CreateImage3D, (this, flags, &format, width, height, depth, row_pitch, slice_pitch, ptr, &res));
327 cl_mem mem = clCreateImage3D (this, flags, &format, width, height,
328 depth, len / (height * slice_pitch), slice_pitch, ptr, &res);
329
330 if (res)
331 FAIL (CreateImage3D, res);
332
333 XPUSH_NEW_OBJ ("OpenCL::Image3D", mem); 596 XPUSH_NEW_OBJ ("OpenCL::Image3D", mem);
334}
335 597
336void 598void
337supported_image_formats (OpenCL::Context this, cl_mem_flags flags, cl_mem_object_type image_type) 599supported_image_formats (OpenCL::Context this, cl_mem_flags flags, cl_mem_object_type image_type)
338 PPCODE: 600 PPCODE:
339{ 601{
356} 618}
357 619
358void 620void
359sampler (OpenCL::Context this, cl_bool normalized_coords, cl_addressing_mode addressing_mode, cl_filter_mode filter_mode) 621sampler (OpenCL::Context this, cl_bool normalized_coords, cl_addressing_mode addressing_mode, cl_filter_mode filter_mode)
360 PPCODE: 622 PPCODE:
361{
362 cl_int res;
363 cl_sampler sampler = clCreateSampler (this, normalized_coords, addressing_mode, filter_mode, &res); 623 NEED_SUCCESS_ARG (cl_sampler sampler, CreateSampler, (this, normalized_coords, addressing_mode, filter_mode, &res));
364
365 if (res)
366 FAIL (CreateSampler, res);
367
368 XPUSH_NEW_OBJ ("OpenCL::Sampler", sampler); 624 XPUSH_NEW_OBJ ("OpenCL::Sampler", sampler);
369}
370 625
371void 626void
372program_with_source (OpenCL::Context this, SV *program) 627program_with_source (OpenCL::Context this, SV *program)
373 PPCODE: 628 PPCODE:
374{
375 STRLEN len; 629 STRLEN len;
376 size_t len2; 630 size_t len2;
377 const char *ptr = SvPVbyte (program, len); 631 const char *ptr = SvPVbyte (program, len);
378 cl_int res;
379 cl_program prog;
380 632
381 len2 = len; 633 len2 = len;
382 prog = clCreateProgramWithSource (this, 1, &ptr, &len2, &res); 634 NEED_SUCCESS_ARG (cl_program prog, CreateProgramWithSource, (this, 1, &ptr, &len2, &res));
383
384 if (res)
385 FAIL (CreateProgramWithSource, res);
386
387 XPUSH_NEW_OBJ ("OpenCL::Program", prog); 635 XPUSH_NEW_OBJ ("OpenCL::Program", prog);
388} 636
637#BEGIN:context
638
639void
640reference_count (OpenCL::Context this)
641 ALIAS:
642 reference_count = CL_CONTEXT_REFERENCE_COUNT
643 num_devices = CL_CONTEXT_NUM_DEVICES
644 PPCODE:
645 cl_uint value [1];
646 NEED_SUCCESS (GetContextInfo, (this, ix, sizeof (value), value, 0));
647 EXTEND (SP, 1);
648 const int i = 0;
649 PUSHs (sv_2mortal (newSVuv (value [i])));
650
651void
652devices (OpenCL::Context this)
653 PPCODE:
654 size_t size;
655 NEED_SUCCESS (GetContextInfo, (this, CL_CONTEXT_DEVICES, 0, 0, &size));
656 cl_device_id *value = tmpbuf (size);
657 NEED_SUCCESS (GetContextInfo, (this, CL_CONTEXT_DEVICES, size, value, 0));
658 int i, n = size / sizeof (*value);
659 EXTEND (SP, n);
660 for (i = 0; i < n; ++i)
661 {
662 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Device", value [i]));
663 }
664
665void
666properties (OpenCL::Context this)
667 PPCODE:
668 size_t size;
669 NEED_SUCCESS (GetContextInfo, (this, CL_CONTEXT_PROPERTIES, 0, 0, &size));
670 cl_context_properties *value = tmpbuf (size);
671 NEED_SUCCESS (GetContextInfo, (this, CL_CONTEXT_PROPERTIES, size, value, 0));
672 int i, n = size / sizeof (*value);
673 EXTEND (SP, n);
674 for (i = 0; i < n; ++i)
675 PUSHs (sv_2mortal (newSVuv ((UV)value [i])));
676
677#END:context
389 678
390MODULE = OpenCL PACKAGE = OpenCL::Queue 679MODULE = OpenCL PACKAGE = OpenCL::Queue
391 680
392void 681void
393DESTROY (OpenCL::Queue this) 682DESTROY (OpenCL::Queue this)
394 CODE: 683 CODE:
395 clReleaseCommandQueue (this); 684 clReleaseCommandQueue (this);
396 685
397void 686void
398info (OpenCL::Queue this, cl_command_queue_info name)
399 PPCODE:
400 INFO (CommandQueue)
401
402void
403enqueue_read_buffer (OpenCL::Queue this, OpenCL::Buffer mem, cl_bool blocking, size_t offset, size_t len, SV *data, ...) 687enqueue_read_buffer (OpenCL::Queue this, OpenCL::Buffer mem, cl_bool blocking, size_t offset, size_t len, SV *data, ...)
404 PPCODE: 688 PPCODE:
405{
406 cl_event ev = 0; 689 cl_event ev = 0;
407 EVENT_LIST (6, items - 6); 690 EVENT_LIST (6, items - 6);
408 691
409 SvUPGRADE (data, SVt_PV); 692 SvUPGRADE (data, SVt_PV);
410 SvGROW (data, len); 693 SvGROW (data, len);
412 SvCUR_set (data, len); 695 SvCUR_set (data, len);
413 NEED_SUCCESS (EnqueueReadBuffer, (this, mem, blocking, offset, len, SvPVX (data), event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); 696 NEED_SUCCESS (EnqueueReadBuffer, (this, mem, blocking, offset, len, SvPVX (data), event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
414 697
415 if (ev) 698 if (ev)
416 XPUSH_NEW_OBJ ("OpenCL::Event", ev); 699 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
417}
418 700
419void 701void
420enqueue_write_buffer (OpenCL::Queue this, OpenCL::Buffer mem, cl_bool blocking, size_t offset, SV *data, ...) 702enqueue_write_buffer (OpenCL::Queue this, OpenCL::Buffer mem, cl_bool blocking, size_t offset, SV *data, ...)
421 PPCODE: 703 PPCODE:
422{
423 cl_event ev = 0; 704 cl_event ev = 0;
424 STRLEN len; 705 STRLEN len;
425 char *ptr = SvPVbyte (data, len); 706 char *ptr = SvPVbyte (data, len);
426 EVENT_LIST (5, items - 5); 707 EVENT_LIST (5, items - 5);
427 708
428 NEED_SUCCESS (EnqueueReadBuffer, (this, mem, blocking, offset, len, ptr, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); 709 NEED_SUCCESS (EnqueueReadBuffer, (this, mem, blocking, offset, len, ptr, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
429 710
430 if (ev) 711 if (ev)
431 XPUSH_NEW_OBJ ("OpenCL::Event", ev); 712 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
432}
433 713
434void 714void
435enqueue_copy_buffer (OpenCL::Queue this, OpenCL::Buffer src, OpenCL::Buffer dst, size_t src_offset, size_t dst_offset, size_t len, ...) 715enqueue_copy_buffer (OpenCL::Queue this, OpenCL::Buffer src, OpenCL::Buffer dst, size_t src_offset, size_t dst_offset, size_t len, ...)
436 PPCODE: 716 PPCODE:
437{
438 cl_event ev = 0; 717 cl_event ev = 0;
439 EVENT_LIST (6, items - 6); 718 EVENT_LIST (6, items - 6);
440 719
441 NEED_SUCCESS (EnqueueCopyBuffer, (this, src, dst, src_offset, dst_offset, len, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); 720 NEED_SUCCESS (EnqueueCopyBuffer, (this, src, dst, src_offset, dst_offset, len, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
442 721
443 if (ev) 722 if (ev)
444 XPUSH_NEW_OBJ ("OpenCL::Event", ev); 723 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
445}
446 724
447 /*TODO http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueReadBufferRect.html */ 725void
448 /*TODO http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWriteBufferRect.html */ 726enqueue_read_buffer_rect (OpenCL::Queue this, OpenCL::Memory buf, cl_bool blocking, size_t buf_x, size_t buf_y, size_t buf_z, size_t host_x, size_t host_y, size_t host_z, size_t width, size_t height, size_t depth, size_t buf_row_pitch, size_t buf_slice_pitch, size_t host_row_pitch, size_t host_slice_pitch, SV *data, ...)
727 PPCODE:
728 cl_event ev = 0;
729 const size_t buf_origin [3] = { buf_x , buf_y , buf_z };
730 const size_t host_origin[3] = { host_x, host_y, host_z };
731 const size_t region[3] = { width, height, depth };
732 EVENT_LIST (17, items - 17);
733
734 if (!buf_row_pitch)
735 buf_row_pitch = region [0];
736
737 if (!buf_slice_pitch)
738 buf_slice_pitch = region [1] * buf_row_pitch;
739
740 if (!host_row_pitch)
741 host_row_pitch = region [0];
742
743 if (!host_slice_pitch)
744 host_slice_pitch = region [1] * host_row_pitch;
745
746 size_t len = host_row_pitch * host_slice_pitch * region [2];
747
748 SvUPGRADE (data, SVt_PV);
749 SvGROW (data, len);
750 SvPOK_only (data);
751 SvCUR_set (data, len);
752 NEED_SUCCESS (EnqueueReadBufferRect, (this, buf, blocking, buf_origin, host_origin, region, buf_row_pitch, buf_slice_pitch, host_row_pitch, host_slice_pitch, SvPVX (data), event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
753
754 if (ev)
755 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
756
757void
758enqueue_write_buffer_rect (OpenCL::Queue this, OpenCL::Memory buf, cl_bool blocking, size_t buf_x, size_t buf_y, size_t buf_z, size_t host_x, size_t host_y, size_t host_z, size_t width, size_t height, size_t depth, size_t buf_row_pitch, size_t buf_slice_pitch, size_t host_row_pitch, size_t host_slice_pitch, SV *data, ...)
759 PPCODE:
760 cl_event ev = 0;
761 const size_t buf_origin [3] = { buf_x , buf_y , buf_z };
762 const size_t host_origin[3] = { host_x, host_y, host_z };
763 const size_t region[3] = { width, height, depth };
764 STRLEN len;
765 char *ptr = SvPVbyte (data, len);
766 EVENT_LIST (17, items - 17);
767
768 if (!buf_row_pitch)
769 buf_row_pitch = region [0];
770
771 if (!buf_slice_pitch)
772 buf_slice_pitch = region [1] * buf_row_pitch;
773
774 if (!host_row_pitch)
775 host_row_pitch = region [0];
776
777 if (!host_slice_pitch)
778 host_slice_pitch = region [1] * host_row_pitch;
779
780 size_t min_len = host_row_pitch * host_slice_pitch * region [2];
781
782 if (len < min_len)
783 croak ("clEnqueueWriteImage: data string is shorter than what would be transferred");
784
785 NEED_SUCCESS (EnqueueWriteBufferRect, (this, buf, blocking, buf_origin, host_origin, region, buf_row_pitch, buf_slice_pitch, host_row_pitch, host_slice_pitch, SvPVX (data), event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
786
787 if (ev)
788 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
789
790void
791enqueue_copy_buffer_rect (OpenCL::Queue this, OpenCL::Buffer src, OpenCL::Buffer dst, size_t src_x, size_t src_y, size_t src_z, size_t dst_x, size_t dst_y, size_t dst_z, size_t width, size_t height, size_t depth, size_t src_row_pitch, size_t src_slice_pitch, size_t dst_row_pitch, size_t dst_slice_pitch, ...)
792 PPCODE:
793 cl_event ev = 0;
794 const size_t src_origin[3] = { src_x, src_y, src_z };
795 const size_t dst_origin[3] = { dst_x, dst_y, dst_z };
796 const size_t region[3] = { width, height, depth };
797 EVENT_LIST (16, items - 16);
798
799 NEED_SUCCESS (EnqueueCopyBufferRect, (this, src, dst, src_origin, dst_origin, region, src_row_pitch, src_slice_pitch, dst_row_pitch, dst_slice_pitch, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
800
801 if (ev)
802 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
449 803
450void 804void
451enqueue_read_image (OpenCL::Queue this, OpenCL::Image src, cl_bool blocking, size_t src_x, size_t src_y, size_t src_z, size_t width, size_t height, size_t depth, size_t row_pitch, size_t slice_pitch, SV *data, ...) 805enqueue_read_image (OpenCL::Queue this, OpenCL::Image src, cl_bool blocking, size_t src_x, size_t src_y, size_t src_z, size_t width, size_t height, size_t depth, size_t row_pitch, size_t slice_pitch, SV *data, ...)
452 PPCODE: 806 PPCODE:
453{
454 cl_event ev = 0; 807 cl_event ev = 0;
455 const size_t src_origin[3] = { src_x, src_y, src_z }; 808 const size_t src_origin[3] = { src_x, src_y, src_z };
456 const size_t region[3] = { width, height, depth }; 809 const size_t region[3] = { width, height, depth };
457 size_t len = row_pitch * slice_pitch * depth;
458 EVENT_LIST (11, items - 11); 810 EVENT_LIST (12, items - 12);
811
812 if (!row_pitch)
813 row_pitch = img_row_pitch (src);
814
815 if (depth > 1 && !slice_pitch)
816 slice_pitch = row_pitch * height;
817
818 size_t len = slice_pitch ? slice_pitch * depth : row_pitch * height;
459 819
460 SvUPGRADE (data, SVt_PV); 820 SvUPGRADE (data, SVt_PV);
461 SvGROW (data, len); 821 SvGROW (data, len);
462 SvPOK_only (data); 822 SvPOK_only (data);
463 SvCUR_set (data, len); 823 SvCUR_set (data, len);
464 NEED_SUCCESS (EnqueueReadImage, (this, src, blocking, src_origin, region, row_pitch, slice_pitch, SvPVX (data), event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); 824 NEED_SUCCESS (EnqueueReadImage, (this, src, blocking, src_origin, region, row_pitch, slice_pitch, SvPVX (data), event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
465 825
466 if (ev) 826 if (ev)
467 XPUSH_NEW_OBJ ("OpenCL::Event", ev); 827 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
468}
469 828
470void 829void
471enqueue_write_image (OpenCL::Queue this, OpenCL::Image dst, cl_bool blocking, size_t dst_x, size_t dst_y, size_t dst_z, size_t width, size_t height, size_t depth, size_t row_pitch, SV *data, ...) 830enqueue_write_image (OpenCL::Queue this, OpenCL::Image dst, cl_bool blocking, size_t dst_x, size_t dst_y, size_t dst_z, size_t width, size_t height, size_t depth, size_t row_pitch, size_t slice_pitch, SV *data, ...)
472 PPCODE: 831 PPCODE:
473{
474 cl_event ev = 0; 832 cl_event ev = 0;
475 const size_t dst_origin[3] = { dst_x, dst_y, dst_z }; 833 const size_t dst_origin[3] = { dst_x, dst_y, dst_z };
476 const size_t region[3] = { width, height, depth }; 834 const size_t region[3] = { width, height, depth };
477 STRLEN len; 835 STRLEN len;
478 char *ptr = SvPVbyte (data, len); 836 char *ptr = SvPVbyte (data, len);
479 size_t slice_pitch = len / (row_pitch * height);
480 EVENT_LIST (11, items - 11); 837 EVENT_LIST (12, items - 12);
838
839 if (!row_pitch)
840 row_pitch = img_row_pitch (dst);
841
842 if (depth > 1 && !slice_pitch)
843 slice_pitch = row_pitch * height;
844
845 size_t min_len = slice_pitch ? slice_pitch * depth : row_pitch * height;
846
847 if (len < min_len)
848 croak ("clEnqueueWriteImage: data string is shorter than what would be transferred");
481 849
482 NEED_SUCCESS (EnqueueWriteImage, (this, dst, blocking, dst_origin, region, row_pitch, slice_pitch, SvPVX (data), event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); 850 NEED_SUCCESS (EnqueueWriteImage, (this, dst, blocking, dst_origin, region, row_pitch, slice_pitch, SvPVX (data), event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
483 851
484 if (ev) 852 if (ev)
485 XPUSH_NEW_OBJ ("OpenCL::Event", ev); 853 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
486}
487 854
488void 855void
489enqueue_copy_buffer_rect (OpenCL::Queue this, OpenCL::Buffer src, OpenCL::Buffer dst, size_t src_x, size_t src_y, size_t src_z, size_t dst_x, size_t dst_y, size_t dst_z, size_t width, size_t height, size_t depth, size_t src_row_pitch, size_t src_slice_pitch, size_t dst_row_pitch, size_t dst_slice_pitch, ...)
490 PPCODE:
491{
492 cl_event ev = 0;
493 const size_t src_origin[3] = { src_x, src_y, src_z };
494 const size_t dst_origin[3] = { dst_x, dst_y, dst_z };
495 const size_t region[3] = { width, height, depth };
496 EVENT_LIST (16, items - 16);
497
498 NEED_SUCCESS (EnqueueCopyBufferRect, (this, src, dst, src_origin, dst_origin, region, src_row_pitch, src_slice_pitch, dst_row_pitch, dst_slice_pitch, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
499
500 if (ev)
501 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
502}
503
504void
505enqueue_copy_buffer_to_image (OpenCL::Queue this, OpenCL::Buffer src, OpenCL::Image dst, size_t src_offset, size_t dst_x, size_t dst_y, size_t dst_z, size_t width, size_t height, size_t depth, ...)
506 PPCODE:
507{
508 cl_event ev = 0;
509 const size_t dst_origin[3] = { dst_x, dst_y, dst_z };
510 const size_t region[3] = { width, height, depth };
511 EVENT_LIST (10, items - 10);
512
513 NEED_SUCCESS (EnqueueCopyBufferToImage, (this, src, dst, src_offset, dst_origin, region, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
514
515 if (ev)
516 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
517}
518
519void
520enqueue_copy_image (OpenCL::Queue this, OpenCL::Image src, OpenCL::Buffer dst, size_t src_x, size_t src_y, size_t src_z, size_t dst_x, size_t dst_y, size_t dst_z, size_t width, size_t height, size_t depth, ...) 856enqueue_copy_image (OpenCL::Queue this, OpenCL::Image src, OpenCL::Image dst, size_t src_x, size_t src_y, size_t src_z, size_t dst_x, size_t dst_y, size_t dst_z, size_t width, size_t height, size_t depth, ...)
521 PPCODE: 857 PPCODE:
522{
523 cl_event ev = 0; 858 cl_event ev = 0;
524 const size_t src_origin[3] = { src_x, src_y, src_z }; 859 const size_t src_origin[3] = { src_x, src_y, src_z };
525 const size_t dst_origin[3] = { dst_x, dst_y, dst_z }; 860 const size_t dst_origin[3] = { dst_x, dst_y, dst_z };
526 const size_t region[3] = { width, height, depth }; 861 const size_t region[3] = { width, height, depth };
527 EVENT_LIST (12, items - 12); 862 EVENT_LIST (12, items - 12);
528 863
529 NEED_SUCCESS (EnqueueCopyImage, (this, src, dst, src_origin, dst_origin, region, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); 864 NEED_SUCCESS (EnqueueCopyImage, (this, src, dst, src_origin, dst_origin, region, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
530 865
531 if (ev) 866 if (ev)
532 XPUSH_NEW_OBJ ("OpenCL::Event", ev); 867 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
533}
534 868
535void 869void
536enqueue_copy_image_to_buffer (OpenCL::Queue this, OpenCL::Image src, OpenCL::Buffer dst, size_t src_x, size_t src_y, size_t src_z, size_t width, size_t height, size_t depth, size_t dst_offset, ...) 870enqueue_copy_image_to_buffer (OpenCL::Queue this, OpenCL::Image src, OpenCL::Buffer dst, size_t src_x, size_t src_y, size_t src_z, size_t width, size_t height, size_t depth, size_t dst_offset, ...)
537 PPCODE: 871 PPCODE:
538{
539 cl_event ev = 0; 872 cl_event ev = 0;
540 const size_t src_origin[3] = { src_x, src_y, src_z }; 873 const size_t src_origin[3] = { src_x, src_y, src_z };
541 const size_t region[3] = { width, height, depth }; 874 const size_t region[3] = { width, height, depth };
542 EVENT_LIST (10, items - 10); 875 EVENT_LIST (10, items - 10);
543 876
544 NEED_SUCCESS (EnqueueCopyImageToBuffer, (this, src, dst, src_origin, region, dst_offset, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); 877 NEED_SUCCESS (EnqueueCopyImageToBuffer, (this, src, dst, src_origin, region, dst_offset, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
545 878
546 if (ev) 879 if (ev)
547 XPUSH_NEW_OBJ ("OpenCL::Event", ev); 880 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
548} 881
882void
883enqueue_copy_buffer_to_image (OpenCL::Queue this, OpenCL::Buffer src, OpenCL::Image dst, size_t src_offset, size_t dst_x, size_t dst_y, size_t dst_z, size_t width, size_t height, size_t depth, ...)
884 PPCODE:
885 cl_event ev = 0;
886 const size_t dst_origin[3] = { dst_x, dst_y, dst_z };
887 const size_t region[3] = { width, height, depth };
888 EVENT_LIST (10, items - 10);
889
890 NEED_SUCCESS (EnqueueCopyBufferToImage, (this, src, dst, src_offset, dst_origin, region, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
891
892 if (ev)
893 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
549 894
550void 895void
551enqueue_task (OpenCL::Queue this, OpenCL::Kernel kernel, ...) 896enqueue_task (OpenCL::Queue this, OpenCL::Kernel kernel, ...)
552 PPCODE: 897 PPCODE:
553{
554 cl_event ev = 0; 898 cl_event ev = 0;
555 EVENT_LIST (2, items - 2); 899 EVENT_LIST (2, items - 2);
556 900
557 NEED_SUCCESS (EnqueueTask, (this, kernel, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); 901 NEED_SUCCESS (EnqueueTask, (this, kernel, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
558 902
559 if (ev) 903 if (ev)
560 XPUSH_NEW_OBJ ("OpenCL::Event", ev); 904 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
561}
562 905
563 /*TODO http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueNDRangeKernel.html */ 906void
907enqueue_nd_range_kernel (OpenCL::Queue this, OpenCL::Kernel kernel, SV *global_work_offset, SV *global_work_size, SV *local_work_size = &PL_sv_undef, ...)
908 PPCODE:
909 cl_event ev = 0;
910 size_t *gwo = 0, *gws, *lws = 0;
911 int gws_len;
912 size_t *lists;
913 int i;
914 EVENT_LIST (5, items - 5);
915
916 if (!SvROK (global_work_size) || SvTYPE (SvRV (global_work_size)) != SVt_PVAV)
917 croak ("clEnqueueNDRangeKernel: global_work_size must be an array reference");
918
919 gws_len = AvFILLp (SvRV (global_work_size)) + 1;
920
921 lists = tmpbuf (sizeof (size_t) * 3 * gws_len);
922
923 gws = lists + gws_len * 0;
924 for (i = 0; i < gws_len; ++i)
925 gws [i] = SvIV (AvARRAY (SvRV (global_work_size))[i]);
926
927 if (SvOK (global_work_offset))
928 {
929 if (!SvROK (global_work_offset) || SvTYPE (SvRV (global_work_offset)) != SVt_PVAV)
930 croak ("clEnqueueNDRangeKernel: global_work_offset must be undef or an array reference");
931
932 if (AvFILLp (SvRV (global_work_size)) + 1 != gws_len)
933 croak ("clEnqueueNDRangeKernel: global_work_offset must be undef or an array of same size as global_work_size");
934
935 gwo = lists + gws_len * 1;
936 for (i = 0; i < gws_len; ++i)
937 gwo [i] = SvIV (AvARRAY (SvRV (global_work_offset))[i]);
938 }
939
940 if (SvOK (local_work_size))
941 {
942 if (SvOK (local_work_size) && !SvROK (local_work_size) || SvTYPE (SvRV (local_work_size)) != SVt_PVAV)
943 croak ("clEnqueueNDRangeKernel: global_work_size must be undef or an array reference");
944
945 if (AvFILLp (SvRV (local_work_size)) + 1 != gws_len)
946 croak ("clEnqueueNDRangeKernel: local_work_local must be undef or an array of same size as global_work_size");
947
948 lws = lists + gws_len * 2;
949 for (i = 0; i < gws_len; ++i)
950 lws [i] = SvIV (AvARRAY (SvRV (local_work_size))[i]);
951 }
952
953 NEED_SUCCESS (EnqueueNDRangeKernel, (this, kernel, gws_len, gwo, gws, lws, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
954
955 if (ev)
956 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
564 957
565void 958void
566enqueue_marker (OpenCL::Queue this) 959enqueue_marker (OpenCL::Queue this)
567 PPCODE: 960 PPCODE:
568{
569 cl_event ev; 961 cl_event ev;
570 NEED_SUCCESS (EnqueueMarker, (this, &ev)); 962 NEED_SUCCESS (EnqueueMarker, (this, &ev));
571 XPUSH_NEW_OBJ ("OpenCL::Event", ev); 963 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
572}
573 964
574void 965void
575enqueue_wait_for_events (OpenCL::Queue this, ...) 966enqueue_wait_for_events (OpenCL::Queue this, ...)
576 CODE: 967 CODE:
577{
578 EVENT_LIST (1, items - 1); 968 EVENT_LIST (1, items - 1);
579 NEED_SUCCESS (EnqueueWaitForEvents, (this, event_list_count, event_list_ptr)); 969 NEED_SUCCESS (EnqueueWaitForEvents, (this, event_list_count, event_list_ptr));
580}
581 970
582void 971void
583enqueue_barrier (OpenCL::Queue this) 972enqueue_barrier (OpenCL::Queue this)
584 CODE: 973 CODE:
585 NEED_SUCCESS (EnqueueBarrier, (this)); 974 NEED_SUCCESS (EnqueueBarrier, (this));
592void 981void
593finish (OpenCL::Queue this) 982finish (OpenCL::Queue this)
594 CODE: 983 CODE:
595 NEED_SUCCESS (Finish, (this)); 984 NEED_SUCCESS (Finish, (this));
596 985
986void
987info (OpenCL::Queue this, cl_command_queue_info name)
988 PPCODE:
989 INFO (CommandQueue)
990
991#BEGIN:command_queue
992
993void
994context (OpenCL::Queue this)
995 PPCODE:
996 cl_context value [1];
997 NEED_SUCCESS (GetCommandQueueInfo, (this, CL_QUEUE_CONTEXT, sizeof (value), value, 0));
998 EXTEND (SP, 1);
999 const int i = 0;
1000 {
1001 NEED_SUCCESS (RetainContext, (value [i]));
1002 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Context", value [i]));
1003 }
1004
1005void
1006device (OpenCL::Queue this)
1007 PPCODE:
1008 cl_device_id value [1];
1009 NEED_SUCCESS (GetCommandQueueInfo, (this, CL_QUEUE_DEVICE, sizeof (value), value, 0));
1010 EXTEND (SP, 1);
1011 const int i = 0;
1012 {
1013 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Device", value [i]));
1014 }
1015
1016void
1017reference_count (OpenCL::Queue this)
1018 PPCODE:
1019 cl_uint value [1];
1020 NEED_SUCCESS (GetCommandQueueInfo, (this, CL_QUEUE_REFERENCE_COUNT, sizeof (value), value, 0));
1021 EXTEND (SP, 1);
1022 const int i = 0;
1023 PUSHs (sv_2mortal (newSVuv (value [i])));
1024
1025void
1026properties (OpenCL::Queue this)
1027 PPCODE:
1028 cl_command_queue_properties value [1];
1029 NEED_SUCCESS (GetCommandQueueInfo, (this, CL_QUEUE_PROPERTIES, sizeof (value), value, 0));
1030 EXTEND (SP, 1);
1031 const int i = 0;
1032 PUSHs (sv_2mortal (newSViv (value [i])));
1033
1034#END:command_queue
1035
597MODULE = OpenCL PACKAGE = OpenCL::Memory 1036MODULE = OpenCL PACKAGE = OpenCL::Memory
598 1037
599void 1038void
600DESTROY (OpenCL::Memory this) 1039DESTROY (OpenCL::Memory this)
601 CODE: 1040 CODE:
604void 1043void
605info (OpenCL::Memory this, cl_mem_info name) 1044info (OpenCL::Memory this, cl_mem_info name)
606 PPCODE: 1045 PPCODE:
607 INFO (MemObject) 1046 INFO (MemObject)
608 1047
1048#BEGIN:mem
1049
1050void
1051type (OpenCL::Memory this)
1052 PPCODE:
1053 cl_mem_object_type value [1];
1054 NEED_SUCCESS (GetMemObjectInfo, (this, CL_MEM_TYPE, sizeof (value), value, 0));
1055 EXTEND (SP, 1);
1056 const int i = 0;
1057 PUSHs (sv_2mortal (newSViv (value [i])));
1058
1059void
1060flags (OpenCL::Memory this)
1061 PPCODE:
1062 cl_mem_flags value [1];
1063 NEED_SUCCESS (GetMemObjectInfo, (this, CL_MEM_FLAGS, sizeof (value), value, 0));
1064 EXTEND (SP, 1);
1065 const int i = 0;
1066 PUSHs (sv_2mortal (newSViv (value [i])));
1067
1068void
1069size (OpenCL::Memory this)
1070 ALIAS:
1071 size = CL_MEM_SIZE
1072 offset = CL_MEM_OFFSET
1073 PPCODE:
1074 size_t value [1];
1075 NEED_SUCCESS (GetMemObjectInfo, (this, ix, sizeof (value), value, 0));
1076 EXTEND (SP, 1);
1077 const int i = 0;
1078 PUSHs (sv_2mortal (newSVuv (value [i])));
1079
1080void
1081host_ptr (OpenCL::Memory this)
1082 PPCODE:
1083 void * value [1];
1084 NEED_SUCCESS (GetMemObjectInfo, (this, CL_MEM_HOST_PTR, sizeof (value), value, 0));
1085 EXTEND (SP, 1);
1086 const int i = 0;
1087 PUSHs (sv_2mortal (newSVuv ((IV)(intptr_t)value [i])));
1088
1089void
1090map_count (OpenCL::Memory this)
1091 ALIAS:
1092 map_count = CL_MEM_MAP_COUNT
1093 reference_count = CL_MEM_REFERENCE_COUNT
1094 PPCODE:
1095 cl_uint value [1];
1096 NEED_SUCCESS (GetMemObjectInfo, (this, ix, sizeof (value), value, 0));
1097 EXTEND (SP, 1);
1098 const int i = 0;
1099 PUSHs (sv_2mortal (newSVuv (value [i])));
1100
1101void
1102context (OpenCL::Memory this)
1103 PPCODE:
1104 cl_context value [1];
1105 NEED_SUCCESS (GetMemObjectInfo, (this, CL_MEM_CONTEXT, sizeof (value), value, 0));
1106 EXTEND (SP, 1);
1107 const int i = 0;
1108 {
1109 NEED_SUCCESS (RetainContext, (value [i]));
1110 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Context", value [i]));
1111 }
1112
1113void
1114associated_memobject (OpenCL::Memory this)
1115 PPCODE:
1116 cl_mem value [1];
1117 NEED_SUCCESS (GetMemObjectInfo, (this, CL_MEM_ASSOCIATED_MEMOBJECT, sizeof (value), value, 0));
1118 EXTEND (SP, 1);
1119 const int i = 0;
1120 {
1121 NEED_SUCCESS (RetainMemObject, (value [i]));
1122 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Memory", value [i]));
1123 }
1124
1125#END:mem
1126
1127MODULE = OpenCL PACKAGE = OpenCL::BufferObj
1128
1129void
1130sub_buffer_region (OpenCL::BufferObj this, cl_mem_flags flags, size_t origin, size_t size)
1131 PPCODE:
1132 if (flags & (CL_MEM_USE_HOST_PTR | CL_MEM_COPY_HOST_PTR | CL_MEM_ALLOC_HOST_PTR))
1133 croak ("clCreateSubBuffer: cannot use/copy/alloc host ptr, doesn't make sense, check your flags!");
1134
1135 cl_buffer_region crdata = { origin, size };
1136
1137 NEED_SUCCESS_ARG (cl_mem mem, CreateSubBuffer, (this, flags, CL_BUFFER_CREATE_TYPE_REGION, &crdata, &res));
1138 XPUSH_NEW_OBJ ("OpenCL::Buffer", mem);
1139
1140MODULE = OpenCL PACKAGE = OpenCL::Image
1141
1142void
1143image_info (OpenCL::Image this, cl_image_info name)
1144 PPCODE:
1145 INFO (Image)
1146
1147#BEGIN:image
1148
1149void
1150element_size (OpenCL::Image this)
1151 ALIAS:
1152 element_size = CL_IMAGE_ELEMENT_SIZE
1153 row_pitch = CL_IMAGE_ROW_PITCH
1154 slice_pitch = CL_IMAGE_SLICE_PITCH
1155 width = CL_IMAGE_WIDTH
1156 height = CL_IMAGE_HEIGHT
1157 depth = CL_IMAGE_DEPTH
1158 PPCODE:
1159 size_t value [1];
1160 NEED_SUCCESS (GetImageInfo, (this, ix, sizeof (value), value, 0));
1161 EXTEND (SP, 1);
1162 const int i = 0;
1163 PUSHs (sv_2mortal (newSVuv (value [i])));
1164
1165#END:image
1166
609MODULE = OpenCL PACKAGE = OpenCL::Sampler 1167MODULE = OpenCL PACKAGE = OpenCL::Sampler
610 1168
611void 1169void
612DESTROY (OpenCL::Sampler this) 1170DESTROY (OpenCL::Sampler this)
613 CODE: 1171 CODE:
616void 1174void
617info (OpenCL::Sampler this, cl_sampler_info name) 1175info (OpenCL::Sampler this, cl_sampler_info name)
618 PPCODE: 1176 PPCODE:
619 INFO (Sampler) 1177 INFO (Sampler)
620 1178
1179#BEGIN:sampler
1180
1181void
1182reference_count (OpenCL::Sampler this)
1183 PPCODE:
1184 cl_uint value [1];
1185 NEED_SUCCESS (GetSamplerInfo, (this, CL_SAMPLER_REFERENCE_COUNT, sizeof (value), value, 0));
1186 EXTEND (SP, 1);
1187 const int i = 0;
1188 PUSHs (sv_2mortal (newSVuv (value [i])));
1189
1190void
1191context (OpenCL::Sampler this)
1192 PPCODE:
1193 cl_context value [1];
1194 NEED_SUCCESS (GetSamplerInfo, (this, CL_SAMPLER_CONTEXT, sizeof (value), value, 0));
1195 EXTEND (SP, 1);
1196 const int i = 0;
1197 {
1198 NEED_SUCCESS (RetainContext, (value [i]));
1199 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Context", value [i]));
1200 }
1201
1202void
1203normalized_coords (OpenCL::Sampler this)
1204 PPCODE:
1205 cl_addressing_mode value [1];
1206 NEED_SUCCESS (GetSamplerInfo, (this, CL_SAMPLER_NORMALIZED_COORDS, sizeof (value), value, 0));
1207 EXTEND (SP, 1);
1208 const int i = 0;
1209 PUSHs (sv_2mortal (newSViv (value [i])));
1210
1211void
1212addressing_mode (OpenCL::Sampler this)
1213 PPCODE:
1214 cl_filter_mode value [1];
1215 NEED_SUCCESS (GetSamplerInfo, (this, CL_SAMPLER_ADDRESSING_MODE, sizeof (value), value, 0));
1216 EXTEND (SP, 1);
1217 const int i = 0;
1218 PUSHs (sv_2mortal (newSViv (value [i])));
1219
1220void
1221filter_mode (OpenCL::Sampler this)
1222 PPCODE:
1223 cl_bool value [1];
1224 NEED_SUCCESS (GetSamplerInfo, (this, CL_SAMPLER_FILTER_MODE, sizeof (value), value, 0));
1225 EXTEND (SP, 1);
1226 const int i = 0;
1227 PUSHs (sv_2mortal (value [i] ? &PL_sv_yes : &PL_sv_no));
1228
1229#END:sampler
1230
621MODULE = OpenCL PACKAGE = OpenCL::Program 1231MODULE = OpenCL PACKAGE = OpenCL::Program
622 1232
623void 1233void
624DESTROY (OpenCL::Program this) 1234DESTROY (OpenCL::Program this)
625 CODE: 1235 CODE:
626 clReleaseProgram (this); 1236 clReleaseProgram (this);
627 1237
628void 1238void
629info (OpenCL::Program this, cl_program_info name)
630 PPCODE:
631 INFO (Program)
632
633void
634build (OpenCL::Program this, OpenCL::Device device, SV *options = &PL_sv_undef) 1239build (OpenCL::Program this, OpenCL::Device device, SV *options = &PL_sv_undef)
635 CODE: 1240 CODE:
636 NEED_SUCCESS (BuildProgram, (this, 1, &device, SvPVbyte_nolen (options), 0, 0)); 1241 NEED_SUCCESS (BuildProgram, (this, 1, &device, SvPVbyte_nolen (options), 0, 0));
637 1242
638void 1243void
639build_info (OpenCL::Program this, OpenCL::Device device, cl_program_build_info name) 1244build_info (OpenCL::Program this, OpenCL::Device device, cl_program_build_info name)
640 PPCODE: 1245 PPCODE:
641{
642 size_t size; 1246 size_t size;
643 SV *sv;
644
645 NEED_SUCCESS (GetProgramBuildInfo, (this, device, name, 0, 0, &size)); 1247 NEED_SUCCESS (GetProgramBuildInfo, (this, device, name, 0, 0, &size));
646 sv = sv_2mortal (newSV (size)); 1248 SV *sv = sv_2mortal (newSV (size));
647 SvUPGRADE (sv, SVt_PV); 1249 SvUPGRADE (sv, SVt_PV);
648 SvPOK_only (sv); 1250 SvPOK_only (sv);
649 SvCUR_set (sv, size); 1251 SvCUR_set (sv, size);
650 NEED_SUCCESS (GetProgramBuildInfo, (this, device, name, size, SvPVX (sv), 0)); 1252 NEED_SUCCESS (GetProgramBuildInfo, (this, device, name, size, SvPVX (sv), 0));
651 XPUSHs (sv); 1253 XPUSHs (sv);
652} 1254
1255#BEGIN:program_build
1256
1257void
1258build_status (OpenCL::Program this, OpenCL::Device device)
1259 PPCODE:
1260 cl_build_status value [1];
1261 NEED_SUCCESS (GetProgramBuildInfo, (this, device, CL_PROGRAM_BUILD_STATUS, sizeof (value), value, 0));
1262 EXTEND (SP, 1);
1263 const int i = 0;
1264 PUSHs (sv_2mortal (newSViv (value [i])));
1265
1266void
1267build_options (OpenCL::Program this, OpenCL::Device device)
1268 ALIAS:
1269 build_options = CL_PROGRAM_BUILD_OPTIONS
1270 build_log = CL_PROGRAM_BUILD_LOG
1271 PPCODE:
1272 size_t size;
1273 NEED_SUCCESS (GetProgramBuildInfo, (this, device, ix, 0, 0, &size));
1274 char *value = tmpbuf (size);
1275 NEED_SUCCESS (GetProgramBuildInfo, (this, device, ix, size, value, 0));
1276 EXTEND (SP, 1);
1277 const int i = 0;
1278 PUSHs (sv_2mortal (newSVpv (value, 0)));
1279
1280#END:program_build
653 1281
654void 1282void
655kernel (OpenCL::Program program, SV *function) 1283kernel (OpenCL::Program program, SV *function)
656 PPCODE: 1284 PPCODE:
657{
658 cl_int res;
659 cl_kernel kernel = clCreateKernel (program, SvPVbyte_nolen (function), &res); 1285 NEED_SUCCESS_ARG (cl_kernel kernel, CreateKernel, (program, SvPVbyte_nolen (function), &res));
660
661 if (res)
662 FAIL (CreateKernel, res);
663
664 XPUSH_NEW_OBJ ("OpenCL::Kernel", kernel); 1286 XPUSH_NEW_OBJ ("OpenCL::Kernel", kernel);
665} 1287
1288void
1289info (OpenCL::Program this, cl_program_info name)
1290 PPCODE:
1291 INFO (Program)
1292
1293void
1294binaries (OpenCL::Program this)
1295 PPCODE:
1296 cl_uint n, i;
1297 size_t size;
1298
1299 NEED_SUCCESS (GetProgramInfo, (this, CL_PROGRAM_NUM_DEVICES , sizeof (n) , &n , 0));
1300 if (!n) XSRETURN_EMPTY;
1301
1302 size_t *sizes = tmpbuf (sizeof (*sizes) * n);
1303 NEED_SUCCESS (GetProgramInfo, (this, CL_PROGRAM_BINARY_SIZES, sizeof (*sizes) * n, sizes, &size));
1304 if (size != sizeof (*sizes) * n) XSRETURN_EMPTY;
1305 unsigned char **ptrs = tmpbuf (sizeof (*ptrs) * n);
1306
1307 EXTEND (SP, n);
1308 for (i = 0; i < n; ++i)
1309 {
1310 SV *sv = sv_2mortal (newSV (sizes [i]));
1311 SvUPGRADE (sv, SVt_PV);
1312 SvPOK_only (sv);
1313 SvCUR_set (sv, sizes [i]);
1314 ptrs [i] = SvPVX (sv);
1315 PUSHs (sv);
1316 }
1317
1318 NEED_SUCCESS (GetProgramInfo, (this, CL_PROGRAM_BINARIES , sizeof (*ptrs ) * n, ptrs , &size));
1319 if (size != sizeof (*ptrs) * n) XSRETURN_EMPTY;
1320
1321#BEGIN:program
1322
1323void
1324reference_count (OpenCL::Program this)
1325 ALIAS:
1326 reference_count = CL_PROGRAM_REFERENCE_COUNT
1327 num_devices = CL_PROGRAM_NUM_DEVICES
1328 PPCODE:
1329 cl_uint value [1];
1330 NEED_SUCCESS (GetProgramInfo, (this, ix, sizeof (value), value, 0));
1331 EXTEND (SP, 1);
1332 const int i = 0;
1333 PUSHs (sv_2mortal (newSVuv (value [i])));
1334
1335void
1336context (OpenCL::Program this)
1337 PPCODE:
1338 cl_context value [1];
1339 NEED_SUCCESS (GetProgramInfo, (this, CL_PROGRAM_CONTEXT, sizeof (value), value, 0));
1340 EXTEND (SP, 1);
1341 const int i = 0;
1342 {
1343 NEED_SUCCESS (RetainContext, (value [i]));
1344 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Context", value [i]));
1345 }
1346
1347void
1348devices (OpenCL::Program this)
1349 PPCODE:
1350 size_t size;
1351 NEED_SUCCESS (GetProgramInfo, (this, CL_PROGRAM_DEVICES, 0, 0, &size));
1352 cl_device_id *value = tmpbuf (size);
1353 NEED_SUCCESS (GetProgramInfo, (this, CL_PROGRAM_DEVICES, size, value, 0));
1354 int i, n = size / sizeof (*value);
1355 EXTEND (SP, n);
1356 for (i = 0; i < n; ++i)
1357 {
1358 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Device", value [i]));
1359 }
1360
1361void
1362source (OpenCL::Program this)
1363 PPCODE:
1364 size_t size;
1365 NEED_SUCCESS (GetProgramInfo, (this, CL_PROGRAM_SOURCE, 0, 0, &size));
1366 char *value = tmpbuf (size);
1367 NEED_SUCCESS (GetProgramInfo, (this, CL_PROGRAM_SOURCE, size, value, 0));
1368 EXTEND (SP, 1);
1369 const int i = 0;
1370 PUSHs (sv_2mortal (newSVpv (value, 0)));
1371
1372void
1373binary_sizes (OpenCL::Program this)
1374 PPCODE:
1375 size_t size;
1376 NEED_SUCCESS (GetProgramInfo, (this, CL_PROGRAM_BINARY_SIZES, 0, 0, &size));
1377 size_t *value = tmpbuf (size);
1378 NEED_SUCCESS (GetProgramInfo, (this, CL_PROGRAM_BINARY_SIZES, size, value, 0));
1379 int i, n = size / sizeof (*value);
1380 EXTEND (SP, n);
1381 for (i = 0; i < n; ++i)
1382 PUSHs (sv_2mortal (newSVuv (value [i])));
1383
1384#END:program
666 1385
667MODULE = OpenCL PACKAGE = OpenCL::Kernel 1386MODULE = OpenCL PACKAGE = OpenCL::Kernel
668 1387
669void 1388void
670DESTROY (OpenCL::Kernel this) 1389DESTROY (OpenCL::Kernel this)
671 CODE: 1390 CODE:
672 clReleaseKernel (this); 1391 clReleaseKernel (this);
673 1392
674void 1393void
1394set_char (OpenCL::Kernel this, cl_uint idx, cl_char value)
1395 CODE:
1396 clSetKernelArg (this, idx, sizeof (value), &value);
1397
1398void
1399set_uchar (OpenCL::Kernel this, cl_uint idx, cl_uchar value)
1400 CODE:
1401 clSetKernelArg (this, idx, sizeof (value), &value);
1402
1403void
1404set_short (OpenCL::Kernel this, cl_uint idx, cl_short value)
1405 CODE:
1406 clSetKernelArg (this, idx, sizeof (value), &value);
1407
1408void
1409set_ushort (OpenCL::Kernel this, cl_uint idx, cl_ushort value)
1410 CODE:
1411 clSetKernelArg (this, idx, sizeof (value), &value);
1412
1413void
1414set_int (OpenCL::Kernel this, cl_uint idx, cl_int value)
1415 CODE:
1416 clSetKernelArg (this, idx, sizeof (value), &value);
1417
1418void
1419set_uint (OpenCL::Kernel this, cl_uint idx, cl_uint value)
1420 CODE:
1421 clSetKernelArg (this, idx, sizeof (value), &value);
1422
1423void
1424set_long (OpenCL::Kernel this, cl_uint idx, cl_long value)
1425 CODE:
1426 clSetKernelArg (this, idx, sizeof (value), &value);
1427
1428void
1429set_ulong (OpenCL::Kernel this, cl_uint idx, cl_ulong value)
1430 CODE:
1431 clSetKernelArg (this, idx, sizeof (value), &value);
1432
1433void
1434set_half (OpenCL::Kernel this, cl_uint idx, cl_half value)
1435 CODE:
1436 clSetKernelArg (this, idx, sizeof (value), &value);
1437
1438void
1439set_float (OpenCL::Kernel this, cl_uint idx, cl_float value)
1440 CODE:
1441 clSetKernelArg (this, idx, sizeof (value), &value);
1442
1443void
1444set_double (OpenCL::Kernel this, cl_uint idx, cl_double value)
1445 CODE:
1446 clSetKernelArg (this, idx, sizeof (value), &value);
1447
1448void
1449set_memory (OpenCL::Kernel this, cl_uint idx, OpenCL::Memory_ornull value)
1450 CODE:
1451 clSetKernelArg (this, idx, sizeof (value), &value);
1452
1453void
1454set_buffer (OpenCL::Kernel this, cl_uint idx, OpenCL::Buffer_ornull value)
1455 CODE:
1456 clSetKernelArg (this, idx, sizeof (value), &value);
1457
1458void
1459set_image2d (OpenCL::Kernel this, cl_uint idx, OpenCL::Image2D_ornull value)
1460 CODE:
1461 clSetKernelArg (this, idx, sizeof (value), &value);
1462
1463void
1464set_image3d (OpenCL::Kernel this, cl_uint idx, OpenCL::Image3D_ornull value)
1465 CODE:
1466 clSetKernelArg (this, idx, sizeof (value), &value);
1467
1468void
1469set_sampler (OpenCL::Kernel this, cl_uint idx, OpenCL::Sampler value)
1470 CODE:
1471 clSetKernelArg (this, idx, sizeof (value), &value);
1472
1473void
1474set_event (OpenCL::Kernel this, cl_uint idx, OpenCL::Event value)
1475 CODE:
1476 clSetKernelArg (this, idx, sizeof (value), &value);
1477
1478void
675info (OpenCL::Kernel this, cl_kernel_info name) 1479info (OpenCL::Kernel this, cl_kernel_info name)
676 PPCODE: 1480 PPCODE:
677 INFO (Kernel) 1481 INFO (Kernel)
678 1482
1483#BEGIN:kernel
1484
679void 1485void
680set_char (OpenCL::Kernel this, cl_uint idx, cl_char value) 1486function_name (OpenCL::Kernel this)
1487 PPCODE:
1488 size_t size;
1489 NEED_SUCCESS (GetKernelInfo, (this, CL_KERNEL_FUNCTION_NAME, 0, 0, &size));
1490 char *value = tmpbuf (size);
1491 NEED_SUCCESS (GetKernelInfo, (this, CL_KERNEL_FUNCTION_NAME, size, value, 0));
1492 EXTEND (SP, 1);
1493 const int i = 0;
1494 PUSHs (sv_2mortal (newSVpv (value, 0)));
1495
1496void
1497num_args (OpenCL::Kernel this)
1498 ALIAS:
1499 num_args = CL_KERNEL_NUM_ARGS
1500 reference_count = CL_KERNEL_REFERENCE_COUNT
1501 PPCODE:
1502 cl_uint value [1];
1503 NEED_SUCCESS (GetKernelInfo, (this, ix, sizeof (value), value, 0));
1504 EXTEND (SP, 1);
1505 const int i = 0;
1506 PUSHs (sv_2mortal (newSVuv (value [i])));
1507
1508void
1509context (OpenCL::Kernel this)
1510 PPCODE:
1511 cl_context value [1];
1512 NEED_SUCCESS (GetKernelInfo, (this, CL_KERNEL_CONTEXT, sizeof (value), value, 0));
1513 EXTEND (SP, 1);
1514 const int i = 0;
1515 {
1516 NEED_SUCCESS (RetainContext, (value [i]));
1517 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Context", value [i]));
1518 }
1519
1520void
1521program (OpenCL::Kernel this)
1522 PPCODE:
1523 cl_program value [1];
1524 NEED_SUCCESS (GetKernelInfo, (this, CL_KERNEL_PROGRAM, sizeof (value), value, 0));
1525 EXTEND (SP, 1);
1526 const int i = 0;
1527 {
1528 NEED_SUCCESS (RetainProgram, (value [i]));
1529 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Program", value [i]));
1530 }
1531
1532#END:kernel
1533
1534void
1535work_group_info (OpenCL::Kernel this, OpenCL::Device device, cl_kernel_work_group_info name)
681 CODE: 1536 PPCODE:
682 clSetKernelArg (this, idx, sizeof (value), &value); 1537 size_t size;
1538 NEED_SUCCESS (GetKernelWorkGroupInfo, (this, device, name, 0, 0, &size));
1539 SV *sv = sv_2mortal (newSV (size));
1540 SvUPGRADE (sv, SVt_PV);
1541 SvPOK_only (sv);
1542 SvCUR_set (sv, size);
1543 NEED_SUCCESS (GetKernelWorkGroupInfo, (this, device, name, size, SvPVX (sv), 0));
1544 XPUSHs (sv);
683 1545
684void 1546#BEGIN:kernel_work_group
685set_uchar (OpenCL::Kernel this, cl_uint idx, cl_uchar value)
686 CODE:
687 clSetKernelArg (this, idx, sizeof (value), &value);
688 1547
689void 1548void
690set_short (OpenCL::Kernel this, cl_uint idx, cl_short value) 1549work_group_size (OpenCL::Kernel this, OpenCL::Device device)
691 CODE: 1550 ALIAS:
692 clSetKernelArg (this, idx, sizeof (value), &value); 1551 work_group_size = CL_KERNEL_WORK_GROUP_SIZE
1552 preferred_work_group_size_multiple = CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE
1553 PPCODE:
1554 size_t value [1];
1555 NEED_SUCCESS (GetKernelWorkGroupInfo, (this, device, ix, sizeof (value), value, 0));
1556 EXTEND (SP, 1);
1557 const int i = 0;
1558 PUSHs (sv_2mortal (newSVuv (value [i])));
693 1559
694void 1560void
695set_ushort (OpenCL::Kernel this, cl_uint idx, cl_ushort value) 1561compile_work_group_size (OpenCL::Kernel this, OpenCL::Device device)
696 CODE: 1562 PPCODE:
697 clSetKernelArg (this, idx, sizeof (value), &value); 1563 size_t size;
1564 NEED_SUCCESS (GetKernelWorkGroupInfo, (this, device, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, 0, 0, &size));
1565 size_t *value = tmpbuf (size);
1566 NEED_SUCCESS (GetKernelWorkGroupInfo, (this, device, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, size, value, 0));
1567 int i, n = size / sizeof (*value);
1568 EXTEND (SP, n);
1569 for (i = 0; i < n; ++i)
1570 PUSHs (sv_2mortal (newSVuv (value [i])));
698 1571
699void 1572void
700set_int (OpenCL::Kernel this, cl_uint idx, cl_int value) 1573local_mem_size (OpenCL::Kernel this, OpenCL::Device device)
701 CODE: 1574 ALIAS:
702 clSetKernelArg (this, idx, sizeof (value), &value); 1575 local_mem_size = CL_KERNEL_LOCAL_MEM_SIZE
1576 private_mem_size = CL_KERNEL_PRIVATE_MEM_SIZE
1577 PPCODE:
1578 cl_ulong value [1];
1579 NEED_SUCCESS (GetKernelWorkGroupInfo, (this, device, ix, sizeof (value), value, 0));
1580 EXTEND (SP, 1);
1581 const int i = 0;
1582 PUSHs (sv_2mortal (newSVuv (value [i])));
703 1583
704void 1584#END:kernel_work_group
705set_uint (OpenCL::Kernel this, cl_uint idx, cl_uint value)
706 CODE:
707 clSetKernelArg (this, idx, sizeof (value), &value);
708
709void
710set_long (OpenCL::Kernel this, cl_uint idx, cl_long value)
711 CODE:
712 clSetKernelArg (this, idx, sizeof (value), &value);
713
714void
715set_ulong (OpenCL::Kernel this, cl_uint idx, cl_ulong value)
716 CODE:
717 clSetKernelArg (this, idx, sizeof (value), &value);
718
719void
720set_half (OpenCL::Kernel this, cl_uint idx, cl_half value)
721 CODE:
722 clSetKernelArg (this, idx, sizeof (value), &value);
723
724void
725set_float (OpenCL::Kernel this, cl_uint idx, cl_float value)
726 CODE:
727 clSetKernelArg (this, idx, sizeof (value), &value);
728
729void
730set_memory (OpenCL::Kernel this, cl_uint idx, OpenCL::Memory_ornull value)
731 CODE:
732 clSetKernelArg (this, idx, sizeof (value), &value);
733
734void
735set_buffer (OpenCL::Kernel this, cl_uint idx, OpenCL::Buffer_ornull value)
736 CODE:
737 clSetKernelArg (this, idx, sizeof (value), &value);
738
739void
740set_image2d (OpenCL::Kernel this, cl_uint idx, OpenCL::Image2D_ornull value)
741 CODE:
742 clSetKernelArg (this, idx, sizeof (value), &value);
743
744void
745set_image3d (OpenCL::Kernel this, cl_uint idx, OpenCL::Image3D_ornull value)
746 CODE:
747 clSetKernelArg (this, idx, sizeof (value), &value);
748
749void
750set_sampler (OpenCL::Kernel this, cl_uint idx, OpenCL::Sampler value)
751 CODE:
752 clSetKernelArg (this, idx, sizeof (value), &value);
753
754void
755set_event (OpenCL::Kernel this, cl_uint idx, OpenCL::Event value)
756 CODE:
757 clSetKernelArg (this, idx, sizeof (value), &value);
758 1585
759MODULE = OpenCL PACKAGE = OpenCL::Event 1586MODULE = OpenCL PACKAGE = OpenCL::Event
760 1587
761void 1588void
762DESTROY (OpenCL::Event this) 1589DESTROY (OpenCL::Event this)
763 CODE: 1590 CODE:
764 clReleaseEvent (this); 1591 clReleaseEvent (this);
765 1592
766void 1593void
1594wait (OpenCL::Event this)
1595 CODE:
1596 clWaitForEvents (1, &this);
1597
1598void
767info (OpenCL::Event this, cl_event_info name) 1599info (OpenCL::Event this, cl_event_info name)
768 PPCODE: 1600 PPCODE:
769 INFO (Event) 1601 INFO (Event)
770 1602
1603#BEGIN:event
1604
771void 1605void
1606command_queue (OpenCL::Event this)
1607 PPCODE:
1608 cl_command_queue value [1];
1609 NEED_SUCCESS (GetEventInfo, (this, CL_EVENT_COMMAND_QUEUE, sizeof (value), value, 0));
1610 EXTEND (SP, 1);
1611 const int i = 0;
1612 {
1613 NEED_SUCCESS (RetainCommandQueue, (value [i]));
1614 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Queue", value [i]));
1615 }
1616
1617void
1618command_type (OpenCL::Event this)
1619 PPCODE:
1620 cl_command_type value [1];
1621 NEED_SUCCESS (GetEventInfo, (this, CL_EVENT_COMMAND_TYPE, sizeof (value), value, 0));
1622 EXTEND (SP, 1);
1623 const int i = 0;
1624 PUSHs (sv_2mortal (newSVuv (value [i])));
1625
1626void
1627reference_count (OpenCL::Event this)
1628 ALIAS:
1629 reference_count = CL_EVENT_REFERENCE_COUNT
1630 command_execution_status = CL_EVENT_COMMAND_EXECUTION_STATUS
1631 PPCODE:
1632 cl_uint value [1];
1633 NEED_SUCCESS (GetEventInfo, (this, ix, sizeof (value), value, 0));
1634 EXTEND (SP, 1);
1635 const int i = 0;
1636 PUSHs (sv_2mortal (newSVuv (value [i])));
1637
1638void
772wait (OpenCL::Event this) 1639context (OpenCL::Event this)
1640 PPCODE:
1641 cl_context value [1];
1642 NEED_SUCCESS (GetEventInfo, (this, CL_EVENT_CONTEXT, sizeof (value), value, 0));
1643 EXTEND (SP, 1);
1644 const int i = 0;
1645 {
1646 NEED_SUCCESS (RetainContext, (value [i]));
1647 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Context", value [i]));
1648 }
1649
1650#END:event
1651
1652void
1653profiling_info (OpenCL::Event this, cl_profiling_info name)
773 CODE: 1654 PPCODE:
774 clWaitForEvents (1, &this); 1655 INFO (EventProfiling)
775 1656
1657#BEGIN:profiling
1658
1659void
1660profiling_command_queued (OpenCL::Event this)
1661 ALIAS:
1662 profiling_command_queued = CL_PROFILING_COMMAND_QUEUED
1663 profiling_command_submit = CL_PROFILING_COMMAND_SUBMIT
1664 profiling_command_start = CL_PROFILING_COMMAND_START
1665 profiling_command_end = CL_PROFILING_COMMAND_END
1666 PPCODE:
1667 cl_ulong value [1];
1668 NEED_SUCCESS (GetEventProfilingInfo, (this, ix, sizeof (value), value, 0));
1669 EXTEND (SP, 1);
1670 const int i = 0;
1671 PUSHs (sv_2mortal (newSVuv (value [i])));
1672
1673#END:profiling
1674
1675MODULE = OpenCL PACKAGE = OpenCL::UserEvent
1676
1677void
1678set_status (OpenCL::UserEvent this, cl_int execution_status)
1679 CODE:
1680 clSetUserEventStatus (this, execution_status);
1681

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines