… | |
… | |
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> |
692 | |
696 | |
693 | =item @formats = $ctx->supported_image_formats ($flags, $image_type) |
697 | =item @formats = $ctx->supported_image_formats ($flags, $image_type) |
694 | |
698 | |
… | |
… | |
771 | |
775 | |
772 | =item $ev = $queue->enqueue_copy_buffer ($src, $dst, $src_offset, $dst_offset, $len, $wait_events...) |
776 | =item $ev = $queue->enqueue_copy_buffer ($src, $dst, $src_offset, $dst_offset, $len, $wait_events...) |
773 | |
777 | |
774 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyBuffer.html> |
778 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyBuffer.html> |
775 | |
779 | |
|
|
780 | =item $ev = $queue->enqueue_read_buffer_rect (OpenCL::Memory buf, cl_bool blocking, $buf_x, $buf_y, $buf_z, $host_x, $host_y, $host_z, $width, $height, $depth, $buf_row_pitch, $buf_slice_pitch, $host_row_pitch, $host_slice_pitch, $data, $wait_events...) |
|
|
781 | |
|
|
782 | http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueReadBufferRect.html |
|
|
783 | |
|
|
784 | =item $ev = $queue->enqueue_write_buffer_rect (OpenCL::Memory buf, cl_bool blocking, $buf_x, $buf_y, $buf_z, $host_x, $host_y, $host_z, $width, $height, $depth, $buf_row_pitch, $buf_slice_pitch, $host_row_pitch, $host_slice_pitch, $data, $wait_events...) |
|
|
785 | |
|
|
786 | http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWriteBufferRect.html |
|
|
787 | |
776 | =item $ev = $queue->enqueue_read_image ($src, $blocking, $x, $y, $z, $width, $height, $depth, $row_pitch, $slice_pitch, $data, $wait_events...) |
788 | =item $ev = $queue->enqueue_read_image ($src, $blocking, $x, $y, $z, $width, $height, $depth, $row_pitch, $slice_pitch, $data, $wait_events...) |
777 | |
789 | |
|
|
790 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyBufferRect.html> |
|
|
791 | |
|
|
792 | =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...) |
|
|
793 | |
778 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueReadImage.html> |
794 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueReadImage.html> |
779 | |
795 | |
780 | =item $ev = $queue->enqueue_write_image ($src, $blocking, $x, $y, $z, $width, $height, $depth, $row_pitch, $slice_pitch, $data, $wait_events...) |
796 | =item $ev = $queue->enqueue_write_image ($src, $blocking, $x, $y, $z, $width, $height, $depth, $row_pitch, $slice_pitch, $data, $wait_events...) |
781 | |
797 | |
782 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWriteImage.html> |
798 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWriteImage.html> |
783 | |
799 | |
|
|
800 | =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...) |
|
|
801 | |
|
|
802 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyImage.html> |
|
|
803 | |
|
|
804 | =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...) |
|
|
805 | |
|
|
806 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyImageToBuffer.html> |
|
|
807 | |
784 | =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...) |
808 | =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...) |
785 | |
809 | |
786 | Yeah. |
810 | Yeah. |
787 | |
811 | |
788 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyBufferRect.html> |
|
|
789 | |
|
|
790 | =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...) |
|
|
791 | |
|
|
792 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyBufferToImage.html>. |
812 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyBufferToImage.html>. |
793 | |
|
|
794 | =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...) |
|
|
795 | |
|
|
796 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyImage.html> |
|
|
797 | |
|
|
798 | =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...) |
|
|
799 | |
|
|
800 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyImageToBuffer.html> |
|
|
801 | |
813 | |
802 | =item $ev = $queue->enqueue_task ($kernel, $wait_events...) |
814 | =item $ev = $queue->enqueue_task ($kernel, $wait_events...) |
803 | |
815 | |
804 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueTask.html> |
816 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueTask.html> |
805 | |
817 | |
… | |
… | |
922 | |
934 | |
923 | =for gengetinfo end mem |
935 | =for gengetinfo end mem |
924 | |
936 | |
925 | =back |
937 | =back |
926 | |
938 | |
|
|
939 | =head2 THE OpenCL::Buffer CLASS |
|
|
940 | |
|
|
941 | This is a subclass of OpenCL::Memory, and the superclass of |
|
|
942 | OpenCL::BufferObj. Its purpose is simply to distinguish between buffers |
|
|
943 | and sub-buffers. |
|
|
944 | |
|
|
945 | =head2 THE OpenCL::BufferObj CLASS |
|
|
946 | |
|
|
947 | This is a subclass of OpenCL::Buffer and thus OpenCL::Memory. It exists |
|
|
948 | because one cna create sub buffers of OpenLC::BufferObj objects, but not |
|
|
949 | sub buffers from these sub buffers. |
|
|
950 | |
|
|
951 | =over 4 |
|
|
952 | |
|
|
953 | =item $subbuf = $buf_obj->sub_buffer_region ($flags, $origin, $size) |
|
|
954 | |
|
|
955 | Creates an OpenCL::Buffer objects from this buffer and returns it. The |
|
|
956 | C<buffer_create_type> is assumed to be C<CL_BUFFER_CREATE_TYPE_REGION>. |
|
|
957 | |
|
|
958 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateSubBuffer.html> |
|
|
959 | |
|
|
960 | =back |
|
|
961 | |
927 | =head2 THE OpenCL::Image CLASS |
962 | =head2 THE OpenCL::Image CLASS |
928 | |
963 | |
929 | This is the superclass of all image objects - OpenCL::Image2D and OpenCL::Image3D. |
964 | This is the superclass of all image objects - OpenCL::Image2D and OpenCL::Image3D. |
930 | |
965 | |
931 | =over 4 |
966 | =over 4 |
… | |
… | |
1267 | package OpenCL; |
1302 | package OpenCL; |
1268 | |
1303 | |
1269 | use common::sense; |
1304 | use common::sense; |
1270 | |
1305 | |
1271 | BEGIN { |
1306 | BEGIN { |
1272 | our $VERSION = '0.55'; |
1307 | our $VERSION = '0.92'; |
1273 | |
1308 | |
1274 | require XSLoader; |
1309 | require XSLoader; |
1275 | XSLoader::load (__PACKAGE__, $VERSION); |
1310 | XSLoader::load (__PACKAGE__, $VERSION); |
1276 | |
1311 | |
1277 | @OpenCL::Buffer::ISA = |
1312 | @OpenCL::Buffer::ISA = |
1278 | @OpenCL::Image::ISA = OpenCL::Memory::; |
1313 | @OpenCL::Image::ISA = OpenCL::Memory::; |
1279 | |
1314 | |
|
|
1315 | @OpenCL::BufferObj::ISA = OpenCL::Buffer::; |
|
|
1316 | |
1280 | @OpenCL::Image2D::ISA = |
1317 | @OpenCL::Image2D::ISA = |
1281 | @OpenCL::Image3D::ISA = OpenCL::Image::; |
1318 | @OpenCL::Image3D::ISA = OpenCL::Image::; |
1282 | |
1319 | |
1283 | @OpenCL::UserEvent::ISA = OpenCL::Event::; |
1320 | @OpenCL::UserEvent::ISA = OpenCL::Event::; |
1284 | } |
1321 | } |
1285 | |
1322 | |
1286 | 1; |
1323 | 1; |
1287 | |
1324 | |
1288 | =head1 AUTHOR |
1325 | =head1 AUTHOR |