Trait cubecl_runtime::server::ComputeServer

source ·
pub trait ComputeServer: Send + Debug
where Self: Sized,
{ type Kernel: Send; type DispatchOptions: Send; type Storage: ComputeStorage; type MemoryManagement: MemoryManagement<Self::Storage>; type FeatureSet: Send + Sync; // Required methods fn read(&mut self, binding: Binding<Self>) -> Reader; fn get_resource( &mut self, binding: Binding<Self>, ) -> <Self::Storage as ComputeStorage>::Resource; fn create(&mut self, data: &[u8]) -> Handle<Self>; fn empty(&mut self, size: usize) -> Handle<Self>; fn execute( &mut self, kernel: Self::Kernel, count: Self::DispatchOptions, bindings: Vec<Binding<Self>>, ); fn sync(&mut self, command: SyncType); }
Expand description

The compute server is responsible for handling resources and computations over resources.

Everything in the server is mutable, therefore it should be solely accessed through the compute channel for thread safety.

Required Associated Types§

source

type Kernel: Send

The kernel type defines the computation algorithms.

source

type DispatchOptions: Send

Options when dispatching the kernel, eg. the number of executions.

source

type Storage: ComputeStorage

The storage type defines how data is stored and accessed.

source

type MemoryManagement: MemoryManagement<Self::Storage>

The memory management type defines strategies for allocation in the storage type.

source

type FeatureSet: Send + Sync

Features supported by the compute server.

Required Methods§

source

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

Given a handle, returns the owned resource as bytes.

source

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

Given a resource handle, returns the storage resource.

source

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

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

source

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

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

source

fn execute( &mut self, kernel: Self::Kernel, count: Self::DispatchOptions, bindings: Vec<Binding<Self>>, )

Executes the kernel over the given memory handles.

Kernels have mutable access to every resource they are given and are responsible of determining which should be read or written.

source

fn sync(&mut self, command: SyncType)

Wait for the completion of every task in the server.

Object Safety§

This trait is not object safe.

Implementors§