Module kernel_args

Module kernel_args 

Source
Expand description

2026-09-25: KernelLaunch, the builder for kernel launches on any GpuBackend. Each argument is recorded as a buffer or as scalar bytes, so the Metal backend can bind buffers with setBuffer:offset:atIndex: and scalars with setBytes:length:atIndex:.

Owner: gpu-runtime. Invariants:

  • Each arg_* call adds exactly one KernelArg to the launch; a CUtensorMap occupies 16 consecutive storage slots but is still one argument.
  • Arguments reach GpuBackend::launch_typed in the order they were added.

Usage:

ⓘ
KernelLaunch::new(gpu, kernel)
    .grid([num_tokens, 1, 1])
    .block([256, 1, 1])
    .arg_ptr(input)
    .arg_u32(hidden_size)
    .arg_f32(eps)
    .launch(stream)?;

Structs§

KernelLaunch
2026-09-25: Builder for a kernel launch: grid, block, dynamic shared memory and typed arguments. launch() passes the arguments as &[KernelArg] to GpuBackend::launch_typed. Grid and block default to [1, 1, 1], shared memory to 0.

Functions§

div_ceil
2026-09-25: a / b, rounded up.