ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/OpenCL/OpenCL.pm
(Generate patch)

Comparing OpenCL/OpenCL.pm (file contents):
Revision 1.1 by root, Tue Nov 15 06:50:30 2011 UTC vs.
Revision 1.16 by root, Thu Nov 17 03:42:03 2011 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines