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-Tag: upstream/10.0.5~659 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7463abd37d65abd4d87abe314e0629c853dd9bca;p=platform%2Fupstream%2Fmesa.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 d6129e6..7fd23d2 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 3bd08f0..4670046 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 41d7b6f..4bcc3c7 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 4eb90cf..1658458 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 + 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. ///