Trait ComputeChannel

Source
pub trait ComputeChannel<Server>:
    Clone
    + Debug
    + Send
    + Sync
where Server: ComputeServer,
{
Show 14 methods // Required methods fn read( &self, bindings: Vec<Binding>, ) -> Pin<Box<dyn Future<Output = Vec<Vec<u8>>> + Send>>; fn read_tensor( &self, bindings: Vec<BindingWithMeta>, ) -> Pin<Box<dyn Future<Output = Vec<Vec<u8>>> + Send>>; fn sync(&self) -> Pin<Box<dyn Future<Output = ()> + Send>>; fn get_resource( &self, binding: Binding, ) -> BindingResource<<<Server as ComputeServer>::Storage as ComputeStorage>::Resource>; fn create(&self, data: &[u8]) -> Handle; fn create_tensors( &self, data: Vec<&[u8]>, shape: Vec<&[usize]>, elem_size: Vec<usize>, ) -> Vec<(Handle, Vec<usize>)>; fn empty(&self, size: usize) -> Handle; fn empty_tensors( &self, shape: Vec<&[usize]>, elem_size: Vec<usize>, ) -> Vec<(Handle, Vec<usize>)>; unsafe fn execute( &self, kernel: <Server as ComputeServer>::Kernel, count: CubeCount, bindings: Bindings, mode: ExecutionMode, logger: Arc<ServerLogger>, ); fn flush(&self); fn memory_usage(&self) -> MemoryUsage; fn memory_cleanup(&self); fn start_profile(&self) -> ProfilingToken; fn end_profile( &self, token: ProfilingToken, ) -> Result<ProfileDuration, ProfileError>;
}
Expand description

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

Required Methods§

Source

fn read( &self, bindings: Vec<Binding>, ) -> Pin<Box<dyn Future<Output = Vec<Vec<u8>>> + Send>>

Given bindings, returns owned resources as bytes

Source

fn read_tensor( &self, bindings: Vec<BindingWithMeta>, ) -> Pin<Box<dyn Future<Output = Vec<Vec<u8>>> + Send>>

Given bindings, returns owned resources as bytes

Source

fn sync(&self) -> Pin<Box<dyn Future<Output = ()> + Send>>

Wait for the completion of every task in the server.

Source

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

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 create_tensors( &self, data: Vec<&[u8]>, shape: Vec<&[usize]>, elem_size: Vec<usize>, ) -> Vec<(Handle, Vec<usize>)>

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

Source

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

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

Source

fn empty_tensors( &self, shape: Vec<&[usize]>, elem_size: Vec<usize>, ) -> Vec<(Handle, Vec<usize>)>

Reserves a tensor with shape in the storage, and returns a handle to it

Source

unsafe fn execute( &self, kernel: <Server as ComputeServer>::Kernel, count: CubeCount, bindings: Bindings, mode: ExecutionMode, logger: Arc<ServerLogger>, )

Executes the kernel over the given bindings.

Optionally returns some debug information about the compilation to be logged.

§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 memory_usage(&self) -> MemoryUsage

Get the current memory usage of the server.

Source

fn memory_cleanup(&self)

Ask the server to release memory that it can release.

Source

fn start_profile(&self) -> ProfilingToken

Start a profile on the server. This allows you to profile kernels.

This will measure execution time either by measuring the ‘full’ execution time by synchronizing the execution at the start and the end of the profile, or ‘device’ time by using device timestamps. This function will handle any required synchronization.

Source

fn end_profile( &self, token: ProfilingToken, ) -> Result<ProfileDuration, ProfileError>

End the profile and return a ProfileDuration.

You can retrieve the Duration of the client profile asynchronously. This function will handle any required synchronization.

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,