diff options
author | Francisco Jerez <[email protected]> | 2013-10-24 12:09:55 -0700 |
---|---|---|
committer | Francisco Jerez <[email protected]> | 2013-10-24 13:33:41 -0700 |
commit | 7463abd37d65abd4d87abe314e0629c853dd9bca (patch) | |
tree | 213cc10169f3819ea8b4488e8d165383da68a5c9 /src/gallium | |
parent | b8d7a97fade140b8fb7c464afc24b210f1fe4ff7 (diff) |
clover: Query maximum kernel block size from the device instead of the kernel object.
Based on a similar fix from Aaron Watry. It seems unlikely that we
will ever need a kernel-specific setting for this, and the Gallium API
doesn't support it. Remove kernel::max_block_size() altogether.
Diffstat (limited to 'src/gallium')
4 files changed, 18 insertions, 10 deletions
diff --git a/src/gallium/state_trackers/clover/api/kernel.cpp b/src/gallium/state_trackers/clover/api/kernel.cpp index d6129e63427..7fd23d2d8f4 100644 --- a/src/gallium/state_trackers/clover/api/kernel.cpp +++ b/src/gallium/state_trackers/clover/api/kernel.cpp @@ -148,15 +148,14 @@ clGetKernelWorkGroupInfo(cl_kernel d_kern, cl_device_id d_dev, size_t size, void *r_buf, size_t *r_size) try { property_buffer buf { r_buf, size, r_size }; auto &kern = obj(d_kern); - auto pdev = pobj(d_dev); + auto &dev = (d_dev ? *pobj(d_dev) : unique(kern.prog.devices())); - if ((!pdev && kern.prog.devices().size() != 1) || - (pdev && !count(*pdev, kern.prog.devices()))) + if (!count(dev, kern.prog.devices())) throw error(CL_INVALID_DEVICE); switch (param) { case CL_KERNEL_WORK_GROUP_SIZE: - buf.as_scalar<size_t>() = kern.max_block_size(); + buf.as_scalar<size_t>() = dev.max_threads_per_block(); break; case CL_KERNEL_COMPILE_WORK_GROUP_SIZE: @@ -183,6 +182,9 @@ clGetKernelWorkGroupInfo(cl_kernel d_kern, cl_device_id d_dev, } catch (error &e) { return e.get(); + +} catch (std::out_of_range &e) { + return CL_INVALID_DEVICE; } namespace { diff --git a/src/gallium/state_trackers/clover/core/kernel.cpp b/src/gallium/state_trackers/clover/core/kernel.cpp index 3bd08f058af..4670046ef93 100644 --- a/src/gallium/state_trackers/clover/core/kernel.cpp +++ b/src/gallium/state_trackers/clover/core/kernel.cpp @@ -120,11 +120,6 @@ kernel::mem_private() const { return 0; } -size_t -kernel::max_block_size() const { - return std::numeric_limits<std::size_t>::max(); -} - const std::string & kernel::name() const { return _name; diff --git a/src/gallium/state_trackers/clover/core/kernel.hpp b/src/gallium/state_trackers/clover/core/kernel.hpp index 41d7b6f2c91..4bcc3c76891 100644 --- a/src/gallium/state_trackers/clover/core/kernel.hpp +++ b/src/gallium/state_trackers/clover/core/kernel.hpp @@ -119,7 +119,6 @@ namespace clover { size_t mem_local() const; size_t mem_private() const; - size_t max_block_size() const; const std::string &name() const; std::vector<size_t> block_size() const; diff --git a/src/gallium/state_trackers/clover/util/algorithm.hpp b/src/gallium/state_trackers/clover/util/algorithm.hpp index 4eb90cffa9f..1658458ee18 100644 --- a/src/gallium/state_trackers/clover/util/algorithm.hpp +++ b/src/gallium/state_trackers/clover/util/algorithm.hpp @@ -56,6 +56,18 @@ namespace clover { } /// + /// Return the only element in a range. + /// + template<typename R> + detail::preferred_reference_type<R> + unique(R &&r) { + if (r.size() != 1) + throw std::out_of_range(""); + + return r.front(); + } + + /// /// Combine a variable number of ranges element-wise in a single /// range of tuples. /// |