cubecl_runtime::channel

Trait ComputeChannel

Source
pub trait ComputeChannel<Server: ComputeServer>:
    Clone
    + Debug
    + Send
    + Sync {
    // Required methods
    fn read(&self, binding: Binding) -> impl Future<Output = Vec<u8>> + Send;
    fn get_resource(&self, binding: Binding) -> BindingResource<Server>;
    fn create(&self, data: &[u8]) -> Handle;
    fn empty(&self, size: usize) -> Handle;
    unsafe fn execute(
        &self,
        kernel: Server::Kernel,
        count: CubeCount,
        bindings: Vec<Binding>,
        mode: ExecutionMode,
    );
    fn flush(&self);
    fn sync(&self) -> impl Future<Output = ()> + Send;
    fn sync_elapsed(&self) -> impl Future<Output = TimestampsResult> + Send;
    fn memory_usage(&self) -> MemoryUsage;
    fn enable_timestamps(&self);
    fn disable_timestamps(&self);
}
Expand description

The ComputeChannel trait links the ComputeClient to the ComputeServer while ensuring thread-safety

Required Methods§

Source

fn read(&self, binding: Binding) -> impl Future<Output = Vec<u8>> + Send

Given a binding, returns owned resource as bytes

Source

fn get_resource(&self, binding: Binding) -> BindingResource<Server>

Given a resource handle, return the storage resource.

Source

fn create(&self, data: &[u8]) -> Handle

Given a resource as bytes, stores it and returns the resource handle

Source

fn empty(&self, size: usize) -> Handle

Reserves size bytes in the storage, and returns a handle over them

Source

unsafe fn execute( &self, kernel: Server::Kernel, count: CubeCount, bindings: Vec<Binding>, mode: ExecutionMode, )

Executes the kernel over the given bindings.

§Safety

When executing with mode ExecutionMode::Unchecked, out-of-bound reads and writes can happen.

Source

fn flush(&self)

Flush outstanding work of the server.

Source

fn sync(&self) -> impl Future<Output = ()> + Send

Wait for the completion of every task in the server.

Source

fn sync_elapsed(&self) -> impl Future<Output = TimestampsResult> + Send

Wait for the completion of every task in the server.

Returns the (approximate) total amount of GPU work done since the last sync.

Source

fn memory_usage(&self) -> MemoryUsage

Get the current memory usage of the server.

Source

fn enable_timestamps(&self)

Enable collecting timestamps.

Source

fn disable_timestamps(&self)

Disable collecting timestamps.

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§

Source§

impl<Server> ComputeChannel<Server> for MpscComputeChannel<Server>
where Server: ComputeServer + 'static,

Source§

impl<Server> ComputeChannel<Server> for MutexComputeChannel<Server>
where Server: ComputeServer,

Source§

impl<Server> ComputeChannel<Server> for RefCellComputeChannel<Server>
where Server: ComputeServer + Send,