… | |
… | |
105 | for my $platform (OpenCL::platforms) { |
105 | for my $platform (OpenCL::platforms) { |
106 | printf "platform: %s\n", $platform->name; |
106 | printf "platform: %s\n", $platform->name; |
107 | printf "extensions: %s\n", $platform->extensions; |
107 | printf "extensions: %s\n", $platform->extensions; |
108 | for my $device ($platform->devices) { |
108 | for my $device ($platform->devices) { |
109 | printf "+ device: %s\n", $device->name; |
109 | printf "+ device: %s\n", $device->name; |
110 | my $ctx = $device->context; |
110 | my $ctx = $platform->context (undef, [$device]); |
111 | # do stuff |
111 | # do stuff |
112 | } |
112 | } |
113 | } |
113 | } |
114 | |
114 | |
115 | =head2 Get a useful context and a command queue. |
115 | =head2 Get a useful context and a command queue. |
… | |
… | |
149 | |
149 | |
150 | =head2 Create and build a program, then create a kernel out of one of its |
150 | =head2 Create and build a program, then create a kernel out of one of its |
151 | functions. |
151 | functions. |
152 | |
152 | |
153 | my $src = ' |
153 | my $src = ' |
154 | __kernel void |
154 | kernel void |
155 | squareit (__global float *input, __global float *output) |
155 | squareit (global float *input, global float *output) |
156 | { |
156 | { |
157 | $id = get_global_id (0); |
157 | $id = get_global_id (0); |
158 | output [id] = input [id] * input [id]; |
158 | output [id] = input [id] * input [id]; |
159 | } |
159 | } |
160 | '; |
160 | '; |
… | |
… | |
286 | |
286 | |
287 | Comverts an error value into a human readable string. |
287 | Comverts an error value into a human readable string. |
288 | |
288 | |
289 | =item $str = OpenCL::enum2str $enum |
289 | =item $str = OpenCL::enum2str $enum |
290 | |
290 | |
291 | Converts most enum values (inof parameter names, image format constants, |
291 | Converts most enum values (of parameter names, image format constants, |
292 | object types, addressing and filter modes, command types etc.) into a |
292 | object types, addressing and filter modes, command types etc.) into a |
293 | human readbale string. When confronted with some random integer it can be |
293 | human readable string. When confronted with some random integer it can be |
294 | very helpful to pass it through this function to maybe get some readable |
294 | very helpful to pass it through this function to maybe get some readable |
295 | string out of it. |
295 | string out of it. |
296 | |
296 | |
297 | =item @platforms = OpenCL::platforms |
297 | =item @platforms = OpenCL::platforms |
298 | |
298 | |
… | |
… | |
326 | |
326 | |
327 | Tries to create a context. Never worked for me, and you need devices explicitly anyway. |
327 | Tries to create a context. Never worked for me, and you need devices explicitly anyway. |
328 | |
328 | |
329 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContextFromType.html> |
329 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContextFromType.html> |
330 | |
330 | |
331 | =item $ctx = $device->context ($properties = undef, @$devices, $notify = undef) |
331 | =item $ctx = $platform->context ($properties = undef, @$devices, $notify = undef) |
332 | |
332 | |
333 | Create a new OpenCL::Context object using the given device object(s)- a |
333 | Create a new OpenCL::Context object using the given device object(s)- a |
334 | CL_CONTEXT_PLATFORM property is supplied automatically. |
334 | CL_CONTEXT_PLATFORM property is supplied automatically. |
335 | |
335 | |
336 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContext.html> |
336 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContext.html> |
… | |
… | |
691 | |
691 | |
692 | Creates a new OpenCL::Image3D object and optionally initialises it with |
692 | Creates a new OpenCL::Image3D object and optionally initialises it with |
693 | the given data values. |
693 | the given data values. |
694 | |
694 | |
695 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateImage3D.html> |
695 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateImage3D.html> |
|
|
696 | |
|
|
697 | =item $buffer = $ctx->gl_buffer ($flags, $bufobj) |
|
|
698 | |
|
|
699 | Creates a new OpenCL::Buffer (actually OpenCL::BufferObj) object that refers to the given |
|
|
700 | OpenGL buffer object. |
|
|
701 | |
|
|
702 | http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateFromGLBuffer.html |
|
|
703 | |
|
|
704 | =item $ctx->gl_texture2d ($flags, $target, $miplevel, $texture) |
|
|
705 | |
|
|
706 | Creates a new OpenCL::Image2D object that refers to the given OpenGL |
|
|
707 | 2D texture object. |
|
|
708 | |
|
|
709 | http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateFromGLTexture2D.html |
|
|
710 | |
|
|
711 | =item $ctx->gl_texture3d ($flags, $target, $miplevel, $texture) |
|
|
712 | |
|
|
713 | Creates a new OpenCL::Image3D object that refers to the given OpenGL |
|
|
714 | 3D texture object. |
|
|
715 | |
|
|
716 | http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateFromGLTexture3D.html |
|
|
717 | |
|
|
718 | =item $ctx->gl_renderbuffer ($flags, $renderbuffer) |
|
|
719 | |
|
|
720 | Creates a new OpenCL::Image2D object that refers to the given OpenGL |
|
|
721 | render buffer. |
|
|
722 | |
|
|
723 | http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateFromGLRenderbuffer.html |
696 | |
724 | |
697 | =item @formats = $ctx->supported_image_formats ($flags, $image_type) |
725 | =item @formats = $ctx->supported_image_formats ($flags, $image_type) |
698 | |
726 | |
699 | Returns a list of matching image formats - each format is an arrayref with |
727 | Returns a list of matching image formats - each format is an arrayref with |
700 | two values, $channel_order and $channel_type, in it. |
728 | two values, $channel_order and $channel_type, in it. |
… | |
… | |
831 | reference to an array of local work sizes, with the same number of |
859 | reference to an array of local work sizes, with the same number of |
832 | elements as @$global_work_size. |
860 | elements as @$global_work_size. |
833 | |
861 | |
834 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueNDRangeKernel.html> |
862 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueNDRangeKernel.html> |
835 | |
863 | |
836 | =item $ev = $queue->enqueue_marker |
864 | =item $ev = $queue->enqueue_marker ($wait_events...) |
837 | |
865 | |
838 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueMarker.html> |
866 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueMarker.html> |
|
|
867 | |
|
|
868 | =item $ev = $queue->enqueue_acquire_gl_objects ([object, ...], $wait_events...) |
|
|
869 | |
|
|
870 | Enqueues a list (an array-ref of OpenCL::Memory objects) to be acquired |
|
|
871 | for subsequent OpenCL usage. |
|
|
872 | |
|
|
873 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueAcquireGLObjects.html> |
|
|
874 | |
|
|
875 | =item $ev = $queue->enqueue_release_gl_objects ([object, ...], $wait_events...) |
|
|
876 | |
|
|
877 | Enqueues a list (an array-ref of OpenCL::Memory objects) to be released |
|
|
878 | for subsequent OpenGL usage. |
|
|
879 | |
|
|
880 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueReleaseGLObjects.html> |
839 | |
881 | |
840 | =item $ev = $queue->enqueue_wait_for_events ($wait_events...) |
882 | =item $ev = $queue->enqueue_wait_for_events ($wait_events...) |
841 | |
883 | |
842 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWaitForEvents.html> |
884 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWaitForEvents.html> |
843 | |
885 | |
… | |
… | |
931 | =item $int = $mem->offset |
973 | =item $int = $mem->offset |
932 | |
974 | |
933 | Calls C<clGetMemObjectInfo> with C<CL_MEM_OFFSET> and returns the result. |
975 | Calls C<clGetMemObjectInfo> with C<CL_MEM_OFFSET> and returns the result. |
934 | |
976 | |
935 | =for gengetinfo end mem |
977 | =for gengetinfo end mem |
|
|
978 | |
|
|
979 | =item ($type, $name) = $mem->gl_object_info |
|
|
980 | |
|
|
981 | Returns the OpenGL object type (e.g. OpenCL::GL_OBJECT_TEXTURE2D) and the |
|
|
982 | object "name" (e.g. the texture name) used to create this memory object. |
|
|
983 | |
|
|
984 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetGLObjectInfo.html> |
936 | |
985 | |
937 | =back |
986 | =back |
938 | |
987 | |
939 | =head2 THE OpenCL::Buffer CLASS |
988 | =head2 THE OpenCL::Buffer CLASS |
940 | |
989 | |
… | |
… | |
999 | =item $int = $image->depth |
1048 | =item $int = $image->depth |
1000 | |
1049 | |
1001 | Calls C<clGetImageInfo> with C<CL_IMAGE_DEPTH> and returns the result. |
1050 | Calls C<clGetImageInfo> with C<CL_IMAGE_DEPTH> and returns the result. |
1002 | |
1051 | |
1003 | =for gengetinfo end image |
1052 | =for gengetinfo end image |
|
|
1053 | |
|
|
1054 | =for gengetinfo begin gl_texture |
|
|
1055 | |
|
|
1056 | =item $GLenum = $gl_texture->target |
|
|
1057 | |
|
|
1058 | Calls C<clGetGlTextureInfo> with C<CL_GL_TEXTURE_TARGET> and returns the result. |
|
|
1059 | |
|
|
1060 | =item $GLint = $gl_texture->gl_mipmap_level |
|
|
1061 | |
|
|
1062 | Calls C<clGetGlTextureInfo> with C<CL_GL_MIPMAP_LEVEL> and returns the result. |
|
|
1063 | |
|
|
1064 | =for gengetinfo end gl_texture |
1004 | |
1065 | |
1005 | =back |
1066 | =back |
1006 | |
1067 | |
1007 | =head2 THE OpenCL::Sampler CLASS |
1068 | =head2 THE OpenCL::Sampler CLASS |
1008 | |
1069 | |
… | |
… | |
1302 | package OpenCL; |
1363 | package OpenCL; |
1303 | |
1364 | |
1304 | use common::sense; |
1365 | use common::sense; |
1305 | |
1366 | |
1306 | BEGIN { |
1367 | BEGIN { |
1307 | our $VERSION = '0.59'; |
1368 | our $VERSION = '0.92'; |
1308 | |
1369 | |
1309 | require XSLoader; |
1370 | require XSLoader; |
1310 | XSLoader::load (__PACKAGE__, $VERSION); |
1371 | XSLoader::load (__PACKAGE__, $VERSION); |
1311 | |
1372 | |
1312 | @OpenCL::Buffer::ISA = |
1373 | @OpenCL::Buffer::ISA = |