[Mesa-dev] [PATCH v10 07/20] clover/api: Fail if trying to build a non-executable binary

Pierre Moreau pierre.morrow at free.fr
Tue Jan 8 21:10:56 UTC 2019


>From the OpenCL 1.2 Specification, Section 5.6.2 (about clBuildProgram):

> If program is created with clCreateProgramWithBinary, then the
> program binary must be an executable binary (not a compiled binary or
> library).

Reviewed-by: Aaron Watry <awatry at gmail.com>
Signed-off-by: Pierre Moreau <pierre.morrow at free.fr>
---
 src/gallium/state_trackers/clover/api/program.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/gallium/state_trackers/clover/api/program.cpp b/src/gallium/state_trackers/clover/api/program.cpp
index 891a002f3d0..ac8bc8a5630 100644
--- a/src/gallium/state_trackers/clover/api/program.cpp
+++ b/src/gallium/state_trackers/clover/api/program.cpp
@@ -186,6 +186,13 @@ clBuildProgram(cl_program d_prog, cl_uint num_devs,
    if (prog.has_source) {
       prog.compile(devs, opts);
       prog.link(devs, opts, { prog });
+   } else if (any_of([&](const device &dev){
+         return prog.build(dev).binary_type() != CL_PROGRAM_BINARY_TYPE_EXECUTABLE;
+         }, devs)) {
+      // According to the OpenCL 1.2 specification, “if program is created
+      // with clCreateProgramWithBinary, then the program binary must be an
+      // executable binary (not a compiled binary or library).”
+      throw error(CL_INVALID_BINARY);
    }
 
    return CL_SUCCESS;
-- 
2.20.1



More information about the mesa-dev mailing list