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

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines