… | |
… | |
52 | |
52 | |
53 | OpenCL manpages: |
53 | OpenCL manpages: |
54 | |
54 | |
55 | http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/ |
55 | http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/ |
56 | |
56 | |
|
|
57 | If you are into UML class diagrams, the following diagram might help - if |
|
|
58 | not, it will be mildly cobfusing: |
|
|
59 | |
|
|
60 | http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/classDiagram.html |
|
|
61 | |
57 | Here's a tutorial from AMD (very AMD-centric, too), not sure how useful it |
62 | Here's a tutorial from AMD (very AMD-centric, too), not sure how useful it |
58 | is, but at least it's free of charge: |
63 | is, but at least it's free of charge: |
59 | |
64 | |
60 | http://developer.amd.com/zones/OpenCLZone/courses/Documents/Introduction_to_OpenCL_Programming%20Training_Guide%20%28201005%29.pdf |
65 | http://developer.amd.com/zones/OpenCLZone/courses/Documents/Introduction_to_OpenCL_Programming%20Training_Guide%20%28201005%29.pdf |
61 | |
66 | |
62 | If you are into UML class diagrams, the following diagram might help - if |
67 | And here's NVIDIA's OpenCL Best Practises Guide: |
63 | not, it will be mildly cofusing: |
|
|
64 | |
68 | |
65 | http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/classDiagram.html |
69 | http://developer.download.nvidia.com/compute/cuda/3_2/toolkit/docs/OpenCL_Best_Practices_Guide.pdf |
66 | |
70 | |
67 | =head1 BASIC WORKFLOW |
71 | =head1 BASIC WORKFLOW |
68 | |
72 | |
69 | To get something done, you basically have to do this once (refer to the |
73 | To get something done, you basically have to do this once (refer to the |
70 | examples below for actual code, this is just a high-level description): |
74 | examples below for actual code, this is just a high-level description): |
… | |
… | |
222 | |
226 | |
223 | =item * Object lifetime managament is automatic - there is no need |
227 | =item * Object lifetime managament is automatic - there is no need |
224 | to free objects explicitly (C<clReleaseXXX>), the release function |
228 | to free objects explicitly (C<clReleaseXXX>), the release function |
225 | is called automatically once all Perl references to it go away. |
229 | is called automatically once all Perl references to it go away. |
226 | |
230 | |
227 | =item * OpenCL uses CamelCase for function names (C<clGetPlatformInfo>), |
231 | =item * OpenCL uses CamelCase for function names (e.g. C<clGetPlatformIDs>, C<clGetPlatformInfo>), |
228 | while this module uses underscores as word separator and often leaves out |
232 | while this module uses underscores as word separator and often leaves out |
229 | prefixes (C<< $platform->info >>). |
233 | prefixes (C<OpenCL::platforms>, C<< $platform->info >>). |
230 | |
234 | |
231 | =item * OpenCL often specifies fixed vector function arguments as short |
235 | =item * OpenCL often specifies fixed vector function arguments as short |
232 | arrays (C<$origin[3]>), while this module explicitly expects the |
236 | arrays (C<size_t origin[3]>), while this module explicitly expects the |
233 | components as separate arguments- |
237 | components as separate arguments (C<$orig_x, $orig_y, $orig_z>) in |
|
|
238 | function calls. |
234 | |
239 | |
235 | =item * Structures are often specified with their components, and returned |
240 | =item * Structures are often specified by flattening out their components |
236 | as arrayrefs. |
241 | as with short vectors, and returned as arrayrefs. |
237 | |
|
|
238 | =item * Where possible, one of the pitch values is calculated from the |
|
|
239 | perl scalar length and need not be specified. |
|
|
240 | |
242 | |
241 | =item * When enqueuing commands, the wait list is specified by adding |
243 | =item * When enqueuing commands, the wait list is specified by adding |
242 | extra arguments to the function - anywhere a C<$wait_events...> argument |
244 | extra arguments to the function - anywhere a C<$wait_events...> argument |
243 | is documented this can be any number of event objects. |
245 | is documented this can be any number of event objects. |
244 | |
246 | |
… | |
… | |
384 | |
386 | |
385 | =item $buf = $ctx->buffer_sv ($flags, $data) |
387 | =item $buf = $ctx->buffer_sv ($flags, $data) |
386 | |
388 | |
387 | Creates a new OpenCL::Buffer object and initialise it with the given data values. |
389 | Creates a new OpenCL::Buffer object and initialise it with the given data values. |
388 | |
390 | |
389 | =item $img = $ctx->image2d ($flags, $channel_order, $channel_type, $width, $height, $data) |
391 | =item $img = $ctx->image2d ($flags, $channel_order, $channel_type, $width, $height, $row_pitch = 0, $data = undef) |
390 | |
392 | |
391 | Creates a new OpenCL::Image2D object and optionally initialises it with the given data values. |
393 | Creates a new OpenCL::Image2D object and optionally initialises it with the given data values. |
392 | |
394 | |
393 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateImage2D.html> |
395 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateImage2D.html> |
394 | |
396 | |
395 | =item $img = $ctx->image3d ($flags, $channel_order, $channel_type, $width, $height, $depth, $slice_pitch, $data) |
397 | =item $img = $ctx->image3d ($flags, $channel_order, $channel_type, $width, $height, $depth, $row_pitch = 0, $slice_pitch = 0, $data = undef) |
396 | |
398 | |
397 | Creates a new OpenCL::Image3D object and optionally initialises it with the given data values. |
399 | Creates a new OpenCL::Image3D object and optionally initialises it with the given data values. |
398 | |
400 | |
399 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateImage3D.html> |
401 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateImage3D.html> |
400 | |
402 | |
… | |
… | |
463 | |
465 | |
464 | =item $ev = $queue->enqueue_read_image ($src, $blocking, $x, $y, $z, $width, $height, $depth, $row_pitch, $slice_pitch, $data, $wait_events...) |
466 | =item $ev = $queue->enqueue_read_image ($src, $blocking, $x, $y, $z, $width, $height, $depth, $row_pitch, $slice_pitch, $data, $wait_events...) |
465 | |
467 | |
466 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueReadImage.html> |
468 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueReadImage.html> |
467 | |
469 | |
468 | =item $ev = $queue->enqueue_write_image ($src, $blocking, $x, $y, $z, $width, $height, $depth, $row_pitch, $data, $wait_events...) |
470 | =item $ev = $queue->enqueue_write_image ($src, $blocking, $x, $y, $z, $width, $height, $depth, $row_pitch, $slice_pitch, $data, $wait_events...) |
469 | |
471 | |
470 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWriteImage.html> |
472 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWriteImage.html> |
471 | |
473 | |
472 | =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, 4dst_row_pitch, $dst_slice_pitch, $wait_event...) |
474 | =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...) |
473 | |
475 | |
474 | Yeah. |
476 | Yeah. |
475 | |
477 | |
476 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyBufferRect.html> |
478 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyBufferRect.html> |
477 | |
479 | |
… | |
… | |
656 | package OpenCL; |
658 | package OpenCL; |
657 | |
659 | |
658 | use common::sense; |
660 | use common::sense; |
659 | |
661 | |
660 | BEGIN { |
662 | BEGIN { |
661 | our $VERSION = '0.14'; |
663 | our $VERSION = '0.15'; |
662 | |
664 | |
663 | require XSLoader; |
665 | require XSLoader; |
664 | XSLoader::load (__PACKAGE__, $VERSION); |
666 | XSLoader::load (__PACKAGE__, $VERSION); |
665 | |
667 | |
666 | @OpenCL::Buffer::ISA = |
668 | @OpenCL::Buffer::ISA = |