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

Comparing OpenCL/OpenCL.pm (file contents):
Revision 1.61 by root, Sat Apr 28 13:31:40 2012 UTC vs.
Revision 1.63 by root, Sun Apr 29 18:24:35 2012 UTC

493=cut 493=cut
494 494
495package OpenCL; 495package OpenCL;
496 496
497use common::sense; 497use common::sense;
498use Carp ();
498use Async::Interrupt (); 499use Async::Interrupt ();
499 500
500our $POLL_FUNC; # set by XS 501our $POLL_FUNC; # set by XS
501 502
502BEGIN { 503BEGIN {
503 our $VERSION = '0.97'; 504 our $VERSION = '0.98';
504 505
505 require XSLoader; 506 require XSLoader;
506 XSLoader::load (__PACKAGE__, $VERSION); 507 XSLoader::load (__PACKAGE__, $VERSION);
507 508
508 @OpenCL::Platform::ISA = 509 @OpenCL::Platform::ISA =
1003=cut 1004=cut
1004 1005
1005sub OpenCL::Context::build_program { 1006sub OpenCL::Context::build_program {
1006 my ($self, $prog, $options) = @_; 1007 my ($self, $prog, $options) = @_;
1007 1008
1008 require Carp;
1009
1010 $prog = $self->program_with_source ($prog) 1009 $prog = $self->program_with_source ($prog)
1011 unless ref $prog; 1010 unless ref $prog;
1012 1011
1013 eval { $prog->build (undef, $options); 1 } 1012 eval { $prog->build (undef, $options); 1 }
1014 or errno == BUILD_PROGRAM_FAILURE 1013 or errno == BUILD_PROGRAM_FAILURE
1014 or errno == INVALID_BINARY # workaround nvidia bug
1015 or Carp::croak "OpenCL::Context->build_program: " . err2str; 1015 or Carp::croak "OpenCL::Context->build_program: " . err2str;
1016 1016
1017 # we check status for all devices 1017 # we check status for all devices
1018 for my $dev ($self->devices) { 1018 for my $dev ($self->devices) {
1019 $prog->build_status ($dev) == BUILD_SUCCESS 1019 $prog->build_status ($dev) == BUILD_SUCCESS
1020 or Carp::croak ("Building OpenCL program for device '" . $dev->name . "' failed:\n" 1020 or Carp::croak "Building OpenCL program for device '" . $dev->name . "' failed:\n"
1021 . $prog->build_log ($dev)); 1021 . $prog->build_log ($dev);
1022 } 1022 }
1023 1023
1024 $prog 1024 $prog
1025} 1025}
1026 1026
1529If a callback is specified, then it will be called when compilation is 1529If a callback is specified, then it will be called when compilation is
1530finished. Note that many OpenCL implementations block your program while 1530finished. Note that many OpenCL implementations block your program while
1531compiling whether you use a callback or not. See C<build_async> if you 1531compiling whether you use a callback or not. See C<build_async> if you
1532want to make sure the build is done in the background. 1532want to make sure the build is done in the background.
1533 1533
1534Note that some OpenCL implementations atc up badly, and don't call the 1534Note that some OpenCL implementations act up badly, and don't call the
1535callback in some error cases (but call it in others). This implementation 1535callback in some error cases (but call it in others). This implementation
1536assumes the callback will always be called, and leaks memory if this is 1536assumes the callback will always be called, and leaks memory if this is
1537not so. So best make sure you don't pass in invalid values. 1537not so. So best make sure you don't pass in invalid values.
1538
1539Some implementations fail with C<OpenCL::INVALID_BINARY> when the
1540compilation state is successful but some later stage fails.
1538 1541
1539L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clBuildProgram.html> 1542L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clBuildProgram.html>
1540 1543
1541=item $program->build_async (\@devices = undef, $options = "", $cb->($program) = undef) 1544=item $program->build_async (\@devices = undef, $options = "", $cb->($program) = undef)
1542 1545

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines