Trait cubecl_runtime::channel::ComputeChannel

source ·
pub trait ComputeChannel<Server: ComputeServer>:
    Clone
    + Debug
    + Send
    + Sync {
    // Required methods
    fn read(&self, binding: Binding<Server>) -> Reader;
    fn get_resource(
        &self,
        binding: Binding<Server>,
    ) -> <Server::Storage as ComputeStorage>::Resource;
    fn create(&self, data: &[u8]) -> Handle<Server>;
    fn empty(&self, size: usize) -> Handle<Server>;
    unsafe fn execute(
        &self,
        kernel: Server::Kernel,
        count: Server::DispatchOptions,
        bindings: Vec<Binding<Server>>,
        mode: ExecutionMode,
    );
    fn sync(&self, sync_type: SyncType);
}
Expand description

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

Required Methods§

source

fn read(&self, binding: Binding<Server>) -> Reader

Given a binding, returns owned resource as bytes

source

fn get_resource( &self, binding: Binding<Server>, ) -> <Server::Storage as ComputeStorage>::Resource

Given a resource handle, return the storage resource.

source

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

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

source

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

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

source

unsafe fn execute( &self, kernel: Server::Kernel, count: Server::DispatchOptions, bindings: Vec<Binding<Server>>, 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 sync(&self, sync_type: SyncType)

Perform some synchronization of commands on the server.

Object Safety§

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,