… | |
… | |
28 | specific device ("compiling and linking"), also binary programs. For each |
28 | specific device ("compiling and linking"), also binary programs. For each |
29 | kernel function in a program you can then create an OpenCL::Kernel object |
29 | kernel function in a program you can then create an OpenCL::Kernel object |
30 | which represents basically a function call with argument values. |
30 | which represents basically a function call with argument values. |
31 | |
31 | |
32 | OpenCL::Memory objects of various flavours: OpenCL::Buffer objects (flat |
32 | OpenCL::Memory objects of various flavours: OpenCL::Buffer objects (flat |
33 | memory areas, think arrays or structs) and OpenCL::Image objects (think 2d |
33 | memory areas, think arrays or structs) and OpenCL::Image objects (think 2D |
34 | or 3d array) for bulk data and input and output for kernels. |
34 | or 3D array) for bulk data and input and output for kernels. |
35 | |
35 | |
36 | OpenCL::Sampler objects, which are kind of like texture filter modes in |
36 | OpenCL::Sampler objects, which are kind of like texture filter modes in |
37 | OpenGL. |
37 | OpenGL. |
38 | |
38 | |
39 | OpenCL::Queue objects - command queues, which allow you to submit memory |
39 | OpenCL::Queue objects - command queues, which allow you to submit memory |
… | |
… | |
213 | $ev->wait; |
213 | $ev->wait; |
214 | |
214 | |
215 | =head2 Use the OpenGL module to share a texture between OpenCL and OpenGL and draw some julia |
215 | =head2 Use the OpenGL module to share a texture between OpenCL and OpenGL and draw some julia |
216 | set flight effect. |
216 | set flight effect. |
217 | |
217 | |
218 | This is quite a long example to get you going - you can download it from |
218 | This is quite a long example to get you going - you can also download it |
219 | L<http://cvs.schmorp.de/OpenCL/examples/juliaflight>. |
219 | from L<http://cvs.schmorp.de/OpenCL/examples/juliaflight>. |
220 | |
220 | |
221 | use OpenGL ":all"; |
221 | use OpenGL ":all"; |
222 | use OpenCL; |
222 | use OpenCL; |
223 | |
223 | |
224 | my $S = $ARGV[0] || 256; # window/texture size, smaller is faster |
224 | my $S = $ARGV[0] || 256; # window/texture size, smaller is faster |
… | |
… | |
388 | |
388 | |
389 | =item * When enqueuing commands, if the enqueue method is called in void |
389 | =item * When enqueuing commands, if the enqueue method is called in void |
390 | context, no event is created. In all other contexts an event is returned |
390 | context, no event is created. In all other contexts an event is returned |
391 | by the method. |
391 | by the method. |
392 | |
392 | |
393 | =item * This module expects all functions to return C<CL_SUCCESS>. If any |
393 | =item * This module expects all functions to return C<OpenCL::SUCCESS>. If any |
394 | other status is returned the function will throw an exception, so you |
394 | other status is returned the function will throw an exception, so you |
395 | don't normally have to to any error checking. |
395 | don't normally have to to any error checking. |
396 | |
396 | |
397 | =back |
397 | =back |
|
|
398 | |
|
|
399 | =head2 CONSTANTS |
|
|
400 | |
|
|
401 | All C<CL_xxx> constants that this module supports are always available |
|
|
402 | in the C<OpenCL> namespace as C<OpenCL::xxx> (i.e. without the C<CL_> |
|
|
403 | prefix). Constants which are not defined in the header files used during |
|
|
404 | compilation, or otherwise are not available, will have the value C<0> (in |
|
|
405 | some cases, this will make them indistinguishable from real constants, |
|
|
406 | sorry). |
|
|
407 | |
|
|
408 | The latest version of this module knows and exports the constants |
|
|
409 | listed in L<http://cvs.schmorp.de/OpenCL/constiv.h>. |
|
|
410 | |
|
|
411 | =head2 OPENCL 1.1 VS. OPENCL 1.2 |
|
|
412 | |
|
|
413 | This module supports both OpenCL version 1.1 and 1.2, although the OpenCL |
|
|
414 | 1.2 interface hasn't been tested much for lack of availability of an |
|
|
415 | actual implementation. |
|
|
416 | |
|
|
417 | Every function or method in this manual page that interfaces to a |
|
|
418 | particular OpenCL function has a link to the its C manual page. |
|
|
419 | |
|
|
420 | If the link contains a F<1.1>, then this function is an OpenCL 1.1 |
|
|
421 | function. Most but not all also exist in OpenCL 1.2, and this module |
|
|
422 | tries to emulate the missing ones for you, when told to do so at |
|
|
423 | compiletime. You can check whether a function was removed in OpenCL 1.2 by |
|
|
424 | replacing the F<1.1> component in the URL by F<1.2>. |
|
|
425 | |
|
|
426 | If the link contains a F<1.2>, then this is a OpenCL 1.2-only |
|
|
427 | function. Even if the module was compiled with OpenCL 1.2 header files |
|
|
428 | and has an 1.2 OpenCL library, calling such a function on a platform that |
|
|
429 | doesn't implement 1.2 causes undefined behaviour, usually a crash (But |
|
|
430 | this is not guaranteed). |
|
|
431 | |
|
|
432 | You can find out whether this module was compiled to prefer 1.1 |
|
|
433 | functionality by ooking at C<OpenCL::PREFER_1_1> - if it is true, then |
|
|
434 | 1.1 functions generally are implemented using 1.1 OpenCL functions. If it |
|
|
435 | is false, then 1.1 functions missing from 1.2 are emulated by calling 1.2 |
|
|
436 | fucntions. |
|
|
437 | |
|
|
438 | This is a somewhat sorry state of affairs, but the Khronos group choose to |
|
|
439 | make every release of OpenCL source and binary incompatible with previous |
|
|
440 | releases. |
398 | |
441 | |
399 | =head2 PERL AND OPENCL TYPES |
442 | =head2 PERL AND OPENCL TYPES |
400 | |
443 | |
401 | This handy(?) table lists OpenCL types and their perl, PDL and pack/unpack |
444 | This handy(?) table lists OpenCL types and their perl, PDL and pack/unpack |
402 | format equivalents: |
445 | format equivalents: |
… | |
… | |
434 | OpenCL can generate a number of (potentially) asynchronous events, for |
477 | OpenCL can generate a number of (potentially) asynchronous events, for |
435 | example, after compiling a program, to signal a context-related error or, |
478 | example, after compiling a program, to signal a context-related error or, |
436 | perhaps most important, to signal completion of queued jobs (by setting |
479 | perhaps most important, to signal completion of queued jobs (by setting |
437 | callbacks on OpenCL::Event objects). |
480 | callbacks on OpenCL::Event objects). |
438 | |
481 | |
|
|
482 | The OpenCL module converts all these callbacks into events - you can |
|
|
483 | still register callbacks, but they are not executed when your OpenCL |
|
|
484 | implementation calls the actual callback, but only later. Therefore, none |
|
|
485 | of the limitations of OpenCL callbacks apply to the perl implementation: |
|
|
486 | it is perfectly safe to make blocking operations from event callbacks, and |
|
|
487 | enqueued operations don't need to be flushed. |
|
|
488 | |
439 | To facilitate this, this module maintains an event queue - each |
489 | To facilitate this, this module maintains an event queue - each |
440 | time an asynchronous event happens, it is queued, and perl will be |
490 | time an asynchronous event happens, it is queued, and perl will be |
441 | interrupted. This is implemented via the L<Async::Interrupt> module. In |
491 | interrupted. This is implemented via the L<Async::Interrupt> module. In |
442 | addition, this module has L<AnyEvent> support, so it can seamlessly |
492 | addition, this module has L<AnyEvent> support, so it can seamlessly |
443 | integrate itself into many event loops. |
493 | integrate itself into many event loops. |
444 | |
494 | |
445 | Since this module is a bit hard to understand, here are some case examples: |
495 | Since L<Async::Interrupt> is a bit hard to understand, here are some case examples: |
446 | |
496 | |
447 | =head3 Don't use callbacks. |
497 | =head3 Don't use callbacks. |
448 | |
498 | |
449 | When your program never uses any callbacks, then there will never be any |
499 | When your program never uses any callbacks, then there will never be any |
450 | notifications you need to take care of, and therefore no need to worry |
500 | notifications you need to take care of, and therefore no need to worry |
… | |
… | |
547 | use Async::Interrupt (); |
597 | use Async::Interrupt (); |
548 | |
598 | |
549 | our $POLL_FUNC; # set by XS |
599 | our $POLL_FUNC; # set by XS |
550 | |
600 | |
551 | BEGIN { |
601 | BEGIN { |
552 | our $VERSION = '0.99'; |
602 | our $VERSION = '1.0'; |
553 | |
603 | |
554 | require XSLoader; |
604 | require XSLoader; |
555 | XSLoader::load (__PACKAGE__, $VERSION); |
605 | XSLoader::load (__PACKAGE__, $VERSION); |
556 | |
606 | |
557 | @OpenCL::Platform::ISA = |
607 | @OpenCL::Platform::ISA = |
… | |
… | |
593 | The last error returned by a function - it's only valid after an error occured |
643 | The last error returned by a function - it's only valid after an error occured |
594 | and before calling another OpenCL function. |
644 | and before calling another OpenCL function. |
595 | |
645 | |
596 | =item $str = OpenCL::err2str [$errval] |
646 | =item $str = OpenCL::err2str [$errval] |
597 | |
647 | |
598 | Converts an error value into a human readable string. IF no error value is |
648 | Converts an error value into a human readable string. If no error value is |
599 | given, then the last error will be used (as returned by OpenCL::errno). |
649 | given, then the last error will be used (as returned by OpenCL::errno). |
|
|
650 | |
|
|
651 | The latest version of this module knows the error constants |
|
|
652 | listed in L<http://cvs.schmorp.de/OpenCL/errstr.h>. |
600 | |
653 | |
601 | =item $str = OpenCL::enum2str $enum |
654 | =item $str = OpenCL::enum2str $enum |
602 | |
655 | |
603 | Converts most enum values (of parameter names, image format constants, |
656 | Converts most enum values (of parameter names, image format constants, |
604 | object types, addressing and filter modes, command types etc.) into a |
657 | object types, addressing and filter modes, command types etc.) into a |
605 | human readable string. When confronted with some random integer it can be |
658 | human readable string. When confronted with some random integer it can be |
606 | very helpful to pass it through this function to maybe get some readable |
659 | very helpful to pass it through this function to maybe get some readable |
607 | string out of it. |
660 | string out of it. |
608 | |
661 | |
|
|
662 | The latest version of this module knows the enumaration constants |
|
|
663 | listed in L<http://cvs.schmorp.de/OpenCL/enumstr.h>. |
|
|
664 | |
609 | =item @platforms = OpenCL::platforms |
665 | =item @platforms = OpenCL::platforms |
610 | |
666 | |
611 | Returns all available OpenCL::Platform objects. |
667 | Returns all available OpenCL::Platform objects. |
612 | |
668 | |
613 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetPlatformIDs.html> |
669 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetPlatformIDs.html> |
614 | |
670 | |
615 | =item $ctx = OpenCL::context_from_type $properties, $type = OpenCL::DEVICE_TYPE_DEFAULT, $callback->($err, $pvt) = $print_stderr |
671 | =item $ctx = OpenCL::context_from_type $properties, $type = OpenCL::DEVICE_TYPE_DEFAULT, $callback->($err, $pvt) = $print_stderr |
616 | |
672 | |
617 | Tries to create a context from a default device and platform type - never worked for me. |
673 | Tries to create a context from a default device and platform type - never worked for me. |
|
|
674 | Consider using C<< $platform->context_from_type >> instead. |
618 | |
675 | |
619 | type: OpenCL::DEVICE_TYPE_DEFAULT, OpenCL::DEVICE_TYPE_CPU, OpenCL::DEVICE_TYPE_GPU, |
676 | type: OpenCL::DEVICE_TYPE_DEFAULT, OpenCL::DEVICE_TYPE_CPU, OpenCL::DEVICE_TYPE_GPU, |
620 | OpenCL::DEVICE_TYPE_ACCELERATOR, OpenCL::DEVICE_TYPE_CUSTOM, OpenCL::DEVICE_TYPE_ALL. |
677 | OpenCL::DEVICE_TYPE_ACCELERATOR, OpenCL::DEVICE_TYPE_CUSTOM, OpenCL::DEVICE_TYPE_ALL. |
621 | |
678 | |
622 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContextFromType.html> |
679 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContextFromType.html> |
623 | |
680 | |
624 | =item $ctx = OpenCL::context $properties, \@devices, $callback->($err, $pvt) = $print_stderr) |
681 | =item $ctx = OpenCL::context $properties, \@devices, $callback->($err, $pvt) = $print_stderr) |
625 | |
682 | |
626 | Create a new OpenCL::Context object using the given device object(s). This |
683 | Create a new OpenCL::Context object using the given device object(s). |
627 | function isn't implemented yet, use C<< $platform->context >> instead. |
684 | Consider using C<< $platform->context >> instead. |
628 | |
685 | |
629 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContext.html> |
686 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContext.html> |
630 | |
687 | |
631 | =item OpenCL::wait_for_events $wait_events... |
688 | =item OpenCL::wait_for_events $wait_events... |
632 | |
689 | |
… | |
… | |
713 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContextFromType.html> |
770 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContextFromType.html> |
714 | |
771 | |
715 | =item $ctx = $platform->context ($properties, \@devices, $callback->($err, $pvt) = $print_stderr) |
772 | =item $ctx = $platform->context ($properties, \@devices, $callback->($err, $pvt) = $print_stderr) |
716 | |
773 | |
717 | Create a new OpenCL::Context object using the given device object(s)- a |
774 | Create a new OpenCL::Context object using the given device object(s)- a |
718 | CL_CONTEXT_PLATFORM property is supplied automatically. |
775 | OpenCL::CONTEXT_PLATFORM property is supplied automatically. |
719 | |
776 | |
720 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContext.html> |
777 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContext.html> |
721 | |
778 | |
722 | =item $packed_value = $platform->info ($name) |
779 | =item $packed_value = $platform->info ($name) |
723 | |
780 | |
… | |
… | |
768 | =over 4 |
825 | =over 4 |
769 | |
826 | |
770 | =item $packed_value = $device->info ($name) |
827 | =item $packed_value = $device->info ($name) |
771 | |
828 | |
772 | See C<< $platform->info >> for details. |
829 | See C<< $platform->info >> for details. |
|
|
830 | |
|
|
831 | type: OpenCL::DEVICE_TYPE_DEFAULT, OpenCL::DEVICE_TYPE_CPU, |
|
|
832 | OpenCL::DEVICE_TYPE_GPU, OpenCL::DEVICE_TYPE_ACCELERATOR, |
|
|
833 | OpenCL::DEVICE_TYPE_CUSTOM, OpenCL::DEVICE_TYPE_ALL. |
|
|
834 | |
|
|
835 | fp_config: OpenCL::FP_DENORM, OpenCL::FP_INF_NAN, OpenCL::FP_ROUND_TO_NEAREST, |
|
|
836 | OpenCL::FP_ROUND_TO_ZERO, OpenCL::FP_ROUND_TO_INF, OpenCL::FP_FMA, |
|
|
837 | OpenCL::FP_SOFT_FLOAT, OpenCL::FP_CORRECTLY_ROUNDED_DIVIDE_SQRT. |
|
|
838 | |
|
|
839 | mem_cache_type: OpenCL::NONE, OpenCL::READ_ONLY_CACHE, OpenCL::READ_WRITE_CACHE. |
|
|
840 | |
|
|
841 | local_mem_type: OpenCL::LOCAL, OpenCL::GLOBAL. |
|
|
842 | |
|
|
843 | exec_capabilities: OpenCL::EXEC_KERNEL, OpenCL::EXEC_NATIVE_KERNEL. |
|
|
844 | |
|
|
845 | command_queue_properties: OpenCL::QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, |
|
|
846 | OpenCL::QUEUE_PROFILING_ENABLE. |
|
|
847 | |
|
|
848 | partition_properties: OpenCL::DEVICE_PARTITION_EQUALLY, |
|
|
849 | OpenCL::DEVICE_PARTITION_BY_COUNTS, OpenCL::DEVICE_PARTITION_BY_COUNTS_LIST_END, |
|
|
850 | OpenCL::DEVICE_PARTITION_BY_AFFINITY_DOMAIN. |
|
|
851 | |
|
|
852 | affinity_domain: OpenCL::DEVICE_AFFINITY_DOMAIN_NUMA, |
|
|
853 | OpenCL::DEVICE_AFFINITY_DOMAIN_L4_CACHE, OpenCL::DEVICE_AFFINITY_DOMAIN_L3_CACHE, |
|
|
854 | OpenCL::DEVICE_AFFINITY_DOMAIN_L2_CACHE, OpenCL::DEVICE_AFFINITY_DOMAIN_L1_CACHE, |
|
|
855 | OpenCL::DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE. |
773 | |
856 | |
774 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetDeviceInfo.html> |
857 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetDeviceInfo.html> |
775 | |
858 | |
776 | =item @devices = $device->sub_devices (\@properties) |
859 | =item @devices = $device->sub_devices (\@properties) |
777 | |
860 | |
… | |
… | |
1157 | OpenCL::UNORM_INT16, OpenCL::UNORM_SHORT_565, OpenCL::UNORM_SHORT_555, |
1240 | OpenCL::UNORM_INT16, OpenCL::UNORM_SHORT_565, OpenCL::UNORM_SHORT_555, |
1158 | OpenCL::UNORM_INT_101010, OpenCL::SIGNED_INT8, OpenCL::SIGNED_INT16, |
1241 | OpenCL::UNORM_INT_101010, OpenCL::SIGNED_INT8, OpenCL::SIGNED_INT16, |
1159 | OpenCL::SIGNED_INT32, OpenCL::UNSIGNED_INT8, OpenCL::UNSIGNED_INT16, |
1242 | OpenCL::SIGNED_INT32, OpenCL::UNSIGNED_INT8, OpenCL::UNSIGNED_INT16, |
1160 | OpenCL::UNSIGNED_INT32, OpenCL::HALF_FLOAT, OpenCL::FLOAT. |
1243 | OpenCL::UNSIGNED_INT32, OpenCL::HALF_FLOAT, OpenCL::FLOAT. |
1161 | |
1244 | |
1162 | |
|
|
1163 | type: OpenCL::MEM_OBJECT_BUFFER, OpenCL::MEM_OBJECT_IMAGE2D, |
1245 | type: OpenCL::MEM_OBJECT_BUFFER, OpenCL::MEM_OBJECT_IMAGE2D, |
1164 | OpenCL::MEM_OBJECT_IMAGE3D, OpenCL::MEM_OBJECT_IMAGE2D_ARRAY, |
1246 | OpenCL::MEM_OBJECT_IMAGE3D, OpenCL::MEM_OBJECT_IMAGE2D_ARRAY, |
1165 | OpenCL::MEM_OBJECT_IMAGE1D, OpenCL::MEM_OBJECT_IMAGE1D_ARRAY, |
1247 | OpenCL::MEM_OBJECT_IMAGE1D, OpenCL::MEM_OBJECT_IMAGE1D_ARRAY, |
1166 | OpenCL::MEM_OBJECT_IMAGE1D_BUFFER. |
1248 | OpenCL::MEM_OBJECT_IMAGE1D_BUFFER. |
1167 | |
1249 | |
… | |
… | |
1264 | |
1346 | |
1265 | Creates a new OpenCL::Program object from the given built-in kernel names. |
1347 | Creates a new OpenCL::Program object from the given built-in kernel names. |
1266 | |
1348 | |
1267 | L<http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clCreateProgramWithBuiltInKernels.html> |
1349 | L<http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clCreateProgramWithBuiltInKernels.html> |
1268 | |
1350 | |
|
|
1351 | =item $program = $ctx->link_program (\@devices, $options, \@programs, $cb->($program) = undef) |
|
|
1352 | |
|
|
1353 | Links all (already compiled) program objects specified in C<@programs> |
|
|
1354 | together and returns a new OpenCL::Program object with the result. |
|
|
1355 | |
|
|
1356 | L<http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clLinkProgram.html> |
|
|
1357 | |
1269 | =item $packed_value = $ctx->info ($name) |
1358 | =item $packed_value = $ctx->info ($name) |
1270 | |
1359 | |
1271 | See C<< $platform->info >> for details. |
1360 | See C<< $platform->info >> for details. |
1272 | |
1361 | |
1273 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetContextInfo.html> |
1362 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetContextInfo.html> |
… | |
… | |
1335 | |
1424 | |
1336 | =item $ev = $queue->copy_buffer ($src, $dst, $src_offset, $dst_offset, $len, $wait_events...) |
1425 | =item $ev = $queue->copy_buffer ($src, $dst, $src_offset, $dst_offset, $len, $wait_events...) |
1337 | |
1426 | |
1338 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyBuffer.html> |
1427 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyBuffer.html> |
1339 | |
1428 | |
1340 | =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...) |
1429 | $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...) |
1341 | |
1430 | |
1342 | http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueReadBufferRect.html |
1431 | http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueReadBufferRect.html |
1343 | |
1432 | |
1344 | =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...) |
1433 | =item $ev = $queue->write_buffer_rect ($buf, $blocking, $buf_y, $host_x, $host_z, $height, $buf_row_pitch, $host_row_pitch, $data, $wait_events...) |
1345 | |
1434 | |
1346 | http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWriteBufferRect.html |
1435 | http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWriteBufferRect.html |
1347 | |
1436 | |
1348 | =item $ev = $queue->copy_buffer_to_image ($src_buffer, $dst_image, $src_offset, $dst_x, $dst_y, $dst_z, $width, $height, $depth, $wait_events...) |
1437 | =item $ev = $queue->copy_buffer_to_image ($src_buffer, $dst_image, $src_offset, $dst_x, $dst_y, $dst_z, $width, $height, $depth, $wait_events...) |
1349 | |
1438 | |
… | |
… | |
1533 | it. You are not necessarily meant to do it this way, this example just |
1622 | it. You are not necessarily meant to do it this way, this example just |
1534 | shows you the accessors to use :) |
1623 | shows you the accessors to use :) |
1535 | |
1624 | |
1536 | my $mapped = $queue->map_image ($image, 1, OpenCL::MAP_WRITE); |
1625 | my $mapped = $queue->map_image ($image, 1, OpenCL::MAP_WRITE); |
1537 | |
1626 | |
1538 | $mapped->set ($_ * $mapped->row_pitch, pack "C", 5) |
1627 | $mapped->write ($_ * $mapped->row_pitch, pack "C", 5) |
1539 | for 0..$image->height; |
1628 | for 0 .. $mapped->height - 1; |
1540 | |
1629 | |
1541 | $mapped->unmap;. |
1630 | $mapped->unmap;. |
1542 | $mapped->wait; # only needed for out of order queues normally |
1631 | $mapped->wait; # only needed for out of order queues normally |
1543 | |
1632 | |
1544 | =item $ev = $queue->unmap ($mapped, $wait_events...) |
1633 | =item $ev = $queue->unmap ($mapped, $wait_events...) |
… | |
… | |
1564 | |
1653 | |
1565 | See C<< $platform->info >> for details. |
1654 | See C<< $platform->info >> for details. |
1566 | |
1655 | |
1567 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetMemObjectInfo.html> |
1656 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetMemObjectInfo.html> |
1568 | |
1657 | |
|
|
1658 | =item $memory->destructor_callback ($cb->()) |
|
|
1659 | |
|
|
1660 | Sets a callback that will be invoked after the memory object is destructed. |
|
|
1661 | |
|
|
1662 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clSetMemObjectDestructorCallback.html> |
|
|
1663 | |
1569 | =for gengetinfo begin mem |
1664 | =for gengetinfo begin mem |
1570 | |
1665 | |
1571 | =item $mem_object_type = $mem->type |
1666 | =item $mem_object_type = $mem->type |
1572 | |
1667 | |
1573 | Calls C<clGetMemObjectInfo> with C<OpenCL::MEM_TYPE> and returns the result. |
1668 | Calls C<clGetMemObjectInfo> with C<OpenCL::MEM_TYPE> and returns the result. |
… | |
… | |
1630 | =over 4 |
1725 | =over 4 |
1631 | |
1726 | |
1632 | =item $subbuf = $buf_obj->sub_buffer_region ($flags, $origin, $size) |
1727 | =item $subbuf = $buf_obj->sub_buffer_region ($flags, $origin, $size) |
1633 | |
1728 | |
1634 | Creates an OpenCL::Buffer objects from this buffer and returns it. The |
1729 | Creates an OpenCL::Buffer objects from this buffer and returns it. The |
1635 | C<buffer_create_type> is assumed to be C<CL_BUFFER_CREATE_TYPE_REGION>. |
1730 | C<buffer_create_type> is assumed to be C<OpenCL::BUFFER_CREATE_TYPE_REGION>. |
1636 | |
1731 | |
1637 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateSubBuffer.html> |
1732 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateSubBuffer.html> |
1638 | |
1733 | |
1639 | =back |
1734 | =back |
1640 | |
1735 | |
… | |
… | |
1656 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetImageInfo.html> |
1751 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetImageInfo.html> |
1657 | |
1752 | |
1658 | =item ($channel_order, $channel_data_type) = $image->format |
1753 | =item ($channel_order, $channel_data_type) = $image->format |
1659 | |
1754 | |
1660 | Returns the channel order and type used to create the image by calling |
1755 | Returns the channel order and type used to create the image by calling |
1661 | C<clGetImageInfo> with C<CL_IMAGE_FORMAT>. |
1756 | C<clGetImageInfo> with C<OpenCL::IMAGE_FORMAT>. |
1662 | |
1757 | |
1663 | =for gengetinfo begin image |
1758 | =for gengetinfo begin image |
1664 | |
1759 | |
1665 | =item $int = $image->element_size |
1760 | =item $int = $image->element_size |
1666 | |
1761 | |
… | |
… | |
1766 | C<-cl-mad-enable>, C<-cl-no-signed-zeros>, C<-cl-unsafe-math-optimizations>, |
1861 | C<-cl-mad-enable>, C<-cl-no-signed-zeros>, C<-cl-unsafe-math-optimizations>, |
1767 | C<-cl-finite-math-only>, C<-cl-fast-relaxed-math>, |
1862 | C<-cl-finite-math-only>, C<-cl-fast-relaxed-math>, |
1768 | C<-w>, C<-Werror>, C<-cl-std=CL1.1/CL1.2>, C<-cl-kernel-arg-info>, |
1863 | C<-w>, C<-Werror>, C<-cl-std=CL1.1/CL1.2>, C<-cl-kernel-arg-info>, |
1769 | C<-create-library>, C<-enable-link-options>. |
1864 | C<-create-library>, C<-enable-link-options>. |
1770 | |
1865 | |
|
|
1866 | build_status: OpenCL::BUILD_SUCCESS, OpenCL::BUILD_NONE, |
|
|
1867 | OpenCL::BUILD_ERROR, OpenCL::BUILD_IN_PROGRESS. |
|
|
1868 | |
1771 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clBuildProgram.html> |
1869 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clBuildProgram.html> |
1772 | |
1870 | |
1773 | =item $program->build_async (\@devices = undef, $options = "", $cb->($program) = undef) |
1871 | =item $program->build_async (\@devices = undef, $options = "", $cb->($program) = undef) |
1774 | |
1872 | |
1775 | Similar to C<< ->build >>, except it starts a thread, and never fails (you |
1873 | Similar to C<< ->build >>, except it starts a thread, and never fails (you |
1776 | need to check the compilation status form the callback, or by polling). |
1874 | need to check the compilation status form the callback, or by polling). |
1777 | |
1875 | |
1778 | build_status: OpenCL::BUILD_SUCCESS, OpenCL::BUILD_NONE, |
1876 | =item $program->compile (\@devices = undef, $options = "", \%headers = undef, $cb->($program) = undef) |
1779 | OpenCL::BUILD_ERROR, OpenCL::BUILD_IN_PROGRESS. |
1877 | |
|
|
1878 | Compiles the given program for the given devices (or all devices if |
|
|
1879 | undef). If C<$headers> is given, it must be a hashref with include name => |
|
|
1880 | OpenCL::Program pairs. |
|
|
1881 | |
|
|
1882 | L<http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clCompileProgram.html> |
1780 | |
1883 | |
1781 | =item $packed_value = $program->build_info ($device, $name) |
1884 | =item $packed_value = $program->build_info ($device, $name) |
1782 | |
1885 | |
1783 | Similar to C<< $platform->info >>, but returns build info for a previous |
1886 | Similar to C<< $platform->info >>, but returns build info for a previous |
1784 | build attempt for the given device. |
1887 | build attempt for the given device. |
1785 | |
1888 | |
|
|
1889 | binary_type: OpenCL::PROGRAM_BINARY_TYPE_NONE, |
|
|
1890 | OpenCL::PROGRAM_BINARY_TYPE_COMPILED_OBJECT, |
|
|
1891 | OpenCL::PROGRAM_BINARY_TYPE_LIBRARY, |
|
|
1892 | OpenCL::PROGRAM_BINARY_TYPE_EXECUTABLE. |
|
|
1893 | |
1786 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetBuildInfo.html> |
1894 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetBuildInfo.html> |
1787 | |
1895 | |
1788 | =item $kernel = $program->kernel ($function_name) |
1896 | =item $kernel = $program->kernel ($function_name) |
1789 | |
1897 | |
1790 | Creates an OpenCL::Kernel object out of the named C<__kernel> function in |
1898 | Creates an OpenCL::Kernel object out of the named C<__kernel> function in |
… | |
… | |
1809 | Calls C<clGetProgramBuildInfo> with C<OpenCL::PROGRAM_BUILD_OPTIONS> and returns the result. |
1917 | Calls C<clGetProgramBuildInfo> with C<OpenCL::PROGRAM_BUILD_OPTIONS> and returns the result. |
1810 | |
1918 | |
1811 | =item $string = $program->build_log ($device) |
1919 | =item $string = $program->build_log ($device) |
1812 | |
1920 | |
1813 | Calls C<clGetProgramBuildInfo> with C<OpenCL::PROGRAM_BUILD_LOG> and returns the result. |
1921 | Calls C<clGetProgramBuildInfo> with C<OpenCL::PROGRAM_BUILD_LOG> and returns the result. |
|
|
1922 | |
|
|
1923 | =item $binary_type = $program->binary_type ($device) |
|
|
1924 | |
|
|
1925 | Calls C<clGetProgramBuildInfo> with C<OpenCL::PROGRAM_BINARY_TYPE> and returns the result. |
1814 | |
1926 | |
1815 | =for gengetinfo end program_build |
1927 | =for gengetinfo end program_build |
1816 | |
1928 | |
1817 | =item $packed_value = $program->info ($name) |
1929 | =item $packed_value = $program->info ($name) |
1818 | |
1930 | |
… | |
… | |
1897 | |
2009 | |
1898 | =item $packed_value = $kernel->work_group_info ($device, $name) |
2010 | =item $packed_value = $kernel->work_group_info ($device, $name) |
1899 | |
2011 | |
1900 | See C<< $platform->info >> for details. |
2012 | See C<< $platform->info >> for details. |
1901 | |
2013 | |
1902 | The reason this method is not called C<info> is that there already is an |
|
|
1903 | C<< ->info >> method. |
|
|
1904 | |
|
|
1905 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetKernelWorkGroupInfo.html> |
2014 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetKernelWorkGroupInfo.html> |
1906 | |
2015 | |
1907 | =for gengetinfo begin kernel_work_group |
2016 | =for gengetinfo begin kernel_work_group |
1908 | |
2017 | |
1909 | =item $int = $kernel->work_group_size ($device) |
2018 | =item $int = $kernel->work_group_size ($device) |
… | |
… | |
1926 | |
2035 | |
1927 | Calls C<clGetKernelWorkGroupInfo> with C<OpenCL::KERNEL_PRIVATE_MEM_SIZE> and returns the result. |
2036 | Calls C<clGetKernelWorkGroupInfo> with C<OpenCL::KERNEL_PRIVATE_MEM_SIZE> and returns the result. |
1928 | |
2037 | |
1929 | =for gengetinfo end kernel_work_group |
2038 | =for gengetinfo end kernel_work_group |
1930 | |
2039 | |
|
|
2040 | =item $packed_value = $kernel->arg_info ($idx, $name) |
|
|
2041 | |
|
|
2042 | See C<< $platform->info >> for details. |
|
|
2043 | |
|
|
2044 | L<http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clGetKernelArgInfo.html> |
|
|
2045 | |
1931 | =for gengetinfo begin kernel_arg_info |
2046 | =for gengetinfo begin kernel_arg |
1932 | |
2047 | |
|
|
2048 | =item $kernel_arg_address_qualifier = $kernel->arg_address_qualifier ($idx) |
|
|
2049 | |
|
|
2050 | Calls C<clGetKernelArgInfo> with C<OpenCL::KERNEL_ARG_ADDRESS_QUALIFIER> and returns the result. |
|
|
2051 | |
|
|
2052 | =item $kernel_arg_access_qualifier = $kernel->arg_access_qualifier ($idx) |
|
|
2053 | |
|
|
2054 | Calls C<clGetKernelArgInfo> with C<OpenCL::KERNEL_ARG_ACCESS_QUALIFIER> and returns the result. |
|
|
2055 | |
|
|
2056 | =item $string = $kernel->arg_type_name ($idx) |
|
|
2057 | |
|
|
2058 | Calls C<clGetKernelArgInfo> with C<OpenCL::KERNEL_ARG_TYPE_NAME> and returns the result. |
|
|
2059 | |
|
|
2060 | =item $kernel_arg_type_qualifier = $kernel->arg_type_qualifier ($idx) |
|
|
2061 | |
|
|
2062 | Calls C<clGetKernelArgInfo> with C<OpenCL::KERNEL_ARG_TYPE_QUALIFIER> and returns the result. |
|
|
2063 | |
|
|
2064 | =item $string = $kernel->arg_name ($idx) |
|
|
2065 | |
|
|
2066 | Calls C<clGetKernelArgInfo> with C<OpenCL::KERNEL_ARG_NAME> and returns the result. |
|
|
2067 | |
1933 | =for gengetinfo end kernel_arg_info |
2068 | =for gengetinfo end kernel_arg |
1934 | |
2069 | |
1935 | =item $kernel->setf ($format, ...) |
2070 | =item $kernel->setf ($format, ...) |
1936 | |
2071 | |
1937 | Sets the arguments of a kernel. Since OpenCL 1.1 doesn't have a generic |
2072 | Sets the arguments of a kernel. Since OpenCL 1.1 doesn't have a generic |
1938 | way to set arguments (and with OpenCL 1.2 it might be rather slow), you |
2073 | way to set arguments (and with OpenCL 1.2 it might be rather slow), you |
… | |
… | |
2210 | |
2345 | |
2211 | This is a subclass of OpenCL::Mapped, representing mapped images. |
2346 | This is a subclass of OpenCL::Mapped, representing mapped images. |
2212 | |
2347 | |
2213 | =over 4 |
2348 | =over 4 |
2214 | |
2349 | |
|
|
2350 | =item $pixels = $mapped->width |
|
|
2351 | |
|
|
2352 | =item $pixels = $mapped->height |
|
|
2353 | |
|
|
2354 | =item $pixels = $mapped->depth |
|
|
2355 | |
|
|
2356 | Return the width/height/depth of the mapped image region, in pixels. |
|
|
2357 | |
2215 | =item $bytes = $mapped->row_pitch |
2358 | =item $bytes = $mapped->row_pitch |
2216 | |
2359 | |
2217 | =item $bytes = $mapped->slice_pitch |
2360 | =item $bytes = $mapped->slice_pitch |
2218 | |
2361 | |
2219 | Return the row or slice pitch of the image that has been mapped. |
2362 | Return the row or slice pitch of the image that has been mapped. |
2220 | |
2363 | |
|
|
2364 | =item $bytes = $mapped->element_size |
|
|
2365 | |
|
|
2366 | Return the size of a single pixel. |
|
|
2367 | |
|
|
2368 | =item $data = $mapped->get_row ($count, $x=0, $y=0, $z=0) |
|
|
2369 | |
|
|
2370 | Return C<$count> pixels from the given coordinates. The pixel data must |
|
|
2371 | be completely contained within a single row. |
|
|
2372 | |
|
|
2373 | If C<$count> is C<undef>, then all the remaining pixels in that row are |
|
|
2374 | returned. |
|
|
2375 | |
|
|
2376 | =item $mapped->set_row ($data, $x=0, $y=0, $z=0) |
|
|
2377 | |
|
|
2378 | Write the given pixel data at the given coordinate. The pixel data must |
|
|
2379 | be completely contained within a single row. |
|
|
2380 | |
2221 | =back |
2381 | =back |
2222 | |
|
|
2223 | |
2382 | |
2224 | =cut |
2383 | =cut |
2225 | |
2384 | |
2226 | 1; |
2385 | 1; |
2227 | |
2386 | |