Skip to main content

Command

Struct Command 

Source
pub struct Command<'a, D: Driver> { /* private fields */ }
Expand description

One unit of work against the device: the context that holds its compiled kernels, and the streams it was resolved against.

Built per operation rather than held, because resolving is what orders the current stream behind whichever streams own the buffers it was given.

Implementations§

Source§

impl<'a, D: Driver> Command<'a, D>

Source

pub fn new( ctx: &'a mut D::Context, streams: ResolvedStreams<'a, D::Backend>, service: ServiceId, ) -> Self

A command against ctx over the streams streams resolved.

Source

pub fn stream(&mut self) -> &mut D::Stream

The stream this command is issued on.

The one part of the resolution a backend reaches for directly: the driver calls take a stream, and this is the one they take.

Source

pub fn resource( &mut self, binding: BufferBinding, ) -> Result<DeviceResource<D>, IoError>

The device allocation binding names, resolved on the stream that created it rather than the current one.

§Errors

IoError::StorageHandleNotFound when the binding names no live allocation.

Source

pub fn memory_usage(&mut self) -> MemoryUsage

The current stream’s device memory usage.

Source

pub fn memory_report(&mut self) -> MemoryReport

Structured per-pool report of the current stream’s device memory.

Source

pub fn memory_cleanup(&mut self)

Release everything the current stream is holding that nothing still needs.

Source

pub fn flush_drops(&mut self)

Flush the current stream’s drop queue, freeing what the device is known to be done with.

Deferred while the stream records a graph — the flush records a fence on the capturing stream, which corrupts the recording — and the window drains the queue itself when it closes. The rule lives here, on the one path a server has to the queue, so no call site can rebuild the flush without the guard.

Source

pub fn allocation_mode(&mut self, mode: MemoryAllocationMode)

Set the MemoryAllocationMode for the current stream.

Source

pub fn install_memory_pools( &mut self, config: MemoryConfiguration, props: &MemoryDeviceProperties, ) -> Result<(), InstallMemoryPoolsError>

Rebuild the current stream’s device pools with a new layout, keeping the old one when something is still live in them.

§Errors

InstallMemoryPoolsError::PoolsInUse when the rebuild was refused.

Source

pub fn reserve(&mut self, size: u64) -> Result<ManagedMemoryHandle, IoError>

Allocate size bytes of device memory on the current stream.

§Errors

IoError::BufferTooBig when no device could ever fit it, and whatever the allocator reports when a reclaim-and-retry still cannot.

Source

pub fn cursor(&self) -> u64

The current stream’s cursor.

Source

pub fn empty(&mut self, size: u64) -> Result<Handle, IoError>

Allocate size bytes of device memory and a handle naming it.

§Errors

Whatever the allocation or the bind reports.

Source

pub fn bind( &mut self, reserved: ManagedMemoryHandle, new: ManagedMemoryHandle, ) -> Result<(), IoError>

Give reserved’s storage to new, so handles issued against new resolve to it.

§Errors

IoError when the reservation has no initialized storage to give.

Source

pub fn reserve_cpu(&mut self, size: usize, origin: Option<StreamId>) -> Bytes

size bytes of host memory, pinned when the pool can serve it.

Pinned pages transfer by DMA without a bounce, but they are scarce, so an exhausted pool falls back to the heap rather than failing: this always answers with a buffer of the size asked for.

Source

pub fn read_async( &mut self, descriptors: Vec<CopyDescriptor>, ) -> impl Future<Output = Result<Vec<Bytes>, ServerError>> + Send + use<D>

Copy each descriptor’s device memory back to the host, resolving once the copies have landed.

The copies are enqueued before the future is returned; awaiting it waits on the fence that follows them.

§Errors

IoError::UnsupportedStrides for a layout the driver cannot copy, and whatever the fence reports when the stream itself failed.

Source

pub fn write_to_cpu( &mut self, descriptor: CopyDescriptor, bytes: &mut Bytes, stream_id: Option<StreamId>, ) -> Result<(), IoError>

Enqueue a copy of descriptor’s device memory into bytes.

§Errors

IoError::UnsupportedStrides for a layout that is not pitched row-major, IoError::StorageHandleNotFound for a binding that names no live allocation, and the driver’s refusal to copy.

Source

pub fn write_to_gpu( &mut self, descriptor: CopyDescriptor, data: Bytes, ) -> Result<(), IoError>

Enqueue a copy of data into the device memory descriptor names.

§Errors

IoError::UnsupportedStrides for a layout that is not pitched row-major, IoError::StorageHandleNotFound for a binding that names no live allocation, and the driver’s refusal to copy.

Source

pub fn create_with_data(&mut self, data: &[u8]) -> Result<Handle, IoError>

Allocate device memory for data and enqueue the copy into it.

§Errors

Whatever the allocation or the copy reports.

Source

pub fn sync(&mut self) -> DynFut<Result<(), ServerError>>

Wait for everything already enqueued on the current stream to finish.

§Errors

The fault the barrier reveals, when the stream itself failed.

Source

pub fn kernel( &mut self, kernel: KernelId, count: (u32, u32, u32), args: &mut D::LaunchArgs, ) -> Result<(), LaunchError>

Enqueue an already-compiled kernel on the current stream.

§Errors

The driver’s refusal to enqueue the launch, returned whether or not a profile is open. An open profile is not a reason to hold the failure here: the caller’s write scope is what claims the buffers the launch never wrote, and the caller invalidates every open profile on the same path, so keeping it would lose the claim and duplicate the report.

Auto Trait Implementations§

§

impl<'a, D> !RefUnwindSafe for Command<'a, D>

§

impl<'a, D> !UnwindSafe for Command<'a, D>

§

impl<'a, D> Freeze for Command<'a, D>
where &'a mut <D as Driver>::Context: Freeze, ResolvedStreams<'a, <D as Driver>::Backend>: Freeze,

§

impl<'a, D> Send for Command<'a, D>
where &'a mut <D as Driver>::Context: Send, ResolvedStreams<'a, <D as Driver>::Backend>: Send,

§

impl<'a, D> Sync for Command<'a, D>
where &'a mut <D as Driver>::Context: Sync, ResolvedStreams<'a, <D as Driver>::Backend>: Sync,

§

impl<'a, D> Unpin for Command<'a, D>
where &'a mut <D as Driver>::Context: Unpin, ResolvedStreams<'a, <D as Driver>::Backend>: Unpin,

§

impl<'a, D> UnsafeUnpin for Command<'a, D>
where &'a mut <D as Driver>::Context: UnsafeUnpin, ResolvedStreams<'a, <D as Driver>::Backend>: UnsafeUnpin,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Sync + Send>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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