From 3a9b1baa8031352532df90433830f784cda21836 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Sat, 4 Jan 2025 00:21:14 +0100 Subject: [PATCH] rusticl/kernel: take set kernel arguments into account for CL_KERNEL_LOCAL_MEM_SIZE Cc: mesa-stable Reviewed-by @LingMan Part-of: --- src/gallium/frontends/rusticl/core/kernel.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/gallium/frontends/rusticl/core/kernel.rs b/src/gallium/frontends/rusticl/core/kernel.rs index 5a0c1c50d28..a3aabe38062 100644 --- a/src/gallium/frontends/rusticl/core/kernel.rs +++ b/src/gallium/frontends/rusticl/core/kernel.rs @@ -1717,9 +1717,22 @@ impl Kernel { } pub fn local_mem_size(&self, dev: &Device) -> cl_ulong { - // TODO include args + // TODO: take alignment into account? // this is purely informational so it shouldn't even matter - self.builds.get(dev).unwrap()[NirKernelVariant::Default].shared_size as cl_ulong + let local = + self.builds.get(dev).unwrap()[NirKernelVariant::Default].shared_size as cl_ulong; + let args: cl_ulong = self + .arg_values() + .iter() + .map(|arg| match arg { + Some(KernelArgValue::LocalMem(val)) => *val as cl_ulong, + // If the local memory size, for any pointer argument to the kernel declared with + // the __local address qualifier, is not specified, its size is assumed to be 0. + _ => 0, + }) + .sum(); + + local + args } pub fn has_svm_devs(&self) -> bool {