[Mesa-dev] [PATCH] clover: Check for executables before enqueueing a kernel

2016-12-29 Thread Pierre Moreau
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 
---
 src/gallium/state_trackers/clover/api/kernel.cpp | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/clover/api/kernel.cpp 
b/src/gallium/state_trackers/clover/api/kernel.cpp
index 73ba34abe8..e3d75af972 100644
--- a/src/gallium/state_trackers/clover/api/kernel.cpp
+++ b/src/gallium/state_trackers/clover/api/kernel.cpp
@@ -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);
}
 
-- 
2.11.0

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] clover: Check for executables before enqueueing a kernel

2016-12-29 Thread Francisco Jerez
Pierre Moreau  writes:

> 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 

Reviewed-by: Francisco Jerez 

> ---
>  src/gallium/state_trackers/clover/api/kernel.cpp | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/state_trackers/clover/api/kernel.cpp 
> b/src/gallium/state_trackers/clover/api/kernel.cpp
> index 73ba34abe8..e3d75af972 100644
> --- a/src/gallium/state_trackers/clover/api/kernel.cpp
> +++ b/src/gallium/state_trackers/clover/api/kernel.cpp
> @@ -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);
> }
>  
> -- 
> 2.11.0


signature.asc
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev