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

Comparing OpenCL/OpenCL.xs (file contents):
Revision 1.16 by root, Tue Nov 22 10:29:18 2011 UTC vs.
Revision 1.18 by root, Wed Nov 23 03:02:38 2011 UTC

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;
560 PPCODE: 561 PPCODE:
561 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))
562 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?");
563 564
564 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));
565 XPUSH_NEW_OBJ ("OpenCL::Buffer", mem); 566 XPUSH_NEW_OBJ ("OpenCL::BufferObj", mem);
566 567
567void 568void
568buffer_sv (OpenCL::Context this, cl_mem_flags flags, SV *data) 569buffer_sv (OpenCL::Context this, cl_mem_flags flags, SV *data)
569 PPCODE: 570 PPCODE:
570 STRLEN len; 571 STRLEN len;
572 573
573 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)))
574 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?");
575 576
576 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));
577 XPUSH_NEW_OBJ ("OpenCL::Buffer", mem); 578 XPUSH_NEW_OBJ ("OpenCL::BufferObj", mem);
578 579
579void 580void
580image2d (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) 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)
581 PPCODE: 582 PPCODE:
582 STRLEN len; 583 STRLEN len;
720 721
721 if (ev) 722 if (ev)
722 XPUSH_NEW_OBJ ("OpenCL::Event", ev); 723 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
723 724
724void 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));
800
801 if (ev)
802 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
803
804void
725enqueue_read_image (OpenCL::Queue this, OpenCL::Image src, cl_bool blocking, size_t src_x, size_t src_y, size_t src_z, size_t width, size_t height, size_t depth, size_t row_pitch, size_t slice_pitch, SV *data, ...) 805enqueue_read_image (OpenCL::Queue this, OpenCL::Image src, cl_bool blocking, size_t src_x, size_t src_y, size_t src_z, size_t width, size_t height, size_t depth, size_t row_pitch, size_t slice_pitch, SV *data, ...)
726 PPCODE: 806 PPCODE:
727 cl_event ev = 0; 807 cl_event ev = 0;
728 const size_t src_origin[3] = { src_x, src_y, src_z }; 808 const size_t src_origin[3] = { src_x, src_y, src_z };
729 const size_t region[3] = { width, height, depth }; 809 const size_t region[3] = { width, height, depth };
771 851
772 if (ev) 852 if (ev)
773 XPUSH_NEW_OBJ ("OpenCL::Event", ev); 853 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
774 854
775void 855void
776enqueue_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, ...)
777 PPCODE:
778 cl_event ev = 0;
779 const size_t src_origin[3] = { src_x, src_y, src_z };
780 const size_t dst_origin[3] = { dst_x, dst_y, dst_z };
781 const size_t region[3] = { width, height, depth };
782 EVENT_LIST (16, items - 16);
783
784 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));
785
786 if (ev)
787 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
788
789void
790enqueue_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, ...)
791 PPCODE:
792 cl_event ev = 0;
793 const size_t dst_origin[3] = { dst_x, dst_y, dst_z };
794 const size_t region[3] = { width, height, depth };
795 EVENT_LIST (10, items - 10);
796
797 NEED_SUCCESS (EnqueueCopyBufferToImage, (this, src, dst, src_offset, dst_origin, region, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0));
798
799 if (ev)
800 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
801
802void
803enqueue_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, ...)
804 PPCODE: 857 PPCODE:
805 cl_event ev = 0; 858 cl_event ev = 0;
806 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 };
807 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 };
820 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 };
821 const size_t region[3] = { width, height, depth }; 874 const size_t region[3] = { width, height, depth };
822 EVENT_LIST (10, items - 10); 875 EVENT_LIST (10, items - 10);
823 876
824 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));
825 891
826 if (ev) 892 if (ev)
827 XPUSH_NEW_OBJ ("OpenCL::Event", ev); 893 XPUSH_NEW_OBJ ("OpenCL::Event", ev);
828 894
829void 895void
1055 NEED_SUCCESS (RetainMemObject, (value [i])); 1121 NEED_SUCCESS (RetainMemObject, (value [i]));
1056 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Memory", value [i])); 1122 PUSHs (NEW_MORTAL_OBJ ("OpenCL::Memory", value [i]));
1057 } 1123 }
1058 1124
1059#END:mem 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);
1060 1139
1061MODULE = OpenCL PACKAGE = OpenCL::Image 1140MODULE = OpenCL PACKAGE = OpenCL::Image
1062 1141
1063void 1142void
1064image_info (OpenCL::Image this, cl_image_info name) 1143image_info (OpenCL::Image this, cl_image_info name)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines