rusticl/device: rework subgroups to subgroup_sizes
authorKarol Herbst <git@karolherbst.de>
Sat, 6 May 2023 23:47:09 +0000 (01:47 +0200)
committerMarge Bot <emma+marge@anholt.net>
Fri, 7 Jul 2023 12:27:35 +0000 (12:27 +0000)
Signed-off-by: Karol Herbst <git@karolherbst.de>
Reviewed-by: Nora Allen <blackcatgames@protonmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22893>

src/gallium/frontends/rusticl/api/device.rs
src/gallium/frontends/rusticl/core/device.rs

index 6399f84..a477d5d 100644 (file)
@@ -248,7 +248,7 @@ impl CLInfo<cl_device_info> for cl_device_id {
             CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG => cl_prop::<cl_uint>(1),
             CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT => cl_prop::<cl_uint>(1),
             CL_DEVICE_PREFERRED_WORK_GROUP_SIZE_MULTIPLE => {
-                cl_prop::<usize>(dev.subgroups() as usize)
+                cl_prop::<usize>(dev.subgroup_sizes()[0])
             }
             CL_DEVICE_PRINTF_BUFFER_SIZE => cl_prop::<usize>(dev.printf_buffer_size()),
             CL_DEVICE_PROFILE => cl_prop(if dev.embedded {
index 1a76df3..530512e 100644 (file)
@@ -15,6 +15,7 @@ use mesa_rust::pipe::resource::*;
 use mesa_rust::pipe::screen::*;
 use mesa_rust::pipe::transfer::*;
 use mesa_rust_gen::*;
+use mesa_rust_util::math::SetBitIndices;
 use mesa_rust_util::static_assert;
 use rusticl_opencl_gen::*;
 
@@ -845,11 +846,15 @@ impl Device {
         &self.screen
     }
 
-    pub fn subgroups(&self) -> u32 {
-        ComputeParam::<u32>::compute_param(
+    pub fn subgroup_sizes(&self) -> Vec<usize> {
+        let subgroup_size = ComputeParam::<u32>::compute_param(
             self.screen.as_ref(),
             pipe_compute_cap::PIPE_COMPUTE_CAP_SUBGROUP_SIZE,
-        )
+        );
+
+        SetBitIndices::from_msb(subgroup_size)
+            .map(|bit| 1 << bit)
+            .collect()
     }
 
     pub fn svm_supported(&self) -> bool {