[Mesa-dev] [PATCH 1/2] clover: support CL_PROGRAM_BINARY_TYPE (CL1.2)

EdB edb+mesa at sigluy.net
Fri Dec 19 07:42:50 PST 2014


CL_PROGRAM_BINARY_TYPE have been added to clGetProgramBuildInfo in CL1.2
---
 src/gallium/state_trackers/clover/api/program.cpp  |  4 +++
 src/gallium/state_trackers/clover/core/program.cpp | 31 +++++++++++++++++-----
 src/gallium/state_trackers/clover/core/program.hpp |  1 +
 3 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/src/gallium/state_trackers/clover/api/program.cpp b/src/gallium/state_trackers/clover/api/program.cpp
index be97ae5..9373fac 100644
--- a/src/gallium/state_trackers/clover/api/program.cpp
+++ b/src/gallium/state_trackers/clover/api/program.cpp
@@ -363,6 +363,10 @@ clGetProgramBuildInfo(cl_program d_prog, cl_device_id d_dev,
       buf.as_string() = prog.build_log(dev);
       break;
 
+   case CL_PROGRAM_BINARY_TYPE:
+      buf.as_scalar<cl_program_binary_type>() = prog.binary_type(dev);
+      break;
+
    default:
       throw error(CL_INVALID_VALUE);
    }
diff --git a/src/gallium/state_trackers/clover/core/program.cpp b/src/gallium/state_trackers/clover/core/program.cpp
index 8bece05..5fcde2c 100644
--- a/src/gallium/state_trackers/clover/core/program.cpp
+++ b/src/gallium/state_trackers/clover/core/program.cpp
@@ -147,14 +147,11 @@ program::has_executable() const {
 
 bool
 program::has_linkable(const device &dev) const {
-   const auto bin = _binaries.find(&dev);
+   cl_program_binary_type type = binary_type(dev);
 
-   if (bin != _binaries.end()) {
-      const auto &secs = bin->second.secs;
-      if (any_of(type_equals(module::section::text_compiled), secs) ||
-          any_of(type_equals(module::section::text_library), secs))
-         return true;
-   }
+   if (type == CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT ||
+       type == CL_PROGRAM_BINARY_TYPE_LIBRARY)
+      return true;
 
    return false;
 }
@@ -192,6 +189,26 @@ program::build_log(const device &dev) const {
    return _logs.count(&dev) ? _logs.find(&dev)->second : "";
 }
 
+cl_program_binary_type
+program::binary_type(const device &dev) const {
+   const auto bin = _binaries.find(&dev);
+
+   if (bin != _binaries.end()) {
+      const auto &secs = bin->second.secs;
+
+      if (any_of(type_equals(module::section::text_compiled), secs))
+         return CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT;
+
+      if (any_of(type_equals(module::section::text_library), secs))
+         return CL_PROGRAM_BINARY_TYPE_LIBRARY;
+
+      if (any_of(type_equals(module::section::text_executable), secs))
+         return CL_PROGRAM_BINARY_TYPE_EXECUTABLE;
+   }
+
+   return CL_PROGRAM_BINARY_TYPE_NONE;
+}
+
 const compat::vector<module::symbol> &
 program::symbols() const {
    if (_binaries.empty())
diff --git a/src/gallium/state_trackers/clover/core/program.hpp b/src/gallium/state_trackers/clover/core/program.hpp
index 19c4420..13abc21 100644
--- a/src/gallium/state_trackers/clover/core/program.hpp
+++ b/src/gallium/state_trackers/clover/core/program.hpp
@@ -63,6 +63,7 @@ namespace clover {
       cl_build_status build_status(const device &dev) const;
       std::string build_opts(const device &dev) const;
       std::string build_log(const device &dev) const;
+      cl_program_binary_type binary_type(const device &dev) const;
 
       const compat::vector<module::symbol> &symbols() const;
 
-- 
2.2.0



More information about the mesa-dev mailing list