diff options
Diffstat (limited to 'src')
5 files changed, 18 insertions, 3 deletions
diff --git a/src/gallium/state_trackers/clover/api/program.cpp b/src/gallium/state_trackers/clover/api/program.cpp index 8d9d3ac62d5..67717353a8c 100644 --- a/src/gallium/state_trackers/clover/api/program.cpp +++ b/src/gallium/state_trackers/clover/api/program.cpp @@ -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; diff --git a/src/gallium/state_trackers/clover/core/kernel.cpp b/src/gallium/state_trackers/clover/core/kernel.cpp index 5e5fe51f1c0..e4b2152e4ab 100644 --- a/src/gallium/state_trackers/clover/core/kernel.cpp +++ b/src/gallium/state_trackers/clover/core/kernel.cpp @@ -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)); diff --git a/src/gallium/state_trackers/clover/core/kernel.hpp b/src/gallium/state_trackers/clover/core/kernel.hpp index e544ec64b63..f9e2765ee36 100644 --- a/src/gallium/state_trackers/clover/core/kernel.hpp +++ b/src/gallium/state_trackers/clover/core/kernel.hpp @@ -225,6 +225,7 @@ namespace clover { std::vector<std::unique_ptr<argument>> _args; std::string _name; exec_context exec; + const ref_holder program_ref; }; } diff --git a/src/gallium/state_trackers/clover/core/program.cpp b/src/gallium/state_trackers/clover/core/program.cpp index e09c3aaa2cf..30a1f0e0762 100644 --- a/src/gallium/state_trackers/clover/core/program.cpp +++ b/src/gallium/state_trackers/clover/core/program.cpp @@ -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(); +} diff --git a/src/gallium/state_trackers/clover/core/program.hpp b/src/gallium/state_trackers/clover/core/program.hpp index 1081454d010..4bb5b680d4e 100644 --- a/src/gallium/state_trackers/clover/core/program.hpp +++ b/src/gallium/state_trackers/clover/core/program.hpp @@ -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; }; } |