aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
authorFrancisco Jerez <[email protected]>2014-08-16 16:25:34 +0300
committerFrancisco Jerez <[email protected]>2014-08-18 09:32:24 +0300
commite9a4e74926ab67d1750c39b49a54df6fbcb0b593 (patch)
tree47eeb79b7a4d83e9cc40deb08262e0ed28b14ef1 /src/gallium/state_trackers
parentc6817f19f60b9b87f55f67cd4dc304a5a2f32414 (diff)
clover: Refuse to build a program if there are kernel objects attached to it.
Fixes piglit cl-api-build-program. Tested-by: EdB <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/clover/api/program.cpp3
-rw-r--r--src/gallium/state_trackers/clover/core/kernel.cpp3
-rw-r--r--src/gallium/state_trackers/clover/core/kernel.hpp1
-rw-r--r--src/gallium/state_trackers/clover/core/program.cpp9
-rw-r--r--src/gallium/state_trackers/clover/core/program.hpp5
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;
};
}