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

Comparing OpenCL/OpenCL.pm (file contents):
Revision 1.25 by root, Tue Nov 22 10:39:47 2011 UTC vs.
Revision 1.34 by root, Thu Apr 19 13:06:55 2012 UTC

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
151functions. 151functions.
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
287Comverts an error value into a human readable string. 287Comverts an error value into a human readable string.
288 288
289=item $str = OpenCL::enum2str $enum 289=item $str = OpenCL::enum2str $enum
290 290
291Converts most enum values (inof parameter names, image format constants, 291Converts most enum values (of parameter names, image format constants,
292object types, addressing and filter modes, command types etc.) into a 292object types, addressing and filter modes, command types etc.) into a
293human readbale string. When confronted with some random integer it can be 293human readable string. When confronted with some random integer it can be
294very helpful to pass it through this function to maybe get some readable 294very helpful to pass it through this function to maybe get some readable
295string out of it. 295string out of it.
296 296
297=item @platforms = OpenCL::platforms 297=item @platforms = OpenCL::platforms
298 298
326 326
327Tries to create a context. Never worked for me, and you need devices explicitly anyway. 327Tries to create a context. Never worked for me, and you need devices explicitly anyway.
328 328
329L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContextFromType.html> 329L<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
333Create a new OpenCL::Context object using the given device object(s)- a 333Create a new OpenCL::Context object using the given device object(s)- a
334CL_CONTEXT_PLATFORM property is supplied automatically. 334CL_CONTEXT_PLATFORM property is supplied automatically.
335 335
336L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContext.html> 336L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContext.html>
668 668
669L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateUserEvent.html> 669L<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
673Creates a new OpenCL::Buffer object with the given flags and octet-size. 673Creates a new OpenCL::Buffer (actually OpenCL::BufferObj) object with the
674given flags and octet-size.
674 675
675L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateBuffer.html> 676L<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
679Creates a new OpenCL::Buffer object and initialise it with the given data values. 680Creates a new OpenCL::Buffer (actually OpenCL::BufferObj) object and
681initialise 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
683Creates a new OpenCL::Image2D object and optionally initialises it with the given data values. 685Creates a new OpenCL::Image2D object and optionally initialises it with
686the given data values.
684 687
685L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateImage2D.html> 688L<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
689Creates a new OpenCL::Image3D object and optionally initialises it with the given data values. 692Creates a new OpenCL::Image3D object and optionally initialises it with
693the given data values.
690 694
691L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateImage3D.html> 695L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateImage3D.html>
696
697=item $buffer = $ctx->gl_buffer ($flags, $bufobj)
698
699Creates a new OpenCL::Buffer (actually OpenCL::BufferObj) object that refers to the given
700OpenGL buffer object.
701
702http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateFromGLBuffer.html
703
704=item $ctx->gl_texture2d ($flags, $target, $miplevel, $texture)
705
706Creates a new OpenCL::Image2D object that refers to the given OpenGL
7072D texture object.
708
709http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateFromGLTexture2D.html
710
711=item $ctx->gl_texture3d ($flags, $target, $miplevel, $texture)
712
713Creates a new OpenCL::Image3D object that refers to the given OpenGL
7143D texture object.
715
716http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateFromGLTexture3D.html
717
718=item $ctx->gl_renderbuffer ($flags, $renderbuffer)
719
720Creates a new OpenCL::Image2D object that refers to the given OpenGL
721render buffer.
722
723http://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
695Returns a list of matching image formats - each format is an arrayref with 727Returns a list of matching image formats - each format is an arrayref with
696two values, $channel_order and $channel_type, in it. 728two values, $channel_order and $channel_type, in it.
781 813
782http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWriteBufferRect.html 814http://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
818L<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
786L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueReadImage.html> 822L<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
790L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWriteImage.html> 826L<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
830L<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
834L<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
794Yeah. 838Yeah.
795 839
796L<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
800L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyBufferToImage.html>. 840L<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
804L<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
808L<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
812L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueTask.html> 844L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueTask.html>
813 845
928 960
929Calls C<clGetMemObjectInfo> with C<CL_MEM_OFFSET> and returns the result. 961Calls C<clGetMemObjectInfo> with C<CL_MEM_OFFSET> and returns the result.
930 962
931=for gengetinfo end mem 963=for gengetinfo end mem
932 964
965=item ($type, $name) = $mem->gl_object_info
966
967Returns the OpenGL object type (e.g. OpenCL::GL_OBJECT_TEXTURE2D) and the
968object "name" (e.g. the texture name) used to create this memory object.
969
970L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetGLObjectInfo.html>
971
972=back
973
974=head2 THE OpenCL::Buffer CLASS
975
976This is a subclass of OpenCL::Memory, and the superclass of
977OpenCL::BufferObj. Its purpose is simply to distinguish between buffers
978and sub-buffers.
979
980=head2 THE OpenCL::BufferObj CLASS
981
982This is a subclass of OpenCL::Buffer and thus OpenCL::Memory. It exists
983because one cna create sub buffers of OpenLC::BufferObj objects, but not
984sub buffers from these sub buffers.
985
986=over 4
987
988=item $subbuf = $buf_obj->sub_buffer_region ($flags, $origin, $size)
989
990Creates an OpenCL::Buffer objects from this buffer and returns it. The
991C<buffer_create_type> is assumed to be C<CL_BUFFER_CREATE_TYPE_REGION>.
992
993L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateSubBuffer.html>
994
933=back 995=back
934 996
935=head2 THE OpenCL::Image CLASS 997=head2 THE OpenCL::Image CLASS
936 998
937This is the superclass of all image objects - OpenCL::Image2D and OpenCL::Image3D. 999This is the superclass of all image objects - OpenCL::Image2D and OpenCL::Image3D.
972=item $int = $image->depth 1034=item $int = $image->depth
973 1035
974Calls C<clGetImageInfo> with C<CL_IMAGE_DEPTH> and returns the result. 1036Calls C<clGetImageInfo> with C<CL_IMAGE_DEPTH> and returns the result.
975 1037
976=for gengetinfo end image 1038=for gengetinfo end image
1039
1040=for gengetinfo begin gl_texture
1041
1042=item $GLenum = $gl_texture->target
1043
1044Calls C<clGetGlTextureInfo> with C<CL_GL_TEXTURE_TARGET> and returns the result.
1045
1046=item $GLint = $gl_texture->gl_mipmap_level
1047
1048Calls C<clGetGlTextureInfo> with C<CL_GL_MIPMAP_LEVEL> and returns the result.
1049
1050=for gengetinfo end gl_texture
977 1051
978=back 1052=back
979 1053
980=head2 THE OpenCL::Sampler CLASS 1054=head2 THE OpenCL::Sampler CLASS
981 1055
1275package OpenCL; 1349package OpenCL;
1276 1350
1277use common::sense; 1351use common::sense;
1278 1352
1279BEGIN { 1353BEGIN {
1280 our $VERSION = '0.55'; 1354 our $VERSION = '0.92';
1281 1355
1282 require XSLoader; 1356 require XSLoader;
1283 XSLoader::load (__PACKAGE__, $VERSION); 1357 XSLoader::load (__PACKAGE__, $VERSION);
1284 1358
1285 @OpenCL::Buffer::ISA = 1359 @OpenCL::Buffer::ISA =
1286 @OpenCL::Image::ISA = OpenCL::Memory::; 1360 @OpenCL::Image::ISA = OpenCL::Memory::;
1287 1361
1362 @OpenCL::BufferObj::ISA = OpenCL::Buffer::;
1363
1288 @OpenCL::Image2D::ISA = 1364 @OpenCL::Image2D::ISA =
1289 @OpenCL::Image3D::ISA = OpenCL::Image::; 1365 @OpenCL::Image3D::ISA = OpenCL::Image::;
1290 1366
1291 @OpenCL::UserEvent::ISA = OpenCL::Event::; 1367 @OpenCL::UserEvent::ISA = OpenCL::Event::;
1292} 1368}
1293 1369
12941; 13701;
1295 1371
1296=head1 AUTHOR 1372=head1 AUTHOR

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines