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

Comparing OpenCL/OpenCL.xs (file contents):
Revision 1.11 by root, Thu Nov 17 04:17:43 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;
25typedef cl_event OpenCL__UserEvent; 26typedef cl_event OpenCL__UserEvent;
26 27
27typedef SV *FUTURE; 28typedef SV *FUTURE;
28 29
29/*****************************************************************************/ 30/*****************************************************************************/
30 31
238void 239void
239info (OpenCL::Platform this, cl_platform_info name) 240info (OpenCL::Platform this, cl_platform_info name)
240 PPCODE: 241 PPCODE:
241 INFO (Platform) 242 INFO (Platform)
242 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
243void 265void
244devices (OpenCL::Platform this, cl_device_type type = CL_DEVICE_TYPE_ALL) 266devices (OpenCL::Platform this, cl_device_type type = CL_DEVICE_TYPE_ALL)
245 PPCODE: 267 PPCODE:
246 cl_device_id *list; 268 cl_device_id *list;
247 cl_uint count; 269 cl_uint count;
284void 306void
285info (OpenCL::Device this, cl_device_info name) 307info (OpenCL::Device this, cl_device_info name)
286 PPCODE: 308 PPCODE:
287 INFO (Device) 309 INFO (Device)
288 310
311#BEGIN:device
312
313void
314type (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
322void
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])));
358
359void
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
534
289MODULE = OpenCL PACKAGE = OpenCL::Context 535MODULE = OpenCL PACKAGE = OpenCL::Context
290 536
291void 537void
292DESTROY (OpenCL::Context context) 538DESTROY (OpenCL::Context context)
293 CODE: 539 CODE:
315 PPCODE: 561 PPCODE:
316 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))
317 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?");
318 564
319 NEED_SUCCESS_ARG (cl_mem mem, CreateBuffer, (this, flags, len, 0, &res)); 565 NEED_SUCCESS_ARG (cl_mem mem, CreateBuffer, (this, flags, len, 0, &res));
320 XPUSH_NEW_OBJ ("OpenCL::Buffer", mem); 566 XPUSH_NEW_OBJ ("OpenCL::BufferObj", mem);
321 567
322void 568void
323buffer_sv (OpenCL::Context this, cl_mem_flags flags, SV *data) 569buffer_sv (OpenCL::Context this, cl_mem_flags flags, SV *data)
324 PPCODE: 570 PPCODE:
325 STRLEN len; 571 STRLEN len;
327 573
328 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)))
329 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?");
330 576
331 NEED_SUCCESS_ARG (cl_mem mem, CreateBuffer, (this, flags, len, ptr, &res)); 577 NEED_SUCCESS_ARG (cl_mem mem, CreateBuffer, (this, flags, len, ptr, &res));
332 XPUSH_NEW_OBJ ("OpenCL::Buffer", mem); 578 XPUSH_NEW_OBJ ("OpenCL::BufferObj", mem);
333 579
334void 580void
335image2d (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, 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)
336 PPCODE: 582 PPCODE:
337 STRLEN len; 583 STRLEN len;
338 char *ptr = SvPVbyte (data, len); 584 char *ptr = SvPVbyte (data, len);
339 const cl_image_format format = { channel_order, channel_type }; 585 const cl_image_format format = { channel_order, channel_type };
340 NEED_SUCCESS_ARG (cl_mem mem, CreateImage2D, (this, flags, &format, width, height, row_pitch, ptr, &res)); 586 NEED_SUCCESS_ARG (cl_mem mem, CreateImage2D, (this, flags, &format, width, height, row_pitch, ptr, &res));
341 XPUSH_NEW_OBJ ("OpenCL::Image2D", mem); 587 XPUSH_NEW_OBJ ("OpenCL::Image2D", mem);
342 588
343void 589void
344image3d (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, 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)
345 PPCODE: 591 PPCODE:
346 STRLEN len; 592 STRLEN len;
347 char *ptr = SvPVbyte (data, len); 593 char *ptr = SvPVbyte (data, len);
348 const cl_image_format format = { channel_order, channel_type }; 594 const cl_image_format format = { channel_order, channel_type };
349 NEED_SUCCESS_ARG (cl_mem mem, CreateImage3D, (this, flags, &format, width, height, depth, row_pitch, slice_pitch, ptr, &res)); 595 NEED_SUCCESS_ARG (cl_mem mem, CreateImage3D, (this, flags, &format, width, height, depth, row_pitch, slice_pitch, ptr, &res));
386 632
387 len2 = len; 633 len2 = len;
388 NEED_SUCCESS_ARG (cl_program prog, CreateProgramWithSource, (this, 1, &ptr, &len2, &res)); 634 NEED_SUCCESS_ARG (cl_program prog, CreateProgramWithSource, (this, 1, &ptr, &len2, &res));
389 XPUSH_NEW_OBJ ("OpenCL::Program", prog); 635 XPUSH_NEW_OBJ ("OpenCL::Program", prog);
390 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
678
391MODULE = OpenCL PACKAGE = OpenCL::Queue 679MODULE = OpenCL PACKAGE = OpenCL::Queue
392 680
393void 681void
394DESTROY (OpenCL::Queue this) 682DESTROY (OpenCL::Queue this)
395 CODE: 683 CODE:
396 clReleaseCommandQueue (this); 684 clReleaseCommandQueue (this);
397
398void
399info (OpenCL::Queue this, cl_command_queue_info name)
400 PPCODE:
401 INFO (CommandQueue)
402 685
403void 686void
404enqueue_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, ...)
405 PPCODE: 688 PPCODE:
406 cl_event ev = 0; 689 cl_event ev = 0;
433 PPCODE: 716 PPCODE:
434 cl_event ev = 0; 717 cl_event ev = 0;
435 EVENT_LIST (6, items - 6); 718 EVENT_LIST (6, items - 6);
436 719
437 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));
721
722 if (ev)
723 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
724
725void
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));
438 800
439 if (ev) 801 if (ev)
440 XPUSH_NEW_OBJ ("OpenCL::Event", ev); 802 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
441 803
442void 804void
489 851
490 if (ev) 852 if (ev)
491 XPUSH_NEW_OBJ ("OpenCL::Event", ev); 853 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
492 854
493void 855void
494enqueue_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, ...)
495 PPCODE:
496 cl_event ev = 0;
497 const size_t src_origin[3] = { src_x, src_y, src_z };
498 const size_t dst_origin[3] = { dst_x, dst_y, dst_z };
499 const size_t region[3] = { width, height, depth };
500 EVENT_LIST (16, items - 16);
501
502 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));
503
504 if (ev)
505 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
506
507void
508enqueue_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, ...)
509 PPCODE:
510 cl_event ev = 0;
511 const size_t dst_origin[3] = { dst_x, dst_y, dst_z };
512 const size_t region[3] = { width, height, depth };
513 EVENT_LIST (10, items - 10);
514
515 NEED_SUCCESS (EnqueueCopyBufferToImage, (this, src, dst, src_offset, dst_origin, region, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
516
517 if (ev)
518 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
519
520void
521enqueue_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, ...) 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, ...)
522 PPCODE: 857 PPCODE:
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 };
538 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 };
539 const size_t region[3] = { width, height, depth }; 874 const size_t region[3] = { width, height, depth };
540 EVENT_LIST (10, items - 10); 875 EVENT_LIST (10, items - 10);
541 876
542 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));
878
879 if (ev)
880 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
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));
543 891
544 if (ev) 892 if (ev)
545 XPUSH_NEW_OBJ ("OpenCL::Event", ev); 893 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
546 894
547void 895void
633void 981void
634finish (OpenCL::Queue this) 982finish (OpenCL::Queue this)
635 CODE: 983 CODE:
636 NEED_SUCCESS (Finish, (this)); 984 NEED_SUCCESS (Finish, (this));
637 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
638MODULE = OpenCL PACKAGE = OpenCL::Memory 1036MODULE = OpenCL PACKAGE = OpenCL::Memory
639 1037
640void 1038void
641DESTROY (OpenCL::Memory this) 1039DESTROY (OpenCL::Memory this)
642 CODE: 1040 CODE:
645void 1043void
646info (OpenCL::Memory this, cl_mem_info name) 1044info (OpenCL::Memory this, cl_mem_info name)
647 PPCODE: 1045 PPCODE:
648 INFO (MemObject) 1046 INFO (MemObject)
649 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
650MODULE = OpenCL PACKAGE = OpenCL::Sampler 1167MODULE = OpenCL PACKAGE = OpenCL::Sampler
651 1168
652void 1169void
653DESTROY (OpenCL::Sampler this) 1170DESTROY (OpenCL::Sampler this)
654 CODE: 1171 CODE:
657void 1174void
658info (OpenCL::Sampler this, cl_sampler_info name) 1175info (OpenCL::Sampler this, cl_sampler_info name)
659 PPCODE: 1176 PPCODE:
660 INFO (Sampler) 1177 INFO (Sampler)
661 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
662MODULE = OpenCL PACKAGE = OpenCL::Program 1231MODULE = OpenCL PACKAGE = OpenCL::Program
663 1232
664void 1233void
665DESTROY (OpenCL::Program this) 1234DESTROY (OpenCL::Program this)
666 CODE: 1235 CODE:
667 clReleaseProgram (this); 1236 clReleaseProgram (this);
668
669void
670info (OpenCL::Program this, cl_program_info name)
671 PPCODE:
672 INFO (Program)
673 1237
674void 1238void
675build (OpenCL::Program this, OpenCL::Device device, SV *options = &PL_sv_undef) 1239build (OpenCL::Program this, OpenCL::Device device, SV *options = &PL_sv_undef)
676 CODE: 1240 CODE:
677 NEED_SUCCESS (BuildProgram, (this, 1, &device, SvPVbyte_nolen (options), 0, 0)); 1241 NEED_SUCCESS (BuildProgram, (this, 1, &device, SvPVbyte_nolen (options), 0, 0));
686 SvPOK_only (sv); 1250 SvPOK_only (sv);
687 SvCUR_set (sv, size); 1251 SvCUR_set (sv, size);
688 NEED_SUCCESS (GetProgramBuildInfo, (this, device, name, size, SvPVX (sv), 0)); 1252 NEED_SUCCESS (GetProgramBuildInfo, (this, device, name, size, SvPVX (sv), 0));
689 XPUSHs (sv); 1253 XPUSHs (sv);
690 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
1281
691void 1282void
692kernel (OpenCL::Program program, SV *function) 1283kernel (OpenCL::Program program, SV *function)
693 PPCODE: 1284 PPCODE:
694 NEED_SUCCESS_ARG (cl_kernel kernel, CreateKernel, (program, SvPVbyte_nolen (function), &res)); 1285 NEED_SUCCESS_ARG (cl_kernel kernel, CreateKernel, (program, SvPVbyte_nolen (function), &res));
695 XPUSH_NEW_OBJ ("OpenCL::Kernel", kernel); 1286 XPUSH_NEW_OBJ ("OpenCL::Kernel", kernel);
696 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
1385
697MODULE = OpenCL PACKAGE = OpenCL::Kernel 1386MODULE = OpenCL PACKAGE = OpenCL::Kernel
698 1387
699void 1388void
700DESTROY (OpenCL::Kernel this) 1389DESTROY (OpenCL::Kernel this)
701 CODE: 1390 CODE:
702 clReleaseKernel (this); 1391 clReleaseKernel (this);
703 1392
704void 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
705info (OpenCL::Kernel this, cl_kernel_info name) 1479info (OpenCL::Kernel this, cl_kernel_info name)
706 PPCODE: 1480 PPCODE:
707 INFO (Kernel) 1481 INFO (Kernel)
708 1482
1483#BEGIN:kernel
1484
709void 1485void
710set_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)
711 CODE: 1536 PPCODE:
712 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);
713 1545
714void 1546#BEGIN:kernel_work_group
715set_uchar (OpenCL::Kernel this, cl_uint idx, cl_uchar value)
716 CODE:
717 clSetKernelArg (this, idx, sizeof (value), &value);
718 1547
719void 1548void
720set_short (OpenCL::Kernel this, cl_uint idx, cl_short value) 1549work_group_size (OpenCL::Kernel this, OpenCL::Device device)
721 CODE: 1550 ALIAS:
722 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])));
723 1559
724void 1560void
725set_ushort (OpenCL::Kernel this, cl_uint idx, cl_ushort value) 1561compile_work_group_size (OpenCL::Kernel this, OpenCL::Device device)
726 CODE: 1562 PPCODE:
727 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])));
728 1571
729void 1572void
730set_int (OpenCL::Kernel this, cl_uint idx, cl_int value) 1573local_mem_size (OpenCL::Kernel this, OpenCL::Device device)
731 CODE: 1574 ALIAS:
732 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])));
733 1583
734void 1584#END:kernel_work_group
735set_uint (OpenCL::Kernel this, cl_uint idx, cl_uint value)
736 CODE:
737 clSetKernelArg (this, idx, sizeof (value), &value);
738
739void
740set_long (OpenCL::Kernel this, cl_uint idx, cl_long value)
741 CODE:
742 clSetKernelArg (this, idx, sizeof (value), &value);
743
744void
745set_ulong (OpenCL::Kernel this, cl_uint idx, cl_ulong value)
746 CODE:
747 clSetKernelArg (this, idx, sizeof (value), &value);
748
749void
750set_half (OpenCL::Kernel this, cl_uint idx, cl_half value)
751 CODE:
752 clSetKernelArg (this, idx, sizeof (value), &value);
753
754void
755set_float (OpenCL::Kernel this, cl_uint idx, cl_float value)
756 CODE:
757 clSetKernelArg (this, idx, sizeof (value), &value);
758
759void
760set_double (OpenCL::Kernel this, cl_uint idx, cl_double value)
761 CODE:
762 clSetKernelArg (this, idx, sizeof (value), &value);
763
764void
765set_memory (OpenCL::Kernel this, cl_uint idx, OpenCL::Memory_ornull value)
766 CODE:
767 clSetKernelArg (this, idx, sizeof (value), &value);
768
769void
770set_buffer (OpenCL::Kernel this, cl_uint idx, OpenCL::Buffer_ornull value)
771 CODE:
772 clSetKernelArg (this, idx, sizeof (value), &value);
773
774void
775set_image2d (OpenCL::Kernel this, cl_uint idx, OpenCL::Image2D_ornull value)
776 CODE:
777 clSetKernelArg (this, idx, sizeof (value), &value);
778
779void
780set_image3d (OpenCL::Kernel this, cl_uint idx, OpenCL::Image3D_ornull value)
781 CODE:
782 clSetKernelArg (this, idx, sizeof (value), &value);
783
784void
785set_sampler (OpenCL::Kernel this, cl_uint idx, OpenCL::Sampler value)
786 CODE:
787 clSetKernelArg (this, idx, sizeof (value), &value);
788
789void
790set_event (OpenCL::Kernel this, cl_uint idx, OpenCL::Event value)
791 CODE:
792 clSetKernelArg (this, idx, sizeof (value), &value);
793 1585
794MODULE = OpenCL PACKAGE = OpenCL::Event 1586MODULE = OpenCL PACKAGE = OpenCL::Event
795 1587
796void 1588void
797DESTROY (OpenCL::Event this) 1589DESTROY (OpenCL::Event this)
798 CODE: 1590 CODE:
799 clReleaseEvent (this); 1591 clReleaseEvent (this);
800 1592
801void 1593void
1594wait (OpenCL::Event this)
1595 CODE:
1596 clWaitForEvents (1, &this);
1597
1598void
802info (OpenCL::Event this, cl_event_info name) 1599info (OpenCL::Event this, cl_event_info name)
803 PPCODE: 1600 PPCODE:
804 INFO (Event) 1601 INFO (Event)
805 1602
1603#BEGIN:event
1604
806void 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
807wait (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)
808 CODE: 1654 PPCODE:
809 clWaitForEvents (1, &this); 1655 INFO (EventProfiling)
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
810 1674
811MODULE = OpenCL PACKAGE = OpenCL::UserEvent 1675MODULE = OpenCL PACKAGE = OpenCL::UserEvent
812 1676
813void 1677void
814set_status (OpenCL::UserEvent this, cl_int execution_status) 1678set_status (OpenCL::UserEvent this, cl_int execution_status)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines