… | |
… | |
434 | OpenCL can generate a number of (potentially) asynchronous events, for |
434 | OpenCL can generate a number of (potentially) asynchronous events, for |
435 | example, after compiling a program, to signal a context-related error or, |
435 | example, after compiling a program, to signal a context-related error or, |
436 | perhaps most important, to signal completion of queued jobs (by setting |
436 | perhaps most important, to signal completion of queued jobs (by setting |
437 | callbacks on OpenCL::Event objects). |
437 | callbacks on OpenCL::Event objects). |
438 | |
438 | |
|
|
439 | The OpenCL module converts all these callbacks into events - you can |
|
|
440 | still register callbacks, but they are not executed when your OpenCL |
|
|
441 | implementation calls the actual callback, but only later. Therefore, none |
|
|
442 | of the limitations of OpenCL callbacks apply to the perl implementation: |
|
|
443 | it is perfectly safe to make blocking operations from event callbacks, and |
|
|
444 | enqueued operations don't need to be flushed. |
|
|
445 | |
439 | To facilitate this, this module maintains an event queue - each |
446 | To facilitate this, this module maintains an event queue - each |
440 | time an asynchronous event happens, it is queued, and perl will be |
447 | time an asynchronous event happens, it is queued, and perl will be |
441 | interrupted. This is implemented via the L<Async::Interrupt> module. In |
448 | interrupted. This is implemented via the L<Async::Interrupt> module. In |
442 | addition, this module has L<AnyEvent> support, so it can seamlessly |
449 | addition, this module has L<AnyEvent> support, so it can seamlessly |
443 | integrate itself into many event loops. |
450 | integrate itself into many event loops. |
444 | |
451 | |
445 | Since this module is a bit hard to understand, here are some case examples: |
452 | Since L<Async::Interrupt> is a bit hard to understand, here are some case examples: |
446 | |
453 | |
447 | =head3 Don't use callbacks. |
454 | =head3 Don't use callbacks. |
448 | |
455 | |
449 | When your program never uses any callbacks, then there will never be any |
456 | 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 |
457 | notifications you need to take care of, and therefore no need to worry |
… | |
… | |
1264 | |
1271 | |
1265 | Creates a new OpenCL::Program object from the given built-in kernel names. |
1272 | Creates a new OpenCL::Program object from the given built-in kernel names. |
1266 | |
1273 | |
1267 | L<http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clCreateProgramWithBuiltInKernels.html> |
1274 | L<http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clCreateProgramWithBuiltInKernels.html> |
1268 | |
1275 | |
|
|
1276 | =item $program = $ctx->link_program (\@devices, $options, \@programs, $cb->($program) = undef) |
|
|
1277 | |
|
|
1278 | Links all (already compiled) program objects specified in C<@programs> |
|
|
1279 | together and returns a new OpenCL::Program object with the result. |
|
|
1280 | |
|
|
1281 | L<http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clLinkProgram.html> |
|
|
1282 | |
1269 | =item $packed_value = $ctx->info ($name) |
1283 | =item $packed_value = $ctx->info ($name) |
1270 | |
1284 | |
1271 | See C<< $platform->info >> for details. |
1285 | See C<< $platform->info >> for details. |
1272 | |
1286 | |
1273 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetContextInfo.html> |
1287 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetContextInfo.html> |
… | |
… | |
1766 | C<-cl-mad-enable>, C<-cl-no-signed-zeros>, C<-cl-unsafe-math-optimizations>, |
1780 | 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>, |
1781 | 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>, |
1782 | C<-w>, C<-Werror>, C<-cl-std=CL1.1/CL1.2>, C<-cl-kernel-arg-info>, |
1769 | C<-create-library>, C<-enable-link-options>. |
1783 | C<-create-library>, C<-enable-link-options>. |
1770 | |
1784 | |
|
|
1785 | build_status: OpenCL::BUILD_SUCCESS, OpenCL::BUILD_NONE, |
|
|
1786 | OpenCL::BUILD_ERROR, OpenCL::BUILD_IN_PROGRESS. |
|
|
1787 | |
1771 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clBuildProgram.html> |
1788 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clBuildProgram.html> |
1772 | |
1789 | |
1773 | =item $program->build_async (\@devices = undef, $options = "", $cb->($program) = undef) |
1790 | =item $program->build_async (\@devices = undef, $options = "", $cb->($program) = undef) |
1774 | |
1791 | |
1775 | Similar to C<< ->build >>, except it starts a thread, and never fails (you |
1792 | 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). |
1793 | need to check the compilation status form the callback, or by polling). |
1777 | |
1794 | |
1778 | build_status: OpenCL::BUILD_SUCCESS, OpenCL::BUILD_NONE, |
1795 | =item $program->compile (\@devices = undef, $options = "", \%headers = undef, $cb->($program) = undef) |
1779 | OpenCL::BUILD_ERROR, OpenCL::BUILD_IN_PROGRESS. |
1796 | |
|
|
1797 | Compiles the given program for the given devices (or all devices if |
|
|
1798 | undef). If C<$headers> is given, it must be a hashref with include name => |
|
|
1799 | OpenCL::Program pairs. |
|
|
1800 | |
|
|
1801 | L<http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clCompileProgram.html> |
1780 | |
1802 | |
1781 | =item $packed_value = $program->build_info ($device, $name) |
1803 | =item $packed_value = $program->build_info ($device, $name) |
1782 | |
1804 | |
1783 | Similar to C<< $platform->info >>, but returns build info for a previous |
1805 | Similar to C<< $platform->info >>, but returns build info for a previous |
1784 | build attempt for the given device. |
1806 | build attempt for the given device. |
… | |
… | |
1897 | |
1919 | |
1898 | =item $packed_value = $kernel->work_group_info ($device, $name) |
1920 | =item $packed_value = $kernel->work_group_info ($device, $name) |
1899 | |
1921 | |
1900 | See C<< $platform->info >> for details. |
1922 | See C<< $platform->info >> for details. |
1901 | |
1923 | |
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> |
1924 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetKernelWorkGroupInfo.html> |
1906 | |
1925 | |
1907 | =for gengetinfo begin kernel_work_group |
1926 | =for gengetinfo begin kernel_work_group |
1908 | |
1927 | |
1909 | =item $int = $kernel->work_group_size ($device) |
1928 | =item $int = $kernel->work_group_size ($device) |
… | |
… | |
1926 | |
1945 | |
1927 | Calls C<clGetKernelWorkGroupInfo> with C<OpenCL::KERNEL_PRIVATE_MEM_SIZE> and returns the result. |
1946 | Calls C<clGetKernelWorkGroupInfo> with C<OpenCL::KERNEL_PRIVATE_MEM_SIZE> and returns the result. |
1928 | |
1947 | |
1929 | =for gengetinfo end kernel_work_group |
1948 | =for gengetinfo end kernel_work_group |
1930 | |
1949 | |
|
|
1950 | =item $packed_value = $kernel->arg_info ($idx, $name) |
|
|
1951 | |
|
|
1952 | See C<< $platform->info >> for details. |
|
|
1953 | |
|
|
1954 | L<http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clGetKernelArgInfo.html> |
|
|
1955 | |
1931 | =for gengetinfo begin kernel_arg_info |
1956 | =for gengetinfo begin kernel_arg |
1932 | |
1957 | |
|
|
1958 | =item $kernel_arg_address_qualifier = $kernel->arg_address_qualifier ($idx) |
|
|
1959 | |
|
|
1960 | Calls C<clGetKernelArgInfo> with C<OpenCL::KERNEL_ARG_ADDRESS_QUALIFIER> and returns the result. |
|
|
1961 | |
|
|
1962 | =item $kernel_arg_access_qualifier = $kernel->arg_access_qualifier ($idx) |
|
|
1963 | |
|
|
1964 | Calls C<clGetKernelArgInfo> with C<OpenCL::KERNEL_ARG_ACCESS_QUALIFIER> and returns the result. |
|
|
1965 | |
|
|
1966 | =item $string = $kernel->arg_type_name ($idx) |
|
|
1967 | |
|
|
1968 | Calls C<clGetKernelArgInfo> with C<OpenCL::KERNEL_ARG_TYPE_NAME> and returns the result. |
|
|
1969 | |
|
|
1970 | =item $kernel_arg_type_qualifier = $kernel->arg_type_qualifier ($idx) |
|
|
1971 | |
|
|
1972 | Calls C<clGetKernelArgInfo> with C<OpenCL::KERNEL_ARG_TYPE_QUALIFIER> and returns the result. |
|
|
1973 | |
|
|
1974 | =item $string = $kernel->arg_name ($idx) |
|
|
1975 | |
|
|
1976 | Calls C<clGetKernelArgInfo> with C<OpenCL::KERNEL_ARG_NAME> and returns the result. |
|
|
1977 | |
1933 | =for gengetinfo end kernel_arg_info |
1978 | =for gengetinfo end kernel_arg |
1934 | |
1979 | |
1935 | =item $kernel->setf ($format, ...) |
1980 | =item $kernel->setf ($format, ...) |
1936 | |
1981 | |
1937 | Sets the arguments of a kernel. Since OpenCL 1.1 doesn't have a generic |
1982 | 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 |
1983 | way to set arguments (and with OpenCL 1.2 it might be rather slow), you |