Skip to main content

AccelBackend

Trait AccelBackend 

Source
pub trait AccelBackend:
    Send
    + Sync
    + 'static {
    type Device: AccelDevice<Backend = Self>;
    type Stream: AccelStream<Backend = Self>;
    type Event: Debug + Send + Sync + 'static;
    type Error: Error + Send + Sync + From<AccelError> + 'static;

    const NAME: &'static str;
}
Expand description

Marker trait identifying a compute-acceleration backend.

Implemented by the Backend zero-sized type in each backend crate. Use as a trait bound:

fn observe_load<B: AccelBackend>(d: &B::Device) -> u32 { ... }

The associated types name the lifetime-bounded handles a backend hands out. They’re all Send + Sync + 'static so they can travel across actor boundaries.

Required Associated Constants§

Source

const NAME: &'static str

Display name, e.g. "cuda", "rocm", "metal".

Required Associated Types§

Source

type Device: AccelDevice<Backend = Self>

Device handle (e.g. cudarc::driver::CudaContext, hipDevice_t, MTLDevice).

Source

type Stream: AccelStream<Backend = Self>

Per-actor stream / queue handle (e.g. cudarc::driver::CudaStream, hipStream_t, MTLCommandQueue).

Source

type Event: Debug + Send + Sync + 'static

Recordable / waitable synchronization primitive (e.g. cudaEvent_t, hipEvent_t, MTLEvent).

Source

type Error: Error + Send + Sync + From<AccelError> + 'static

Backend-specific error variants supplement the core AccelError enum via the LibraryError { lib, msg } catch-all. Backends that need finer granularity wrap AccelError in their own type; the core itself is #[non_exhaustive] so adding variants is a minor bump, not a breaking change.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§