pub struct LaunchBuilder<'f> { /* private fields */ }Expand description
Builder produced by Function::launch. Call LaunchBuilder::launch
to actually enqueue the kernel.
Implementations§
Source§impl<'f> LaunchBuilder<'f>
impl<'f> LaunchBuilder<'f>
Sourcepub fn block(self, block: impl Into<Dim3>) -> Self
pub fn block(self, block: impl Into<Dim3>) -> Self
Set the block (number of threads per block per axis).
Set the amount of dynamic shared memory (bytes). Defaults to 0.
Sourcepub fn stream(self, stream: &'f Stream) -> Self
pub fn stream(self, stream: &'f Stream) -> Self
Launch on the specified Stream. Defaults to the legacy null stream.
Sourcepub fn arg<K: KernelArg>(self, arg: K) -> Self
pub fn arg<K: KernelArg>(self, arg: K) -> Self
Append one kernel argument. Pass &value for each kernel parameter:
the referent must remain alive until launch is
called. CUDA copies argument bytes at submission time, so the
values don’t need to outlive the device execution — only the
submission.
Sourcepub unsafe fn launch(self) -> Result<()>
pub unsafe fn launch(self) -> Result<()>
Actually enqueue the kernel.
§Safety
The caller must ensure that:
- The number, order, and types of arguments match what the kernel expects. Baracuda cannot see the kernel’s signature, so a mismatch here causes undefined behavior (typically corrupted output, a device fault, or silent memory corruption).
- Any pointer-typed argument (e.g.
DeviceBuffer::as_raw()) is live for the duration of kernel execution — use streams + events to manage this. - Grid and block dimensions are within the device’s supported
limits (see
crate::Device::attribute).
Sourcepub unsafe fn launch_ex(
self,
attributes: &mut [CUlaunchAttribute],
) -> Result<()>
pub unsafe fn launch_ex( self, attributes: &mut [CUlaunchAttribute], ) -> Result<()>
Enqueue the kernel via cuLaunchKernelEx (CUDA 12.0+), letting the
caller attach launch attributes (cluster dims, programmatic stream
serialization, priority, …). Pass an empty slice when you just want
the modern launch entry point with no attributes.
§Safety
Same responsibilities as launch. Attribute payloads
in attributes must be populated correctly per
baracuda_cuda_sys::types::CUlaunchAttributeID — invalid
attribute payloads cause undefined behavior on the device.