From ea02dfce8806268cc1777cf6ccc7d636d4c00f01 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Wed, 16 Mar 2022 15:52:40 +0100 Subject: [PATCH] rusticl/kernel: more clGetKernelWorkGroupInfo props Signed-off-by: Karol Herbst Acked-by: Alyssa Rosenzweig Part-of: --- src/gallium/frontends/rusticl/api/kernel.rs | 6 ++++-- src/gallium/frontends/rusticl/core/kernel.rs | 9 +++++++++ src/gallium/frontends/rusticl/mesa/compiler/nir.rs | 4 ++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/gallium/frontends/rusticl/api/kernel.rs b/src/gallium/frontends/rusticl/api/kernel.rs index 2818b0477a1..7923343a34b 100644 --- a/src/gallium/frontends/rusticl/api/kernel.rs +++ b/src/gallium/frontends/rusticl/api/kernel.rs @@ -64,10 +64,12 @@ impl CLInfoObj for cl_kernel { impl CLInfoObj for cl_kernel { fn query(&self, dev: cl_device_id, q: cl_kernel_work_group_info) -> CLResult> { - let _kernel = self.get_ref()?; - let _dev = dev.get_ref()?; + let kernel = self.get_ref()?; + let dev = dev.get_arc()?; Ok(match *q { + CL_KERNEL_LOCAL_MEM_SIZE => cl_prop::(kernel.local_mem_size(&dev)), CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE => cl_prop::(1), + CL_KERNEL_PRIVATE_MEM_SIZE => cl_prop::(kernel.priv_mem_size(&dev)), // TODO CL_KERNEL_WORK_GROUP_SIZE => cl_prop::(1), // CL_INVALID_VALUE if param_name is not one of the supported values diff --git a/src/gallium/frontends/rusticl/core/kernel.rs b/src/gallium/frontends/rusticl/core/kernel.rs index 51e15ac412b..aa1f28f59f6 100644 --- a/src/gallium/frontends/rusticl/core/kernel.rs +++ b/src/gallium/frontends/rusticl/core/kernel.rs @@ -486,4 +486,13 @@ impl Kernel { pub fn arg_type_name(&self, idx: cl_uint) -> &String { &self.args[idx as usize].spirv.type_name } + + pub fn priv_mem_size(&self, dev: &Arc) -> cl_ulong { + self.nirs.get(dev).unwrap().scratch_size() as cl_ulong + } + + pub fn local_mem_size(&self, dev: &Arc) -> cl_ulong { + // TODO include args + self.nirs.get(dev).unwrap().shared_size() as cl_ulong + } } diff --git a/src/gallium/frontends/rusticl/mesa/compiler/nir.rs b/src/gallium/frontends/rusticl/mesa/compiler/nir.rs index 5b659555921..b3067306d0a 100644 --- a/src/gallium/frontends/rusticl/mesa/compiler/nir.rs +++ b/src/gallium/frontends/rusticl/mesa/compiler/nir.rs @@ -144,6 +144,10 @@ impl NirShader { } } + pub fn scratch_size(&self) -> u32 { + unsafe { (*self.nir.as_ptr()).scratch_size } + } + pub fn shared_size(&self) -> u32 { unsafe { (*self.nir.as_ptr()).info.shared_size } }