… | |
… | |
43 | |
43 | |
44 | OpenCL::Event objects are used to signal when something is complete. |
44 | OpenCL::Event objects are used to signal when something is complete. |
45 | |
45 | |
46 | =head2 HELPFUL RESOURCES |
46 | =head2 HELPFUL RESOURCES |
47 | |
47 | |
48 | The OpenCL spec used to develop this module (1.2 spec was available, but |
48 | The OpenCL specs used to develop this module: |
49 | no implementation was available to me :). |
|
|
50 | |
49 | |
51 | http://www.khronos.org/registry/cl/specs/opencl-1.1.pdf |
50 | http://www.khronos.org/registry/cl/specs/opencl-1.1.pdf |
|
|
51 | http://www.khronos.org/registry/cl/specs/opencl-1.2.pdf |
|
|
52 | http://www.khronos.org/registry/cl/specs/opencl-1.2-extensions.pdf |
52 | |
53 | |
53 | OpenCL manpages: |
54 | OpenCL manpages: |
54 | |
55 | |
55 | http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/ |
56 | http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/ |
|
|
57 | http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/ |
56 | |
58 | |
57 | If you are into UML class diagrams, the following diagram might help - if |
59 | If you are into UML class diagrams, the following diagram might help - if |
58 | not, it will be mildly cobfusing: |
60 | not, it will be mildly confusing (also, the class hierarchy of this module |
|
|
61 | is much more fine-grained): |
59 | |
62 | |
60 | http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/classDiagram.html |
63 | http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/classDiagram.html |
61 | |
64 | |
62 | Here's a tutorial from AMD (very AMD-centric, too), not sure how useful it |
65 | Here's a tutorial from AMD (very AMD-centric, too), not sure how useful it |
63 | is, but at least it's free of charge: |
66 | is, but at least it's free of charge: |
64 | |
67 | |
65 | http://developer.amd.com/zones/OpenCLZone/courses/Documents/Introduction_to_OpenCL_Programming%20Training_Guide%20%28201005%29.pdf |
68 | http://developer.amd.com/zones/OpenCLZone/courses/Documents/Introduction_to_OpenCL_Programming%20Training_Guide%20%28201005%29.pdf |
… | |
… | |
376 | |
379 | |
377 | For this to work, the OpenGL library must be loaded, a GLX context must |
380 | For this to work, the OpenGL library must be loaded, a GLX context must |
378 | have been created and be made current, and C<dlsym> must be available and |
381 | have been created and be made current, and C<dlsym> must be available and |
379 | capable of finding the function via C<RTLD_DEFAULT>. |
382 | capable of finding the function via C<RTLD_DEFAULT>. |
380 | |
383 | |
|
|
384 | =head2 EVENT SYSTEM |
|
|
385 | |
|
|
386 | OpenCL can generate a number of (potentially) asynchronous events, for |
|
|
387 | example, after compiling a program, to signal a context-related error or, |
|
|
388 | perhaps most important, to signal completion of queued jobs (by setting |
|
|
389 | callbacks on OpenCL::Event objects). |
|
|
390 | |
|
|
391 | To facilitate this, this module maintains an event queue - each |
|
|
392 | time an asynchronous event happens, it is queued, and perl will be |
|
|
393 | interrupted. This is implemented via the L<Async::Interrupt> module. In |
|
|
394 | addition, this module has L<AnyEvent> support, so it can seamlessly |
|
|
395 | integrate itself into many event loops. |
|
|
396 | |
|
|
397 | Since this module is a bit hard to understand, here are some case examples: |
|
|
398 | |
|
|
399 | =head3 Don't use callbacks. |
|
|
400 | |
|
|
401 | When your program never uses any callbacks, then there will never be any |
|
|
402 | notifications you need to take care of, and therefore no need to worry |
|
|
403 | about all this. |
|
|
404 | |
|
|
405 | You can achieve a great deal by explicitly waiting for events, or using |
|
|
406 | barriers and flush calls. In many programs, there is no need at all to |
|
|
407 | tinker with asynchronous events. |
|
|
408 | |
|
|
409 | =head3 Use AnyEvent |
|
|
410 | |
|
|
411 | This module automatically registers a watcher that invokes all outstanding |
|
|
412 | event callbacks when AnyEvent is initialised (and block asynchronous |
|
|
413 | interruptions). Using this mode of operations is the safest and most |
|
|
414 | recommended one. |
|
|
415 | |
|
|
416 | To use this, simply use AnyEvent and this module normally, make sure you |
|
|
417 | have an event loop running: |
|
|
418 | |
|
|
419 | use Gtk2 -init; |
|
|
420 | use AnyEvent; |
|
|
421 | |
|
|
422 | # initialise AnyEvent, by creating a watcher, or: |
|
|
423 | AnyEvent::detect; |
|
|
424 | |
|
|
425 | my $e = $queue->enqueue_marker; |
|
|
426 | $e->cb (sub { |
|
|
427 | warn "opencl is finished\n"; |
|
|
428 | }) |
|
|
429 | |
|
|
430 | main Gtk2; |
|
|
431 | |
|
|
432 | Note that this module will not initialise AnyEvent for you. Before |
|
|
433 | AnyEvent is initialised, the module will asynchronously interrupt perl |
|
|
434 | instead. To avoid any surprises, it's best to explicitly initialise |
|
|
435 | AnyEvent. |
|
|
436 | |
|
|
437 | You can temporarily enable asynchronous interruptions (see next paragraph) |
|
|
438 | by calling C<$OpenCL::INTERRUPT->unblock> and disable them again by |
|
|
439 | calling C<$OpenCL::INTERRUPT->block>. |
|
|
440 | |
|
|
441 | =head3 Let yourself be interrupted at any time |
|
|
442 | |
|
|
443 | This mode is the default unless AnyEvent is loaded and initialised. In |
|
|
444 | this mode, OpenCL asynchronously interrupts a running perl program. The |
|
|
445 | emphasis is on both I<asynchronously> and I<running> here. |
|
|
446 | |
|
|
447 | Asynchronously means that perl might execute your callbacks at any |
|
|
448 | time. For example, in the following code (I<THAT YOU SHOULD NOT COPY>), |
|
|
449 | the C<until> loop following the marker call will be interrupted by the |
|
|
450 | callback: |
|
|
451 | |
|
|
452 | my $e = $queue->enqueue_marker; |
|
|
453 | my $flag; |
|
|
454 | $e->cb (sub { $flag = 1 }); |
|
|
455 | 1 until $flag; |
|
|
456 | # $flag is now 1 |
|
|
457 | |
|
|
458 | The reason why you shouldn't blindly copy the above code is that |
|
|
459 | busy waiting is a really really bad thing, and really really bad for |
|
|
460 | performance. |
|
|
461 | |
|
|
462 | While at first this asynchronous business might look exciting, it can be |
|
|
463 | really hard, because you need to be prepared for the callback code to be |
|
|
464 | executed at any time, which limits the amount of things the callback code |
|
|
465 | can do safely. |
|
|
466 | |
|
|
467 | This can be mitigated somewhat by using C<< |
|
|
468 | $OpenCL::INTERRUPT->scope_block >> (see the L<Async::Interrupt> |
|
|
469 | documentation for details). |
|
|
470 | |
|
|
471 | The other problem is that your program must be actively I<running> to be |
|
|
472 | interrupted. When you calculate stuff, your program is running. When you |
|
|
473 | hang in some C functions or other block execution (by calling C<sleep>, |
|
|
474 | C<select>, running an event loop and so on), your program is waiting, not |
|
|
475 | running. |
|
|
476 | |
|
|
477 | One way around that would be to attach a read watcher to your event loop, |
|
|
478 | listening for events on C<< $OpenCL::INTERRUPT->pipe_fileno >>, using a |
|
|
479 | dummy callback (C<sub { }>) to temporarily execute some perl code. |
|
|
480 | |
|
|
481 | That is then awfully close to using the built-in AnyEvent support above, |
|
|
482 | though, so consider that one instead. |
|
|
483 | |
|
|
484 | =head3 Be creative |
|
|
485 | |
|
|
486 | OpenCL exports the L<Async::Interrupt> object it uses in the global |
|
|
487 | variable C<$OpenCL::INTERRUPT>. You can configure it in any way you like. |
|
|
488 | |
|
|
489 | So if you want to feel like a real pro, err, wait, if you feel no risk |
|
|
490 | menas no fun, you can experiment by implementing your own mode of |
|
|
491 | operations. |
|
|
492 | |
381 | =cut |
493 | =cut |
382 | |
494 | |
383 | package OpenCL; |
495 | package OpenCL; |
384 | |
496 | |
385 | use common::sense; |
497 | use common::sense; |
|
|
498 | use Async::Interrupt (); |
|
|
499 | |
|
|
500 | our $POLL_FUNC; # set by XS |
386 | |
501 | |
387 | BEGIN { |
502 | BEGIN { |
388 | our $VERSION = '0.96'; |
503 | our $VERSION = '0.97'; |
389 | |
504 | |
390 | require XSLoader; |
505 | require XSLoader; |
391 | XSLoader::load (__PACKAGE__, $VERSION); |
506 | XSLoader::load (__PACKAGE__, $VERSION); |
392 | |
507 | |
393 | @OpenCL::Platform::ISA = |
508 | @OpenCL::Platform::ISA = |
… | |
… | |
440 | |
555 | |
441 | Returns all available OpenCL::Platform objects. |
556 | Returns all available OpenCL::Platform objects. |
442 | |
557 | |
443 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetPlatformIDs.html> |
558 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetPlatformIDs.html> |
444 | |
559 | |
445 | =item $ctx = OpenCL::context_from_type $properties, $type = OpenCL::DEVICE_TYPE_DEFAULT, $notify = undef |
560 | =item $ctx = OpenCL::context_from_type $properties, $type = OpenCL::DEVICE_TYPE_DEFAULT, $callback->($err, $pvt) = $print_stderr |
446 | |
561 | |
447 | Tries to create a context from a default device and platform - never worked for me. |
562 | Tries to create a context from a default device and platform type - never worked for me. |
448 | |
563 | |
449 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContextFromType.html> |
564 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContextFromType.html> |
450 | |
565 | |
|
|
566 | =item $ctx = OpenCL::context $properties, \@devices, $callback->($err, $pvt) = $print_stderr) |
|
|
567 | |
|
|
568 | Create a new OpenCL::Context object using the given device object(s). This |
|
|
569 | function isn't implemented yet, use C<< $platform->context >> instead. |
|
|
570 | |
|
|
571 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContext.html> |
|
|
572 | |
451 | =item OpenCL::wait_for_events $wait_events... |
573 | =item OpenCL::wait_for_events $wait_events... |
452 | |
574 | |
453 | Waits for all events to complete. |
575 | Waits for all events to complete. |
454 | |
576 | |
455 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clWaitForEvents.html> |
577 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clWaitForEvents.html> |
|
|
578 | |
|
|
579 | =item OpenCL::poll |
|
|
580 | |
|
|
581 | Checks if there are any outstanding events (see L<EVENT SYSTEM>) and |
|
|
582 | invokes their callbacks. |
|
|
583 | |
|
|
584 | =item $OpenCL::INTERRUPT |
|
|
585 | |
|
|
586 | The L<Async::Interrupt> object used to signal asynchronous events (see |
|
|
587 | L<EVENT SYSTEM>). |
|
|
588 | |
|
|
589 | =cut |
|
|
590 | |
|
|
591 | our $INTERRUPT = new Async::Interrupt c_cb => [$POLL_FUNC, 0]; |
|
|
592 | |
|
|
593 | &_eq_initialise ($INTERRUPT->signal_func); |
|
|
594 | |
|
|
595 | =item $OpenCL::WATCHER |
|
|
596 | |
|
|
597 | The L<AnyEvent> watcher object used to watch for asynchronous events (see |
|
|
598 | L<EVENT SYSTEM>). This variable is C<undef> until L<AnyEvent> has been |
|
|
599 | loaded I<and> initialised (e.g. by calling C<AnyEvent::detect>). |
|
|
600 | |
|
|
601 | =cut |
|
|
602 | |
|
|
603 | our $WATCHER; |
|
|
604 | |
|
|
605 | sub _init_anyevent { |
|
|
606 | $INTERRUPT->block; |
|
|
607 | $WATCHER = AE::io ($INTERRUPT->pipe_fileno, 0, sub { $INTERRUPT->handle }); |
|
|
608 | } |
|
|
609 | |
|
|
610 | if (defined $AnyEvent::MODEL) { |
|
|
611 | _init_anyevent; |
|
|
612 | } else { |
|
|
613 | push @AnyEvent::post_detect, \&_init_anyevent; |
|
|
614 | } |
456 | |
615 | |
457 | =back |
616 | =back |
458 | |
617 | |
459 | =head2 THE OpenCL::Object CLASS |
618 | =head2 THE OpenCL::Object CLASS |
460 | |
619 | |
… | |
… | |
472 | C<IV> type in your code and cast that to the correct type. |
631 | C<IV> type in your code and cast that to the correct type. |
473 | |
632 | |
474 | =cut |
633 | =cut |
475 | |
634 | |
476 | sub OpenCL::Object::id { |
635 | sub OpenCL::Object::id { |
|
|
636 | ref $_[0] eq "SCALAR" |
477 | ${$_[0]} |
637 | ? ${ $_[0] } |
|
|
638 | : $_[0][0] |
478 | } |
639 | } |
479 | |
640 | |
480 | =back |
641 | =back |
481 | |
642 | |
482 | =head2 THE OpenCL::Platform CLASS |
643 | =head2 THE OpenCL::Platform CLASS |
… | |
… | |
485 | |
646 | |
486 | =item @devices = $platform->devices ($type = OpenCL::DEVICE_TYPE_ALL) |
647 | =item @devices = $platform->devices ($type = OpenCL::DEVICE_TYPE_ALL) |
487 | |
648 | |
488 | Returns a list of matching OpenCL::Device objects. |
649 | Returns a list of matching OpenCL::Device objects. |
489 | |
650 | |
490 | =item $ctx = $platform->context_from_type ($properties, $type = OpenCL::DEVICE_TYPE_DEFAULT, $notify = undef) |
651 | =item $ctx = $platform->context_from_type ($properties, $type = OpenCL::DEVICE_TYPE_DEFAULT, $callback->($err, $pvt) = $print_stderr) |
491 | |
652 | |
492 | Tries to create a context. Never worked for me, and you need devices explicitly anyway. |
653 | Tries to create a context. Never worked for me, and you need devices explicitly anyway. |
493 | |
654 | |
494 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContextFromType.html> |
655 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContextFromType.html> |
495 | |
656 | |
496 | =item $ctx = $platform->context ($properties = undef, @$devices, $notify = undef) |
657 | =item $ctx = $platform->context ($properties, \@devices, $callback->($err, $pvt) = $print_stderr) |
497 | |
658 | |
498 | Create a new OpenCL::Context object using the given device object(s)- a |
659 | Create a new OpenCL::Context object using the given device object(s)- a |
499 | CL_CONTEXT_PLATFORM property is supplied automatically. |
660 | CL_CONTEXT_PLATFORM property is supplied automatically. |
500 | |
661 | |
501 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContext.html> |
662 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateContext.html> |
… | |
… | |
841 | =cut |
1002 | =cut |
842 | |
1003 | |
843 | sub OpenCL::Context::build_program { |
1004 | sub OpenCL::Context::build_program { |
844 | my ($self, $prog, $options) = @_; |
1005 | my ($self, $prog, $options) = @_; |
845 | |
1006 | |
|
|
1007 | require Carp; |
|
|
1008 | |
846 | $prog = $self->program_with_source ($prog) |
1009 | $prog = $self->program_with_source ($prog) |
847 | unless ref $prog; |
1010 | unless ref $prog; |
848 | |
1011 | |
|
|
1012 | # we build separately per device so we instantly know which one failed |
849 | for my $dev ($self->devices) { |
1013 | for my $dev ($self->devices) { |
850 | eval { $prog->build ($dev, $options); 1 } |
1014 | eval { $prog->build ([$dev], $options); 1 } |
851 | or Carp::croak "Building OpenCL program for device '" . $dev->name . "' failed:\n" |
1015 | or Carp::croak ("Building OpenCL program for device '" . $dev->name . "' failed:\n" |
852 | . $prog->build_log ($dev); |
1016 | . $prog->build_log ($dev)); |
853 | } |
1017 | } |
854 | |
1018 | |
855 | $prog |
1019 | $prog |
856 | } |
1020 | } |
857 | |
1021 | |
… | |
… | |
1080 | |
1244 | |
1081 | =item $ev = $queue->enqueue_task ($kernel, $wait_events...) |
1245 | =item $ev = $queue->enqueue_task ($kernel, $wait_events...) |
1082 | |
1246 | |
1083 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueTask.html> |
1247 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueTask.html> |
1084 | |
1248 | |
1085 | =item $ev = $queue->enqueue_nd_range_kernel ($kernel, @$global_work_offset, @$global_work_size, @$local_work_size, $wait_events...) |
1249 | =item $ev = $queue->enqueue_nd_range_kernel ($kernel, \@global_work_offset, \@global_work_size, \@local_work_size, $wait_events...) |
1086 | |
1250 | |
1087 | Enqueues a kernel execution. |
1251 | Enqueues a kernel execution. |
1088 | |
1252 | |
1089 | @$global_work_size must be specified as a reference to an array of |
1253 | \@global_work_size must be specified as a reference to an array of |
1090 | integers specifying the work sizes (element counts). |
1254 | integers specifying the work sizes (element counts). |
1091 | |
1255 | |
1092 | @$global_work_offset must be either C<undef> (in which case all offsets |
1256 | \@global_work_offset must be either C<undef> (in which case all offsets |
1093 | are C<0>), or a reference to an array of work offsets, with the same number |
1257 | are C<0>), or a reference to an array of work offsets, with the same number |
1094 | of elements as @$global_work_size. |
1258 | of elements as \@global_work_size. |
1095 | |
1259 | |
1096 | @$local_work_size must be either C<undef> (in which case the |
1260 | \@local_work_size must be either C<undef> (in which case the |
1097 | implementation is supposed to choose good local work sizes), or a |
1261 | implementation is supposed to choose good local work sizes), or a |
1098 | reference to an array of local work sizes, with the same number of |
1262 | reference to an array of local work sizes, with the same number of |
1099 | elements as @$global_work_size. |
1263 | elements as \@global_work_size. |
1100 | |
1264 | |
1101 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueNDRangeKernel.html> |
1265 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueNDRangeKernel.html> |
1102 | |
1266 | |
1103 | =item $ev = $queue->enqueue_acquire_gl_objects ([object, ...], $wait_events...) |
1267 | =item $ev = $queue->enqueue_acquire_gl_objects ([object, ...], $wait_events...) |
1104 | |
1268 | |
… | |
… | |
1349 | |
1513 | |
1350 | =head2 THE OpenCL::Program CLASS |
1514 | =head2 THE OpenCL::Program CLASS |
1351 | |
1515 | |
1352 | =over 4 |
1516 | =over 4 |
1353 | |
1517 | |
1354 | =item $program->build ($device, $options = "") |
1518 | =item $program->build (\@devices = undef, $options = "", $cb->($program) = undef) |
1355 | |
1519 | |
1356 | Tries to build the program with the given options. See also the |
1520 | Tries to build the program with the given options. See also the |
1357 | C<$ctx->build> convenience function. |
1521 | C<$ctx->build> convenience function. |
1358 | |
1522 | |
|
|
1523 | If a callback is specified, then it will be called when compilation is |
|
|
1524 | finished. Note that many OpenCL implementations block your program while |
|
|
1525 | compiling whether you use a callback or not. See C<build_async> if you |
|
|
1526 | want to make sure the build is done in the background. |
|
|
1527 | |
|
|
1528 | Note that some OpenCL implementations atc up badly, and don't call the |
|
|
1529 | callback in some error cases (but call it in others). This implementation |
|
|
1530 | assumes the callback will always be called, and leaks memory if this is |
|
|
1531 | not so. So best make sure you don't pass in invalid values. |
|
|
1532 | |
1359 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clBuildProgram.html> |
1533 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clBuildProgram.html> |
|
|
1534 | |
|
|
1535 | =item $program->build_async (\@devices = undef, $options = "", $cb->($program) = undef) |
|
|
1536 | |
|
|
1537 | Similar to C<< ->build >>, except it starts a thread, and never fails (you |
|
|
1538 | need to check the compilation status form the callback, or by polling). |
1360 | |
1539 | |
1361 | =item $packed_value = $program->build_info ($device, $name) |
1540 | =item $packed_value = $program->build_info ($device, $name) |
1362 | |
1541 | |
1363 | Similar to C<< $platform->info >>, but returns build info for a previous |
1542 | Similar to C<< $platform->info >>, but returns build info for a previous |
1364 | build attempt for the given device. |
1543 | build attempt for the given device. |
… | |
… | |
1506 | |
1685 | |
1507 | Calls C<clGetKernelWorkGroupInfo> with C<CL_KERNEL_PRIVATE_MEM_SIZE> and returns the result. |
1686 | Calls C<clGetKernelWorkGroupInfo> with C<CL_KERNEL_PRIVATE_MEM_SIZE> and returns the result. |
1508 | |
1687 | |
1509 | =for gengetinfo end kernel_work_group |
1688 | =for gengetinfo end kernel_work_group |
1510 | |
1689 | |
1511 | =item $kernel->set_TYPE ($index, $value) |
1690 | =item $kernel->set_TYPE ($index, $value) |
1512 | |
1691 | |
|
|
1692 | =item $kernel->set_char ($index, $value) |
|
|
1693 | |
|
|
1694 | =item $kernel->set_uchar ($index, $value) |
|
|
1695 | |
|
|
1696 | =item $kernel->set_short ($index, $value) |
|
|
1697 | |
|
|
1698 | =item $kernel->set_ushort ($index, $value) |
|
|
1699 | |
|
|
1700 | =item $kernel->set_int ($index, $value) |
|
|
1701 | |
|
|
1702 | =item $kernel->set_uint ($index, $value) |
|
|
1703 | |
|
|
1704 | =item $kernel->set_long ($index, $value) |
|
|
1705 | |
|
|
1706 | =item $kernel->set_ulong ($index, $value) |
|
|
1707 | |
|
|
1708 | =item $kernel->set_half ($index, $value) |
|
|
1709 | |
|
|
1710 | =item $kernel->set_float ($index, $value) |
|
|
1711 | |
|
|
1712 | =item $kernel->set_double ($index, $value) |
|
|
1713 | |
|
|
1714 | =item $kernel->set_memory ($index, $value) |
|
|
1715 | |
|
|
1716 | =item $kernel->set_buffer ($index, $value) |
|
|
1717 | |
|
|
1718 | =item $kernel->set_image ($index, $value) |
|
|
1719 | |
|
|
1720 | =item $kernel->set_sampler ($index, $value) |
|
|
1721 | |
|
|
1722 | =item $kernel->set_local ($index, $value) |
|
|
1723 | |
|
|
1724 | =item $kernel->set_event ($index, $value) |
|
|
1725 | |
1513 | This is a family of methods to set the kernel argument with the number C<$index> to the give C<$value>. |
1726 | This is a family of methods to set the kernel argument with the number |
1514 | |
1727 | C<$index> to the give C<$value>. |
1515 | TYPE is one of C<char>, C<uchar>, C<short>, C<ushort>, C<int>, C<uint>, |
|
|
1516 | C<long>, C<ulong>, C<half>, C<float>, C<double>, C<memory>, C<buffer>, |
|
|
1517 | C<image2d>, C<image3d>, C<sampler>, C<local> or C<event>. |
|
|
1518 | |
1728 | |
1519 | Chars and integers (including the half type) are specified as integers, |
1729 | Chars and integers (including the half type) are specified as integers, |
1520 | float and double as floating point values, memory/buffer/image2d/image3d |
1730 | float and double as floating point values, memory/buffer/image must be |
1521 | must be an object of that type or C<undef>, local-memory arguments are |
1731 | an object of that type or C<undef>, local-memory arguments are set by |
1522 | set by specifying the size, and sampler and event must be objects of that |
1732 | specifying the size, and sampler and event must be objects of that type. |
1523 | type. |
1733 | |
|
|
1734 | Note that C<set_memory> works for all memory objects (all types of buffers |
|
|
1735 | and images) - the main purpose of the more specific C<set_TYPE> functions |
|
|
1736 | is type checking. |
1524 | |
1737 | |
1525 | Setting an argument for a kernel does NOT keep a reference to the object - |
1738 | Setting an argument for a kernel does NOT keep a reference to the object - |
1526 | for example, if you set an argument to some image object, free the image, |
1739 | for example, if you set an argument to some image object, free the image, |
1527 | and call the kernel, you will run into undefined behaviour. |
1740 | and call the kernel, you will run into undefined behaviour. |
1528 | |
1741 | |
… | |
… | |
1541 | |
1754 | |
1542 | Waits for the event to complete. |
1755 | Waits for the event to complete. |
1543 | |
1756 | |
1544 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clWaitForEvents.html> |
1757 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clWaitForEvents.html> |
1545 | |
1758 | |
|
|
1759 | =item $ev->cb ($exec_callback_type, $callback->($event, $event_command_exec_status)) |
|
|
1760 | |
|
|
1761 | Adds a callback to the callback stack for the given event type. There is |
|
|
1762 | no way to remove a callback again. |
|
|
1763 | |
|
|
1764 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clSetEventCallback.html> |
|
|
1765 | |
1546 | =item $packed_value = $ev->info ($name) |
1766 | =item $packed_value = $ev->info ($name) |
1547 | |
1767 | |
1548 | See C<< $platform->info >> for details. |
1768 | See C<< $platform->info >> for details. |
1549 | |
1769 | |
1550 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetEventInfo.html> |
1770 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetEventInfo.html> |
… | |
… | |
1610 | |
1830 | |
1611 | =over 4 |
1831 | =over 4 |
1612 | |
1832 | |
1613 | =item $ev->set_status ($execution_status) |
1833 | =item $ev->set_status ($execution_status) |
1614 | |
1834 | |
|
|
1835 | Sets the execution status of the user event. Can only be called once, |
|
|
1836 | either with OpenCL::COMPLETE or a negative number as status. |
|
|
1837 | |
1615 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clSetUserEventStatus.html> |
1838 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clSetUserEventStatus.html> |
1616 | |
1839 | |
1617 | =back |
1840 | =back |
1618 | |
1841 | |
1619 | =cut |
1842 | =cut |