ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/OpenCL/OpenCL.xs
Revision: 1.18
Committed: Wed Nov 23 03:02:38 2011 UTC (12 years, 5 months ago) by root
Branch: MAIN
Changes since 1.17: +38 -24 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 #include "EXTERN.h"
2 #include "perl.h"
3 #include "XSUB.h"
4
5 #include <CL/opencl.h>
6
7 typedef cl_platform_id OpenCL__Platform;
8 typedef cl_device_id OpenCL__Device;
9 typedef cl_context OpenCL__Context;
10 typedef cl_command_queue OpenCL__Queue;
11 typedef cl_mem OpenCL__Memory;
12 typedef cl_mem OpenCL__Buffer;
13 typedef cl_mem OpenCL__BufferObj;
14 typedef cl_mem OpenCL__Image;
15 typedef cl_mem OpenCL__Image2D;
16 typedef cl_mem OpenCL__Image3D;
17 typedef cl_mem OpenCL__Memory_ornull;
18 typedef cl_mem OpenCL__Buffer_ornull;
19 typedef cl_mem OpenCL__Image_ornull;
20 typedef cl_mem OpenCL__Image2D_ornull;
21 typedef cl_mem OpenCL__Image3D_ornull;
22 typedef cl_sampler OpenCL__Sampler;
23 typedef cl_program OpenCL__Program;
24 typedef cl_kernel OpenCL__Kernel;
25 typedef cl_event OpenCL__Event;
26 typedef cl_event OpenCL__UserEvent;
27
28 typedef SV *FUTURE;
29
30 /*****************************************************************************/
31
32 /* up to two temporary buffers */
33 static void *
34 tmpbuf (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 /*****************************************************************************/
53
54 typedef struct
55 {
56 IV iv;
57 const char *name;
58 #define const_iv(name) { (IV)CL_ ## name, # name },
59 } ivstr;
60
61 static const char *
62 iv2str (IV value, const ivstr *base, int count, const char *fallback)
63 {
64 int i;
65 static char strbuf [32];
66
67 for (i = count; i--; )
68 if (base [i].iv == value)
69 return base [i].name;
70
71 snprintf (strbuf, sizeof (strbuf), fallback, (int)value);
72
73 return strbuf;
74 }
75
76 static const char *
77 enum2str (cl_uint value)
78 {
79 static const ivstr enumstr[] = {
80 #include "enumstr.h"
81 };
82
83 return iv2str (value, enumstr, sizeof (enumstr) / sizeof (enumstr [0]), "ENUM(0x%04x)");
84 }
85
86 static const char *
87 err2str (cl_int err)
88 {
89 static const ivstr errstr[] = {
90 #include "errstr.h"
91 };
92
93 return iv2str (err, errstr, sizeof (errstr) / sizeof (errstr [0]), "ERROR(%d)");
94 }
95
96 /*****************************************************************************/
97
98 static cl_int res;
99
100 #define FAIL(name) \
101 croak ("cl" # name ": %s", err2str (res));
102
103 #define NEED_SUCCESS(name,args) \
104 do { \
105 res = cl ## name args; \
106 \
107 if (res) \
108 FAIL (name); \
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 /*****************************************************************************/
117
118 #define NEW_MORTAL_OBJ(class,ptr) sv_setref_pv (sv_newmortal (), class, ptr)
119 #define XPUSH_NEW_OBJ(class,ptr) XPUSHs (NEW_MORTAL_OBJ (class, ptr))
120
121 static void *
122 SvPTROBJ (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
132 static size_t
133 img_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
140 static cl_event *
141 event_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)
154
155 #define INFO(class) \
156 { \
157 size_t size; \
158 NEED_SUCCESS (Get ## class ## Info, (this, name, 0, 0, &size)); \
159 SV *sv = sv_2mortal (newSV (size)); \
160 SvUPGRADE (sv, SVt_PV); \
161 SvPOK_only (sv); \
162 SvCUR_set (sv, size); \
163 NEED_SUCCESS (Get ## class ## Info, (this, name, size, SvPVX (sv), 0)); \
164 XPUSHs (sv); \
165 }
166
167 MODULE = OpenCL PACKAGE = OpenCL
168
169 PROTOTYPES: ENABLE
170
171 BOOT:
172 {
173 HV *stash = gv_stashpv ("OpenCL", 1);
174 static const ivstr *civ, const_iv[] = {
175 { sizeof (cl_char ), "SIZEOF_CHAR" },
176 { sizeof (cl_uchar ), "SIZEOF_UCHAR" },
177 { sizeof (cl_short ), "SIZEOF_SHORT" },
178 { sizeof (cl_ushort), "SIZEOF_USHORT" },
179 { sizeof (cl_int ), "SIZEOF_INT" },
180 { sizeof (cl_uint ), "SIZEOF_UINT" },
181 { sizeof (cl_long ), "SIZEOF_LONG" },
182 { sizeof (cl_ulong ), "SIZEOF_ULONG" },
183 { sizeof (cl_half ), "SIZEOF_HALF" },
184 { sizeof (cl_float ), "SIZEOF_FLOAT" },
185 { sizeof (cl_double), "SIZEOF_DOUBLE" },
186 #include "constiv.h"
187 };
188 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--)
189 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
190 }
191
192 cl_int
193 errno ()
194 CODE:
195 errno = res;
196
197 const char *
198 err2str (cl_int err)
199
200 const char *
201 enum2str (cl_uint value)
202
203 void
204 platforms ()
205 PPCODE:
206 cl_platform_id *list;
207 cl_uint count;
208 int i;
209
210 NEED_SUCCESS (GetPlatformIDs, (0, 0, &count));
211 list = tmpbuf (sizeof (*list) * count);
212 NEED_SUCCESS (GetPlatformIDs, (count, list, 0));
213
214 EXTEND (SP, count);
215 for (i = 0; i < count; ++i)
216 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Platform", list [i]));
217
218 void
219 context_from_type (FUTURE properties = 0, cl_device_type type = CL_DEVICE_TYPE_DEFAULT, FUTURE notify = 0)
220 PPCODE:
221 NEED_SUCCESS_ARG (cl_context ctx, CreateContextFromType, (0, type, 0, 0, &res));
222 XPUSH_NEW_OBJ ("OpenCL::Context", ctx);
223
224 void
225 context (FUTURE properties, FUTURE devices, FUTURE notify = 0)
226 PPCODE:
227 /* der Gipfel der Kunst */
228
229 void
230 wait_for_events (...)
231 CODE:
232 EVENT_LIST (0, items);
233 NEED_SUCCESS (WaitForEvents, (event_list_count, event_list_ptr));
234
235 PROTOTYPES: DISABLE
236
237 MODULE = OpenCL PACKAGE = OpenCL::Platform
238
239 void
240 info (OpenCL::Platform this, cl_platform_info name)
241 PPCODE:
242 INFO (Platform)
243
244 #BEGIN:platform
245
246 void
247 profile (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
265 void
266 devices (OpenCL::Platform this, cl_device_type type = CL_DEVICE_TYPE_ALL)
267 PPCODE:
268 cl_device_id *list;
269 cl_uint count;
270 int i;
271
272 NEED_SUCCESS (GetDeviceIDs, (this, type, 0, 0, &count));
273 list = tmpbuf (sizeof (*list) * count);
274 NEED_SUCCESS (GetDeviceIDs, (this, type, count, list, 0));
275
276 EXTEND (SP, count);
277 for (i = 0; i < count; ++i)
278 PUSHs (sv_setref_pv (sv_newmortal (), "OpenCL::Device", list [i]));
279
280 void
281 context (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
297 void
298 context_from_type (OpenCL::Platform this, FUTURE properties = 0, cl_device_type type = CL_DEVICE_TYPE_DEFAULT, FUTURE notify = 0)
299 PPCODE:
300 cl_context_properties props[] = { CL_CONTEXT_PLATFORM, (cl_context_properties)this, 0 };
301 NEED_SUCCESS_ARG (cl_context ctx, CreateContextFromType, (props, type, 0, 0, &res));
302 XPUSH_NEW_OBJ ("OpenCL::Context", ctx);
303
304 MODULE = OpenCL PACKAGE = OpenCL::Device
305
306 void
307 info (OpenCL::Device this, cl_device_info name)
308 PPCODE:
309 INFO (Device)
310
311 #BEGIN:device
312
313 void
314 type (OpenCL::Device this)
315 PPCODE:
316 cl_device_type value [1];
317 NEED_SUCCESS (GetDeviceInfo, (this, CL_DEVICE_TYPE, sizeof (value), value, 0));
318 EXTEND (SP, 1);
319 const int i = 0;
320 PUSHs (sv_2mortal (newSViv (value [i])));
321
322 void
323 vendor_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])));
358
359 void
360 max_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
377 void
378 max_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
389 void
390 address_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
398 void
399 max_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
413 void
414 single_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
426 void
427 global_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
435 void
436 local_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
444 void
445 error_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
459 void
460 execution_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
468 void
469 properties (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
477 void
478 platform (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
488 void
489 name (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
506 void
507 parent_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
517 void
518 partition_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
534
535 MODULE = OpenCL PACKAGE = OpenCL::Context
536
537 void
538 DESTROY (OpenCL::Context context)
539 CODE:
540 clReleaseContext (context);
541
542 void
543 info (OpenCL::Context this, cl_context_info name)
544 PPCODE:
545 INFO (Context)
546
547 void
548 queue (OpenCL::Context this, OpenCL::Device device, cl_command_queue_properties properties = 0)
549 PPCODE:
550 NEED_SUCCESS_ARG (cl_command_queue queue, CreateCommandQueue, (this, device, properties, &res));
551 XPUSH_NEW_OBJ ("OpenCL::Queue", queue);
552
553 void
554 user_event (OpenCL::Context this)
555 PPCODE:
556 NEED_SUCCESS_ARG (cl_event ev, CreateUserEvent, (this, &res));
557 XPUSH_NEW_OBJ ("OpenCL::UserEvent", ev);
558
559 void
560 buffer (OpenCL::Context this, cl_mem_flags flags, size_t len)
561 PPCODE:
562 if (flags & (CL_MEM_USE_HOST_PTR | CL_MEM_COPY_HOST_PTR))
563 croak ("clCreateBuffer: cannot use/copy host ptr when no data is given, use $context->buffer_sv instead?");
564
565 NEED_SUCCESS_ARG (cl_mem mem, CreateBuffer, (this, flags, len, 0, &res));
566 XPUSH_NEW_OBJ ("OpenCL::BufferObj", mem);
567
568 void
569 buffer_sv (OpenCL::Context this, cl_mem_flags flags, SV *data)
570 PPCODE:
571 STRLEN len;
572 char *ptr = SvPVbyte (data, len);
573
574 if (!(flags & (CL_MEM_USE_HOST_PTR | CL_MEM_COPY_HOST_PTR)))
575 croak ("clCreateBuffer: have to specify use or copy host ptr when buffer data is given, use $context->buffer instead?");
576
577 NEED_SUCCESS_ARG (cl_mem mem, CreateBuffer, (this, flags, len, ptr, &res));
578 XPUSH_NEW_OBJ ("OpenCL::BufferObj", mem);
579
580 void
581 image2d (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)
582 PPCODE:
583 STRLEN len;
584 char *ptr = SvPVbyte (data, len);
585 const cl_image_format format = { channel_order, channel_type };
586 NEED_SUCCESS_ARG (cl_mem mem, CreateImage2D, (this, flags, &format, width, height, row_pitch, ptr, &res));
587 XPUSH_NEW_OBJ ("OpenCL::Image2D", mem);
588
589 void
590 image3d (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)
591 PPCODE:
592 STRLEN len;
593 char *ptr = SvPVbyte (data, len);
594 const cl_image_format format = { channel_order, channel_type };
595 NEED_SUCCESS_ARG (cl_mem mem, CreateImage3D, (this, flags, &format, width, height, depth, row_pitch, slice_pitch, ptr, &res));
596 XPUSH_NEW_OBJ ("OpenCL::Image3D", mem);
597
598 void
599 supported_image_formats (OpenCL::Context this, cl_mem_flags flags, cl_mem_object_type image_type)
600 PPCODE:
601 {
602 cl_uint count;
603 cl_image_format *list;
604 int i;
605
606 NEED_SUCCESS (GetSupportedImageFormats, (this, flags, image_type, 0, 0, &count));
607 Newx (list, count, cl_image_format);
608 NEED_SUCCESS (GetSupportedImageFormats, (this, flags, image_type, count, list, 0));
609
610 EXTEND (SP, count);
611 for (i = 0; i < count; ++i)
612 {
613 AV *av = newAV ();
614 av_store (av, 1, newSVuv (list [i].image_channel_data_type));
615 av_store (av, 0, newSVuv (list [i].image_channel_order));
616 PUSHs (sv_2mortal (newRV_noinc ((SV *)av)));
617 }
618 }
619
620 void
621 sampler (OpenCL::Context this, cl_bool normalized_coords, cl_addressing_mode addressing_mode, cl_filter_mode filter_mode)
622 PPCODE:
623 NEED_SUCCESS_ARG (cl_sampler sampler, CreateSampler, (this, normalized_coords, addressing_mode, filter_mode, &res));
624 XPUSH_NEW_OBJ ("OpenCL::Sampler", sampler);
625
626 void
627 program_with_source (OpenCL::Context this, SV *program)
628 PPCODE:
629 STRLEN len;
630 size_t len2;
631 const char *ptr = SvPVbyte (program, len);
632
633 len2 = len;
634 NEED_SUCCESS_ARG (cl_program prog, CreateProgramWithSource, (this, 1, &ptr, &len2, &res));
635 XPUSH_NEW_OBJ ("OpenCL::Program", prog);
636
637 #BEGIN:context
638
639 void
640 reference_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
651 void
652 devices (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
665 void
666 properties (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
678
679 MODULE = OpenCL PACKAGE = OpenCL::Queue
680
681 void
682 DESTROY (OpenCL::Queue this)
683 CODE:
684 clReleaseCommandQueue (this);
685
686 void
687 enqueue_read_buffer (OpenCL::Queue this, OpenCL::Buffer mem, cl_bool blocking, size_t offset, size_t len, SV *data, ...)
688 PPCODE:
689 cl_event ev = 0;
690 EVENT_LIST (6, items - 6);
691
692 SvUPGRADE (data, SVt_PV);
693 SvGROW (data, len);
694 SvPOK_only (data);
695 SvCUR_set (data, len);
696 NEED_SUCCESS (EnqueueReadBuffer, (this, mem, blocking, offset, len, SvPVX (data), event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
697
698 if (ev)
699 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
700
701 void
702 enqueue_write_buffer (OpenCL::Queue this, OpenCL::Buffer mem, cl_bool blocking, size_t offset, SV *data, ...)
703 PPCODE:
704 cl_event ev = 0;
705 STRLEN len;
706 char *ptr = SvPVbyte (data, len);
707 EVENT_LIST (5, items - 5);
708
709 NEED_SUCCESS (EnqueueReadBuffer, (this, mem, blocking, offset, len, ptr, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
710
711 if (ev)
712 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
713
714 void
715 enqueue_copy_buffer (OpenCL::Queue this, OpenCL::Buffer src, OpenCL::Buffer dst, size_t src_offset, size_t dst_offset, size_t len, ...)
716 PPCODE:
717 cl_event ev = 0;
718 EVENT_LIST (6, items - 6);
719
720 NEED_SUCCESS (EnqueueCopyBuffer, (this, src, dst, src_offset, dst_offset, len, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
721
722 if (ev)
723 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
724
725 void
726 enqueue_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
757 void
758 enqueue_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
790 void
791 enqueue_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);
803
804 void
805 enqueue_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, ...)
806 PPCODE:
807 cl_event ev = 0;
808 const size_t src_origin[3] = { src_x, src_y, src_z };
809 const size_t region[3] = { width, height, depth };
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;
819
820 SvUPGRADE (data, SVt_PV);
821 SvGROW (data, len);
822 SvPOK_only (data);
823 SvCUR_set (data, len);
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));
825
826 if (ev)
827 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
828
829 void
830 enqueue_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, ...)
831 PPCODE:
832 cl_event ev = 0;
833 const size_t dst_origin[3] = { dst_x, dst_y, dst_z };
834 const size_t region[3] = { width, height, depth };
835 STRLEN len;
836 char *ptr = SvPVbyte (data, len);
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");
849
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));
851
852 if (ev)
853 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
854
855 void
856 enqueue_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, ...)
857 PPCODE:
858 cl_event ev = 0;
859 const size_t src_origin[3] = { src_x, src_y, src_z };
860 const size_t dst_origin[3] = { dst_x, dst_y, dst_z };
861 const size_t region[3] = { width, height, depth };
862 EVENT_LIST (12, items - 12);
863
864 NEED_SUCCESS (EnqueueCopyImage, (this, src, dst, src_origin, dst_origin, region, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
865
866 if (ev)
867 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
868
869 void
870 enqueue_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, ...)
871 PPCODE:
872 cl_event ev = 0;
873 const size_t src_origin[3] = { src_x, src_y, src_z };
874 const size_t region[3] = { width, height, depth };
875 EVENT_LIST (10, items - 10);
876
877 NEED_SUCCESS (EnqueueCopyImageToBuffer, (this, src, dst, src_origin, region, dst_offset, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
878
879 if (ev)
880 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
881
882 void
883 enqueue_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);
894
895 void
896 enqueue_task (OpenCL::Queue this, OpenCL::Kernel kernel, ...)
897 PPCODE:
898 cl_event ev = 0;
899 EVENT_LIST (2, items - 2);
900
901 NEED_SUCCESS (EnqueueTask, (this, kernel, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
902
903 if (ev)
904 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
905
906 void
907 enqueue_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);
957
958 void
959 enqueue_marker (OpenCL::Queue this)
960 PPCODE:
961 cl_event ev;
962 NEED_SUCCESS (EnqueueMarker, (this, &ev));
963 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
964
965 void
966 enqueue_wait_for_events (OpenCL::Queue this, ...)
967 CODE:
968 EVENT_LIST (1, items - 1);
969 NEED_SUCCESS (EnqueueWaitForEvents, (this, event_list_count, event_list_ptr));
970
971 void
972 enqueue_barrier (OpenCL::Queue this)
973 CODE:
974 NEED_SUCCESS (EnqueueBarrier, (this));
975
976 void
977 flush (OpenCL::Queue this)
978 CODE:
979 NEED_SUCCESS (Flush, (this));
980
981 void
982 finish (OpenCL::Queue this)
983 CODE:
984 NEED_SUCCESS (Finish, (this));
985
986 void
987 info (OpenCL::Queue this, cl_command_queue_info name)
988 PPCODE:
989 INFO (CommandQueue)
990
991 #BEGIN:command_queue
992
993 void
994 context (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
1005 void
1006 device (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
1016 void
1017 reference_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
1025 void
1026 properties (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
1036 MODULE = OpenCL PACKAGE = OpenCL::Memory
1037
1038 void
1039 DESTROY (OpenCL::Memory this)
1040 CODE:
1041 clReleaseMemObject (this);
1042
1043 void
1044 info (OpenCL::Memory this, cl_mem_info name)
1045 PPCODE:
1046 INFO (MemObject)
1047
1048 #BEGIN:mem
1049
1050 void
1051 type (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
1059 void
1060 flags (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
1068 void
1069 size (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
1080 void
1081 host_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
1089 void
1090 map_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
1101 void
1102 context (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
1113 void
1114 associated_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
1127 MODULE = OpenCL PACKAGE = OpenCL::BufferObj
1128
1129 void
1130 sub_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
1140 MODULE = OpenCL PACKAGE = OpenCL::Image
1141
1142 void
1143 image_info (OpenCL::Image this, cl_image_info name)
1144 PPCODE:
1145 INFO (Image)
1146
1147 #BEGIN:image
1148
1149 void
1150 element_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
1167 MODULE = OpenCL PACKAGE = OpenCL::Sampler
1168
1169 void
1170 DESTROY (OpenCL::Sampler this)
1171 CODE:
1172 clReleaseSampler (this);
1173
1174 void
1175 info (OpenCL::Sampler this, cl_sampler_info name)
1176 PPCODE:
1177 INFO (Sampler)
1178
1179 #BEGIN:sampler
1180
1181 void
1182 reference_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
1190 void
1191 context (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
1202 void
1203 normalized_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
1211 void
1212 addressing_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
1220 void
1221 filter_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
1231 MODULE = OpenCL PACKAGE = OpenCL::Program
1232
1233 void
1234 DESTROY (OpenCL::Program this)
1235 CODE:
1236 clReleaseProgram (this);
1237
1238 void
1239 build (OpenCL::Program this, OpenCL::Device device, SV *options = &PL_sv_undef)
1240 CODE:
1241 NEED_SUCCESS (BuildProgram, (this, 1, &device, SvPVbyte_nolen (options), 0, 0));
1242
1243 void
1244 build_info (OpenCL::Program this, OpenCL::Device device, cl_program_build_info name)
1245 PPCODE:
1246 size_t size;
1247 NEED_SUCCESS (GetProgramBuildInfo, (this, device, name, 0, 0, &size));
1248 SV *sv = sv_2mortal (newSV (size));
1249 SvUPGRADE (sv, SVt_PV);
1250 SvPOK_only (sv);
1251 SvCUR_set (sv, size);
1252 NEED_SUCCESS (GetProgramBuildInfo, (this, device, name, size, SvPVX (sv), 0));
1253 XPUSHs (sv);
1254
1255 #BEGIN:program_build
1256
1257 void
1258 build_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
1266 void
1267 build_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
1281
1282 void
1283 kernel (OpenCL::Program program, SV *function)
1284 PPCODE:
1285 NEED_SUCCESS_ARG (cl_kernel kernel, CreateKernel, (program, SvPVbyte_nolen (function), &res));
1286 XPUSH_NEW_OBJ ("OpenCL::Kernel", kernel);
1287
1288 void
1289 info (OpenCL::Program this, cl_program_info name)
1290 PPCODE:
1291 INFO (Program)
1292
1293 void
1294 binaries (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
1323 void
1324 reference_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
1335 void
1336 context (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
1347 void
1348 devices (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
1361 void
1362 source (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
1372 void
1373 binary_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
1385
1386 MODULE = OpenCL PACKAGE = OpenCL::Kernel
1387
1388 void
1389 DESTROY (OpenCL::Kernel this)
1390 CODE:
1391 clReleaseKernel (this);
1392
1393 void
1394 set_char (OpenCL::Kernel this, cl_uint idx, cl_char value)
1395 CODE:
1396 clSetKernelArg (this, idx, sizeof (value), &value);
1397
1398 void
1399 set_uchar (OpenCL::Kernel this, cl_uint idx, cl_uchar value)
1400 CODE:
1401 clSetKernelArg (this, idx, sizeof (value), &value);
1402
1403 void
1404 set_short (OpenCL::Kernel this, cl_uint idx, cl_short value)
1405 CODE:
1406 clSetKernelArg (this, idx, sizeof (value), &value);
1407
1408 void
1409 set_ushort (OpenCL::Kernel this, cl_uint idx, cl_ushort value)
1410 CODE:
1411 clSetKernelArg (this, idx, sizeof (value), &value);
1412
1413 void
1414 set_int (OpenCL::Kernel this, cl_uint idx, cl_int value)
1415 CODE:
1416 clSetKernelArg (this, idx, sizeof (value), &value);
1417
1418 void
1419 set_uint (OpenCL::Kernel this, cl_uint idx, cl_uint value)
1420 CODE:
1421 clSetKernelArg (this, idx, sizeof (value), &value);
1422
1423 void
1424 set_long (OpenCL::Kernel this, cl_uint idx, cl_long value)
1425 CODE:
1426 clSetKernelArg (this, idx, sizeof (value), &value);
1427
1428 void
1429 set_ulong (OpenCL::Kernel this, cl_uint idx, cl_ulong value)
1430 CODE:
1431 clSetKernelArg (this, idx, sizeof (value), &value);
1432
1433 void
1434 set_half (OpenCL::Kernel this, cl_uint idx, cl_half value)
1435 CODE:
1436 clSetKernelArg (this, idx, sizeof (value), &value);
1437
1438 void
1439 set_float (OpenCL::Kernel this, cl_uint idx, cl_float value)
1440 CODE:
1441 clSetKernelArg (this, idx, sizeof (value), &value);
1442
1443 void
1444 set_double (OpenCL::Kernel this, cl_uint idx, cl_double value)
1445 CODE:
1446 clSetKernelArg (this, idx, sizeof (value), &value);
1447
1448 void
1449 set_memory (OpenCL::Kernel this, cl_uint idx, OpenCL::Memory_ornull value)
1450 CODE:
1451 clSetKernelArg (this, idx, sizeof (value), &value);
1452
1453 void
1454 set_buffer (OpenCL::Kernel this, cl_uint idx, OpenCL::Buffer_ornull value)
1455 CODE:
1456 clSetKernelArg (this, idx, sizeof (value), &value);
1457
1458 void
1459 set_image2d (OpenCL::Kernel this, cl_uint idx, OpenCL::Image2D_ornull value)
1460 CODE:
1461 clSetKernelArg (this, idx, sizeof (value), &value);
1462
1463 void
1464 set_image3d (OpenCL::Kernel this, cl_uint idx, OpenCL::Image3D_ornull value)
1465 CODE:
1466 clSetKernelArg (this, idx, sizeof (value), &value);
1467
1468 void
1469 set_sampler (OpenCL::Kernel this, cl_uint idx, OpenCL::Sampler value)
1470 CODE:
1471 clSetKernelArg (this, idx, sizeof (value), &value);
1472
1473 void
1474 set_event (OpenCL::Kernel this, cl_uint idx, OpenCL::Event value)
1475 CODE:
1476 clSetKernelArg (this, idx, sizeof (value), &value);
1477
1478 void
1479 info (OpenCL::Kernel this, cl_kernel_info name)
1480 PPCODE:
1481 INFO (Kernel)
1482
1483 #BEGIN:kernel
1484
1485 void
1486 function_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
1496 void
1497 num_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
1508 void
1509 context (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
1520 void
1521 program (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
1534 void
1535 work_group_info (OpenCL::Kernel this, OpenCL::Device device, cl_kernel_work_group_info name)
1536 PPCODE:
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);
1545
1546 #BEGIN:kernel_work_group
1547
1548 void
1549 work_group_size (OpenCL::Kernel this, OpenCL::Device device)
1550 ALIAS:
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])));
1559
1560 void
1561 compile_work_group_size (OpenCL::Kernel this, OpenCL::Device device)
1562 PPCODE:
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])));
1571
1572 void
1573 local_mem_size (OpenCL::Kernel this, OpenCL::Device device)
1574 ALIAS:
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])));
1583
1584 #END:kernel_work_group
1585
1586 MODULE = OpenCL PACKAGE = OpenCL::Event
1587
1588 void
1589 DESTROY (OpenCL::Event this)
1590 CODE:
1591 clReleaseEvent (this);
1592
1593 void
1594 wait (OpenCL::Event this)
1595 CODE:
1596 clWaitForEvents (1, &this);
1597
1598 void
1599 info (OpenCL::Event this, cl_event_info name)
1600 PPCODE:
1601 INFO (Event)
1602
1603 #BEGIN:event
1604
1605 void
1606 command_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
1617 void
1618 command_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
1626 void
1627 reference_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
1638 void
1639 context (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
1652 void
1653 profiling_info (OpenCL::Event this, cl_profiling_info name)
1654 PPCODE:
1655 INFO (EventProfiling)
1656
1657 #BEGIN:profiling
1658
1659 void
1660 profiling_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
1675 MODULE = OpenCL PACKAGE = OpenCL::UserEvent
1676
1677 void
1678 set_status (OpenCL::UserEvent this, cl_int execution_status)
1679 CODE:
1680 clSetUserEventStatus (this, execution_status);
1681