clover: implement CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE
authorGrigori Goronzy <greg@chown.ath.cx>
Thu, 28 May 2015 11:01:51 +0000 (13:01 +0200)
committerGrigori Goronzy <greg@chown.ath.cx>
Mon, 29 Jun 2015 11:24:37 +0000 (13:24 +0200)
Work-group size should always be aligned to subgroup size; this is a
basic requirement, otherwise some work-items will be no-operation.

It might make sense to refine the value according to a kernel's
resource usage, but that's a possible optimization for the future.

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
src/gallium/state_trackers/clover/api/kernel.cpp
src/gallium/state_trackers/clover/core/device.cpp
src/gallium/state_trackers/clover/core/device.hpp

index 05cc392a91421c08791329b1a610ecea141d6488..857a152b554f4bc672a43f627cf48655ed212333 100644 (file)
@@ -169,7 +169,7 @@ clGetKernelWorkGroupInfo(cl_kernel d_kern, cl_device_id d_dev,
       break;
 
    case CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE:
-      buf.as_scalar<size_t>() = 1;
+      buf.as_scalar<size_t>() = dev.subgroup_size();
       break;
 
    case CL_KERNEL_PRIVATE_MEM_SIZE:
index 42b45b7f2b8656152ae091f7f4d0bd6733a6d4d9..c42d1d260042e774c69076d034c0c00e4aa6f370 100644 (file)
@@ -185,6 +185,11 @@ device::max_block_size() const {
    return { v.begin(), v.end() };
 }
 
+cl_uint
+device::subgroup_size() const {
+   return get_compute_param<uint32_t>(pipe, PIPE_COMPUTE_CAP_SUBGROUP_SIZE)[0];
+}
+
 std::string
 device::device_name() const {
    return pipe->get_name(pipe);
index de5fc6bb9c41792eff7c2cee29c036bf5a7b7984..285784744f38bf2206bcd8766931f95ab4c47813 100644 (file)
@@ -67,6 +67,7 @@ namespace clover {
       bool has_doubles() const;
 
       std::vector<size_t> max_block_size() const;
+      cl_uint subgroup_size() const;
       std::string device_name() const;
       std::string vendor_name() const;
       enum pipe_shader_ir ir_format() const;