[Mesa-dev] [PATCH v6 3/3] clover: add clLinkProgram (CL 1.2)
Serge Martin
edb+mesa at sigluy.net
Thu Dec 31 08:19:41 PST 2015
Reviewed-by: Francisco Jerez <currojerez at riseup.net>
---
src/gallium/state_trackers/clover/api/program.cpp | 31 +++++++++++++++++++---
src/gallium/state_trackers/clover/core/program.hpp | 4 +--
2 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/src/gallium/state_trackers/clover/api/program.cpp b/src/gallium/state_trackers/clover/api/program.cpp
index f8d946e..4176562 100644
--- a/src/gallium/state_trackers/clover/api/program.cpp
+++ b/src/gallium/state_trackers/clover/api/program.cpp
@@ -241,10 +241,33 @@ clCompileProgram(cl_program d_prog, cl_uint num_devs,
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) {
- CLOVER_NOT_SUPPORTED_UNTIL("1.2");
- ret_error(r_errcode, CL_LINKER_NOT_AVAILABLE);
+ 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);
+ try {
+ prog().link(devs, opts, progs);
+ ret_error(r_errcode, CL_SUCCESS);
+ } catch (link_error &e) {
+ ret_error(r_errcode, CL_LINK_PROGRAM_FAILURE);
+ }
+
+ return ret_object(prog);
+} catch (error &e) {
+ ret_error(r_errcode, e);
return NULL;
}
diff --git a/src/gallium/state_trackers/clover/core/program.hpp b/src/gallium/state_trackers/clover/core/program.hpp
index 7d86018..a70ed08 100644
--- a/src/gallium/state_trackers/clover/core/program.hpp
+++ b/src/gallium/state_trackers/clover/core/program.hpp
@@ -40,8 +40,8 @@ namespace clover {
program(clover::context &ctx,
const std::string &source);
program(clover::context &ctx,
- const ref_vector<device> &devs,
- const std::vector<module> &binaries);
+ const ref_vector<device> &devs = {},
+ const std::vector<module> &binaries = {});
program(const program &prog) = delete;
program &
--
2.5.0
More information about the mesa-dev
mailing list