--- OpenCL/OpenCL.pm 2012/05/05 13:07:19 1.78 +++ OpenCL/OpenCL.pm 2012/05/05 16:44:02 1.84 @@ -30,8 +30,8 @@ which represents basically a function call with argument values. OpenCL::Memory objects of various flavours: OpenCL::Buffer objects (flat -memory areas, think arrays or structs) and OpenCL::Image objects (think 2d -or 3d array) for bulk data and input and output for kernels. +memory areas, think arrays or structs) and OpenCL::Image objects (think 2D +or 3D array) for bulk data and input and output for kernels. OpenCL::Sampler objects, which are kind of like texture filter modes in OpenGL. @@ -99,37 +99,6 @@ Enqueue buffer reads for your output buffer to read results. -=head1 OPENCL 1.1 VS. OPENCL 1.2 - -This module supports both OpenCL version 1.1 and 1.2, although the OpenCL -1.2 interface hasn't been tested much for lack of availability of an -actual implementation. - -Every function or method in this manual page that interfaces to a -particular OpenCL function has a link to the its C manual page. - -If the link contains a F<1.1>, then this function is an OpenCL 1.1 -function. Most but not all also exist in OpenCL 1.2, and this module -tries to emulate the missing ones for you, when told to do so at -compiletime. You cna check whether a function was removed in OpenCL 1.2 by -replacing the F<1.1> component in the URL by F<1.2>. - -If the link contains a F<1.2>, then this is a OpenCL 1.2-only -function. Even if the module was compiled with OpenCL 1.2 header files -and has an 1.2 OpenCL library, calling such a function on a platform that -doesn't implement 1.2 causes undefined behaviour, usually a crash (But -this is not guaranteed). - -You can find out whether this module was compiled to prefer 1.1 -functionality by ooking at C - if it is true, then -1.1 functions generally are implemented using 1.1 OpenCL functions. If it -is false, then 1.1 functions missing from 1.2 are emulated by calling 1.2 -fucntions. - -This is a somewhat sorry state of affairs, but the Khronos group choose to -make every release of OpenCL source and binary incompatible with previous -releases. - =head1 EXAMPLES =head2 Enumerate all devices and get contexts for them. @@ -246,8 +215,8 @@ =head2 Use the OpenGL module to share a texture between OpenCL and OpenGL and draw some julia set flight effect. -This is quite a long example to get you going - you can download it from -L. +This is quite a long example to get you going - you can also download it +from L. use OpenGL ":all"; use OpenCL; @@ -421,12 +390,53 @@ context, no event is created. In all other contexts an event is returned by the method. -=item * This module expects all functions to return C. If any +=item * This module expects all functions to return C. If any other status is returned the function will throw an exception, so you don't normally have to to any error checking. =back +=head2 CONSTANTS + +All C constants that this module supports are always available +in the C namespace as C (i.e. without the C +prefix). Constants which are not defined in the header files used during +compilation, or otherwise are not available, will have the value C<-1>. + +The latest version of this module knows and exports the constants +listed in L. + +=head2 OPENCL 1.1 VS. OPENCL 1.2 + +This module supports both OpenCL version 1.1 and 1.2, although the OpenCL +1.2 interface hasn't been tested much for lack of availability of an +actual implementation. + +Every function or method in this manual page that interfaces to a +particular OpenCL function has a link to the its C manual page. + +If the link contains a F<1.1>, then this function is an OpenCL 1.1 +function. Most but not all also exist in OpenCL 1.2, and this module +tries to emulate the missing ones for you, when told to do so at +compiletime. You can check whether a function was removed in OpenCL 1.2 by +replacing the F<1.1> component in the URL by F<1.2>. + +If the link contains a F<1.2>, then this is a OpenCL 1.2-only +function. Even if the module was compiled with OpenCL 1.2 header files +and has an 1.2 OpenCL library, calling such a function on a platform that +doesn't implement 1.2 causes undefined behaviour, usually a crash (But +this is not guaranteed). + +You can find out whether this module was compiled to prefer 1.1 +functionality by ooking at C - if it is true, then +1.1 functions generally are implemented using 1.1 OpenCL functions. If it +is false, then 1.1 functions missing from 1.2 are emulated by calling 1.2 +fucntions. + +This is a somewhat sorry state of affairs, but the Khronos group choose to +make every release of OpenCL source and binary incompatible with previous +releases. + =head2 PERL AND OPENCL TYPES This handy(?) table lists OpenCL types and their perl, PDL and pack/unpack @@ -633,9 +643,12 @@ =item $str = OpenCL::err2str [$errval] -Converts an error value into a human readable string. IF no error value is +Converts an error value into a human readable string. If no error value is given, then the last error will be used (as returned by OpenCL::errno). +The latest version of this module knows the error constants +listed in L. + =item $str = OpenCL::enum2str $enum Converts most enum values (of parameter names, image format constants, @@ -644,6 +657,9 @@ very helpful to pass it through this function to maybe get some readable string out of it. +The latest version of this module knows the enumaration constants +listed in L. + =item @platforms = OpenCL::platforms Returns all available OpenCL::Platform objects. @@ -754,7 +770,7 @@ =item $ctx = $platform->context ($properties, \@devices, $callback->($err, $pvt) = $print_stderr) Create a new OpenCL::Context object using the given device object(s)- a -CL_CONTEXT_PLATFORM property is supplied automatically. +OpenCL::CONTEXT_PLATFORM property is supplied automatically. L @@ -1408,11 +1424,11 @@ L -=item $ev = $queue->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...) +$eue->read_buffer_rect ($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...) http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueReadBufferRect.html -=item $ev = $queue->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...) +=item $ev = $queue->write_buffer_rect ($buf, $blocking, $buf_y, $host_x, $host_z, $height, $buf_row_pitch, $host_row_pitch, $data, $wait_events...) http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWriteBufferRect.html @@ -1606,8 +1622,8 @@ my $mapped = $queue->map_image ($image, 1, OpenCL::MAP_WRITE); - $mapped->set ($_ * $mapped->row_pitch, pack "C", 5) - for 0..$image->height; + $mapped->write ($_ * $mapped->row_pitch, pack "C", 5) + for 0 .. $mapped->height - 1; $mapped->unmap;. $mapped->wait; # only needed for out of order queues normally @@ -1637,6 +1653,12 @@ L +=item $memory->destructor_callback ($cb->()) + +Sets a callback that will be invoked after the memory object is destructed. + +L + =for gengetinfo begin mem =item $mem_object_type = $mem->type @@ -1703,7 +1725,7 @@ =item $subbuf = $buf_obj->sub_buffer_region ($flags, $origin, $size) Creates an OpenCL::Buffer objects from this buffer and returns it. The -C is assumed to be C. +C is assumed to be C. L @@ -1729,7 +1751,7 @@ =item ($channel_order, $channel_data_type) = $image->format Returns the channel order and type used to create the image by calling -C with C. +C with C. =for gengetinfo begin image @@ -1896,6 +1918,10 @@ Calls C with C and returns the result. +=item $binary_type = $program->binary_type ($device) + +Calls C with C and returns the result. + =for gengetinfo end program_build =item $packed_value = $program->info ($name) @@ -2319,14 +2345,38 @@ =over 4 +=item $pixels = $mapped->width + +=item $pixels = $mapped->height + +=item $pixels = $mapped->depth + +Return the width/height/depth of the mapped image region, in pixels. + =item $bytes = $mapped->row_pitch =item $bytes = $mapped->slice_pitch Return the row or slice pitch of the image that has been mapped. -=back +=item $bytes = $mapped->element_size + +Return the size of a single pixel. + +=item $data = $mapped->get_row ($count, $x=0, $y=0, $z=0) +Return C<$count> pixels from the given coordinates. The pixel data must +be completely contained within a single row. + +If C<$count> is C, then all the remaining pixels in that row are +returned. + +=item $mapped->set_row ($data, $x=0, $y=0, $z=0) + +Write the given pixel data at the given coordinate. The pixel data must +be completely contained within a single row. + +=back =cut