ComputeServer

Trait ComputeServer 

Source
pub trait ComputeServer:
    Send
    + Debug
    + ServerCommunication
    + DeviceState
    + 'static
    + Sized {
    type Kernel: KernelMetadata;
    type Info: Debug + Send + Sync;
    type Storage: ComputeStorage;

Show 15 methods // Required methods fn create( &mut self, descriptors: Vec<AllocationDescriptor<'_>>, stream_id: StreamId, ) -> Result<Vec<Allocation>, IoError>; fn logger(&self) -> Arc<ServerLogger>; fn utilities(&self) -> Arc<ServerUtilities<Self>>; fn read<'a>( &mut self, descriptors: Vec<CopyDescriptor<'a>>, stream_id: StreamId, ) -> Pin<Box<dyn Future<Output = Result<Vec<Bytes>, IoError>> + Send>>; fn write( &mut self, descriptors: Vec<(CopyDescriptor<'_>, &[u8])>, stream_id: StreamId, ) -> Result<(), IoError>; fn sync( &mut self, stream_id: StreamId, ) -> Pin<Box<dyn Future<Output = ()> + Send>>; fn get_resource( &mut self, binding: Binding, stream_id: StreamId, ) -> BindingResource<<Self::Storage as ComputeStorage>::Resource>; unsafe fn execute( &mut self, kernel: Self::Kernel, count: CubeCount, bindings: Bindings, kind: ExecutionMode, stream_id: StreamId, ); fn flush(&mut self, stream_id: StreamId); fn memory_usage(&mut self, stream_id: StreamId) -> MemoryUsage; fn memory_cleanup(&mut self, stream_id: StreamId); fn start_profile(&mut self, stream_id: StreamId) -> ProfilingToken; fn end_profile( &mut self, stream_id: StreamId, token: ProfilingToken, ) -> Result<ProfileDuration, ProfileError>; fn allocation_mode( &mut self, mode: MemoryAllocationMode, stream_id: StreamId, ); // Provided method fn create_with_data( &mut self, data: &[u8], stream_id: StreamId, ) -> Result<Handle, IoError> { ... }
}
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: KernelMetadata

The kernel type defines the computation algorithms.

Source

type Info: Debug + Send + Sync

Information that can be retrieved for the runtime.

Source

type Storage: ComputeStorage

The storage type defines how data is stored and accessed.

Required Methods§

Source

fn create( &mut self, descriptors: Vec<AllocationDescriptor<'_>>, stream_id: StreamId, ) -> Result<Vec<Allocation>, IoError>

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

Source

fn logger(&self) -> Arc<ServerLogger>

Retrieve the server logger.

Source

fn utilities(&self) -> Arc<ServerUtilities<Self>>

Retrieve the server utilities.

Source

fn read<'a>( &mut self, descriptors: Vec<CopyDescriptor<'a>>, stream_id: StreamId, ) -> Pin<Box<dyn Future<Output = Result<Vec<Bytes>, IoError>> + Send>>

Given bindings, returns the owned resources as bytes.

Source

fn write( &mut self, descriptors: Vec<(CopyDescriptor<'_>, &[u8])>, stream_id: StreamId, ) -> Result<(), IoError>

Writes the specified bytes into the buffers given

Source

fn sync( &mut self, stream_id: StreamId, ) -> Pin<Box<dyn Future<Output = ()> + Send>>

Wait for the completion of every task in the server.

Source

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

Given a resource handle, returns the storage resource.

Source

unsafe fn execute( &mut self, kernel: Self::Kernel, count: CubeCount, bindings: Bindings, kind: ExecutionMode, stream_id: StreamId, )

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.

§Safety

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

Source

fn flush(&mut self, stream_id: StreamId)

Flush all outstanding tasks in the server.

Source

fn memory_usage(&mut self, stream_id: StreamId) -> MemoryUsage

The current memory usage of the server.

Source

fn memory_cleanup(&mut self, stream_id: StreamId)

Ask the server to release memory that it can release.

Source

fn start_profile(&mut self, stream_id: StreamId) -> ProfilingToken

Enable collecting timestamps.

Source

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

Disable collecting timestamps.

Source

fn allocation_mode(&mut self, mode: MemoryAllocationMode, stream_id: StreamId)

Update the memory mode of allocation in the server.

Provided Methods§

Source

fn create_with_data( &mut self, data: &[u8], stream_id: StreamId, ) -> Result<Handle, IoError>

Utility to create a new buffer and immediately copy contiguous data into it

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§