… | |
… | |
138 | |
138 | |
139 | my $src = ' |
139 | my $src = ' |
140 | __kernel void |
140 | __kernel void |
141 | squareit (__global float *input, __global float *output) |
141 | squareit (__global float *input, __global float *output) |
142 | { |
142 | { |
143 | size_t id = get_global_id (0); |
143 | $id = get_global_id (0); |
144 | output [id] = input [id] * input [id]; |
144 | output [id] = input [id] * input [id]; |
145 | } |
145 | } |
146 | '; |
146 | '; |
147 | |
147 | |
148 | my $prog = $ctx->program_with_source ($src); |
148 | my $prog = $ctx->program_with_source ($src); |
… | |
… | |
201 | |
201 | |
202 | =head1 DOCUMENTATION |
202 | =head1 DOCUMENTATION |
203 | |
203 | |
204 | =head2 BASIC CONVENTIONS |
204 | =head2 BASIC CONVENTIONS |
205 | |
205 | |
206 | This is not a 1:1 C-style translation of OpenCL to Perl - instead I |
206 | This is not a one-to-one C-style translation of OpenCL to Perl - instead |
207 | attempted to make the interface as type-safe as possible and introducing |
207 | I attempted to make the interface as type-safe as possible by introducing |
208 | object syntax where it makes sense. There are a number of important |
208 | object syntax where it makes sense. There are a number of important |
209 | differences between the OpenCL C API and this module: |
209 | differences between the OpenCL C API and this module: |
210 | |
210 | |
211 | =over 4 |
211 | =over 4 |
212 | |
212 | |
… | |
… | |
217 | =item * OpenCL uses CamelCase for function names (C<clGetPlatformInfo>), |
217 | =item * OpenCL uses CamelCase for function names (C<clGetPlatformInfo>), |
218 | while this module uses underscores as word separator and often leaves out |
218 | while this module uses underscores as word separator and often leaves out |
219 | prefixes (C<< $platform->info >>). |
219 | prefixes (C<< $platform->info >>). |
220 | |
220 | |
221 | =item * OpenCL often specifies fixed vector function arguments as short |
221 | =item * OpenCL often specifies fixed vector function arguments as short |
222 | arrays (C<size_t origin[3]>), while this module explicitly expects the |
222 | arrays (C<$origin[3]>), while this module explicitly expects the |
223 | components as separate arguments- |
223 | components as separate arguments- |
|
|
224 | |
|
|
225 | =item * Structures are often specified with their components, and returned |
|
|
226 | as arrayrefs. |
224 | |
227 | |
225 | =item * Where possible, one of the pitch values is calculated from the |
228 | =item * Where possible, one of the pitch values is calculated from the |
226 | perl scalar length and need not be specified. |
229 | perl scalar length and need not be specified. |
227 | |
230 | |
228 | =item * When enqueuing commands, the wait list is specified by adding |
231 | =item * When enqueuing commands, the wait list is specified by adding |
… | |
… | |
454 | |
457 | |
455 | =item $ev = $queue->enqueue_write_image ($src, $blocking, $x, $y, $z, $width, $height, $depth, $row_pitch, $data, $wait_events...) |
458 | =item $ev = $queue->enqueue_write_image ($src, $blocking, $x, $y, $z, $width, $height, $depth, $row_pitch, $data, $wait_events...) |
456 | |
459 | |
457 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWriteImage.html> |
460 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWriteImage.html> |
458 | |
461 | |
459 | =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, $ait_event...) |
462 | =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...) |
460 | |
463 | |
461 | Yeah. |
464 | Yeah. |
462 | |
465 | |
463 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyBufferRect.html> |
466 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyBufferRect.html> |
464 | |
467 | |
465 | =item $ev = $queue->enqueue_copy_buffer_to_image (OpenCL::Buffer src, OpenCL::Image dst, size_t src_offset, size_t dst_x, size_t dst_y, size_t dst_z, size_t width, size_t height, size_t depth, ...) |
468 | =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...) |
466 | |
469 | |
467 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyBufferToImage.html>. |
470 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyBufferToImage.html>. |
468 | |
471 | |
469 | =item $ev = $queue->enqueue_copy_image (OpenCL::Image src, OpenCL::Buffer dst, size_t src_x, size_t src_y, size_t src_z, size_t dst_x, size_t dst_y, size_t dst_z, size_t width, size_t height, size_t depth, ...) |
472 | =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...) |
470 | |
473 | |
471 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyImage.html> |
474 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyImage.html> |
472 | |
475 | |
473 | =item $ev = $queue->enqueue_copy_image_to_buffer (OpenCL::Image src, OpenCL::Buffer dst, size_t src_x, size_t src_y, size_t src_z, size_t width, size_t height, size_t depth, size_t dst_offset, ...) |
476 | =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...) |
474 | |
477 | |
475 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyImageToBuffer.html> |
478 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyImageToBuffer.html> |
476 | |
479 | |
477 | =item $ev = $queue->enqueue_task ($kernel, $wait_events...) |
480 | =item $ev = $queue->enqueue_task ($kernel, $wait_events...) |
478 | |
481 | |