Skip to main content

VulkanAccelerator

Struct VulkanAccelerator 

Source
pub struct VulkanAccelerator { /* private fields */ }

Implementations§

Source§

impl VulkanAccelerator

Source

pub fn new() -> Result<Self, InitError>

Open the preferred Vulkan 1.3 compute device: discrete, integrated, virtual, then CPU.

Source

pub fn with_device(device: &str) -> Result<Self, InitError>

Open the device whose enumerated name (available_devices) equals device.

Source

pub fn with_device_options( device: &str, options: VulkanOptions, ) -> Result<Self, InitError>

with_device with explicit VulkanOptions.

Source

pub fn available_devices() -> Result<Vec<String>, InitError>

Enumerate the names of every suitable device visible through the loader.

Source

pub fn device_name(&self) -> &str

The enumerated name of the device this instance executes on.

Source

pub fn is_poisoned(&self) -> bool

Whether this instance observed device loss and refuses further work.

Source

pub fn host_gate(&self) -> Result<VulkanHostGate, BackendError>

A new VulkanHostGate at value 0, or Unsupported without timeline semaphores.

Source

pub fn submit_after( &self, queue: &VulkanQueue, program: &VulkanProgram, bindings: &[BindingRef<'_, VulkanBuffer>], gate: &VulkanHostGate, value: u64, ) -> Result<VulkanEvent, SubmitFailure<VulkanEvent>>

Accelerator::submit, the work waiting on the device until gate reaches value (ADR 0013). The bindings are held from now, as submit holds them, with one difference the gate exists for: the bytes of the program’s input bindings may still be written until the gate is raised to value (by host stores into an imported buffer, or by a device’s DMA the host has seen complete), because raising the gate orders every host operation before it ahead of the device’s wait. Outputs, and inputs after the raise, follow submit’s rules.

Source

pub fn host_import_alignment(&self) -> Option<u64>

The alignment import_host_buffer requires of a pointer and a length, or None when the device cannot import host memory.

Source

pub unsafe fn import_host_buffer( &self, context: &VulkanContext, desc: BufferDesc, memory: NonNull<u8>, len: u64, ) -> Result<AllocatedBuffer<VulkanBuffer>, BackendError>

A buffer over caller-owned host memory, imported rather than copied (ADR 0013): the device addresses memory..memory + len itself, so bytes placed there by the host, or by another device’s DMA, are the buffer’s contents with no write_buffer. Behaves as an allocated buffer of desc in every other respect: bound by submissions, gated while in flight, read and written by the explicit transfers, released by free_buffer. Its domain must be Host or Shared, the domains whose contract is host-visible memory.

This is a host-side API of this backend, not a protocol feature: the protocol’s external memory import remains deferred.

§Safety

memory..memory + len must be live host memory (anonymous or huge-page mappings; not a device mapping) that stays allocated and mapped, and is not remapped, until the buffer is released and no submission that bound it is still executing. While a submission that binds the buffer is in flight, the host must not write bytes that submission reads or read bytes it writes.

Source

pub fn direct_binding_admissions(&self) -> u64

Cumulative count of buffers admitted as direct bindings.

Source

pub fn explicit_transfer_bytes(&self) -> u64

Cumulative bytes moved by explicit write_buffer/read_buffer transfers.

Source

pub fn live_resources(&self) -> LiveResources

Provider handles currently alive for this instance.

Trait Implementations§

Source§

impl Accelerator for VulkanAccelerator

Source§

type Context = VulkanContext

Owned context handle. It may be a native value and need not be boxed, cloneable, or thread safe.
Source§

type Buffer = VulkanBuffer

Owned handle for the exact allocation described by its accompanying BufferInfo.
Source§

type Program = VulkanProgram

Owned resident-program handle with no borrow of its source artifact.
Source§

type Queue = VulkanQueue

Owned accelerator execution-queue handle.
Source§

type Event = VulkanEvent

Owned submission and completion token with no borrow of the submitted binding slice.
Source§

fn device_info(&self) -> Result<DeviceInfo, BackendError>

Return immutable identity, capability, and limit metadata. Read more
Source§

fn create_context( &self, desc: ContextDesc, ) -> Result<Self::Context, BackendError>

Create one context from prevalidated intent. Read more
Source§

fn destroy_context( &self, context: Self::Context, ) -> Result<(), ReleaseFailure<Self::Context>>

Destroy an empty context. Read more
Source§

fn allocate_buffer( &self, context: &Self::Context, desc: BufferDesc, ) -> Result<AllocatedBuffer<Self::Buffer>, BackendError>

Allocate one exact provider-owned buffer backing. Read more
Source§

fn write_buffer( &self, buffer: &mut Self::Buffer, offset: u64, data: &dyn ByteSource, ) -> Result<(), BackendError>

Perform one explicit host-to-buffer transfer. Read more
Source§

fn read_buffer( &self, buffer: &Self::Buffer, offset: u64, data: &mut dyn ByteSink, ) -> Result<(), BackendError>

Perform one explicit buffer-to-host transfer. Read more
Source§

fn free_buffer( &self, buffer: Self::Buffer, ) -> Result<(), ReleaseFailure<Self::Buffer>>

Release an unreferenced buffer and its exact backing allocation. Read more
Source§

fn load_program( &self, context: &Self::Context, artifact: ArtifactRef<'_>, ) -> Result<Self::Program, BackendError>

Create a resident program from an opaque, possibly segmented artifact. Read more
Source§

fn unload_program( &self, program: Self::Program, ) -> Result<(), ReleaseFailure<Self::Program>>

Release an unreferenced resident program. Read more
Source§

fn create_queue( &self, context: &Self::Context, desc: QueueDesc, ) -> Result<Self::Queue, BackendError>

Create one accelerator execution queue. Read more
Source§

fn destroy_queue( &self, _queue: Self::Queue, ) -> Result<(), ReleaseFailure<Self::Queue>>

Release an unreferenced execution queue. Read more
Source§

fn submit( &self, queue: &Self::Queue, program: &Self::Program, bindings: &[BindingRef<'_, Self::Buffer>], timeout: Timeout, ) -> Result<Self::Event, SubmitFailure<Self::Event>>

Attempt to admit one program execution and return its event. Read more
Source§

fn poll_event(&self, event: &Self::Event) -> Result<EventState, BackendError>

Observe event state without blocking or driving an executor. Read more
Source§

fn destroy_event( &self, event: Self::Event, ) -> Result<(), ReleaseFailure<Self::Event>>

Release one terminal event and its provider invocation state. Read more
Source§

fn cancel_event(&self, _event: &Self::Event) -> Result<(), BackendError>

Attempt to make a pending event terminal as EventState::Cancelled. Read more
Source§

impl Debug for VulkanAccelerator

Source§

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

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

impl TosaCapabilityProvider for VulkanAccelerator

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, 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.