Skip to main content

ArgBuilder

Struct ArgBuilder 

Source
pub struct ArgBuilder { /* private fields */ }
Expand description

A builder for constructing named kernel argument arrays.

Collects typed argument values along with their names, then produces the Vec<*mut c_void> array needed by cuLaunchKernel.

§Example

use oxicuda_launch::named_args::ArgBuilder;

let x: f32 = 3.14;
let n: u32 = 512;
let mut builder = ArgBuilder::new();
builder.add("x", &x).add("n", &n);
assert_eq!(builder.arg_count(), 2);
let ptrs = builder.build();
assert_eq!(ptrs.len(), 2);

Implementations§

Source§

impl ArgBuilder

Source

pub fn new() -> Self

Creates a new empty argument builder.

Source

pub fn with_capacity(capacity: usize) -> Self

Creates a new argument builder with the given initial capacity.

Source

pub fn add<T: Copy>(&mut self, name: &str, val: &T) -> &mut Self

Adds a named argument to the builder.

The pointer to val is stored. The caller must ensure that val remains valid (not moved or dropped) until the kernel launch using the built pointer array completes.

Returns &mut Self for method chaining.

Source

pub fn build(self) -> Vec<*mut c_void>

Builds the argument pointer array for cuLaunchKernel.

Returns the raw pointer array. The names are consumed; use names before calling build if you need them.

Source

pub fn names(&self) -> Vec<&str>

Returns the names of all added arguments in order.

Source

pub fn arg_count(&self) -> usize

Returns the number of arguments added so far.

Source

pub fn is_empty(&self) -> bool

Returns true if no arguments have been added.

Source

pub fn summary(&self) -> String

Returns a human-readable summary of the arguments.

Trait Implementations§

Source§

impl Debug for ArgBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ArgBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more