pub trait Driver: Sized {
type Backend: EventStreamBackend<Stream = Self::Stream>;
type Stream: DeviceStream;
type Context;
type LaunchArgs: ?Sized;
// Required methods
unsafe fn pinned_bytes(
binding: ManagedMemoryBinding,
resource: HostResource<Self>,
size: usize,
) -> Bytes;
unsafe fn copy_to_host(
resource: &DeviceResource<Self>,
layout: &CopyLayout<'_>,
bytes: &mut Bytes,
stream: &Self::Stream,
) -> Result<(), IoError>;
unsafe fn copy_to_device(
resource: &DeviceResource<Self>,
layout: &CopyLayout<'_>,
data: &[u8],
stream: &Self::Stream,
) -> Result<(), IoError>;
fn launch(
ctx: &mut Self::Context,
stream: &mut Self::Stream,
kernel: KernelId,
count: (u32, u32, u32),
args: &mut Self::LaunchArgs,
) -> Result<(), LaunchError>;
}Expand description
The device calls a Command cannot make itself.
Four, because everything else a command does — deciding what to stage, when to reclaim, whether a layout needs a 2D copy, when the drop queue may be flushed — is the same whichever driver is underneath.
Required Associated Types§
Sourcetype Backend: EventStreamBackend<Stream = Self::Stream>
type Backend: EventStreamBackend<Stream = Self::Stream>
The multi-stream backend whose streams this driver drives.
Sourcetype Stream: DeviceStream
type Stream: DeviceStream
The backend’s stream.
Sourcetype Context
type Context
Whatever the backend needs to launch a compiled kernel — its loaded modules, its profiling clocks.
Sourcetype LaunchArgs: ?Sized
type LaunchArgs: ?Sized
What this backend hands a kernel at launch.
Not simply the buffers: CUDA passes tensor-map descriptors alongside
them and HIP has none, so what a launch is given is the backend’s to
say. The command only carries it from the server to launch.
Required Methods§
Sourceunsafe fn pinned_bytes(
binding: ManagedMemoryBinding,
resource: HostResource<Self>,
size: usize,
) -> Bytes
unsafe fn pinned_bytes( binding: ManagedMemoryBinding, resource: HostResource<Self>, size: usize, ) -> Bytes
Sourceunsafe fn copy_to_host(
resource: &DeviceResource<Self>,
layout: &CopyLayout<'_>,
bytes: &mut Bytes,
stream: &Self::Stream,
) -> Result<(), IoError>
unsafe fn copy_to_host( resource: &DeviceResource<Self>, layout: &CopyLayout<'_>, bytes: &mut Bytes, stream: &Self::Stream, ) -> Result<(), IoError>
Sourceunsafe fn copy_to_device(
resource: &DeviceResource<Self>,
layout: &CopyLayout<'_>,
data: &[u8],
stream: &Self::Stream,
) -> Result<(), IoError>
unsafe fn copy_to_device( resource: &DeviceResource<Self>, layout: &CopyLayout<'_>, data: &[u8], stream: &Self::Stream, ) -> Result<(), IoError>
Sourcefn launch(
ctx: &mut Self::Context,
stream: &mut Self::Stream,
kernel: KernelId,
count: (u32, u32, u32),
args: &mut Self::LaunchArgs,
) -> Result<(), LaunchError>
fn launch( ctx: &mut Self::Context, stream: &mut Self::Stream, kernel: KernelId, count: (u32, u32, u32), args: &mut Self::LaunchArgs, ) -> Result<(), LaunchError>
Enqueue an already-compiled kernel on stream.
Always a compiled kernel: the server compiles before entering its write scope, and a skipped launch stops there, before any resource is resolved.
§Errors
The driver’s refusal to enqueue the launch.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".