Expand description
Type-safe kernel argument builder for CUDA + Metal kernel launches.
Replaces manual Vec<*mut c_void> construction with a builder
pattern that prevents parameter type/order mismatches AND records
per-arg type information so the metal backend can dispatch buffer
args via setBuffer:offset:atIndex: and scalar args via
setBytes:length:atIndex: (cuda’s untyped cuLaunchKernel cannot
distinguish the two; metal cannot conflate them).
§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)?;Internally, every arg is recorded with its kind (Buffer / Scalar)
and its native byte width. launch() materializes a typed
KernelArg slice and calls GpuBackend::launch_typed. The
cuda backend’s default launch_typed impl flattens that back
into the legacy void** shape; the metal backend overrides
launch_typed to thread the type info through to the encoder.
Structs§
- Kernel
Launch - Builder for type-safe kernel launches across CUDA + Metal.
Functions§
- div_
ceil - Convenience: divide and round up.