ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/OpenCL/OpenCL.pm
Revision: 1.13
Committed: Thu Nov 17 03:01:35 2011 UTC (12 years, 6 months ago) by root
Branch: MAIN
CVS Tags: rel-0_14
Changes since 1.12: +3 -0 lines
Log Message:
0.14

File Contents

# User Rev Content
1 root 1.1 =head1 NAME
2    
3 root 1.5 OpenCL - Open Computing Language Bindings
4 root 1.1
5     =head1 SYNOPSIS
6    
7     use OpenCL;
8    
9     =head1 DESCRIPTION
10    
11 root 1.7 This is an early release which might be useful, but hasn't seen much testing.
12 root 1.1
13 root 1.9 =head2 OpenCL FROM 10000 FEET HEIGHT
14    
15     Here is a high level overview of OpenCL:
16    
17     First you need to find one or more OpenCL::Platforms (kind of like
18     vendors) - usually there is only one.
19    
20     Each platform gives you access to a number of OpenCL::Device objects, e.g.
21     your graphics card.
22    
23 root 1.11 From a platform and some device(s), you create an OpenCL::Context, which is
24 root 1.9 a very central object in OpenCL: Once you have a context you can create
25     most other objects:
26    
27 root 1.11 OpenCL::Program objects, which store source code and, after building for a
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
30     which represents basically a function call with argument values.
31 root 1.9
32     OpenCL::Memory objects of various flavours: OpenCL::Buffers objects (flat
33     memory areas, think array) and OpenCL::Image objects (think 2d or 3d
34     array) for bulk data and input and output for kernels.
35    
36     OpenCL::Sampler objects, which are kind of like texture filter modes in
37     OpenGL.
38    
39     OpenCL::Queue objects - command queues, which allow you to submit memory
40     reads, writes and copies, as well as kernel calls to your devices. They
41     also offer a variety of methods to synchronise request execution, for
42     example with barriers or OpenCL::Event objects.
43    
44     OpenCL::Event objects are used to signal when something is complete.
45    
46     =head2 HELPFUL RESOURCES
47 root 1.3
48 root 1.5 The OpenCL spec used to develop this module (1.2 spec was available, but
49 root 1.3 no implementation was available to me :).
50    
51     http://www.khronos.org/registry/cl/specs/opencl-1.1.pdf
52    
53     OpenCL manpages:
54    
55     http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/
56    
57 root 1.9 =head1 BASIC WORKFLOW
58    
59 root 1.11 To get something done, you basically have to do this once (refer to the
60     examples below for actual code, this is just a high-level description):
61 root 1.9
62 root 1.11 Find some platform (e.g. the first one) and some device(s) (e.g. the first
63     device of the platform), and create a context from those.
64 root 1.9
65 root 1.11 Create program objects from your OpenCL source code, then build (compile)
66     the programs for each device you want to run them on.
67 root 1.9
68 root 1.11 Create kernel objects for all kernels you want to use (surprisingly, these
69     are not device-specific).
70 root 1.9
71 root 1.11 Then, to execute stuff, you repeat these steps, possibly resuing or
72     sharing some buffers:
73 root 1.9
74 root 1.11 Create some input and output buffers from your context. Set these as
75     arguments to your kernel.
76    
77     Enqueue buffer writes to initialise your input buffers (when not
78     initialised at creation time).
79 root 1.9
80     Enqueue the kernel execution.
81    
82     Enqueue buffer reads for your output buffer to read results.
83    
84 root 1.3 =head1 EXAMPLES
85    
86 root 1.5 =head2 Enumerate all devices and get contexts for them.
87 root 1.1
88 root 1.11 Best run this once to get a feel for the platforms and devices in your
89     system.
90    
91 root 1.1 for my $platform (OpenCL::platforms) {
92 root 1.10 printf "platform: %s\n", $platform->info (OpenCL::PLATFORM_NAME);
93     printf "extensions: %s\n", $platform->info (OpenCL::PLATFORM_EXTENSIONS);
94 root 1.1 for my $device ($platform->devices) {
95 root 1.10 printf "+ device: %s\n", $device->info (OpenCL::DEVICE_NAME);
96     my $ctx = $device->context;
97 root 1.1 # do stuff
98     }
99     }
100    
101 root 1.5 =head2 Get a useful context and a command queue.
102 root 1.1
103 root 1.11 This is a useful boilerplate for any OpenCL program that only wants to use
104     one device,
105    
106     my ($platform) = OpenCL::platforms; # find first platform
107     my ($dev) = $platform->devices; # find first device of platform
108     my $ctx = $platform->context (undef, [$dev]); # create context out of those
109     my $queue = $ctx->queue ($dev); # create a command queue for the device
110 root 1.1
111 root 1.5 =head2 Print all supported image formats of a context.
112    
113 root 1.11 Best run this once for your context, to see whats available and how to
114     gather information.
115    
116 root 1.5 for my $type (OpenCL::MEM_OBJECT_IMAGE2D, OpenCL::MEM_OBJECT_IMAGE3D) {
117 root 1.10 print "supported image formats for ", OpenCL::enum2str $type, "\n";
118 root 1.5
119     for my $f ($ctx->supported_image_formats (0, $type)) {
120     printf " %-10s %-20s\n", OpenCL::enum2str $f->[0], OpenCL::enum2str $f->[1];
121     }
122     }
123    
124     =head2 Create a buffer with some predefined data, read it back synchronously,
125     then asynchronously.
126 root 1.3
127     my $buf = $ctx->buffer_sv (OpenCL::MEM_COPY_HOST_PTR, "helmut");
128    
129     $queue->enqueue_read_buffer ($buf, 1, 1, 3, my $data);
130 root 1.10 print "$data\n";
131 root 1.3
132     my $ev = $queue->enqueue_read_buffer ($buf, 0, 1, 3, my $data);
133     $ev->wait;
134 root 1.10 print "$data\n"; # prints "elm"
135 root 1.3
136 root 1.5 =head2 Create and build a program, then create a kernel out of one of its
137     functions.
138 root 1.3
139     my $src = '
140     __kernel void
141     squareit (__global float *input, __global float *output)
142     {
143     size_t id = get_global_id (0);
144     output [id] = input [id] * input [id];
145     }
146     ';
147    
148     my $prog = $ctx->program_with_source ($src);
149    
150 root 1.11 # build croaks on compile errors, so catch it and print the compile errors
151 root 1.3 eval { $prog->build ($dev); 1 }
152     or die $prog->build_info ($dev, OpenCL::PROGRAM_BUILD_LOG);
153    
154     my $kernel = $prog->kernel ("squareit");
155    
156 root 1.11 =head2 Create some input and output float buffers, then call the
157     'squareit' kernel on them.
158 root 1.4
159     my $input = $ctx->buffer_sv (OpenCL::MEM_COPY_HOST_PTR, pack "f*", 1, 2, 3, 4.5);
160     my $output = $ctx->buffer (0, OpenCL::SIZEOF_FLOAT * 5);
161    
162     # set buffer
163     $kernel->set_buffer (0, $input);
164     $kernel->set_buffer (1, $output);
165    
166     # execute it for all 4 numbers
167     $queue->enqueue_nd_range_kernel ($kernel, undef, [4], undef);
168    
169 root 1.5 # enqueue a synchronous read
170     $queue->enqueue_read_buffer ($output, 1, 0, OpenCL::SIZEOF_FLOAT * 4, my $data);
171    
172     # print the results:
173 root 1.10 printf "%s\n", join ", ", unpack "f*", $data;
174 root 1.5
175     =head2 The same enqueue operations as before, but assuming an out-of-order queue,
176     showing off barriers.
177    
178     # execute it for all 4 numbers
179     $queue->enqueue_nd_range_kernel ($kernel, undef, [4], undef);
180    
181     # enqueue a barrier to ensure in-order execution
182 root 1.4 $queue->enqueue_barrier;
183    
184 root 1.5 # enqueue an async read
185     $queue->enqueue_read_buffer ($output, 0, 0, OpenCL::SIZEOF_FLOAT * 4, my $data);
186    
187     # wait for all requests to finish
188     $queue->finish;
189    
190     =head2 The same enqueue operations as before, but assuming an out-of-order queue,
191     showing off event objects and wait lists.
192    
193     # execute it for all 4 numbers
194     my $ev = $queue->enqueue_nd_range_kernel ($kernel, undef, [4], undef);
195    
196     # enqueue an async read
197     $ev = $queue->enqueue_read_buffer ($output, 0, 0, OpenCL::SIZEOF_FLOAT * 4, my $data, $ev);
198    
199     # wait for the last event to complete
200 root 1.4 $ev->wait;
201    
202 root 1.5 =head1 DOCUMENTATION
203    
204     =head2 BASIC CONVENTIONS
205    
206     This is not a 1:1 C-style translation of OpenCL to Perl - instead I
207     attempted to make the interface as type-safe as possible and introducing
208     object syntax where it makes sense. There are a number of important
209     differences between the OpenCL C API and this module:
210    
211     =over 4
212    
213     =item * Object lifetime managament is automatic - there is no need
214     to free objects explicitly (C<clReleaseXXX>), the release function
215     is called automatically once all Perl references to it go away.
216    
217     =item * OpenCL uses CamelCase for function names (C<clGetPlatformInfo>),
218     while this module uses underscores as word separator and often leaves out
219     prefixes (C<< $platform->info >>).
220    
221     =item * OpenCL often specifies fixed vector function arguments as short
222     arrays (C<size_t origin[3]>), while this module explicitly expects the
223     components as separate arguments-
224    
225 root 1.13 =item * Structures are often specified with their components, and returned
226     as arrayrefs.
227    
228 root 1.9 =item * Where possible, one of the pitch values is calculated from the
229     perl scalar length and need not be specified.
230 root 1.5
231     =item * When enqueuing commands, the wait list is specified by adding
232 root 1.9 extra arguments to the function - anywhere a C<$wait_events...> argument
233 root 1.5 is documented this can be any number of event objects.
234    
235     =item * When enqueuing commands, if the enqueue method is called in void
236     context, no event is created. In all other contexts an event is returned
237     by the method.
238    
239     =item * This module expects all functions to return C<CL_SUCCESS>. If any
240     other status is returned the function will throw an exception, so you
241     don't normally have to to any error checking.
242    
243     =back
244    
245 root 1.7 =head2 PERL AND OPENCL TYPES
246    
247 root 1.8 This handy(?) table lists OpenCL types and their perl, PDL and pack/unpack
248 root 1.7 format equivalents:
249    
250 root 1.8 OpenCL perl PDL pack/unpack
251     char IV - c
252     uchar IV byte C
253     short IV short s
254     ushort IV ushort S
255     int IV long? l
256     uint IV - L
257     long IV longlong q
258     ulong IV - Q
259     float NV float f
260     half IV ushort S
261     double NV double d
262 root 1.7
263 root 1.5 =head2 THE OpenCL PACKAGE
264    
265     =over 4
266    
267     =item $int = OpenCL::errno
268    
269 root 1.11 The last error returned by a function - it's only valid after an error occured
270     and before calling another OpenCL function.
271 root 1.5
272     =item $str = OpenCL::err2str $errval
273    
274     Comverts an error value into a human readable string.
275    
276 root 1.9 =item $str = OpenCL::enum2str $enum
277 root 1.5
278     Converts most enum values (inof parameter names, image format constants,
279     object types, addressing and filter modes, command types etc.) into a
280     human readbale string. When confronted with some random integer it can be
281     very helpful to pass it through this function to maybe get some readable
282     string out of it.
283    
284     =item @platforms = OpenCL::platforms
285    
286     Returns all available OpenCL::Platform objects.
287    
288     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetPlatformIDs.html>
289    
290 root 1.10 =item $ctx = OpenCL::context_from_type $properties, $type = OpenCL::DEVICE_TYPE_DEFAULT, $notify = undef
291 root 1.5
292     Tries to create a context from a default device and platform - never worked for me.
293    
294     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContextFromType.html>
295    
296     =item OpenCL::wait_for_events $wait_events...
297    
298     Waits for all events to complete.
299    
300     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clWaitForEvents.html>
301    
302     =back
303    
304     =head2 THE OpenCL::Platform CLASS
305    
306     =over 4
307    
308     =item $packed_value = $platform->info ($name)
309    
310     Calls C<clGetPlatformInfo> and returns the packed, raw value - for
311     strings, this will be the string, for other values you probably need to
312     use the correct C<unpack>. This might get improved in the future. Hopefully.
313    
314     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetPlatformInfo.html>
315    
316     =item @devices = $platform->devices ($type = OpenCL::DEVICE_TYPE_ALL)
317    
318     Returns a list of matching OpenCL::Device objects.
319    
320 root 1.10 =item $ctx = $platform->context_from_type ($properties, $type = OpenCL::DEVICE_TYPE_DEFAULT, $notify = undef)
321 root 1.5
322 root 1.11 Tries to create a context. Never worked for me, and you need devices explitly anyway.
323 root 1.5
324     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContextFromType.html>
325    
326 root 1.11 =item $ctx = $device->context ($properties = undef, @$devices, $notify = undef)
327    
328     Create a new OpenCL::Context object using the given device object(s)- a
329     CL_CONTEXT_PLATFORM property is supplied automatically.
330    
331     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContext.html>
332    
333 root 1.5 =back
334    
335     =head2 THE OpenCL::Device CLASS
336    
337     =over 4
338    
339     =item $packed_value = $device->info ($name)
340    
341     See C<< $platform->info >> for details.
342    
343     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetDeviceInfo.html>
344    
345     =back
346    
347     =head2 THE OpenCL::Context CLASS
348    
349     =over 4
350    
351     =item $packed_value = $ctx->info ($name)
352    
353     See C<< $platform->info >> for details.
354    
355     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetContextInfo.html>
356    
357 root 1.9 =item $queue = $ctx->queue ($device, $properties)
358 root 1.5
359 root 1.9 Create a new OpenCL::Queue object from the context and the given device.
360 root 1.5
361     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateCommandQueue.html>
362    
363     =item $ev = $ctx->user_event
364    
365     Creates a new OpenCL::UserEvent object.
366    
367     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateUserEvent.html>
368    
369     =item $buf = $ctx->buffer ($flags, $len)
370    
371     Creates a new OpenCL::Buffer object with the given flags and octet-size.
372    
373     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateBuffer.html>
374    
375     =item $buf = $ctx->buffer_sv ($flags, $data)
376    
377     Creates a new OpenCL::Buffer object and initialise it with the given data values.
378    
379     =item $img = $ctx->image2d ($flags, $channel_order, $channel_type, $width, $height, $data)
380    
381     Creates a new OpenCL::Image2D object and optionally initialises it with the given data values.
382    
383     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateImage2D.html>
384    
385     =item $img = $ctx->image3d ($flags, $channel_order, $channel_type, $width, $height, $depth, $slice_pitch, $data)
386    
387     Creates a new OpenCL::Image3D object and optionally initialises it with the given data values.
388    
389     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateImage3D.html>
390    
391     =item @formats = $ctx->supported_image_formats ($flags, $image_type)
392    
393     Returns a list of matching image formats - each format is an arrayref with
394     two values, $channel_order and $channel_type, in it.
395    
396     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetSupportedImageFormats.html>
397    
398     =item $sampler = $ctx->sampler ($normalized_coords, $addressing_mode, $filter_mode)
399    
400     Creates a new OpenCL::Sampler object.
401    
402     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateSampler.html>
403    
404     =item $program = $ctx->program_with_source ($string)
405    
406     Creates a new OpenCL::Program object from the given source code.
407    
408     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateProgramWithSource.html>
409    
410     =back
411    
412     =head2 THE OpenCL::Queue CLASS
413    
414     An OpenCL::Queue represents an execution queue for OpenCL. You execute
415     requests by calling their respective C<enqueue_xxx> method and waitinf for
416     it to complete in some way.
417    
418     All the enqueue methods return an event object that can be used to wait
419     for completion, unless the method is called in void context, in which case
420     no event object is created.
421    
422     They also allow you to specify any number of other event objects that this
423     request has to wait for before it starts executing, by simply passing the
424     event objects as extra parameters to the enqueue methods.
425    
426     Queues execute in-order by default, without any parallelism, so in most
427 root 1.6 cases (i.e. you use only one queue) it's not necessary to wait for or
428     create event objects.
429 root 1.5
430     =over 4
431    
432     =item $packed_value = $ctx->info ($name)
433    
434     See C<< $platform->info >> for details.
435    
436     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetCommandQueueInfo.html>
437    
438     =item $ev = $queue->enqueue_read_buffer ($buffer, $blocking, $offset, $len, $data, $wait_events...)
439    
440     Reads data from buffer into the given string.
441    
442     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueReadBuffer.html>
443    
444     =item $ev = $queue->enqueue_write_buffer ($buffer, $blocking, $offset, $data, $wait_events...)
445    
446     Writes data to buffer from the given string.
447    
448     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWriteBuffer.html>
449    
450     =item $ev = $queue->enqueue_copy_buffer ($src, $dst, $src_offset, $dst_offset, $len, $wait_events...)
451    
452     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyBuffer.html>
453    
454     =item $ev = $queue->enqueue_read_image ($src, $blocking, $x, $y, $z, $width, $height, $depth, $row_pitch, $slice_pitch, $data, $wait_events...)
455    
456     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueReadImage.html>
457    
458     =item $ev = $queue->enqueue_write_image ($src, $blocking, $x, $y, $z, $width, $height, $depth, $row_pitch, $data, $wait_events...)
459    
460     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWriteImage.html>
461    
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, $ait_event...)
463    
464     Yeah.
465    
466     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyBufferRect.html>
467    
468     =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, ...)
469    
470     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyBufferToImage.html>.
471    
472     =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, ...)
473    
474     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyImage.html>
475    
476     =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, ...)
477    
478     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyImageToBuffer.html>
479    
480     =item $ev = $queue->enqueue_task ($kernel, $wait_events...)
481    
482     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueTask.html>
483    
484     =item $ev = $queue->enqueue_nd_range_kernel ($kernel, @$global_work_offset, @$global_work_size, @$local_work_size, $wait_events...)
485    
486     Enqueues a kernel execution.
487    
488     @$global_work_size must be specified as a reference to an array of
489     integers specifying the work sizes (element counts).
490    
491     @$global_work_offset must be either C<undef> (in which case all offsets
492     are C<0>), or a reference to an array of work offsets, with the same number
493     of elements as @$global_work_size.
494    
495     @$local_work_size must be either C<undef> (in which case the
496     implementation is supposed to choose good local work sizes), or a
497     reference to an array of local work sizes, with the same number of
498     elements as @$global_work_size.
499    
500     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueNDRangeKernel.html>
501    
502     =item $ev = $queue->enqueue_marker
503    
504     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueMarker.html>
505    
506     =item $ev = $queue->enqueue_wait_for_events ($wait_events...)
507    
508     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWaitForEvents.html>
509    
510     =item $queue->enqueue_barrier
511    
512     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueBarrier.html>
513    
514     =item $queue->flush
515    
516     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clFlush.html>
517    
518     =item $queue->finish
519    
520     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clFinish.html>
521    
522     =back
523    
524     =head2 THE OpenCL::Memory CLASS
525    
526     This the superclass of all memory objects - OpenCL::Buffer, OpenCL::Image,
527     OpenCL::Image2D and OpenCL::Image3D. The subclasses of this class
528     currently only exist to allow type-checking.
529    
530     =over 4
531    
532     =item $packed_value = $memory->info ($name)
533    
534     See C<< $platform->info >> for details.
535    
536     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetMemObjectInfo.html>
537    
538     =back
539    
540     =head2 THE OpenCL::Sampler CLASS
541    
542     =over 4
543    
544     =item $packed_value = $sampler->info ($name)
545    
546     See C<< $platform->info >> for details.
547    
548     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetSamplerInfo.html>
549    
550     =back
551    
552     =head2 THE OpenCL::Program CLASS
553    
554     =over 4
555    
556     =item $packed_value = $program->info ($name)
557    
558     See C<< $platform->info >> for details.
559    
560     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetProgramInfo.html>
561    
562     =item $program->build ($device, $options = "")
563    
564     Tries to build the program with the givne options.
565    
566     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clBuildProgram.html>
567    
568     =item $packed_value = $program->build_info ($device, $name)
569    
570     Similar to C<< $platform->info >>, but returns build info for a previous
571     build attempt for the given device.
572    
573     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetBuildInfo.html>
574    
575     =item $kernel = $program->kernel ($function_name)
576    
577     Creates an OpenCL::Kernel object out of the named C<__kernel> function in
578     the program.
579    
580     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateKernel.html>
581    
582     =back
583    
584     =head2 THE OpenCL::Kernel CLASS
585    
586     =over 4
587    
588     =item $packed_value = $kernel->info ($name)
589    
590     See C<< $platform->info >> for details.
591    
592     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetKernelInfo.html>
593    
594     =item $kernel->set_TYPE ($index, $value)
595    
596     This is a family of methods to set the kernel argument with the number C<$index> to the give C<$value>.
597    
598     TYPE is one of C<char>, C<uchar>, C<short>, C<ushort>, C<int>, C<uint>,
599     C<long>, C<ulong>, C<half>, C<float>, C<double>, C<memory>, C<buffer>,
600     C<image2d>, C<image3d>, C<sampler> or C<event>.
601    
602     Chars and integers (including the half type) are specified as integers,
603     float and double as floating point values, memory/buffer/image2d/image3d
604     must be an object of that type or C<undef>, and sampler and event must be
605     objects of that type.
606    
607     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clSetKernelArg.html>
608    
609     =back
610    
611     =head2 THE OpenCL::Event CLASS
612    
613     This is the superclass for all event objects (including OpenCL::UserEvent
614     objects).
615    
616     =over 4
617    
618     =item $packed_value = $ev->info ($name)
619    
620     See C<< $platform->info >> for details.
621    
622     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetEventInfo.html>
623    
624     =item $ev->wait
625    
626     Waits for the event to complete.
627    
628     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clWaitForEvents.html>
629    
630     =back
631    
632     =head2 THE OpenCL::UserEvent CLASS
633    
634     This is a subclass of OpenCL::Event.
635 root 1.4
636 root 1.1 =over 4
637    
638 root 1.5 =item $ev->set_status ($execution_status)
639    
640     L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clSetUserEventStatus.html>
641    
642     =back
643    
644 root 1.1 =cut
645    
646     package OpenCL;
647    
648 root 1.2 use common::sense;
649    
650 root 1.1 BEGIN {
651 root 1.12 our $VERSION = '0.14';
652 root 1.1
653     require XSLoader;
654     XSLoader::load (__PACKAGE__, $VERSION);
655 root 1.3
656 root 1.5 @OpenCL::Buffer::ISA =
657     @OpenCL::Image::ISA = OpenCL::Memory::;
658 root 1.3
659 root 1.5 @OpenCL::Image2D::ISA =
660     @OpenCL::Image3D::ISA = OpenCL::Image::;
661    
662     @OpenCL::UserEvent::ISA = OpenCL::Event::;
663 root 1.1 }
664    
665     1;
666    
667     =head1 AUTHOR
668    
669     Marc Lehmann <schmorp@schmorp.de>
670     http://home.schmorp.de/
671    
672     =cut
673