Commit e9a4e749 authored by Francisco Jerez's avatar Francisco Jerez
Browse files

clover: Refuse to build a program if there are kernel objects attached to it.



Fixes piglit cl-api-build-program.
Tested-by: Serge Martin's avatarEdB <edb+mesa@sigluy.net>
parent c6817f19
......@@ -167,6 +167,9 @@ clBuildProgram(cl_program d_prog, cl_uint num_devs,
}, devs))
throw error(CL_INVALID_DEVICE);
if (prog.kernel_ref_count())
throw error(CL_INVALID_OPERATION);
prog.build(devs, opts);
return CL_SUCCESS;
......
......@@ -30,7 +30,8 @@ using namespace clover;
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));
......
......@@ -225,6 +225,7 @@ namespace clover {
std::vector<std::unique_ptr<argument>> _args;
std::string _name;
exec_context exec;
const ref_holder program_ref;
};
}
......
......@@ -26,14 +26,14 @@
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 });
},
......@@ -110,3 +110,8 @@ program::symbols() const {
return _binaries.begin()->second.syms;
}
unsigned
program::kernel_ref_count() const {
return _kernel_ref_counter.ref_count();
}
......@@ -60,14 +60,19 @@ namespace clover {
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;
};
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment