… | |
… | |
105 | for my $platform (OpenCL::platforms) { |
105 | for my $platform (OpenCL::platforms) { |
106 | printf "platform: %s\n", $platform->name; |
106 | printf "platform: %s\n", $platform->name; |
107 | printf "extensions: %s\n", $platform->extensions; |
107 | printf "extensions: %s\n", $platform->extensions; |
108 | for my $device ($platform->devices) { |
108 | for my $device ($platform->devices) { |
109 | printf "+ device: %s\n", $device->name; |
109 | printf "+ device: %s\n", $device->name; |
110 | my $ctx = $device->context; |
110 | my $ctx = $platform->context (undef, [$device]); |
111 | # do stuff |
111 | # do stuff |
112 | } |
112 | } |
113 | } |
113 | } |
114 | |
114 | |
115 | =head2 Get a useful context and a command queue. |
115 | =head2 Get a useful context and a command queue. |
… | |
… | |
149 | |
149 | |
150 | =head2 Create and build a program, then create a kernel out of one of its |
150 | =head2 Create and build a program, then create a kernel out of one of its |
151 | functions. |
151 | functions. |
152 | |
152 | |
153 | my $src = ' |
153 | my $src = ' |
154 | __kernel void |
154 | kernel void |
155 | squareit (__global float *input, __global float *output) |
155 | squareit (global float *input, global float *output) |
156 | { |
156 | { |
157 | $id = get_global_id (0); |
157 | $id = get_global_id (0); |
158 | output [id] = input [id] * input [id]; |
158 | output [id] = input [id] * input [id]; |
159 | } |
159 | } |
160 | '; |
160 | '; |
… | |
… | |
286 | |
286 | |
287 | Comverts an error value into a human readable string. |
287 | Comverts an error value into a human readable string. |
288 | |
288 | |
289 | =item $str = OpenCL::enum2str $enum |
289 | =item $str = OpenCL::enum2str $enum |
290 | |
290 | |
291 | Converts most enum values (inof parameter names, image format constants, |
291 | Converts most enum values (of parameter names, image format constants, |
292 | object types, addressing and filter modes, command types etc.) into a |
292 | object types, addressing and filter modes, command types etc.) into a |
293 | human readbale string. When confronted with some random integer it can be |
293 | human readable string. When confronted with some random integer it can be |
294 | very helpful to pass it through this function to maybe get some readable |
294 | very helpful to pass it through this function to maybe get some readable |
295 | string out of it. |
295 | string out of it. |
296 | |
296 | |
297 | =item @platforms = OpenCL::platforms |
297 | =item @platforms = OpenCL::platforms |
298 | |
298 | |
… | |
… | |
326 | |
326 | |
327 | Tries to create a context. Never worked for me, and you need devices explicitly anyway. |
327 | Tries to create a context. Never worked for me, and you need devices explicitly anyway. |
328 | |
328 | |
329 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContextFromType.html> |
329 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContextFromType.html> |
330 | |
330 | |
331 | =item $ctx = $device->context ($properties = undef, @$devices, $notify = undef) |
331 | =item $ctx = $platform->context ($properties = undef, @$devices, $notify = undef) |
332 | |
332 | |
333 | Create a new OpenCL::Context object using the given device object(s)- a |
333 | Create a new OpenCL::Context object using the given device object(s)- a |
334 | CL_CONTEXT_PLATFORM property is supplied automatically. |
334 | CL_CONTEXT_PLATFORM property is supplied automatically. |
335 | |
335 | |
336 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContext.html> |
336 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContext.html> |
… | |
… | |
668 | |
668 | |
669 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateUserEvent.html> |
669 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateUserEvent.html> |
670 | |
670 | |
671 | =item $buf = $ctx->buffer ($flags, $len) |
671 | =item $buf = $ctx->buffer ($flags, $len) |
672 | |
672 | |
673 | Creates a new OpenCL::Buffer object with the given flags and octet-size. |
673 | Creates a new OpenCL::Buffer (actually OpenCL::BufferObj) object with the |
|
|
674 | given flags and octet-size. |
674 | |
675 | |
675 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateBuffer.html> |
676 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateBuffer.html> |
676 | |
677 | |
677 | =item $buf = $ctx->buffer_sv ($flags, $data) |
678 | =item $buf = $ctx->buffer_sv ($flags, $data) |
678 | |
679 | |
679 | Creates a new OpenCL::Buffer object and initialise it with the given data values. |
680 | Creates a new OpenCL::Buffer (actually OpenCL::BufferObj) object and |
|
|
681 | initialise it with the given data values. |
680 | |
682 | |
681 | =item $img = $ctx->image2d ($flags, $channel_order, $channel_type, $width, $height, $row_pitch = 0, $data = undef) |
683 | =item $img = $ctx->image2d ($flags, $channel_order, $channel_type, $width, $height, $row_pitch = 0, $data = undef) |
682 | |
684 | |
683 | Creates a new OpenCL::Image2D object and optionally initialises it with the given data values. |
685 | Creates a new OpenCL::Image2D object and optionally initialises it with |
|
|
686 | the given data values. |
684 | |
687 | |
685 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateImage2D.html> |
688 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateImage2D.html> |
686 | |
689 | |
687 | =item $img = $ctx->image3d ($flags, $channel_order, $channel_type, $width, $height, $depth, $row_pitch = 0, $slice_pitch = 0, $data = undef) |
690 | =item $img = $ctx->image3d ($flags, $channel_order, $channel_type, $width, $height, $depth, $row_pitch = 0, $slice_pitch = 0, $data = undef) |
688 | |
691 | |
689 | Creates a new OpenCL::Image3D object and optionally initialises it with the given data values. |
692 | Creates a new OpenCL::Image3D object and optionally initialises it with |
|
|
693 | the given data values. |
690 | |
694 | |
691 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateImage3D.html> |
695 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateImage3D.html> |
|
|
696 | |
|
|
697 | =item $buffer = $ctx->gl_buffer ($flags, $bufobj) |
|
|
698 | |
|
|
699 | Creates a new OpenCL::Buffer (actually OpenCL::BufferObj) object that refers to the given |
|
|
700 | OpenGL buffer object. |
|
|
701 | |
|
|
702 | http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateFromGLBuffer.html |
|
|
703 | |
|
|
704 | =item $ctx->gl_texture2d ($flags, $target, $miplevel, $texture) |
|
|
705 | |
|
|
706 | Creates a new OpenCL::Image2D object that refers to the given OpenGL |
|
|
707 | 2D texture object. |
|
|
708 | |
|
|
709 | http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateFromGLTexture2D.html |
|
|
710 | |
|
|
711 | =item $ctx->gl_texture3d ($flags, $target, $miplevel, $texture) |
|
|
712 | |
|
|
713 | Creates a new OpenCL::Image3D object that refers to the given OpenGL |
|
|
714 | 3D texture object. |
|
|
715 | |
|
|
716 | http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateFromGLTexture3D.html |
|
|
717 | |
|
|
718 | =item $ctx->gl_renderbuffer ($flags, $renderbuffer) |
|
|
719 | |
|
|
720 | Creates a new OpenCL::Image2D object that refers to the given OpenGL |
|
|
721 | render buffer. |
|
|
722 | |
|
|
723 | http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateFromGLRenderbuffer.html |
692 | |
724 | |
693 | =item @formats = $ctx->supported_image_formats ($flags, $image_type) |
725 | =item @formats = $ctx->supported_image_formats ($flags, $image_type) |
694 | |
726 | |
695 | Returns a list of matching image formats - each format is an arrayref with |
727 | Returns a list of matching image formats - each format is an arrayref with |
696 | two values, $channel_order and $channel_type, in it. |
728 | two values, $channel_order and $channel_type, in it. |
… | |
… | |
781 | |
813 | |
782 | http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWriteBufferRect.html |
814 | http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWriteBufferRect.html |
783 | |
815 | |
784 | =item $ev = $queue->enqueue_read_image ($src, $blocking, $x, $y, $z, $width, $height, $depth, $row_pitch, $slice_pitch, $data, $wait_events...) |
816 | =item $ev = $queue->enqueue_read_image ($src, $blocking, $x, $y, $z, $width, $height, $depth, $row_pitch, $slice_pitch, $data, $wait_events...) |
785 | |
817 | |
|
|
818 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyBufferRect.html> |
|
|
819 | |
|
|
820 | =item $ev = $queue->enqueue_copy_buffer_to_image ($src_buffer, $dst_image, $src_offset, $dst_x, $dst_y, $dst_z, $width, $height, $depth, $wait_events...) |
|
|
821 | |
786 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueReadImage.html> |
822 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueReadImage.html> |
787 | |
823 | |
788 | =item $ev = $queue->enqueue_write_image ($src, $blocking, $x, $y, $z, $width, $height, $depth, $row_pitch, $slice_pitch, $data, $wait_events...) |
824 | =item $ev = $queue->enqueue_write_image ($src, $blocking, $x, $y, $z, $width, $height, $depth, $row_pitch, $slice_pitch, $data, $wait_events...) |
789 | |
825 | |
790 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWriteImage.html> |
826 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWriteImage.html> |
791 | |
827 | |
|
|
828 | =item $ev = $queue->enqueue_copy_image ($src_image, $dst_image, $src_x, $src_y, $src_z, $dst_x, $dst_y, $dst_z, $width, $height, $depth, $wait_events...) |
|
|
829 | |
|
|
830 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyImage.html> |
|
|
831 | |
|
|
832 | =item $ev = $queue->enqueue_copy_image_to_buffer ($src_image, $dst_image, $src_x, $src_y, $src_z, $width, $height, $depth, $dst_offset, $wait_events...) |
|
|
833 | |
|
|
834 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyImageToBuffer.html> |
|
|
835 | |
792 | =item $ev = $queue->enqueue_copy_buffer_rect ($src, $dst, $src_x, $src_y, $src_z, $dst_x, $dst_y, $dst_z, $width, $height, $depth, $src_row_pitch, $src_slice_pitch, $dst_row_pitch, $dst_slice_pitch, $wait_event...) |
836 | =item $ev = $queue->enqueue_copy_buffer_rect ($src, $dst, $src_x, $src_y, $src_z, $dst_x, $dst_y, $dst_z, $width, $height, $depth, $src_row_pitch, $src_slice_pitch, $dst_row_pitch, $dst_slice_pitch, $wait_event...) |
793 | |
837 | |
794 | Yeah. |
838 | Yeah. |
795 | |
839 | |
796 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyBufferRect.html> |
|
|
797 | |
|
|
798 | =item $ev = $queue->enqueue_copy_buffer_to_image ($src_buffer, $dst_image, $src_offset, $dst_x, $dst_y, $dst_z, $width, $height, $depth, $wait_events...) |
|
|
799 | |
|
|
800 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyBufferToImage.html>. |
840 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyBufferToImage.html>. |
801 | |
|
|
802 | =item $ev = $queue->enqueue_copy_image ($src_image, $dst_image, $src_x, $src_y, $src_z, $dst_x, $dst_y, $dst_z, $width, $height, $depth, $wait_events...) |
|
|
803 | |
|
|
804 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyImage.html> |
|
|
805 | |
|
|
806 | =item $ev = $queue->enqueue_copy_image_to_buffer ($src_image, $dst_image, $src_x, $src_y, $src_z, $width, $height, $depth, $dst_offset, $wait_events...) |
|
|
807 | |
|
|
808 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyImageToBuffer.html> |
|
|
809 | |
841 | |
810 | =item $ev = $queue->enqueue_task ($kernel, $wait_events...) |
842 | =item $ev = $queue->enqueue_task ($kernel, $wait_events...) |
811 | |
843 | |
812 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueTask.html> |
844 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueTask.html> |
813 | |
845 | |
… | |
… | |
930 | |
962 | |
931 | =for gengetinfo end mem |
963 | =for gengetinfo end mem |
932 | |
964 | |
933 | =back |
965 | =back |
934 | |
966 | |
|
|
967 | =head2 THE OpenCL::Buffer CLASS |
|
|
968 | |
|
|
969 | This is a subclass of OpenCL::Memory, and the superclass of |
|
|
970 | OpenCL::BufferObj. Its purpose is simply to distinguish between buffers |
|
|
971 | and sub-buffers. |
|
|
972 | |
|
|
973 | =head2 THE OpenCL::BufferObj CLASS |
|
|
974 | |
|
|
975 | This is a subclass of OpenCL::Buffer and thus OpenCL::Memory. It exists |
|
|
976 | because one cna create sub buffers of OpenLC::BufferObj objects, but not |
|
|
977 | sub buffers from these sub buffers. |
|
|
978 | |
|
|
979 | =over 4 |
|
|
980 | |
|
|
981 | =item $subbuf = $buf_obj->sub_buffer_region ($flags, $origin, $size) |
|
|
982 | |
|
|
983 | Creates an OpenCL::Buffer objects from this buffer and returns it. The |
|
|
984 | C<buffer_create_type> is assumed to be C<CL_BUFFER_CREATE_TYPE_REGION>. |
|
|
985 | |
|
|
986 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateSubBuffer.html> |
|
|
987 | |
|
|
988 | =back |
|
|
989 | |
935 | =head2 THE OpenCL::Image CLASS |
990 | =head2 THE OpenCL::Image CLASS |
936 | |
991 | |
937 | This is the superclass of all image objects - OpenCL::Image2D and OpenCL::Image3D. |
992 | This is the superclass of all image objects - OpenCL::Image2D and OpenCL::Image3D. |
938 | |
993 | |
939 | =over 4 |
994 | =over 4 |
… | |
… | |
1275 | package OpenCL; |
1330 | package OpenCL; |
1276 | |
1331 | |
1277 | use common::sense; |
1332 | use common::sense; |
1278 | |
1333 | |
1279 | BEGIN { |
1334 | BEGIN { |
1280 | our $VERSION = '0.55'; |
1335 | our $VERSION = '0.92'; |
1281 | |
1336 | |
1282 | require XSLoader; |
1337 | require XSLoader; |
1283 | XSLoader::load (__PACKAGE__, $VERSION); |
1338 | XSLoader::load (__PACKAGE__, $VERSION); |
1284 | |
1339 | |
1285 | @OpenCL::Buffer::ISA = |
1340 | @OpenCL::Buffer::ISA = |
1286 | @OpenCL::Image::ISA = OpenCL::Memory::; |
1341 | @OpenCL::Image::ISA = OpenCL::Memory::; |
1287 | |
1342 | |
|
|
1343 | @OpenCL::BufferObj::ISA = OpenCL::Buffer::; |
|
|
1344 | |
1288 | @OpenCL::Image2D::ISA = |
1345 | @OpenCL::Image2D::ISA = |
1289 | @OpenCL::Image3D::ISA = OpenCL::Image::; |
1346 | @OpenCL::Image3D::ISA = OpenCL::Image::; |
1290 | |
1347 | |
1291 | @OpenCL::UserEvent::ISA = OpenCL::Event::; |
1348 | @OpenCL::UserEvent::ISA = OpenCL::Event::; |
1292 | } |
1349 | } |
1293 | |
1350 | |
1294 | 1; |
1351 | 1; |
1295 | |
1352 | |
1296 | =head1 AUTHOR |
1353 | =head1 AUTHOR |