… | |
… | |
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 |
… | |
… | |
96 | initialised at creation time). |
96 | initialised at creation time). |
97 | |
97 | |
98 | Enqueue the kernel execution. |
98 | Enqueue the kernel execution. |
99 | |
99 | |
100 | Enqueue buffer reads for your output buffer to read results. |
100 | Enqueue buffer reads for your output buffer to read results. |
101 | |
|
|
102 | =head1 OPENCL 1.1 VS. OPENCL 1.2 |
|
|
103 | |
|
|
104 | This module supports both OpenCL version 1.1 and 1.2, although the OpenCL |
|
|
105 | 1.2 interface hasn't been tested much for lack of availability of an |
|
|
106 | actual implementation. |
|
|
107 | |
|
|
108 | Every function or method in this manual page that interfaces to a |
|
|
109 | particular OpenCL function has a link to the its C manual page. |
|
|
110 | |
|
|
111 | If the link contains a F<1.1>, then this function is an OpenCL 1.1 |
|
|
112 | function. Most but not all also exist in OpenCL 1.2, and this module |
|
|
113 | tries to emulate the missing ones for you, when told to do so at |
|
|
114 | compiletime. You cna check whether a function was removed in OpenCL 1.2 by |
|
|
115 | replacing the F<1.1> component in the URL by F<1.2>. |
|
|
116 | |
|
|
117 | If the link contains a F<1.2>, then this is a OpenCL 1.2-only |
|
|
118 | function. Even if the module was compiled with OpenCL 1.2 header files |
|
|
119 | and has an 1.2 OpenCL library, calling such a function on a platform that |
|
|
120 | doesn't implement 1.2 causes undefined behaviour, usually a crash (But |
|
|
121 | this is not guaranteed). |
|
|
122 | |
|
|
123 | You can find out whether this module was compiled to prefer 1.1 |
|
|
124 | functionality by ooking at C<OpenCL::PREFER_1_1> - if it is true, then |
|
|
125 | 1.1 functions generally are implemented using 1.1 OpenCL functions. If it |
|
|
126 | is false, then 1.1 functions missing from 1.2 are emulated by calling 1.2 |
|
|
127 | fucntions. |
|
|
128 | |
|
|
129 | This is a somewhat sorry state of affairs, but the Khronos group choose to |
|
|
130 | make every release of OpenCL source and binary incompatible with previous |
|
|
131 | releases. |
|
|
132 | |
101 | |
133 | =head1 EXAMPLES |
102 | =head1 EXAMPLES |
134 | |
103 | |
135 | =head2 Enumerate all devices and get contexts for them. |
104 | =head2 Enumerate all devices and get contexts for them. |
136 | |
105 | |
… | |
… | |
419 | |
388 | |
420 | =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 |
421 | 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 |
422 | by the method. |
391 | by the method. |
423 | |
392 | |
424 | =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 |
425 | 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 |
426 | don't normally have to to any error checking. |
395 | don't normally have to to any error checking. |
427 | |
396 | |
428 | =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 heaer files used during |
|
|
404 | compilation, or otherwise are not available, will have the value C<-1>. |
|
|
405 | |
|
|
406 | =head2 OPENCL 1.1 VS. OPENCL 1.2 |
|
|
407 | |
|
|
408 | This module supports both OpenCL version 1.1 and 1.2, although the OpenCL |
|
|
409 | 1.2 interface hasn't been tested much for lack of availability of an |
|
|
410 | actual implementation. |
|
|
411 | |
|
|
412 | Every function or method in this manual page that interfaces to a |
|
|
413 | particular OpenCL function has a link to the its C manual page. |
|
|
414 | |
|
|
415 | If the link contains a F<1.1>, then this function is an OpenCL 1.1 |
|
|
416 | function. Most but not all also exist in OpenCL 1.2, and this module |
|
|
417 | tries to emulate the missing ones for you, when told to do so at |
|
|
418 | compiletime. You cna check whether a function was removed in OpenCL 1.2 by |
|
|
419 | replacing the F<1.1> component in the URL by F<1.2>. |
|
|
420 | |
|
|
421 | If the link contains a F<1.2>, then this is a OpenCL 1.2-only |
|
|
422 | function. Even if the module was compiled with OpenCL 1.2 header files |
|
|
423 | and has an 1.2 OpenCL library, calling such a function on a platform that |
|
|
424 | doesn't implement 1.2 causes undefined behaviour, usually a crash (But |
|
|
425 | this is not guaranteed). |
|
|
426 | |
|
|
427 | You can find out whether this module was compiled to prefer 1.1 |
|
|
428 | functionality by ooking at C<OpenCL::PREFER_1_1> - if it is true, then |
|
|
429 | 1.1 functions generally are implemented using 1.1 OpenCL functions. If it |
|
|
430 | is false, then 1.1 functions missing from 1.2 are emulated by calling 1.2 |
|
|
431 | fucntions. |
|
|
432 | |
|
|
433 | This is a somewhat sorry state of affairs, but the Khronos group choose to |
|
|
434 | make every release of OpenCL source and binary incompatible with previous |
|
|
435 | releases. |
429 | |
436 | |
430 | =head2 PERL AND OPENCL TYPES |
437 | =head2 PERL AND OPENCL TYPES |
431 | |
438 | |
432 | This handy(?) table lists OpenCL types and their perl, PDL and pack/unpack |
439 | This handy(?) table lists OpenCL types and their perl, PDL and pack/unpack |
433 | format equivalents: |
440 | format equivalents: |
… | |
… | |
752 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContextFromType.html> |
759 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContextFromType.html> |
753 | |
760 | |
754 | =item $ctx = $platform->context ($properties, \@devices, $callback->($err, $pvt) = $print_stderr) |
761 | =item $ctx = $platform->context ($properties, \@devices, $callback->($err, $pvt) = $print_stderr) |
755 | |
762 | |
756 | Create a new OpenCL::Context object using the given device object(s)- a |
763 | Create a new OpenCL::Context object using the given device object(s)- a |
757 | CL_CONTEXT_PLATFORM property is supplied automatically. |
764 | OpenCL::CONTEXT_PLATFORM property is supplied automatically. |
758 | |
765 | |
759 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContext.html> |
766 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContext.html> |
760 | |
767 | |
761 | =item $packed_value = $platform->info ($name) |
768 | =item $packed_value = $platform->info ($name) |
762 | |
769 | |
… | |
… | |
807 | =over 4 |
814 | =over 4 |
808 | |
815 | |
809 | =item $packed_value = $device->info ($name) |
816 | =item $packed_value = $device->info ($name) |
810 | |
817 | |
811 | See C<< $platform->info >> for details. |
818 | See C<< $platform->info >> for details. |
|
|
819 | |
|
|
820 | type: OpenCL::DEVICE_TYPE_DEFAULT, OpenCL::DEVICE_TYPE_CPU, |
|
|
821 | OpenCL::DEVICE_TYPE_GPU, OpenCL::DEVICE_TYPE_ACCELERATOR, |
|
|
822 | OpenCL::DEVICE_TYPE_CUSTOM, OpenCL::DEVICE_TYPE_ALL. |
|
|
823 | |
|
|
824 | fp_config: OpenCL::FP_DENORM, OpenCL::FP_INF_NAN, OpenCL::FP_ROUND_TO_NEAREST, |
|
|
825 | OpenCL::FP_ROUND_TO_ZERO, OpenCL::FP_ROUND_TO_INF, OpenCL::FP_FMA, |
|
|
826 | OpenCL::FP_SOFT_FLOAT, OpenCL::FP_CORRECTLY_ROUNDED_DIVIDE_SQRT. |
|
|
827 | |
|
|
828 | mem_cache_type: OpenCL::NONE, OpenCL::READ_ONLY_CACHE, OpenCL::READ_WRITE_CACHE. |
|
|
829 | |
|
|
830 | local_mem_type: OpenCL::LOCAL, OpenCL::GLOBAL. |
|
|
831 | |
|
|
832 | exec_capabilities: OpenCL::EXEC_KERNEL, OpenCL::EXEC_NATIVE_KERNEL. |
|
|
833 | |
|
|
834 | command_queue_properties: OpenCL::QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, |
|
|
835 | OpenCL::QUEUE_PROFILING_ENABLE. |
|
|
836 | |
|
|
837 | partition_properties: OpenCL::DEVICE_PARTITION_EQUALLY, |
|
|
838 | OpenCL::DEVICE_PARTITION_BY_COUNTS, OpenCL::DEVICE_PARTITION_BY_COUNTS_LIST_END, |
|
|
839 | OpenCL::DEVICE_PARTITION_BY_AFFINITY_DOMAIN. |
|
|
840 | |
|
|
841 | affinity_domain: OpenCL::DEVICE_AFFINITY_DOMAIN_NUMA, |
|
|
842 | OpenCL::DEVICE_AFFINITY_DOMAIN_L4_CACHE, OpenCL::DEVICE_AFFINITY_DOMAIN_L3_CACHE, |
|
|
843 | OpenCL::DEVICE_AFFINITY_DOMAIN_L2_CACHE, OpenCL::DEVICE_AFFINITY_DOMAIN_L1_CACHE, |
|
|
844 | OpenCL::DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE. |
812 | |
845 | |
813 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetDeviceInfo.html> |
846 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetDeviceInfo.html> |
814 | |
847 | |
815 | =item @devices = $device->sub_devices (\@properties) |
848 | =item @devices = $device->sub_devices (\@properties) |
816 | |
849 | |
… | |
… | |
1196 | OpenCL::UNORM_INT16, OpenCL::UNORM_SHORT_565, OpenCL::UNORM_SHORT_555, |
1229 | OpenCL::UNORM_INT16, OpenCL::UNORM_SHORT_565, OpenCL::UNORM_SHORT_555, |
1197 | OpenCL::UNORM_INT_101010, OpenCL::SIGNED_INT8, OpenCL::SIGNED_INT16, |
1230 | OpenCL::UNORM_INT_101010, OpenCL::SIGNED_INT8, OpenCL::SIGNED_INT16, |
1198 | OpenCL::SIGNED_INT32, OpenCL::UNSIGNED_INT8, OpenCL::UNSIGNED_INT16, |
1231 | OpenCL::SIGNED_INT32, OpenCL::UNSIGNED_INT8, OpenCL::UNSIGNED_INT16, |
1199 | OpenCL::UNSIGNED_INT32, OpenCL::HALF_FLOAT, OpenCL::FLOAT. |
1232 | OpenCL::UNSIGNED_INT32, OpenCL::HALF_FLOAT, OpenCL::FLOAT. |
1200 | |
1233 | |
1201 | |
|
|
1202 | type: OpenCL::MEM_OBJECT_BUFFER, OpenCL::MEM_OBJECT_IMAGE2D, |
1234 | type: OpenCL::MEM_OBJECT_BUFFER, OpenCL::MEM_OBJECT_IMAGE2D, |
1203 | OpenCL::MEM_OBJECT_IMAGE3D, OpenCL::MEM_OBJECT_IMAGE2D_ARRAY, |
1235 | OpenCL::MEM_OBJECT_IMAGE3D, OpenCL::MEM_OBJECT_IMAGE2D_ARRAY, |
1204 | OpenCL::MEM_OBJECT_IMAGE1D, OpenCL::MEM_OBJECT_IMAGE1D_ARRAY, |
1236 | OpenCL::MEM_OBJECT_IMAGE1D, OpenCL::MEM_OBJECT_IMAGE1D_ARRAY, |
1205 | OpenCL::MEM_OBJECT_IMAGE1D_BUFFER. |
1237 | OpenCL::MEM_OBJECT_IMAGE1D_BUFFER. |
1206 | |
1238 | |
… | |
… | |
1676 | =over 4 |
1708 | =over 4 |
1677 | |
1709 | |
1678 | =item $subbuf = $buf_obj->sub_buffer_region ($flags, $origin, $size) |
1710 | =item $subbuf = $buf_obj->sub_buffer_region ($flags, $origin, $size) |
1679 | |
1711 | |
1680 | Creates an OpenCL::Buffer objects from this buffer and returns it. The |
1712 | Creates an OpenCL::Buffer objects from this buffer and returns it. The |
1681 | C<buffer_create_type> is assumed to be C<CL_BUFFER_CREATE_TYPE_REGION>. |
1713 | C<buffer_create_type> is assumed to be C<OpenCL::BUFFER_CREATE_TYPE_REGION>. |
1682 | |
1714 | |
1683 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateSubBuffer.html> |
1715 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateSubBuffer.html> |
1684 | |
1716 | |
1685 | =back |
1717 | =back |
1686 | |
1718 | |
… | |
… | |
1702 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetImageInfo.html> |
1734 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetImageInfo.html> |
1703 | |
1735 | |
1704 | =item ($channel_order, $channel_data_type) = $image->format |
1736 | =item ($channel_order, $channel_data_type) = $image->format |
1705 | |
1737 | |
1706 | Returns the channel order and type used to create the image by calling |
1738 | Returns the channel order and type used to create the image by calling |
1707 | C<clGetImageInfo> with C<CL_IMAGE_FORMAT>. |
1739 | C<clGetImageInfo> with C<OpenCL::IMAGE_FORMAT>. |
1708 | |
1740 | |
1709 | =for gengetinfo begin image |
1741 | =for gengetinfo begin image |
1710 | |
1742 | |
1711 | =item $int = $image->element_size |
1743 | =item $int = $image->element_size |
1712 | |
1744 | |
… | |
… | |
1835 | =item $packed_value = $program->build_info ($device, $name) |
1867 | =item $packed_value = $program->build_info ($device, $name) |
1836 | |
1868 | |
1837 | Similar to C<< $platform->info >>, but returns build info for a previous |
1869 | Similar to C<< $platform->info >>, but returns build info for a previous |
1838 | build attempt for the given device. |
1870 | build attempt for the given device. |
1839 | |
1871 | |
|
|
1872 | binary_type: OpenCL::PROGRAM_BINARY_TYPE_NONE, |
|
|
1873 | OpenCL::PROGRAM_BINARY_TYPE_COMPILED_OBJECT, |
|
|
1874 | OpenCL::PROGRAM_BINARY_TYPE_LIBRARY, |
|
|
1875 | OpenCL::PROGRAM_BINARY_TYPE_EXECUTABLE. |
|
|
1876 | |
1840 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetBuildInfo.html> |
1877 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetBuildInfo.html> |
1841 | |
1878 | |
1842 | =item $kernel = $program->kernel ($function_name) |
1879 | =item $kernel = $program->kernel ($function_name) |
1843 | |
1880 | |
1844 | Creates an OpenCL::Kernel object out of the named C<__kernel> function in |
1881 | Creates an OpenCL::Kernel object out of the named C<__kernel> function in |
… | |
… | |
1863 | Calls C<clGetProgramBuildInfo> with C<OpenCL::PROGRAM_BUILD_OPTIONS> and returns the result. |
1900 | Calls C<clGetProgramBuildInfo> with C<OpenCL::PROGRAM_BUILD_OPTIONS> and returns the result. |
1864 | |
1901 | |
1865 | =item $string = $program->build_log ($device) |
1902 | =item $string = $program->build_log ($device) |
1866 | |
1903 | |
1867 | Calls C<clGetProgramBuildInfo> with C<OpenCL::PROGRAM_BUILD_LOG> and returns the result. |
1904 | Calls C<clGetProgramBuildInfo> with C<OpenCL::PROGRAM_BUILD_LOG> and returns the result. |
|
|
1905 | |
|
|
1906 | =item $binary_type = $program->binary_type ($device) |
|
|
1907 | |
|
|
1908 | Calls C<clGetProgramBuildInfo> with C<OpenCL::PROGRAM_BINARY_TYPE> and returns the result. |
1868 | |
1909 | |
1869 | =for gengetinfo end program_build |
1910 | =for gengetinfo end program_build |
1870 | |
1911 | |
1871 | =item $packed_value = $program->info ($name) |
1912 | =item $packed_value = $program->info ($name) |
1872 | |
1913 | |