clover: Check for executables before enqueueing a kernel
authorPierre Moreau <pierre.morrow@free.fr>
Thu, 29 Dec 2016 23:29:20 +0000 (00:29 +0100)
committerFrancisco Jerez <currojerez@riseup.net>
Thu, 12 Jan 2017 00:50:56 +0000 (16:50 -0800)
Without this check, the kernel::bind() method would fail with a
std::out_of_range exception, letting an exception escape from the
library into the client, rather than returning the corresponding error
code CL_INVALID_PROGRAM_EXECUTABLE.

Signed-off-by: Pierre Moreau <pierre.morrow@free.fr>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
src/gallium/state_trackers/clover/api/kernel.cpp

index 73ba34abe8ea234e8ea7e9eefce541a12b1316fe..b665773d9ecd24c808fca13ad3da51cc2f2c2805 100644 (file)
@@ -215,7 +215,10 @@ namespace {
             }, kern.args()))
          throw error(CL_INVALID_KERNEL_ARGS);
 
-      if (!count(q.device(), kern.program().devices()))
+      // If the command queue's device is not associated to the program, we get
+      // a module, with no sections, which will also fail the following test.
+      auto &m = kern.program().build(q.device()).binary;
+      if (!any_of(type_equals(module::section::text_executable), m.secs))
          throw error(CL_INVALID_PROGRAM_EXECUTABLE);
    }