pub struct KernelArgs { /* private fields */ }Expand description
Typed builder for GPU kernel launch arguments.
KernelArgs packs scalar values and device-buffer pointers into the
(args, arg_sizes) byte/size pair that the
[fabricbios_gpu_v1] bridge expects. Each push_* records the
raw bytes and their per-arg size so the daemon can build a CUDA
kernelParams array with one pointer per argument.
§Example
use grafos_std::gpu::{GpuBuilder, GpuSession, KernelArgs};
let lease = GpuBuilder::new().acquire()?;
let mut sess = GpuSession::new(&lease);
let buf = sess.mem_alloc(64)?;
let module = sess.module_load(&[0u8; 8])?;
let args = KernelArgs::new()
.push_u32(7)
.push_f32(2.5)
.push_buffer(&buf);
sess.launch_with_args(&module, "k", [1, 1, 1], [1, 1, 1], args)?;§Wire format
- Scalars are written little-endian.
- Buffer args are written as 8-byte little-endian device pointers
(the raw
cuMemAllocreturn value carried byGpuMemHandle). - The daemon’s launch path packs these into a contiguous byte
buffer and walks
arg_sizesto compute per-arg pointer offsets forkernelParams. Seecrates/fabricbios-platform-linux/src/gpu.rs::launch.
Implementations§
Source§impl KernelArgs
impl KernelArgs
Sourcepub fn push_buffer(self, handle: &GpuMemHandle) -> Self
pub fn push_buffer(self, handle: &GpuMemHandle) -> Self
Push a device buffer argument (the raw 8-byte device pointer).
This is the typed equivalent of manually appending
handle.raw().to_le_bytes() with size 8. The daemon will pass
the underlying device pointer to the kernel as the
corresponding kernelParams entry.
Sourcepub unsafe fn push_raw<T: Copy>(self, value: &T) -> Self
pub unsafe fn push_raw<T: Copy>(self, value: &T) -> Self
Push a value of arbitrary type by reinterpreting its bytes.
§Safety
T must satisfy all of the following:
Copyand trivially-destructible.- No interior padding bytes whose value matters to the kernel.
For C-ABI structs, this generally means
#[repr(C)]plus manual layout review. - No interior pointers, references, or non-
'staticlifetimes. - Endianness matches what the kernel expects (host order is little-endian on every platform fabricBIOS targets).
In short: the value must be a “POD” (plain-old-data) blob that
can be byte-copied into a CUDA kernelParams slot. Prefer the
typed push_* helpers for primitive scalars; reach for
push_raw only when packing a #[repr(C)] struct argument.
Trait Implementations§
Source§impl Clone for KernelArgs
impl Clone for KernelArgs
Source§fn clone(&self) -> KernelArgs
fn clone(&self) -> KernelArgs
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more