Skip to main content

Backend

Trait Backend 

Source
pub trait Backend: Send + 'static {
    type Allocation: Send + 'static;
}
Expand description

One GPU backend: the concrete types the seam carries without naming them.

The shared layer stores and passes allocations through [Buffer] and never reads a backend type. A second backend supplies its own allocation handle here; the execution vocabulary that lets it reuse the dispatch, transfer and publication code lands with that vocabulary’s first implementor rather than as an unused declaration.

§Examples

use tenferro_gpu::gpu::{Backend, Buffer, StorageIdentity};
use tenferro_tensor::AllocationDomainId;

struct ExampleBackend;
impl Backend for ExampleBackend {
    type Allocation = u64;
}

let identity = StorageIdentity {
    domain: AllocationDomainId::fresh(),
    allocation: tenferro_tensor::AllocationId::from_backend_id(2),
    device: 0,
};
let buffer = Buffer::<ExampleBackend>::new(identity, 64, 0xdead_beef);
assert_eq!(buffer.len(), 64);
assert_eq!(*buffer.allocation(), 0xdead_beef);

Required Associated Types§

Source

type Allocation: Send + 'static

One device allocation. The [Buffer] that carries it owns it.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§