[Mesa-dev] [PATCH] clover: fix piglit cl-api-build-program test
EdB
edb+mesa at sigluy.net
Sat Aug 16 19:28:45 PDT 2014
Hello
There is a crash with your version.
This one works
---
diff --git a/src/gallium/state_trackers/clover/api/program.cpp
b/src/gallium/state_trackers/clover/api/program.cpp
index b81ce69..ab6cf7c 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 5e5fe51..e4b2152 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 e544ec6..754970e 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 intrusive_ref<ref_counter> program_ref;
};
}
diff --git a/src/gallium/state_trackers/clover/core/program.cpp
b/src/gallium/state_trackers/clover/core/program.cpp
index e09c3aa..8204e95 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() {
}
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() {
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() - 1;
+}
diff --git a/src/gallium/state_trackers/clover/core/program.hpp
b/src/gallium/state_trackers/clover/core/program.hpp
index 1081454..4bb5b68 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;
};
}
diff --git a/src/gallium/state_trackers/clover/util/pointer.hpp
b/src/gallium/state_trackers/clover/util/pointer.hpp
index 59c6e6e..b68fb58 100644
--- a/src/gallium/state_trackers/clover/util/pointer.hpp
+++ b/src/gallium/state_trackers/clover/util/pointer.hpp
@@ -31,10 +31,10 @@ namespace clover {
///
class ref_counter {
public:
- ref_counter() : _ref_count(1) {}
+ ref_counter(unsigned x = 1) : _ref_count(x) {}
unsigned
- ref_count() {
+ ref_count() const {
return _ref_count;
}
More information about the mesa-dev
mailing list