diff options
author | Karol Herbst <kherbst@redhat.com> | 2024-04-23 02:29:27 +0200 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2024-04-27 18:19:53 +0000 |
commit | d8ed73b5f618d1bd1fdbd661e1f15f1b599e2d47 (patch) | |
tree | 3e30b8832303e6c86268462e083c5af66fe817a7 | |
parent | 672de78d667922f285305e7adf38a6a4ac872a76 (diff) |
rusticl/program: Arc the stored KernelInfo
This way we don't have to constantly copy the full thing at kernel
creation time lowering CPU overhead significantly.
With the previous changes clCreateKernel is basically for free.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28872>
-rw-r--r-- | src/gallium/frontends/rusticl/core/kernel.rs | 4 | ||||
-rw-r--r-- | src/gallium/frontends/rusticl/core/program.rs | 5 |
2 files changed, 5 insertions, 4 deletions
diff --git a/src/gallium/frontends/rusticl/core/kernel.rs b/src/gallium/frontends/rusticl/core/kernel.rs index 7eec3a46621..f1ba43faf49 100644 --- a/src/gallium/frontends/rusticl/core/kernel.rs +++ b/src/gallium/frontends/rusticl/core/kernel.rs @@ -302,7 +302,7 @@ pub struct Kernel { pub name: String, values: Mutex<Vec<Option<KernelArgValue>>>, builds: HashMap<&'static Device, Arc<NirKernelBuild>>, - pub kernel_info: KernelInfo, + pub kernel_info: Arc<KernelInfo>, } impl_cl_type_trait!(cl_kernel, Kernel, CL_INVALID_KERNEL); @@ -813,7 +813,7 @@ fn extract<'a, const S: usize>(buf: &'a mut &[u8]) -> &'a [u8; S] { impl Kernel { pub fn new(name: String, prog: Arc<Program>) -> Arc<Kernel> { let prog_build = prog.build_info(); - let kernel_info = prog_build.kernel_info.get(&name).unwrap().clone(); + let kernel_info = Arc::clone(prog_build.kernel_info.get(&name).unwrap()); let builds = prog_build .builds .iter() diff --git a/src/gallium/frontends/rusticl/core/program.rs b/src/gallium/frontends/rusticl/core/program.rs index 901d68befd6..b71e9ea4471 100644 --- a/src/gallium/frontends/rusticl/core/program.rs +++ b/src/gallium/frontends/rusticl/core/program.rs @@ -99,7 +99,7 @@ unsafe impl Sync for NirKernelBuild {} pub struct ProgramBuild { pub builds: HashMap<&'static Device, ProgramDevBuild>, - pub kernel_info: HashMap<String, KernelInfo>, + pub kernel_info: HashMap<String, Arc<KernelInfo>>, spec_constants: HashMap<u32, nir_const_value>, kernels: Vec<String>, } @@ -204,7 +204,8 @@ impl ProgramBuild { kernel_info.attributes_string = String::new(); } - self.kernel_info.insert(kernel_name.clone(), kernel_info); + self.kernel_info + .insert(kernel_name.clone(), Arc::new(kernel_info)); } } |