Fixes piglit cl-api-build-program.
Tested-by: EdB <edb+mesa@sigluy.net>
}, devs))
throw error(CL_INVALID_DEVICE);
+ if (prog.kernel_ref_count())
+ throw error(CL_INVALID_OPERATION);
+
prog.build(devs, opts);
return CL_SUCCESS;
kernel::kernel(clover::program &prog, const std::string &name,
const std::vector<module::argument> &margs) :
- program(prog), _name(name), exec(*this) {
+ program(prog), _name(name), exec(*this),
+ program_ref(prog._kernel_ref_counter) {
for (auto &marg : margs) {
if (marg.type == module::argument::scalar)
_args.emplace_back(new scalar_argument(marg.size));
std::vector<std::unique_ptr<argument>> _args;
std::string _name;
exec_context exec;
+ const ref_holder program_ref;
};
}
using namespace clover;
program::program(clover::context &ctx, const std::string &source) :
- has_source(true), context(ctx), _source(source) {
+ has_source(true), context(ctx), _source(source), _kernel_ref_counter(0) {
}
program::program(clover::context &ctx,
const ref_vector<device> &devs,
const std::vector<module> &binaries) :
has_source(false), context(ctx),
- _devices(devs) {
+ _devices(devs), _kernel_ref_counter(0) {
for_each([&](device &dev, const module &bin) {
_binaries.insert({ &dev, bin });
},
return _binaries.begin()->second.syms;
}
+
+unsigned
+program::kernel_ref_count() const {
+ return _kernel_ref_counter.ref_count();
+}
const compat::vector<module::symbol> &symbols() const;
+ unsigned kernel_ref_count() const;
+
const intrusive_ref<clover::context> context;
+ friend class kernel;
+
private:
std::vector<intrusive_ref<device>> _devices;
std::map<const device *, module> _binaries;
std::map<const device *, std::string> _logs;
std::map<const device *, std::string> _opts;
std::string _source;
+ ref_counter _kernel_ref_counter;
};
}