diff options
author | Francisco Jerez <[email protected]> | 2016-05-17 16:03:14 +0200 |
---|---|---|
committer | Francisco Jerez <[email protected]> | 2016-07-11 20:34:35 -0700 |
commit | 010918f5aa78f51dda6c98a639f6f4422e9be2e5 (patch) | |
tree | 26fdc4b7bd72f852e517ade678a09613b699f642 /src/gallium/state_trackers/clover | |
parent | 1942490bae01d44a08f263ea2dc747d11c82acfe (diff) |
clover: Provide separate program methods for compilation and linking.
[ Serge Martin: Fix inverted opts and log build ctor args.
Keep the log related to the build. Fix indentation ]
Reviewed-by: Serge Martin <[email protected]>
Tested-by: Jan Vesely <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/clover')
-rw-r--r-- | src/gallium/state_trackers/clover/api/program.cpp | 8 | ||||
-rw-r--r-- | src/gallium/state_trackers/clover/core/program.cpp | 34 | ||||
-rw-r--r-- | src/gallium/state_trackers/clover/core/program.hpp | 12 |
3 files changed, 42 insertions, 12 deletions
diff --git a/src/gallium/state_trackers/clover/api/program.cpp b/src/gallium/state_trackers/clover/api/program.cpp index 91a81dfcc85..2dc9ee74f87 100644 --- a/src/gallium/state_trackers/clover/api/program.cpp +++ b/src/gallium/state_trackers/clover/api/program.cpp @@ -181,7 +181,11 @@ clBuildProgram(cl_program d_prog, cl_uint num_devs, validate_build_program_common(prog, num_devs, d_devs, pfn_notify, user_data); - prog.build(devs, opts); + if (prog.has_source) { + prog.compile(devs, opts); + prog.link(devs, opts, { prog }); + } + return CL_SUCCESS; } catch (error &e) { @@ -221,7 +225,7 @@ clCompileProgram(cl_program d_prog, cl_uint num_devs, range(header_names, num_headers), objs<allow_empty_tag>(d_header_progs, num_headers)); - prog.build(devs, opts, headers); + prog.compile(devs, opts, headers); return CL_SUCCESS; } catch (invalid_build_options_error &e) { diff --git a/src/gallium/state_trackers/clover/core/program.cpp b/src/gallium/state_trackers/clover/core/program.cpp index 87a97cb1bff..79ac85117e3 100644 --- a/src/gallium/state_trackers/clover/core/program.cpp +++ b/src/gallium/state_trackers/clover/core/program.cpp @@ -21,6 +21,7 @@ // #include "core/program.hpp" +#include "llvm/invocation.hpp" #include "tgsi/invocation.hpp" using namespace clover; @@ -41,8 +42,8 @@ program::program(clover::context &ctx, } void -program::build(const ref_vector<device> &devs, const std::string &opts, - const header_map &headers) { +program::compile(const ref_vector<device> &devs, const std::string &opts, + const header_map &headers) { if (has_source) { _devices = devs; @@ -52,9 +53,8 @@ program::build(const ref_vector<device> &devs, const std::string &opts, try { const module m = (dev.ir_format() == PIPE_SHADER_IR_TGSI ? tgsi::compile_program(_source, log) : - compile_program_llvm(_source, headers, - dev.ir_format(), - dev.ir_target(), opts, log)); + llvm::compile_program(_source, headers, + dev.ir_target(), opts, log)); _builds[&dev] = { m, opts, log }; } catch (...) { _builds[&dev] = { module(), opts, log }; @@ -64,6 +64,30 @@ program::build(const ref_vector<device> &devs, const std::string &opts, } } +void +program::link(const ref_vector<device> &devs, const std::string &opts, + const ref_vector<program> &progs) { + _devices = devs; + + for (auto &dev : devs) { + const std::vector<module> ms = map([&](const program &prog) { + return prog.build(dev).binary; + }, progs); + std::string log = _builds[&dev].log; + + try { + const module m = (dev.ir_format() == PIPE_SHADER_IR_TGSI ? + tgsi::link_program(ms) : + llvm::link_program(ms, dev.ir_format(), + dev.ir_target(), opts, log)); + _builds[&dev] = { m, opts, log }; + } catch (...) { + _builds[&dev] = { module(), opts, log }; + throw; + } + } +} + const std::string & program::source() const { return _source; diff --git a/src/gallium/state_trackers/clover/core/program.hpp b/src/gallium/state_trackers/clover/core/program.hpp index ade225d29ae..95dfd8edca7 100644 --- a/src/gallium/state_trackers/clover/core/program.hpp +++ b/src/gallium/state_trackers/clover/core/program.hpp @@ -40,15 +40,17 @@ 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 & operator=(const program &prog) = delete; - void build(const ref_vector<device> &devs, const std::string &opts, - const header_map &headers = {}); + void compile(const ref_vector<device> &devs, const std::string &opts, + const header_map &headers = {}); + void link(const ref_vector<device> &devs, const std::string &opts, + const ref_vector<program> &progs); const bool has_source; const std::string &source() const; @@ -66,7 +68,7 @@ namespace clover { std::string log; }; - const struct build &build(const device &dev) const; + const build &build(const device &dev) const; const std::vector<module::symbol> &symbols() const; |