Expand description
Core trait definitions for the kernel dispatch system.
Kernel is a marker trait that associates typed input/output with a
compute operation. KernelDispatch<K> is implemented by each concrete
backend device (CudaDevice, VulkanDevice, CpuDevice) and by
DeviceBackend itself, so callers never need to name the backend:
ⓘ
let output = backend.run::<CompareScore>(input)?;§Adding a new kernel
- Create
src/kernels/my_kernel.rs, define a marker struct + typedInput/Outputandimpl Kernel for MyKernel. - For CUDA add
src/backend/cuda/launch/my_kernel.rswithimpl KernelDispatch<MyKernel> for CudaDevice. - Add the CPU fallback
impl KernelDispatch<MyKernel> for CpuDeviceinsrc/backend/cpu/launch/my_kernel.rs. - Add
impl KernelDispatch<MyKernel> for DeviceBackendinsrc/backend/mod.rs(a match that delegates to the above). - Register the new kernel in
build.rsso it gets compiled to PTX.
Traits§
- Kernel
- Marker trait that binds typed
InputandOutputto a compute operation. - Kernel
Dispatch - Execute kernel
Konself.