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) {
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) {
//
#include "core/program.hpp"
+#include "llvm/invocation.hpp"
#include "tgsi/invocation.hpp"
using namespace clover;
}
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;
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 };
}
}
+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;
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;
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;