pub struct KernelCacheCL {
pub kernel_cache: HashMap<String, Rc<Kernel>>,
}Expand description
This stores the previously compiled OpenCL kernels.
Fields§
§kernel_cache: HashMap<String, Rc<Kernel>>Implementations§
Source§impl KernelCacheCL
impl KernelCacheCL
Sourcepub fn kernel_cache(
&mut self,
device: &OpenCL,
src: &str,
) -> Result<Rc<Kernel>, Box<dyn Error + Sync + Send>>
pub fn kernel_cache( &mut self, device: &OpenCL, src: &str, ) -> Result<Rc<Kernel>, Box<dyn Error + Sync + Send>>
Returns a cached kernel. If the kernel source code does not exist, a new kernel is created and cached.
§Example
use std::collections::HashMap;
use custos::{OpenCL, opencl::KernelCacheCL};
fn main() -> custos::Result<()> {
let device = OpenCL::new(0)?;
let mut kernel_cache = KernelCacheCL {
kernel_cache: HashMap::new(),
};
let mut kernel_fn = || kernel_cache.kernel_cache(&device, "
__kernel void test(__global float* test) {}
");
let kernel = kernel_fn()?;
let same_kernel = kernel_fn()?;
assert_eq!(kernel.0, same_kernel.0);
Ok(())
}Trait Implementations§
Source§impl Debug for KernelCacheCL
impl Debug for KernelCacheCL
Source§impl Default for KernelCacheCL
impl Default for KernelCacheCL
Source§fn default() -> KernelCacheCL
fn default() -> KernelCacheCL
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for KernelCacheCL
impl RefUnwindSafe for KernelCacheCL
impl !Send for KernelCacheCL
impl !Sync for KernelCacheCL
impl Unpin for KernelCacheCL
impl UnwindSafe for KernelCacheCL
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more