[Mesa-dev] [PATCH 3/3] clover: add clLinkProgramm for CL 1.2

EdB edb+mesa at sigluy.net
Sun Jul 5 04:38:39 PDT 2015


---
 src/gallium/state_trackers/clover/api/dispatch.cpp |  2 +-
 src/gallium/state_trackers/clover/api/program.cpp  | 31 ++++++++++++++++++++++
 src/gallium/state_trackers/clover/core/program.cpp |  4 +++
 src/gallium/state_trackers/clover/core/program.hpp |  1 +
 4 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/clover/api/dispatch.cpp b/src/gallium/state_trackers/clover/api/dispatch.cpp
index b5a4094..44bff4f 100644
--- a/src/gallium/state_trackers/clover/api/dispatch.cpp
+++ b/src/gallium/state_trackers/clover/api/dispatch.cpp
@@ -123,7 +123,7 @@ namespace clover {
       clCreateImage,
       clCreateProgramWithBuiltInKernels,
       clCompileProgram,
-      NULL, // clLinkProgram
+      clLinkProgram,
       clUnloadPlatformCompiler,
       NULL, // clGetKernelArgInfo
       NULL, // clEnqueueFillBuffer
diff --git a/src/gallium/state_trackers/clover/api/program.cpp b/src/gallium/state_trackers/clover/api/program.cpp
index 2441d81..d532b66 100644
--- a/src/gallium/state_trackers/clover/api/program.cpp
+++ b/src/gallium/state_trackers/clover/api/program.cpp
@@ -227,6 +227,37 @@ clCompileProgram(cl_program d_prog, cl_uint num_devs,
    return e.get();
 }
 
+CLOVER_API cl_program
+clLinkProgram (cl_context d_ctx, cl_uint num_devs, const cl_device_id *d_devs,
+               const char *p_opts, cl_uint num_progs, const cl_program *d_progs,
+               void (*pfn_notify) (cl_program, void *), void *user_data,
+               cl_int *r_errcode) try {
+   auto &ctx = obj(d_ctx);
+   auto devs = (d_devs ? objs(d_devs, num_devs) :
+                ref_vector<device>(ctx.devices()));
+   auto opts = (p_opts ? p_opts : "");
+   auto progs = objs(d_progs, num_progs);
+
+   if ((!pfn_notify && user_data))
+         throw error(CL_INVALID_VALUE);
+
+   if (any_of([&](const device &dev) {
+            return !count(dev, ctx.devices());
+         }, objs<allow_empty_tag>(d_devs, num_devs)))
+      throw error(CL_INVALID_DEVICE);
+
+   auto prog = create<program>(ctx);
+   if (prog().link(devs, opts, progs))
+      *r_errcode = CL_SUCCESS;
+   else
+      *r_errcode = CL_LINK_PROGRAM_FAILURE;
+
+   return ret_object(prog);
+} catch (error &e) {
+   ret_error(r_errcode, e);
+   return NULL;
+}
+
 CLOVER_API cl_int
 clUnloadCompiler() {
    return CL_SUCCESS;
diff --git a/src/gallium/state_trackers/clover/core/program.cpp b/src/gallium/state_trackers/clover/core/program.cpp
index 21faf4e..825537f 100644
--- a/src/gallium/state_trackers/clover/core/program.cpp
+++ b/src/gallium/state_trackers/clover/core/program.cpp
@@ -24,6 +24,10 @@
 
 using namespace clover;
 
+program::program(clover::context &ctx) :
+   has_source(false), context(ctx), _kernel_ref_counter(0) {
+}
+
 program::program(clover::context &ctx, const std::string &source) :
    has_source(true), context(ctx), _source(source), _kernel_ref_counter(0) {
 }
diff --git a/src/gallium/state_trackers/clover/core/program.hpp b/src/gallium/state_trackers/clover/core/program.hpp
index 314979b..a1036b7 100644
--- a/src/gallium/state_trackers/clover/core/program.hpp
+++ b/src/gallium/state_trackers/clover/core/program.hpp
@@ -37,6 +37,7 @@ namespace clover {
          evals, const std::vector<intrusive_ref<device>> &> device_range;
 
    public:
+      program(clover::context &ctx);
       program(clover::context &ctx,
               const std::string &source);
       program(clover::context &ctx,
-- 
2.4.3



More information about the mesa-dev mailing list