Skip to main content

transpile_ring_kernel

Function transpile_ring_kernel 

Source
pub fn transpile_ring_kernel(
    handler: &ItemFn,
    config: &RingKernelConfig,
) -> Result<String>
Expand description

Transpile a Rust handler function to a WGSL ring kernel.

Ring kernels in WGPU are emulated using host-driven dispatch loops since WebGPU does not support true persistent kernels. The handler function processes a batch of messages per dispatch.

§Example

use ringkernel_wgpu_codegen::{transpile_ring_kernel, RingKernelConfig};
use syn::parse_quote;

let handler: syn::ItemFn = parse_quote! {
    fn process(value: f32) -> f32 {
        value * 2.0
    }
};

let config = RingKernelConfig::new("processor")
    .with_workgroup_size(256)
    .with_hlc(true);

let wgsl = transpile_ring_kernel(&handler, &config)?;

§WGSL Limitations

  • No K2K: Kernel-to-kernel messaging is not supported
  • No persistent loop: Host must re-dispatch until termination
  • No 64-bit atomics: Counters use lo/hi u32 pair emulation