From: Francisco Jerez Date: Thu, 24 Oct 2013 19:09:55 +0000 (-0700) Subject: clover: Query maximum kernel block size from the device instead of the kernel object. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7463abd37d65abd4d87abe314e0629c853dd9bca;p=mesa.git 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. --- 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() = kern.max_block_size(); + buf.as_scalar() = 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::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 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 @@ -55,6 +55,18 @@ namespace clover { return { std::forward(r), 1, r.size() }; } + /// + /// Return the only element in a range. + /// + template + detail::preferred_reference_type + 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.